diff options
| author | astaf <astaf@proxy.ccwn.org.ccwn.org> | 2012-06-26 17:11:26 +0200 |
|---|---|---|
| committer | astaf <astaf@proxy.ccwn.org.ccwn.org> | 2012-06-26 17:11:26 +0200 |
| commit | f0e90d88a5766e67ff69339b27711ffb5f41e1ca (patch) | |
| tree | 387f30bc7cd39114f6db71a7deb7d5f16442c03c /protected/modules/cms/models/Cms.php | |
| parent | 1a52e642b8bb388fd4c4b29798fa3809a2114c9f (diff) | |
| parent | d58f7cf02dc0c5ce2df2f0db00361fe673074be8 (diff) | |
Merge branch 'master' of ssh://proxy:9044/home/ccwn/git-repos/admin.astaf.de
Diffstat (limited to 'protected/modules/cms/models/Cms.php')
| -rw-r--r-- | protected/modules/cms/models/Cms.php | 77 |
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;
+ } +} |
