PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
admin
/
controllers
<?php class SkinpresetController extends PController { public $layout = 'admin_column'; public function filters() { return array( 'accessControl', ); } public function actionWriteToFile() { Yii::import('site_app.classes.Functions'); Yii::import('site_app.classes.CSSParser'); /* $system_skins = SkinPreset::model()->findAll(); $compiled_css = ''; $skin_css = ''; foreach ($system_skins as $skin) { } $file_name = 'themes.css'; $filePath = Yii::getPathofAlias('site_app.css').DIRECTORY_SEPARATOR.$file_name; $out = fopen($filePath, 'wb'); fwrite($out, $compiled_css); $file_name = 'themes.css_skin'; $filePath = Yii::getPathofAlias('site_app.css').DIRECTORY_SEPARATOR.$file_name; $out = fopen($filePath, 'wb'); fwrite($out, $skin_css); */ $skins = SkinPreset::model()->findAll(); foreach($skins as $skin) { if (!isset($skin->module_type)) { continue; } $css = $skin->css; // $compiled_css = ''; try { $pased_css = Functions::parseCSS($css); if ($pased_css == false) { continue; } foreach ($pased_css as $ps) { if (isset($ps['selector_body'])) { $rule = $this->getCSSRule($skin, $ps['selector'], $ps['selector_body']); // $skin_css .= $rule['skin']; $compiled_css .= $rule['css']; } elseif (isset($ps['rules'])) { $rule_css = ''; $rule_skin = ''; foreach ($ps['rules'] as $rule) { $ps_selector = $rule['selector']; if (isset($rule['selector_body'])) { $rule = $this->getCSSRule($skin, $rule['selector'], $rule['selector_body']); $rule_skin .= $rule['skin']; $rule_css .= $rule['css']; } } //$skin_css .= $ps['selector'].'{'.$rule_skin.'}'; $compiled_css .= $ps['selector'].'{'.$rule_css.'}'; } } } catch (Exception $e) { //echo $skin->module_type->name.$skin->name; } $file_name = 'themes.css'; $filePath = Yii::getPathofAlias('site_app.skins').DIRECTORY_SEPARATOR.$skin->module_type->name; if(!file_exists($filePath)) { mkdir($filePath); } $content = '<?php return array( "display_name"=>"'.$skin->display_name.'",'.' "css"=>"'.addslashes ($compiled_css).'", "html"=>"'.addslashes ($skin->html).'", "format"=>"'.$skin->format.'", ) ?>'; $fileName = $filePath.DIRECTORY_SEPARATOR.$skin->name.'.skn.php'; $out = fopen($fileName, 'wb'); fwrite($out, $content); } } public function accesssRules() { $module = $this->getModule(); return array( array('allow', 'actions' => array( 'checkterm','ajaxupdate','index','create','view','delete','update', ), 'roles' => array($module->generalManagerRole), ), array('deny', // deny all users 'users' => array('*'), ), ); } public function actionIndex() { $this->breadcrumbs = array( Yii::t('admin', 'Skin Preset'), ); $model = new SkinPreset('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['SkinPreset'])) { $model->attributes = $_GET['SkinPreset']; } $this->render('index', array( 'model' => $model, )); } public function actionUpdate() { $model = new SkinPresetForm('update'); if (isset($_POST['SkinPresetForm'])) { $model->attributes = $_POST['SkinPresetForm']; if ($model->save()) { $url = $this->createUrl('index'); $this->redirect($url); } } if (!isset($_REQUEST['id'])) { $url = $this->createUrl('index'); $this->redirect($url); } $id = $_REQUEST['id']; $t = SkinPreset::model()->findByPk((int) $id); if ($t == null) { $url = $this->createUrl('index'); $this->redirect($url); } $this->breadcrumbs = array( Yii::t('admin', 'Skin Preset') => array('skinpreset/index'), $t->name, ); $attributes = array(); foreach ($model->getAttributes() as $name => $value) { $model->$name = $t->$name; } $this->render('update', array('model' => $model)); } public function actionDelete() { if (!isset($_REQUEST['id'])) { $url = $this->createUrl('index'); $this->redirect($url); } $id = $_REQUEST['id']; $t = SkinPreset::model()->findByPk((int) $id); $t->delete(); if ($t == null) { // $url = $this->createUrl('index'); //$this->redirect($url); } } public function actionAjaxUpdate() { $act = $_GET['act']; if ($act == 'doSync') { $this->sync(); echo 'ok'; return; } $autoIdAll = array(); if (isset($_POST['autoId'])) { $autoIdAll = $_POST['autoId']; } if (count($autoIdAll) > 0) { foreach ($autoIdAll as $autoId) { $model = Language::model()->findByPk((int) $autoId); if ($act == 'doDelete') { $model->delete(); } if ($model->save()) { echo 'ok'; } else { throw new Exception('Sorry', 500); } } } } protected function getCSSRule($skin, $selector, $rules) { $selector = Functions::getModuleSelector($skin, $selector); $skin_selector_body = ''; $selector_body = ''; foreach ($rules as $sb) { $property = $sb['property']; $value = $sb['value']; if (strpos($value, '##') !== false) { $skin_selector_body .= $property.':'.$value.';'; } $selector_body .= $property.':'.$value.';'; } $skin_css = $selector.'{'.$skin_selector_body.'}'; $compiled_css = $selector.'{'.$selector_body.'}'; return array('skin' => $skin_css,'css' => $compiled_css); } protected function sync() { $this->actionWriteToFile(); } public function actionCreate() { $this->breadcrumbs = array( Yii::t('admin', 'Skin Preset') => array('skinpreset/index'), Yii::t('admin', 'Create'), ); $model = new SkinPresetForm('create'); if (isset($_POST['SkinPresetForm'])) { $model->attributes = $_POST['SkinPresetForm']; if ($model->save()) { $url = $this->createUrl('index'); $this->redirect($url); } } $this->render('create', array('model' => $model)); } public function actionCheckterm() { $system_skins = SkinPreset::model()->findAll(); foreach ($system_skins as $skin) { $this->parseHtml($skin->html); } } protected function parseHtml($html) { $rs = array(); if (!isset($html)) { return $rs; } $blocks = explode('}', $html); $len = sizeof($blocks); for ($i = 0; $i < $len; ++$i) { $pair = explode('{', $blocks[$i]); if (sizeof($pair) >= 2) { $r = array(); $label = trim($pair[0]); if (!Yii::app()->lang->_isset($label)) { echo $label.'<br/>'; } } } } public function actiongetFontList() { $folder = Yii::getPathofAlias('webroot').'\css\open-iconic\svg'; $files = scandir($folder, 1); foreach ($files as $file) { $name = substr($file, 0, strripos($file, '.')); echo '"'.$name.'",'; } } }
[+]
..
[-] TemplateController.php
[edit]
[-] PlanController.php
[edit]
[-] DomainController.php
[edit]
[-] WebsiteController.php
[edit]
[-] ConfigController.php
[edit]
[-] TransactionController.php
[edit]
[-] MailtemplateController.php
[edit]
[-] DefaultController.php
[edit]
[-] CategoryController.php
[edit]
[-] DashboardController.php
[edit]
[-] UserController.php
[edit]
[-] LanguageController.php
[edit]
[-] ModuleController.php
[edit]
[-] ModulecategoryController.php
[edit]
[-] PlanDescriptionController.php
[edit]
[-] TermController.php
[edit]
[-] SubscriptionController.php
[edit]
[-] InterfaceController.php
[edit]
[-] ColorController.php
[edit]
[-] ShareButtonController.php
[edit]
[-] SkinpresetController.php
[edit]
[-] ContentController.php
[edit]
[-] LogController.php
[edit]
[-] ProfileController.php
[edit]