public function run() { Yii::import('application.modules.cms.models.*'); $this->model = Cms::model()->findByPK($this->parent_id); $tree = $this->getTreeViewData($this->showRoot, 'name'); if ($this->tpl) { $this->render($this->tpl, array('tree' => $tree)); } else { $this->widget('CTreeView', array('data' => $tree, 'animated' => false, 'persist' => 'location')); } }
private function getMenu() { if ($items = Cms::model()->findAllByAttributes($this->attributes)) { $menu = array(); $menu[] = array('label' => 'Home', 'url' => array('/')); foreach ($items as $item) { $menu[] = array('label' => $item->name, 'url' => array('/' . $item->url)); } return $menu; } return array(); }
function isTaken() { $this->normalizeUrl(); $params = array(':url' => $this->url, ':type_link' => self::LINK); if (!$this->getIsNewRecord()) { $params[':id'] = $this->id; $idCond .= ' AND id!=:id'; } $count = Cms::model()->count('url=:url AND type!=:type_link' . $idCond, $params); return $count; }
public static function renderHomePage() { $cmsHandler = new CmsHandler(); $page = Cms::model()->findByPk(1); $cmsHandler->processCms($page); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Cms the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Cms::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function renderContent() { $model = Cms::model()->findAllByAttributes(array('status' => 1, 'show_in_menu' => 1)); //$model = Cms::model()->findAll(); $this->render('navmenu', array('models' => $model, 'idul' => $this->idul, 'classli' => $this->classli, 'before_link' => $this->before_link, 'after_link' => $this->after_link, 'before_content' => $this->before_content, 'after_content' => $this->after_content)); }
/** * Modify User POST */ function modcms() { $clang = Yii::app()->lang; $page_id = flattenText($_POST['page_id'], false, true, 'UTF-8', true); $page_name = flattenText($_POST['page_name'], false, true, 'UTF-8', true); $page_title = flattenText($_POST['page_title'], false, true, 'UTF-8', true); $page_meta = flattenText($_POST['page_meta'], false, true, 'UTF-8', true); $page_language = Yii::app()->request->getPost("page_language"); $page_type = flattenText($_POST['page_type'], false, true, 'UTF-8', true); $shwmenu = flattenText(Yii::app()->request->getPost("shwmenu")); $shw_menu = 0; if ($shwmenu) { $shw_menu = 1; } if ($page_type == 1) { $page_content = $_POST['page_content']; } elseif ($page_type == 2) { $page_content = flattenText($_POST['redirectlink'], false, true, 'UTF-8', true); } $IsActive = flattenText(Yii::app()->request->getPost("IsActive")); $aViewUrls = array(); $is_Active = 0; if ($IsActive) { $is_Active = 1; } $sresult = Cms::model()->findAllByAttributes(array('page_id' => $page_id)); $sresultcount = count($sresult); if (Permission::model()->hasGlobalPermission('superadmin', 'read') || $sresultcount > 0 && Permission::model()->hasGlobalPermission('CMS', 'update')) { if ($page_name == '') { $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing page"), $clang->gT("Could not modify Contact."), "warningheader", $clang->gT("Page name not be empty."), $this->getController()->createUrl('admin/cms/sa/modifycms'), $clang->gT("Back"), array('page_id' => $page_id)); } else { $oRecord = Cms::model()->findByPk($page_id); $oRecord->page_name = $page_name; $oRecord->page_title = $page_title; $oRecord->contenttype = $page_type; $oRecord->showinmenu = $shw_menu; $oRecord->IsActive = $is_Active; $EditContact = $oRecord->save(); if ($EditContact) { // When saved successfully $sql = "SELECT count(*) as cnt FROM {{cms_page_content}}\n WHERE page_id = '{$page_id}' AND language_code = '{$page_language}'"; $result = Yii::app()->db->createCommand($sql)->queryRow(); if ($result['cnt'] > 0) { $sqlupdate = "UPDATE {{cms_page_content}} SET\n page_content = '" . str_replace("'", "'", $page_content) . "'\n , meta_tags = '{$page_meta}'\n WHERE page_id = '{$page_id}' AND language_code = '{$page_language}'"; $result = Yii::app()->db->createCommand($sqlupdate)->query(); } else { $sqlupdate = "INSERT INTO {{cms_page_content}} (page_id,language_code,page_content,meta_tags) \n VALUES('{$page_id}', '{$page_language}', '" . str_replace("'", "'", $page_content) . "', '{$page_meta}');"; $result = Yii::app()->db->createCommand($sqlupdate)->query(); } Yii::app()->setFlashMessage($clang->gT("Page updated successfully")); $this->getController()->redirect(array("admin/cms/index")); } else { $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing Page"), $clang->gT("Could not modify Page."), 'warningheader'); } } } else { Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error'); $this->getController()->redirect(array("admin/index")); } $this->_renderWrappedTemplate('cms', $aViewUrls); }
public function actionGetParentUrl() { $parentId = $_POST['parent_id']; $parent = Cms::model()->findByPk($parentId); if ($parent && $parent->url) { echo $parent->url . '/'; } }