summaryrefslogtreecommitdiff
path: root/protected/modules/cms/models/Cms.php
diff options
context:
space:
mode:
Diffstat (limited to 'protected/modules/cms/models/Cms.php')
-rw-r--r--protected/modules/cms/models/Cms.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/protected/modules/cms/models/Cms.php b/protected/modules/cms/models/Cms.php
new file mode 100644
index 0000000..e07ad4e
--- /dev/null
+++ b/protected/modules/cms/models/Cms.php
@@ -0,0 +1,77 @@
+<?php
+
+Yii::import('application.modules.cms.models.*');
+Yii::import('application.modules.cms.controllers.*');
+
+class Cms {
+ public function module() {
+ return Yii::app()->getModule('cms');
+
+ }
+ public static function t($string, $params = array())
+ {
+ Yii::import('application.modules.cms.CmsModule');
+ return Yii::t('CmsModule.cms', $string, $params);
+ }
+
+ public static function render($id = null, $return = false, $lang = null) {
+ if($lang === null)
+ $lang = Yii::app()->language;
+
+ $column = 'id';
+ if(!is_numeric($id))
+ $column = 'title_url';
+
+ if($id) {
+ $sitecontent = Sitecontent::model()->find(
+ $column . ' = :id and language = :lang', array(
+ ':id' => $id,
+ ':lang' => $lang));
+
+ // If the sitecontent is not available in the requested language,
+ // try to fallback to the first natural found sitecontent in the db
+ if(!$sitecontent)
+ $sitecontent = Sitecontent::model()->find(
+ $column .' = :id', array(
+ ':id' => $id));
+
+ if(!$sitecontent && Yii::app()->getModule('cms')->strict404raising)
+ throw new CHttpException(404);
+ else if (!$sitecontent) {
+ $sitecontent = new Sitecontent();
+ $sitecontent->content = "";
+ }
+ else if($return)
+ return $sitecontent->content;
+ else
+ echo $sitecontent->content;
+ }
+ }
+
+ public static function renderMenuPoints($id) {
+ if(is_numeric($id))
+ $sitecontent = Sitecontent::model()->findByAttributes(array('id'=> $id));
+ $childs = $sitecontent->childs;
+ if($childs) {
+ foreach($sitecontent->childs as $child) {
+ printf('<li>%s</li>',
+ CHtml::link($child->title, array(
+ '/cms/sitecontent/view', 'page' => $child->title_url) ));
+ }
+ }
+ }
+ public static function getMenuPoints($id) {
+ $tmp=array();
+ if(is_numeric($id))
+ $sitecontent = Sitecontent::model()->findByAttributes(array('id'=> $id));
+ $childs = $sitecontent->childs;
+ if($childs) {
+
+ foreach($sitecontent->childs as $child) {
+ Yii::trace("Lala","Debug");
+ $tmp = array_merge($tmp,array(array('label'=>$child->title, 'url'=>array('/cms/sitecontent/view', 'page'=>$child->title_url))));
+ }
+ }
+ return $tmp;
+ }
+}