PATH:
home
/
letacommog
/
letaweb
/
admin
/
api
/
customize
<?php class SkinManager extends BaseManager { public function getSkinList() { $type = $_POST['name']; $format = $_POST['format']; $module = new BModule($this->pageObj); $db = $module->getDbConnection(); $command = $db->createCommand(); $skin = $command ->select('id,display_name, name, css,html, thumbnail') ->from('skins') ->where('type=:name and format=:format', array(':name' => $type, ':format' => $format)) ->queryAll(); $skin_directory = isset(Yii::app()->params['template_skin_directory']) ? Yii::app()->params['template_skin_directory'] : 'skins'; $skin_thumbnail_ext = isset(Yii::app()->params['skin_thumbnail_ext']) ? Yii::app()->params['skin_thumbnail_ext'] : 'png'; $prefix = 'b_'; $postfix = ''; for ($i = 0; $i < sizeof($skin); ++$i) { $skin[$i]['thumbnail'] = $this->pageObj->getFileUrl($skin_directory.'/'.$type, $skin[$i]['name'], $skin_thumbnail_ext); $skin[$i]['name'] = $prefix.$skin[$i]['name'].$postfix; } $this->ajaxSuccess($skin); } public function getDefaultSkin() { $type = $_REQUEST['type']; $skin = $this->_getDefaultSkin($type); if (isset($skin)) { $this->ajaxSuccess($skin); return; } $skin = array(); $this->ajaxSuccess($skin); } public function _getDefaultSkin($type) { $module = new BModule($this->pageObj); $db = $module->getDbConnection(); $command = $db->createCommand(); $s = $command ->select('id,display_name, name, format, css,html') ->from('skins') ->where('type=:name ', array(':name' => $type)) ->queryRow(); if (isset($s)) { $prefix = 'b_'; $postfix = ''; $skin = array('name' => $prefix.$s['name'].$postfix, 'format' => $s['format'], 'html' => $s['html'], 'css' => $s['css']); return $skin; } else { $s = Yii::app()->db->createCommand() ->select('s.id, s.name, s.display_name, css, html, format') ->from('tbl_skinpreset s') ->join('tbl_modulelist m', 's.type=m.id') ->where('m.name=:name', array(':name' => $type)) ->queryRow(); if (isset($s)) { $prefix = 'a_'; $postfix = ''; $skin = array('name' => $prefix.$s['name'].$postfix, 'format' => $s['format'], 'html' => $s['html'] , 'css' => $s['css']); return $skin; } } } public function actiondeleteItem() { $id = $_REQUEST['id']; BSkins::model()->deleteByPk((int) $id); $this->ajaxSuccess(1); } public function deleteItems() { $ids = $_REQUEST['ids']; BSkins::model()->deleteAll($id); $this->ajaxSuccess(1); } public function actionsaveForm() { $form = new SkinForm('update'); if (isset($_POST['SkinForm'])) { $form->attributes = $_POST['SkinForm']; if (($skin = $form->save()) === false) { $errors = $form->getErrors(); $this->ajaxError(CHtml::errorSummary($form)); return; } else { $this->ajaxSuccess($skin->attributes); return; } } $this->ajaxError(1); } public function actiondeleteItems() { $ids = $_POST['ids']; $criteria = new CDbCriteria(); $criteria->addInCondition('id', $ids); BSkins::model()->deleteAll($criteria); $this->ajaxSuccess(1); } public function actiongetmoduleListList() { $s = Yii::app()->db->createCommand() ->select('*') ->from('tbl_modulelist s') ->queryAll(); $this->ajaxSuccess($s); } public function _sync() { } public function actionSync() { $color_palette = BSkins::getColorPalette(); $system_skins = BSkins::model()->findAll(); $compiled_css = ''; $skin_css = ''; foreach ($system_skins as $skin) { $css = $skin->css; try { $pased_css = Functions::parseCSS($css); if ($pased_css == false) { continue; } foreach ($pased_css as $ps) { $ps_selector = $ps['selector']; if (!isset($ps['selector_body'])) { continue; } $ps_selectorbody = $ps['selector_body']; $selector = Functions::getModuleSelector($skin, $ps_selector); $skin_selector_body = ''; $selector_body = ''; foreach ($ps_selectorbody as $sb) { $property = $sb['property']; $value = $sb['value']; if (strpos($sb['value'], '##') !== false) { $skin_selector_body .= $property.':'.$sb['value'].';'; } $selector_body .= $property.':'.$value.';'; } $skin_css .= $selector.'{'.$skin_selector_body.'}'; $compiled_css .= $selector.'{'.$selector_body.'}'; } } catch (Exception $e) { } } Yii::app()->site->model->writeFile('css', 'themes', $compiled_css, '.css'); Yii::app()->site->model->writeFile('css', 'themes', $skin_css, '.css_skin'); $this->ajaxSuccess(1); } }
[+]
..
[-] SkinManager.php
[edit]
[-] ColorManager.php
[edit]