PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
<?php class BPages extends BActiveRecord { public $sample_page; public $maxpriority; public static function model($className = __CLASS__) { return parent::model($className); } public function tableName() { return '{{pages}}'; } public function rules() { return array( array('name,file_name', 'unique'), array('id, name, display_name, file_name, parent_id, is_homepage, system_page, is_movable, can_haschild, is_protected, password, priority, title, description, keywords, favicon, sample_page, login_required, no_display, date_added, date_modified, author_id, last_modify_id, site_id', 'safe'), ); } public function stripUnicode($str) { if (!$str) { return false; } $unicode = array( 'a' => 'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ', 'd' => 'đ', 'e' => 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ', 'i' => 'í|ì|ỉ|ĩ|ị', 'o' => 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ', 'u' => 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự', 'y' => 'ý|ỳ|ỷ|ỹ|ỵ', ); foreach ($unicode as $nonUnicode => $uni) { $str = preg_replace("/($uni)/i", $nonUnicode, $str); } return $str; } public $mainPageContent; public $headerContent; public function beforeSave() { parent::beforeSave(); $this->name = trim($this->name); if ($this->getIsNewRecord()) { $file_name = $this->name; $pagename = strtolower($file_name); $file_name = strtolower($pagename); $file_name = str_replace(' ', '-', $pagename); $file_name = $this->stripUnicode($pagename); $system_page = array('index', 'blog', 'blogview'); for ($i = 0; $i < sizeof($system_page);++$i) { if ($file_name == $system_page[$i]) { $file_name .= rand(10, 99); } } while (Yii::app()->site->model->checkFileExist('views', $file_name)) { $file_name .= rand(10, 99); } $this->file_name = $file_name; } return true; } public function afterSave() { parent::afterSave(); if ($this->getIsNewRecord()) { if (isset($this->sample_page) && strlen($this->sample_page)) { $sample_page = $this->sample_page; if (is_array($this->sample_page)) { $sample_page = $this->sample_page[0]; } $sample_page = trim($sample_page); $dir = Yii::getPathofAlias('application.common_views'); $file = $dir.DIRECTORY_SEPARATOR.$sample_page.'.php'; $content = file_get_contents($file); Yii::app()->site->model->writeFile('views', $this->file_name, $content); } else { Yii::app()->site->model->writeFile('views', $this->file_name, ''); } } } public function afterDelete() { if (!$this->getIsNewRecord()) { Yii::app()->site->model->deleteFile('views', $this->file_name); } $this->clearPageData(); Yii::app()->site->model->deleteFile('page_data', $this->id, '.json'); } public function getElements() { $path = Yii::app()->site->model->getFilePath('page_data', $this->id, '.json'); $rs = array(); if (file_exists($path)) { $content = file_get_contents($path); $rs = explode(',', $content); } return $rs; } public function clearPageData() { $valid_modules = $this->getElements(); $skin_css_file_path = Yii::app()->site->model->getFilePath('css', 'skin', '.css'); $skin_css = Functions::readCSSContentFromFile($skin_css_file_path); $removed_skin_css = Functions::removeCSS($skin_css, $valid_modules); $skin_css_skin_file_path = Yii::app()->site->model->getFilePath('css', 'skin', '.css_skin'); $skin_css_skin = Functions::readCSSContentFromFile($skin_css_skin_file_path); $removed_skin_css_skin = Functions::removeCSS($skin_css_skin, $valid_modules); $skin_css_code = Functions::getCSSTextFormArray($removed_skin_css); $skin_css_skin_code = Functions::getCSSTextFormArray($removed_skin_css_skin); Yii::app()->site->model->writeFile('css', 'skin', $skin_css_code, '.css'); Yii::app()->site->model->writeFile('css', 'skin', $skin_css_skin_code, '.css_skin'); foreach ($valid_modules as $md) { Yii::app()->site->model->deleteFile('module_data', $md, '.json'); } return $valid_modules; } public function getViewPath() { $site_view_path = 'application_site.views'; $site_view_file = $site_view_path.'.'.$this->file_name; $view_file = Yii::getPathOfAlias($site_view_file); if (is_file($view_file.'.php') === true) { return $site_view_file; } $common_view_path = 'application.common_views'; $common_view_file = $common_view_path.'.'.$this->file_name; $view_file = Yii::getPathOfAlias($common_view_file); if (is_file($view_file.'.php') === true) { return $common_view_file; } return ''; } public function getHeaderViewPath() { $site_view_path = 'application_site.views'; $site_view_file = $site_view_path.'._header'; $view_file = Yii::getPathOfAlias($site_view_file); // if(is_file($view_file.'.php')) return $site_view_file; return false; } public function getFooterViewPath() { $site_view_path = 'application_site.views'; $site_view_file = $site_view_path.'._footer'; $view_file = Yii::getPathOfAlias($site_view_file); if (is_file($view_file.'.php')) { return $site_view_file; } return false; } public function getZoneViewPath($zone) { $zone_view_path = 'application_site.zones'; $site_view_file = $zone_view_path.'.'.$zone; $view_file = Yii::getPathOfAlias($site_view_file); if (is_file($view_file.'.php') === true) { return $site_view_file; } $common_view_path = 'application.zones'; $common_view_file = $common_view_path.'.'.$zone; $view_file = Yii::getPathOfAlias($common_view_file); if (is_file($view_file.'.php') === true) { return $common_view_file; } return ''; } public static function getHomePage() { $page = self::model()->find('is_homepage=1'); if (isset($page)) { return $page; } $page = self::model()->find(); if (isset($page)) { return $page; } return false; } }
[+]
..
[-] BTag.php
[edit]
[-] BActiveRecord.php
[edit]
[-] BModule.php
[edit]
[-] BPages.php
[edit]
[-] BComments.php
[edit]
[-] BNews_News_Category.php
[edit]
[-] BNewsModule.php
[edit]
[-] BAuthAssignment.php
[edit]
[-] BNewsCategory.php
[edit]
[-] BConfigurations.php
[edit]
[-] BPages_Elements.php
[edit]
[-] BNews_Comments.php
[edit]
[-] BNews_Categories.php
[edit]
[-] BUsers.php
[edit]
[-] BUserIdentity.php
[edit]
[-] BNews.php
[edit]
[-] BWebUser.php
[edit]
[+]
forms
[-] BColors.php
[edit]
[-] BSkins.php
[edit]
[-] BNews_Tag.php
[edit]
[-] BContributor_Invites.php
[edit]
[-] BContributor.php
[edit]