PATH:
home
/
letacommog
/
letaweb
/
admin
/
widgets
<?php // widget class to render the module class CWidgetModule extends CWidget { public $page_id; public $data; public $module_data; public $layout_type = 0; protected $invalid = false; public $script = true; // generate identifier for module if necessary public static function generate_page_id() { $suffix = 'module-'; $page_id = uniqid($suffix); $page_id .= rand(10, 99); return $page_id; } // initialize module widget public function init() { if (!isset($this->data)) { $this->data = array('data' => array()); $json_path = Yii::app()->site->model->getFilePath('module_data', $this->page_id, '.json'); if (file_exists($json_path)) { $content = file_get_contents($json_path); $this->data = json_decode($content, true); } } $data = getIndex($this->data, 'data', array()); if (!is_array($data) && is_string($data)) { $data = json_decode($data, true); } if (!isset($this->page_id) || strlen($this->page_id) == 0) { $this->page_id = self::generate_page_id(); } $this->module_data = $data; $this->decodeData(); } protected function addError($error) { } // extract value from module data protected function decodeData() { } protected function getModuleType() { $class = get_class($this); $class = substr($class, strlen('CWidget')); $class = strtolower($class); return $class; } //function to render necessary javascript for module //Path to admin/widgets/view/modules/script protected function registerHeaderScripts() { $class = get_class($this); $class = substr($class, strlen('CWidget')); $class = strtolower($class); $script_path = Yii::getPathofAlias('application.widgets.views.modules.script'); if (is_file($script_path.DIRECTORY_SEPARATOR.$class.'.php')) { include_once $script_path.DIRECTORY_SEPARATOR.$class.'.php'; } $script_path = Yii::getPathofAlias('application.admin.modules.'.$class.'script'); if (is_file($script_path.DIRECTORY_SEPARATOR.$class.'.php')) { // include_once $script_path.DIRECTORY_SEPARATOR.$class.'.php'; } } // function to render a css file protected function registerCssFile($name) { if ((Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'module') || (Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'view' && isset($_REQUEST["body"])) ) { echo '<link rel="stylesheet" type="text/css" href="'.Yii::app()->url->get_script_path().'/css/'.$name.'.css" />'; return; } $scripts = ''; $clientScript = Yii::app()->getClientScript(); $position = CClientScript::POS_HEAD; $clientScript->registerCssFile(Yii::app()->url->get_script_path().'/css/'.$name.'.css'); $clientScript->render($scripts); return $scripts; } // function to render a javascript file protected function registerScriptFile($name) { if ((Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'module') || (Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'view' && isset($_REQUEST["body"])) ) { echo '<script type="text/javascript" src="'.Yii::app()->url->get_script_path().'/scripts/'.$name.'.js"></script>'; return; } $scripts = ''; $clientScript = Yii::app()->getClientScript(); $clientScript->registerScriptFile(Yii::app()->url->get_script_path().'/scripts/'.$name.'.js'); $clientScript->render($scripts); return $scripts; } // function to render a javascript block protected function registerScript($id = '', $script) { if ((Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'module') || (Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'view' && isset($_REQUEST["body"])) ) { echo '<script type="text/javascript">'; echo $script; echo '</script>'; return; } $clientScript = Yii::app()->getClientScript(); //echo $script; $clientScript->registerScript($this->page_id.'_script'.$id, $script); $clientScript->render($scripts); return $scripts; } // return the skin of an element in the module protected function getSubModuleSkin($submodule) { $submoduleData = getIndex($this->module_data, 'subModules', array()); if (isset($submoduleData[$submodule]) && strlen($submoduleData[$submodule]) > 0) { return $submoduleData[$submodule]; } return false; } // get default skin when no kin is set to this module protected function getDefaultSkin($type, $layout_type) { $skin = BSkins::model()->find('type=:type and format=:format', array(':type' => $type, ':format' => $layout_type)); if (isset($skin)) { return 'b_'.$skin->name.'_'.$layout_type; } $skinDir = Yii::getPathofAlias('application.skins.'.$type); foreach(glob($skinDir. DIRECTORY_SEPARATOR .'*.skn.php') as $file) { $filename = basename($file); $skinName = str_replace('.skn.php', '',$filename); $skin = include($file); if(isset($skin) && is_array($skin)) { return 'a_'.$skinName.'_'.$layout_type; } } // $skin = SkinPreset::model()->with(array('module_type' => array('condition' => 'module_type.name=:name', 'params' => array(':name' => $type))))->find('format=:format', array(':format' => $layout_type)); // if (isset($skin)) { // return 'a_'.$skin->name.'_'.$layout_type; // } return ''; } // check current skin set to this module is exists protected function checkSkinValid($skin, $type) { $s = explode('_', $skin); if (sizeof($s) < 3) { return false; } $c = array_shift($s); $layout_type = array_pop($s); $skin_name = $s[0]; if (sizeof($s) > 0) { $skin_name = implode('_', $s); } $class = 'SkinPreset'; if ($c == 'a') { return SkinPreset::model()->with(array('module_type' => array('condition' => 'module_type.name=:name', 'params' => array(':name' => $type))))->exists('name=:name and format=:format', array(':name' => $skin_name, ':format' => $layout_type)); } else { return BSkins::model()->exists('name=:name and type=:type and format=:format', array(':name' => $skin_name, ':type' => $type, ':format' => $layout_type)); } return true; } //render open div tag for this module protected function openTag() { $module = $this->data; $type = $module['type']; $id = isset($module['id']) ? $module['id'] : 0; $is_float = isset($module['is_float']) ? $module['is_float'] : 0; $float_dir = isset($module['float_dir']) ? $module['float_dir'] : 'left'; $float_size = isset($module['float_size']) ? $module['float_size'] : 5; $layout_type = isset($module->layout_type) ? $module->layout_type : 0; $page_id = isset($this->page_id) ? $this->page_id : self::generate_page_id(); if (strlen($page_id) == 0) { $page_id = $this->generate_page_id(); } $skin = isset($module['skin']) ? $module['skin'] : ''; $class_name = $type.'Module'; if (strlen($skin) == 0 /*|| $this->checkSkinValid($skin, $type) == false*/) { $skin = $this->getDefaultSkin($type, $layout_type); } $data = isset($module['data']) ? $module['data'] : array(); if (!is_array($data)) { $data = CJavaScript::jsonDecode($data); } else { $data = (object) ($data); } $animation = getIndex($data, 'animation', false, 'boolean'); $animation_loop = getIndex($data, 'animation_loop', false, 'boolean'); $animation_type = getIndex($data, 'animation_type', ''); $full_class = 'module-'.$type.' module'.(strlen($skin) ? ' '.$skin : ''); $full_class .= ($is_float ? ' column-float-'.$float_dir : ''); $full_class .= ($is_float ? ' column'.$float_size : ''); $full_class .= ($animation ? ' wow animated' : ''); $full_class .= ($animation_loop ? ' infinite' : ''); $full_class .= ($animation ? ' '.$animation_type : ''); //if($full) echo '<div id="'.$page_id.'" class="'.$full_class.'" data-layout="'.$layout_type.'" data-type="'.$type.'" data-id="'.$id.'" data-skin="'.$skin.'">'; } protected function endTag() { echo '</div>'; } // render the body html of this module // Path to admin/widgets/views/modules/ public function renderBody() { $this->render($this->data['type']); } // return this view path for this widget public function getViewPath($checkTheme = false) { $path = Yii::getPathofAlias('application.admin.modules.'.$this->getModuleType()); if(file_exists($path.$this->getModuleType().'frontend_view.php')) { //return $path; } $path = Yii::getPathofAlias('application.widgets.views.modules'); return $path; if(file_exists($path.$this->getModuleType().'.php')) { return $path; } } // run the widget public function run() { $none_render_header_script = $this->script && Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'module'; if (!$this->invalid) { if (!$none_render_header_script) { $this->registerHeaderScripts(); } $unwrapTag = Yii::app()->controller->id == 'builder' && Yii::app()->controller->action->id == 'module'; if (!$unwrapTag) { $this->openTag(); } $this->renderBody(); $this->renderEditTag(); if (!$unwrapTag) { $this->endTag(); } } } // render the script tag contain data of this module protected function renderEditTag() { if (Yii::app()->controller->id == 'builder' && (Yii::app()->controller->action->id == 'view'||Yii::app()->controller->action->id == 'viewzone')) { $data = getIndex($this->data, 'data', array()); if (is_array($data)) { $dstring = json_encode($data); } else { $dstring = $data; } echo '<script id="'.$this->page_id.'_data'.'" type="text/json">'.$dstring.'</script>'; } } public function includeViewFile($name, $arr = array(), $return = false) { global $data, $edit, $skin, $db, $type,$page_id, $id, $ajax_load; $view_path = 'site.views'; $path = Yii::getPathOfAlias($view_path); $view_file = ''; if (file_exists($path.DIRECTORY_SEPARATOR.$name.'.php')) { $view_file = $path.DIRECTORY_SEPARATOR.$name.'.php'; } else { $view_path = 'application.widgets.views.modules'; $path = Yii::getPathOfAlias($view_path); if (file_exists($path.DIRECTORY_SEPARATOR.$name.'.php')) { $view_file = $path.DIRECTORY_SEPARATOR.$name.'.php'; } } if (strlen($view_file)) { if (!$return) { if (isset($arr)) { extract($arr); } include $view_file; } else { ob_start(); if (isset($arr)) { extract($arr); } include $view_file; $content = ob_get_clean(); return $content; } } return ''; } public function includeLanguageFile($file) { $language = Yii::app()->language; $dir = Yii::getPathofAlias('application.languages.'.$language); if (file_exists($dir.DIRECTORY_SEPARATOR.$file.'.php')) { include_once $dir.DIRECTORY_SEPARATOR.$file.'.php'; } } // return the type of this module protected function getType() { $type = get_class($this); $type = str_replace('CWidget', '', $type); $type = strtolower($type); $this->type = $type; return $this->type; } }
[+]
..
[+]
views
[-] Pagination.php
[edit]
[-] CWidgetCustomModule.php
[edit]
[-] CWidgetModuleRenderer.php
[edit]
[-] CWidgetZone.php
[edit]
[-] CTab.php
[edit]
[-] CWidgetRow.php
[edit]
[-] CWidgetEcommerce.php
[edit]
[+]
modules
[-] CWidgetCMS.php
[edit]
[-] CPanel.php
[edit]
[-] ActiveDataProvider.php
[edit]
[-] CPager.php
[edit]
[-] CWidgetModule.php
[edit]
[-] CWidgetColumn.php
[edit]
[-] CTabContent.php
[edit]
[-] CWidgetStructure.php
[edit]
[-] CPriceTable.php
[edit]