PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
/
forms
<?php class PageForm extends CFormModel { public $id; public $sample_page; public $display_name; public $file_name; public $name; public $title; public $description,$keywords; public $parent_id,$system_page,$favicon; public $is_homepage; public $login_required, $is_protected, $password,$no_display,$priority,$date_added,$date_modified; public $last_modify_id,$author_id; public function PageForm() { } public function rules() { return array( array('id', 'numerical'), array('display_name', 'required'), array('name,file_name,sample_page', 'required','on' => 'create'), array('name,file_name', 'length', 'max' => 100), array('login_required, is_homepage,is_protected,no_display', 'in' , 'range' => array(0,1)), array('title,description,sample_page,keywords,no_display,favicon,system_page,parent_id, password,priority,last_modify_id,author_id,date_added,date_modified', 'safe'), ); } protected function preProcess() { if ($this->scenario === 'create' || !isset($this->id) || $this->id == 0) { // $this->name = $this->display_name; $name = Functions::stripUnicode($this->name); $name = str_replace(' ', '_', $name); $temp_name = trim($name); while (BPages::model()->exists('name=:name', array(':name' => $temp_name))) { $temp_name = rand(1, 1000).'_'.$name; } $this->name = $temp_name; $this->parent_id = 0; $criteria = new CDbCriteria(); $criteria->condition = 'parent_id='.$this->parent_id; $criteria->select = 'max(priority) AS maxpriority'; $row = BPages::model()->find($criteria); $this->priority = !is_null($row['maxpriority']) ? ($row['maxpriority'] + 1) : 1; } if (isset($this->sample_page) && is_array($this->sample_page)) { $this->sample_page = sizeof($this->sample_page) ? $this->sample_page[0] : ''; } } public function save($item = null) { $this->preProcess(); $now = date('Y-m-d H:i:s'); if ($this->validate()) { if ($this->scenario === 'create' || !isset($this->id) || $this->id == 0) { $page = new BPages(); $page->setIsNewRecord(true); $page->id = $page->getMaxId() + 1; $page->date_added = $now; $page->name = $this->name; $page->author_id = Yii::app()->user->id; } else { $page = BPages::model()->findByPk($this->id); $page->setIsNewRecord(false); } $page->display_name = $this->display_name; $page->title = $this->title; $page->description = $this->description; $page->keywords = $this->keywords; $page->login_required = $this->login_required; $page->is_homepage = $this->is_homepage; $page->is_protected = $this->is_protected; $page->password = $this->password; $page->no_display = $this->no_display; $page->parent_id = $this->parent_id; $page->priority = $this->priority; $page->sample_page = $this->sample_page; $page->date_modified = $now; $page->last_modify_id = Yii::app()->user->id; if ($page->validate() && $page->save()) { if ($page->is_homepage) { BPages::model()->updateAll(array('is_homepage' => 0), 'id<>'.$page->id); } if (is_null($page->no_display)) { $page->no_display =0; } return $page; } else { $this->addError($page->getErrors()); return false; } } else { return false; } } }
[+]
..
[-] ColorForm.php
[edit]
[-] ProfileResetPassForm.php
[edit]
[-] NewsCommentForm.php
[edit]
[-] SkinForm.php
[edit]
[-] PageForm.php
[edit]
[-] BLoginForm.php
[edit]
[-] UserResetPassForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] NewsForm.php
[edit]
[-] ContributorForm.php
[edit]
[-] News_CategoriesForm.php
[edit]
[-] InviteForm.php
[edit]
[-] NewsTagForm.php
[edit]
[-] DomainForm.php
[edit]