summaryrefslogtreecommitdiff
path: root/protected/modules/cms
diff options
context:
space:
mode:
Diffstat (limited to 'protected/modules/cms')
-rw-r--r--protected/modules/cms/CmsModule.php39
-rw-r--r--protected/modules/cms/components/MenuWidget.php36
-rw-r--r--protected/modules/cms/components/Relation.php636
-rw-r--r--protected/modules/cms/components/SearchWidget.php10
-rw-r--r--protected/modules/cms/components/views/advert.php16
-rw-r--r--protected/modules/cms/components/views/search.php6
-rw-r--r--protected/modules/cms/controllers/DefaultController.php20
-rw-r--r--protected/modules/cms/controllers/SitecontentController.php176
-rw-r--r--protected/modules/cms/docs/cms.mwbbin0 -> 5803 bytes
-rw-r--r--protected/modules/cms/docs/install.txt64
-rw-r--r--protected/modules/cms/docs/schema_mysql.sql17
-rw-r--r--protected/modules/cms/messages/de/cms.php50
-rw-r--r--protected/modules/cms/models/Cms.php77
-rw-r--r--protected/modules/cms/models/Sitecontent.php92
-rw-r--r--protected/modules/cms/views/default/index.php21
-rw-r--r--protected/modules/cms/views/layouts/cms.php38
-rw-r--r--protected/modules/cms/views/sitecontent/_form.php105
-rw-r--r--protected/modules/cms/views/sitecontent/_search.php49
-rw-r--r--protected/modules/cms/views/sitecontent/_short.php34
-rw-r--r--protected/modules/cms/views/sitecontent/_view.php34
-rw-r--r--protected/modules/cms/views/sitecontent/admin.php71
-rw-r--r--protected/modules/cms/views/sitecontent/create.php21
-rw-r--r--protected/modules/cms/views/sitecontent/draw.php4
-rw-r--r--protected/modules/cms/views/sitecontent/index.php25
-rw-r--r--protected/modules/cms/views/sitecontent/results.php19
-rw-r--r--protected/modules/cms/views/sitecontent/update.php18
-rw-r--r--protected/modules/cms/views/sitecontent/view.php47
27 files changed, 1725 insertions, 0 deletions
diff --git a/protected/modules/cms/CmsModule.php b/protected/modules/cms/CmsModule.php
new file mode 100644
index 0000000..79847ed
--- /dev/null
+++ b/protected/modules/cms/CmsModule.php
@@ -0,0 +1,39 @@
+<?php
+Yii::setPathOfAlias('CmsAssets' , dirname(__FILE__) . '/assets/');
+
+class CmsModule extends CWebModule
+{
+ public $version = '0.4';
+ public $layout = 'cms';
+ public $dateformat = 'd.m.Y G:i:s';
+ public $enableHtmlPurifier = true;
+ public $rtepath = false; // Don't use an Rich text Editor
+ public $rteadapter = false; // Don't use an Adapter
+ public $ckfinderPath = false; // do not use CKFinder
+
+ // Which languages do your cms serve?
+ public $languages = array('en' => 'English', 'de' => 'Deutsch');
+
+ // If a page is requested by CMS::render and not found, should
+ // a 404 be raised or the content simply not be delivered?
+ public $strict404raising = false;
+
+ public function init()
+ {
+ $this->setImport(array(
+ 'cms.models.*',
+ 'cms.components.*',
+ 'cms.controllers.*',
+ ));
+ }
+
+ public function beforeControllerAction($controller, $action)
+ {
+ if(parent::beforeControllerAction($controller, $action))
+ {
+ return true;
+ }
+ else
+ return false;
+ }
+}
diff --git a/protected/modules/cms/components/MenuWidget.php b/protected/modules/cms/components/MenuWidget.php
new file mode 100644
index 0000000..d17f356
--- /dev/null
+++ b/protected/modules/cms/components/MenuWidget.php
@@ -0,0 +1,36 @@
+<?php
+Yii::import('application.modules.cms.models.Sitecontent');
+
+class MenuWidget extends CWidget
+{
+ public $point;
+ protected $menu;
+
+ public function init()
+ {
+ if($this->point == 0)
+ throw new CException("Please provide a menu to render");
+
+ parent::init();
+ $this->menu = Sitecontent::model()->findAll(array(
+ 'condition' => 'parent = :point',
+ 'params' => array(':point' => $this->point),
+ 'order' => 'position',
+ )
+ );
+
+ $items = array();
+ if($this->menu)
+ foreach($this->menu as $point) {
+ $items[] = array('label' => $point->title,
+ 'active' => stripos(Yii::app()->request->url, $point->title_url) !== false,
+ 'url' => array('/site/view', 'page' => $point->title_url));
+ }
+
+ $this->widget('zii.widgets.CMenu',array(
+ 'items'=>$items
+ ));
+ }
+
+}
+?>
diff --git a/protected/modules/cms/components/Relation.php b/protected/modules/cms/components/Relation.php
new file mode 100644
index 0000000..c0dfcd1
--- /dev/null
+++ b/protected/modules/cms/components/Relation.php
@@ -0,0 +1,636 @@
+<?php
+/*
+ The Relation widget is used in forms, where the User can choose
+ between a selection of model elements, that this models belongs to.
+
+ It is able to handle BELONGS_TO, HAS_ONE and MANY_MANY Relations. The Relation
+type is detected automatically from the Model 'relations()' section.
+
+ The Widget has different styles in which it can render the possible choices.
+ Use the 'style' option to set the appropriate style.
+
+ The following example shows how to use Relation with a minimal config,
+ assuming we have a Model "Post" and "User", where one User belongs
+ to a Post:
+
+ <pre>
+ $this->widget('application.components.Relation', array(
+ 'model' => 'Post',
+ 'relation' => 'user'
+ 'fields' => 'username' // show the field "username" of the parent element
+ ));
+ </pre>
+
+ Results in a drop down list in which the user can choose between
+ all available Users in the Database. The shown field of the
+ Table "User" is "username" in this example.
+
+ You can choose the Style of your Widget in the 'style' option.
+ Note that a Many_Many Relation always gets rendered as a Listbox,
+ since you can select multiple Elements.
+
+ 'fields' can be an array or an string.
+ If you pass an array to 'fields', the Widget will display every field in
+ this array. If you want to show further sub-relations, separate the values
+ with '.', for example: 'fields' => 'array('parent.grandparent.description')
+
+ Optional Parameters:
+
+ You can use 'field' => 'post_userid' if the field in the model
+ that represents the foreign model is called different than in the
+ relation
+
+ Use 'relatedPk' => 'id_of_user' if the primary Key of the Foreign
+ Model differs from the one given in the relation.
+
+ Normally you shouldn´t use this fields cause the Widget get the relations
+ automatically from the relation.
+
+ Use 'allowEmpty' to let the user be able to choose no parent. If you
+ set this to a string, this string will be displayed with the available
+ choices.
+
+ With 'showAddButton' => 'false' you can disable the 'create new Foreignkey'
+ Button generated beside the Selectbox.
+
+ Define the AddButtonString with 'addButtonString' => 'Add...'. This string
+ is set default to '+'
+
+ When using the '+' button you most likely want to return to where you came.
+ To accomplish this, we pass a 'returnTo' parameter by $_GET.
+ The Controller can send the user back to where he came from this way:
+
+ <pre>
+ if($model->save())
+ if(isset($_GET['returnTo']))
+ $this->redirect(array(urldecode($_GET['returnTo'])));
+ </pre>
+
+ Using the 'style' option we can configure how our Widget gets rendered.
+ The following styles are available:
+ Selectbox (default), Listbox, Checkbox and in MANY_MANY relations 'twopane'
+ The style is case insensitive so one can use dropdownlist or dropDownList.
+
+ Use the option 'createAction' if the action to add additional foreign Model
+ options differs from 'create'.
+
+ With 'parentObjects' you can limit the Parent Elements that are being shown.
+ It takes an array of elements that could be returned from an scope or
+ an SQL Query.
+
+ The parentObjects can be grouped, for example, with
+ 'groupParentsBy' => 'city'
+
+ Use the option 'htmlOptions' to pass any html Options to the
+ Selectbox/Listbox form element.
+
+ Full Example:
+ <pre>
+ $this->widget('application.components.Relation', array(
+ 'model' => 'Post',
+ 'field' => 'Userid',
+ 'style' => 'ListBox',
+ 'parentObjects' => Parentmodel::model()->findAll('userid = 17'),
+ 'groupParentsBy' => 'city',
+ 'relation' => 'user',
+ 'relatedPk' => 'id_of_user',
+ 'fields' => array( 'username', 'username.group.groupid' ),
+ 'delimiter' => ' -> ', // default: ' | '
+ 'returnTo' => 'model/create',
+ 'addButtonLink' => 'othercontroller/otheraction', // default: ''
+ 'showAddButton' => 'click here to add a new User', // default: ''
+ 'htmlOptions' => array('style' => 'width: 100px;')
+ ));
+ </pre>
+
+
+ @author Herbert Maschke <thyseus@gmail.com>
+ @version 1.0rc5
+ @since 1.1
+ */
+
+class Relation extends CWidget
+{
+ // this Variable holds an instance of the Object
+ protected $_model;
+
+ // this Variable holds an instance of the related Object
+ protected $_relatedModel;
+
+ // draw the relation of which model?
+ public $model;
+
+ // which relation should be rendered?
+ public $relation;
+
+ public $field;
+
+ // the Primary Key of the foreign Model
+ public $relatedPk;
+
+ // a field or an array of fields that determine which field values
+ // should be rendered in the selection
+ public $fields;
+
+ // if this is set, the User is able to select no related model
+ // if this is set to a string, this string will be presented
+ public $allowEmpty = 0;
+
+ // Preselect which items?
+ public $preselect = array();
+
+ // disable this to hide the Add Button
+ // set this to a string to set the String to be displayed
+ public $showAddButton = true;
+ public $addButtonLink = '';
+ // Set this to false to generate a Link rather than a LinkButton
+ // This is useful when Javascript is not available
+ public $useLinkButton = true;
+
+ // use this to set the link where the user should return to after
+ // clicking the add Button
+ public $returnLink;
+
+ // How should a data row be rendered. {id} will be replaced by the id of
+ // the model. You can also insert every field that is available in the
+ // parent object.
+ // Use {fields} to display all fields delimited by $this->delimiter
+ // Use {func0} to {funcX} to evaluate user-contributed functions with the
+ // $functions array. Example:
+ //
+ // 'functions' => array( "CHtml::checkBoxList('parent{id}', '',
+ // CHtml::listData(Othermodel::model()->findAll(), 'id', 'title'));",),
+ // 'template' => '#{id} : {fields} ({title}) Allowed other Models: {func0}',
+ public $template = '{fields}';
+
+ // User-Contributed functions to be evaluated in template
+ public $functions = array();
+
+ // how should multiple fields be delimited
+ public $delimiter = " | ";
+
+ // style of the selection Widget
+ public $style = "dropDownList";
+ public $htmlOptions = array();
+ public $parentObjects = 0;
+ public $orderParentsBy = 0;
+ public $groupParentsBy = 0;
+
+ // override this for complicated MANY_MANY relations:
+ public $manyManyTable = '';
+ public $manyManyTableLeft = '';
+ public $manyManyTableRight = '';
+
+ public function init()
+ {
+ if(!is_object($this->model))
+ {
+ if(!$this->_model = new $this->model)
+ throw new CException(
+ Yii::t('yii','Relation widget is not able to instantiate the given Model'));
+ }
+ else
+ {
+ $this->_model = $this->model;
+ }
+
+ // Instantiate Model and related Model
+ foreach($this->_model->relations() as $key => $value)
+ {
+ if(strcmp($this->relation,$key) == 0)
+ {
+ // $key = Name of the Relation
+ // $value[0] = Type of the Relation
+ // $value[1] = Related Model
+ // $value[2] = Related Field or Many_Many Table
+ switch($value[0])
+ {
+ case 'CBelongsToRelation':
+ case 'CHasOneRelation':
+ $this->_relatedModel = new $value[1];
+ if(!isset($this->field))
+ {
+ $this->field = $value[2];
+ }
+ break;
+ case 'CManyManyRelation':
+ preg_match_all('/^.*\(/', $value[2], $matches);
+ $this->manyManyTable = substr($matches[0][0], 0, strlen($matches[0][0]) -1);
+ preg_match_all('/\(.*,/', $value[2], $matches);
+ $this->manyManyTableLeft = substr($matches[0][0], 1, strlen($matches[0][0]) - 2);
+ preg_match_all('/,.*\)/', $value[2], $matches);
+ $this->manyManyTableRight = substr($matches[0][0], 2, strlen($matches[0][0]) - 3);
+
+ $this->_relatedModel = new $value[1];
+ break;
+ }
+ }
+ }
+
+ if(!is_object($this->_relatedModel))
+ throw new CException(
+ Yii::t('yii','Relation widget cannot find the given Relation('.$this->relation.')'));
+
+ if(!isset($this->relatedPk) || $this->relatedPk == "")
+ {
+ $this->relatedPk = $this->_relatedModel->tableSchema->primaryKey;
+ }
+
+ if(!isset($this->fields) || $this->fields == "" || $this->fields == array())
+ throw new CException(Yii::t('yii','Widget "Relation" has been run without fields Option(string or array)'));
+ }
+
+ // Check if model-value contains '.' and generate -> directives:
+ public function getModelData($model, $field)
+ {
+ if(strstr($field, '.'))
+ {
+ $data = explode('.', $field);
+ $value = $model->getRelated($data[0])->$data[1];
+ } else
+ $value = $model->$field;
+
+ return $value;
+ }
+
+ /**
+ * This function fetches all needed data of the related Object and returns them
+ * in an array that is prepared for use in ListData.
+ */
+ public function getRelatedData()
+ {
+ /* At first we determine, if we want to display all parent Objects, or
+ * if the User supplied an list of Objects */
+ if(is_object($this->parentObjects)) // a single Element
+ {
+ $parentobjects = array($this->parentObjects);
+ }
+ else if(is_array($this->parentObjects)) // Only show this elements
+ {
+ $parentobjects = $this->parentObjects;
+ }
+ else // Show all Parent elements
+ {
+ $parentobjects = CActiveRecord::model(get_class($this->_relatedModel))->findAll();
+ }
+
+ if($this->allowEmpty)
+ if(is_string($this->allowEmpty))
+ $dataArray[0] = $this->allowEmpty;
+ else
+ $dataArray[0] = Yii::t('app', 'None');
+
+ foreach($parentobjects as $obj)
+ {
+ if(!is_array($this->fields))
+ $this->fields = array($this->fields);
+
+ $fields = '';
+ foreach($this->fields as $field)
+ {
+ $rule = sprintf('{%s}',$field);
+ $rules[$rule] = $obj->$field;
+ $fields .= $this->getModelData($obj, $field);
+ if(count($this->fields) >1)
+ $fields .= $this->delimiter;
+ }
+
+ $defaultrules = array(
+ '{fields}' => $fields,
+ '{id}' => $obj->{$obj->tableSchema->primaryKey});
+
+ // Look for user-contributed functions and evaluate them
+ if($this->functions != array())
+ {
+ foreach($this->functions as $key => $function)
+ {
+ $funcrules[sprintf('{func%d}', $key)] = CComponent::evaluateExpression(
+ strtr($function, $defaultrules));
+ }
+ }
+
+ // Merge the evaluated rules, if exist
+ if(isset($funcrules))
+ $rules = array_merge($rules, $funcrules);
+
+ // Merge the default rules into our ruleset
+ $rules = array_merge($rules, $defaultrules);
+
+ // Apply the rules to the template
+ $value = strtr($this->template, $rules);
+
+ if($this->groupParentsBy != '')
+ {
+ $dataArray[$obj->{$this->groupParentsBy}][$obj->{$this->relatedPk}] = $value;
+ }
+ else
+ {
+ $dataArray[$obj->{$this->relatedPk}] = $value;
+ }
+ }
+
+ if(!isset($dataArray) || !is_array($dataArray))
+ $dataArray = array();
+
+ return $dataArray;
+ }
+
+
+ /**
+ * Retrieves the Assigned Objects of the MANY_MANY related Table
+ */
+ public function getAssignedObjects()
+ {
+ if(!$this->_model->{$this->_model->tableSchema->primaryKey})
+ return array();
+
+ $sql = sprintf("select * from %s where %s = %s",
+ $this->manyManyTable,
+ $this->manyManyTableLeft,
+ $this->_model->{$this->_model->tableSchema->primaryKey});
+
+ $result = Yii::app()->db->createCommand($sql)->queryAll();
+
+ foreach($result as $foreignObject) {
+ $id = $foreignObject[$this->manyManyTableRight];
+ $objects[$id] = $this->_relatedModel->findByPk($id);
+ }
+
+ return isset($objects) ? $objects : array();
+ }
+
+ /**
+ * Retrieves the not Assigned Objects of the MANY_MANY related Table
+ * This is used in the two-pane style view.
+ */
+ public function getNotAssignedObjects()
+ {
+ foreach($this->getRelatedData() as $key => $value)
+ {
+ if(!array_key_exists($key, $this->getAssignedObjects()))
+ {
+ $objects[$key] = $this->_relatedModel->findByPk($key);
+ }
+ }
+
+ return $objects ? $objects : array();
+ }
+
+ /**
+ * Gets the Values of the given Object or Objects depending on the
+ * $this->fields the widget requests
+ */
+ public function getObjectValues($objects)
+ {
+ if(is_array($objects)) {
+ foreach($objects as $object)
+ {
+ $attributeValues[$object->primaryKey] = $object->{$this->fields};
+ }
+ }
+ else if(is_object($objects))
+ {
+ $attributeValues[$object->primaryKey] = $objects->{$this->fields};
+ }
+
+ return isset($attributeValues) ? $attributeValues : array();
+ }
+
+ /*
+ * How will the Listbox of the MANY_MANY Assignment be called?
+ */
+ public function getListBoxName($ajax = false)
+ {
+ if($ajax)
+ {
+ return sprintf('%s_%s',
+ get_class($this->_model),
+ get_class($this->_relatedModel)
+ );
+ }
+ else
+ {
+ return sprintf('%s[%s]',
+ get_class($this->_model),
+ get_class($this->_relatedModel)
+ );
+ }
+ }
+
+ public function renderBelongsToSelection() {
+ if(strcasecmp($this->style, "dropDownList") == 0)
+ echo CHtml::ActiveDropDownList(
+ $this->_model,
+ $this->field,
+ $this->getRelatedData(),
+ $this->htmlOptions);
+ else if(strcasecmp($this->style, "listbox") == 0)
+ echo CHtml::ActiveListBox(
+ $this->_model,
+ $this->field,
+ $this->getRelatedData(),
+ $this->htmlOptions);
+ else if(strcasecmp($this->style, "checkbox") == 0)
+ echo CHtml::ActiveCheckBoxList(
+ $this->_model,
+ $this->field,
+ $this->getRelatedData(),
+ $this->htmlOptions);
+
+ }
+
+ public function renderManyManySelection() {
+ if(strcasecmp($this->style, 'twopane') == 0)
+ $this->renderTwoPaneSelection();
+ else if(strcasecmp($this->style, 'checkbox') == 0)
+ $this->renderCheckBoxListSelection();
+ else if(strcasecmp($this->style, 'dropDownList') == 0)
+ $this->renderManyManyDropDownListSelection();
+ else
+ $this->renderOnePaneSelection();
+ }
+
+
+ /*
+ * Renders one dropDownList per selectable related Element.
+ * The users can add additional entries with the + and remove entries
+ * with the - Button .
+ */
+ public function renderManyManyDropDownListSelection()
+ {
+ $i = 0;
+ foreach($this->_relatedModel->findAll() as $obj)
+ {
+ $i++;
+ $isAssigned = $this->isAssigned($obj->id);
+
+ echo CHtml::openTag('div', array(
+ 'id' => 'div' . $i,
+ 'style' => $isAssigned ? '' : 'display:none;',
+ ));
+ echo CHtml::dropDownList('rel-' . $obj->id . "-" . $this->getListBoxName(),
+ $isAssigned ? $obj->id : 0,
+ CHtml::listData(
+ array_merge(
+ array('0' => $this->allowEmpty),
+ $this->_relatedModel->findAll()),
+ $this->relatedPk,
+ $this->fields
+ )
+ );
+ echo CHtml::closeTag('div');
+ }
+
+ $jsadd = '
+ i = 1;
+ maxi = '.$i.';
+ $(\'#add\').click(function() {
+$(\'#div\' + i).show();
+if(i <= maxi) ++i;
+});
+';
+
+ $jssub = '
+$(\'#sub\').click(function() {
+if(i > 2) --i;
+$(\'#div\' + i).hide();
+});
+';
+
+ Yii::app()->clientScript->registerScript('addbutton', $jsadd);
+ Yii::app()->clientScript->registerScript('subbutton', $jssub);
+
+ echo CHtml::button('+', array('id' => 'add'));
+ echo '&nbsp;';
+ echo CHtml::button('-', array('id' => 'sub'));
+ echo '&nbsp;';
+ }
+
+ public function isAssigned($id)
+ {
+ return in_array($id, array_keys($this->getAssignedObjects()));
+ }
+
+ public static function retrieveValues($data, $field)
+ {
+ $returnArray = array();
+
+ foreach($data as $key => $value)
+ {
+ if(strpos($key, 'rel') !== false)
+ {
+ if(isset($value[$field]))
+ $returnArray[] = $value[$field];
+ }
+ }
+
+ return $returnArray;
+ }
+
+
+public function renderCheckBoxListSelection()
+{
+ $keys = array_keys($this->getAssignedObjects());
+
+ if(isset($this->preselect))
+ $keys = $this->preselect;
+
+ echo CHtml::CheckBoxList($this->getListBoxName(),
+ $keys,
+ $this->getRelatedData(),
+ $this->htmlOptions);
+ }
+
+
+ public function renderOnePaneSelection()
+ {
+ $keys = array_keys($this->getAssignedObjects());
+
+ echo CHtml::ListBox($this->getListBoxName(),
+ $keys,
+ $this->getRelatedData(),
+ array('multiple' => 'multiple'));
+ }
+
+ public function handleAjaxRequest($_POST) {
+ print_r($_POST);
+ }
+
+ public function renderTwoPaneSelection()
+ {
+ echo CHtml::ListBox($this->getListBoxName(),
+ array(),
+ $this->getObjectValues($this->getAssignedObjects()),
+ array('multiple' => 'multiple'));
+
+ $ajax =
+ array(
+ 'type'=>'POST',
+ 'data'=>array('yeah'),
+ 'update'=>'#' . $this->getListBoxName(true),
+ );
+
+ echo CHtml::ajaxSubmitButton('<<',
+ array('assign'),
+ $ajax
+ );
+
+ $ajax =
+ array(
+ 'type'=>'POST',
+ 'update'=>'#not_'.$this->getListBoxName(true)
+ );
+
+ echo CHtml::ajaxSubmitButton('>>',
+ array('assign','revoke'=>1),
+ $ajax);//,
+ //$data['revoke']);
+
+
+ echo CHtml::ListBox('not_' . $this->getListBoxName(),
+ array(),
+ $this->getObjectValues($this->getNotAssignedObjects()),
+ array('multiple' => 'multiple'));
+ }
+
+public function run()
+{
+ if($this->manyManyTable != '')
+ $this->renderManyManySelection();
+ else
+ $this->renderBelongsToSelection();
+
+ if($this->showAddButton !== false)
+ {
+ $this->renderAddButton();
+ }
+}
+protected function renderAddButton()
+{
+ if(!isset($this->returnLink) or $this->returnLink == "")
+ $this->returnLink = $this->model->tableSchema->name . "/create";
+
+ if($this->addButtonLink != '')
+ $link = $this->addButtonLink;
+ else
+ $link = array(
+ $this->_relatedModel->tableSchema->name . "/create",
+ 'returnTo' => $this->returnLink);
+
+
+ if(!$this->useLinkButton)
+ {
+ echo CHtml::Link(
+ is_string($this->showAddButton) ? $this->showAddButton : 'New', $link
+ );
+ }
+ else
+ {
+ echo CHtml::LinkButton(
+ is_string($this->showAddButton) ? $this->showAddButton : 'New',
+ array('submit' => $link));
+ }
+
+}
+}
+
diff --git a/protected/modules/cms/components/SearchWidget.php b/protected/modules/cms/components/SearchWidget.php
new file mode 100644
index 0000000..eee7332
--- /dev/null
+++ b/protected/modules/cms/components/SearchWidget.php
@@ -0,0 +1,10 @@
+<?php
+class SearchWidget extends CWidget
+{
+ public function init()
+ {
+ parent::init();
+ $this->render('search');
+ }
+}
+?>
diff --git a/protected/modules/cms/components/views/advert.php b/protected/modules/cms/components/views/advert.php
new file mode 100644
index 0000000..676348f
--- /dev/null
+++ b/protected/modules/cms/components/views/advert.php
@@ -0,0 +1,16 @@
+<?php
+$url = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('CmsAssets'));
+$file = $url . DIRECTORY_SEPARATOR . 'jquery.jshowoff.min.js';
+Yii::app()->clientScript->registerScriptFile($file);
+Yii::app()->clientScript->registerScript('advertising', "$('#adverts').jshowoff({links: false, controls:false});");
+
+echo '<div id="adverts">';
+foreach($adverts as $advert) {
+ echo '<div class="advert">';
+ echo $advert->content;
+ echo '</div>';
+}
+
+echo '</div>';
+?>
+<div style="clear:both;"></div>
diff --git a/protected/modules/cms/components/views/search.php b/protected/modules/cms/components/views/search.php
new file mode 100644
index 0000000..1163abd
--- /dev/null
+++ b/protected/modules/cms/components/views/search.php
@@ -0,0 +1,6 @@
+<?php
+echo CHtml::beginForm(array('/cms/sitecontent/search'));
+echo CHtml::textField('search', '', array('size' => 10));
+echo CHtml::submitButton('Suche');
+echo CHtml::endForm();
+?>
diff --git a/protected/modules/cms/controllers/DefaultController.php b/protected/modules/cms/controllers/DefaultController.php
new file mode 100644
index 0000000..b76d17b
--- /dev/null
+++ b/protected/modules/cms/controllers/DefaultController.php
@@ -0,0 +1,20 @@
+<?php
+
+class DefaultController extends Controller
+{
+ public function beforeAction($action)
+ {
+ $this->layout = Yii::app()->controller->module->layout;
+ return true;
+ }
+
+ public function actionIndex()
+ {
+ $this->render('index');
+ }
+ public function actionAdmin()
+ {
+ $this->render('admin');
+ }
+
+}
diff --git a/protected/modules/cms/controllers/SitecontentController.php b/protected/modules/cms/controllers/SitecontentController.php
new file mode 100644
index 0000000..72dde78
--- /dev/null
+++ b/protected/modules/cms/controllers/SitecontentController.php
@@ -0,0 +1,176 @@
+<?php
+
+Yii::import('application.modules.cms.models.Sitecontent');
+class SitecontentController extends Controller
+{
+ public $defaultAction='admin';
+ private $_model;
+
+ public function beforeAction($action)
+ {
+ $this->layout = Yii::app()->controller->module->layout;
+ return true;
+ }
+ public function accessRules()
+ {
+ return array(
+ array('deny',
+ 'actions'=>array('*'),
+ 'users'=>array('*'),
+ ),
+ array('allow',
+ 'actions'=>array('*'),
+ 'roles'=>array('admin'),
+ )
+ );
+ }
+ public function actionSearch()
+ {
+ $q = new CDbCriteria();
+ $q->addSearchCondition('content',$_POST['search']);
+ $results = Sitecontent::model()->findAll($q);
+ $q = new CDbCriteria();
+ $q->addSearchCondition('beschreibung',$_POST['search']);
+ $results = Verein::model()->findAll($q);
+
+ $this->render('results', array(
+ 'results' => $results,
+ 'search' => $_POST['search']));
+ }
+
+ public static function getContent($id) {
+ if($model = Sitecontent::model()->findByPk($id)) {
+ return $model->content;
+ }
+ }
+
+ public function filters()
+ {
+ return array('accessControl');
+ }
+
+ public function actionView()
+ {
+ $model = $this->loadContent();
+
+ $this->breadcrumbs = array($model->title);
+ if($model->depth == 1) {
+ $this->menu = CMS::getMenuPoints($model->id);
+ } elseif ($model->depth == 2){
+ $this->menu = CMS::getMenuPoints($model->oparent->id);
+ }
+ $this->render('view', array(
+ 'sitecontent' => $model,
+ ));
+ }
+
+ public function actionCreate()
+ {
+ $model=new Sitecontent;
+
+ $this->performAjaxValidation($model);
+
+ if(isset($_POST['Sitecontent']))
+ {
+ $model->attributes=$_POST['Sitecontent'];
+ $model->createtime = time();
+ $model->updatetime = time();
+
+ if(isset(Yii::app()->user->id))
+ $model->authorid = Yii::app()->user->id;
+
+ if($model->save())
+ $this->redirect(array('admin'));
+ }
+
+ if(isset($_GET['position']))
+ $model->position = $_GET['position'];
+
+ $this->render('create',array(
+ 'model'=>$model,
+ ));
+ }
+
+ public function actionUpdate()
+ {
+ $model=$this->loadContent();
+
+ $this->performAjaxValidation($model);
+
+ if(isset($_POST['Sitecontent']))
+ {
+ $model->attributes=$_POST['Sitecontent'];
+ $model->updatetime = time();
+ if($model->save())
+ $this->redirect(array('admin'));
+ }
+
+ $this->render('update',array(
+ 'model'=>$model,
+ ));
+ }
+
+ public function actionDelete()
+ {
+ if(Yii::app()->request->isPostRequest)
+ {
+ $this->loadContent()->delete();
+
+ if(!isset($_POST['ajax']))
+ $this->redirect(array('index'));
+ }
+ else
+ throw new CHttpException(400,Yii::t('App','Invalid request. Please do not repeat this request again.'));
+ }
+
+ public function actionIndex()
+ {
+ $dataProvider=new CActiveDataProvider('Sitecontent');
+ $this->render('index',array(
+ 'dataProvider'=>$dataProvider,
+ ));
+ }
+
+ public function actionAdmin()
+ {
+ $model=new Sitecontent('search');
+ if(isset($_GET['Sitecontent']))
+ $model->attributes=$_GET['Sitecontent'];
+
+ $this->render('admin',array(
+ 'model'=>$model,
+ ));
+ }
+
+ public function loadContent()
+ {
+ if($this->_model===null)
+ {
+ if(isset($_GET['id']) && is_array(@$_GET['id']))
+ $this->_model = Sitecontent::model()->find('id = :id and language = :language', array(
+ ':id' => $_GET['id']['id'],
+ ':language' => $_GET['id']['language'],
+ ));
+ if(isset($_GET['id']) && !is_array($_GET['id']))
+ $this->_model = Sitecontent::model()->find('id = :id', array(
+ ':id' => $_GET['id'],
+ ));
+
+ if($this->_model === null)
+ $this->_model = Sitecontent::model()->find("title_url = :page", array(
+ ':page' => $_GET['page']));
+ if($this->_model===null)
+ throw new CHttpException(404,Yii::t('App','We are sorry. The requested page does not exist.'));
+ }
+ return $this->_model;
+ }
+
+ protected function performAjaxValidation($model)
+ {
+ if(isset($_POST['ajax']) && $_POST['ajax']==='sitecontent-form')
+ {
+ echo CActiveForm::validate($model);
+ Yii::app()->end();
+ }
+ }
+}
diff --git a/protected/modules/cms/docs/cms.mwb b/protected/modules/cms/docs/cms.mwb
new file mode 100644
index 0000000..07682c5
--- /dev/null
+++ b/protected/modules/cms/docs/cms.mwb
Binary files differ
diff --git a/protected/modules/cms/docs/install.txt b/protected/modules/cms/docs/install.txt
new file mode 100644
index 0000000..72b92dc
--- /dev/null
+++ b/protected/modules/cms/docs/install.txt
@@ -0,0 +1,64 @@
+How to install this Content Management Module in your Yii application:
+
+1.) Extract the archive into your protected/modules folder.
+
+2.) Import the docs/schema_mysql.sql to the mysql Database that your
+Application runs. Only one table, called 'sitecontent', will be inserted.
+
+$ mysql -u root -p < docs/schema_mysql.sql -D database_name
+
+Add the module to your application Configuration.
+[...]
+'modules' => array(
+ 'cms' => array(
+ 'languages' => array('en', 'de') // <-- languages you want to allow
+ )
+ ),
+[...]
+
+If you want to use the layout of your existing Web Application, set the layout
+to an empty string, or null:
+
+ 'layout' => null,
+
+Otherwise an lightweight default layout of the cms will be used.
+
+Administrate your Content by using
+http://app/index.php?r=cms/sitecontent/admin
+
+or, when using a Route configuration, possibly
+
+http://app/index.php/cms/sitecontent/admin
+
+Please not that a 'sitecontent'-entry acts as a sitecontent as well as a
+menu point.
+
+In order to let your Application render the content at appropriate places,
+do is like this:
+
+// This will render a <ul><li>-based Menu containing all child elements of
+// the menu points.
+Cms::renderMenuPoints($id_of_the_sitecontent_page);
+
+Use Cms::render($page, $language) to render sitecontent everywhere you want
+in your views, models or controllers:
+
+// render sitecontent page 3
+<?php echo Cms::render(3); ?>
+
+// render sitecontent page with the url_title footer
+<?php echo Cms::render('footer'); ?>
+
+// render sitecontent page with the url_title footer in _french_.
+// note that, by default, cms::render tries to resolve the page in the
+// language of Yii::app()->language:
+<?php echo Cms::render('footer', 'fr'); ?>
+
+
+Please also read CmsModule.php for additional configuration options.
+
+Feel free to contact me at:
+skype: herbertmaschke
+icq: 38541423
+email: thyseus@gmail.com
+yii-forum username: thyseus
diff --git a/protected/modules/cms/docs/schema_mysql.sql b/protected/modules/cms/docs/schema_mysql.sql
new file mode 100644
index 0000000..372f837
--- /dev/null
+++ b/protected/modules/cms/docs/schema_mysql.sql
@@ -0,0 +1,17 @@
+CREATE TABLE IF NOT EXISTS `sitecontent` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `parent` int(11) NOT NULL,
+ `authorid` varchar(255) DEFAULT NULL,
+ `language` varchar(5) NOT NULL,
+ `position` int(10) unsigned NOT NULL,
+ `keywords` varchar(255) NULL,
+ `description` varchar(255) NULL,
+ `title_url` varchar(80) NOT NULL,
+ `title_browser` varchar(80) NOT NULL,
+ `title` varchar(255) NOT NULL,
+ `content` text NOT NULL,
+ `createtime` int(11) DEFAULT NULL,
+ `updatetime` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`, `language`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
diff --git a/protected/modules/cms/messages/de/cms.php b/protected/modules/cms/messages/de/cms.php
new file mode 100644
index 0000000..ea84286
--- /dev/null
+++ b/protected/modules/cms/messages/de/cms.php
@@ -0,0 +1,50 @@
+<?php
+return array(
+ 'Search results' => 'Suchergebnisse',
+ 'Promote' => 'Bewerben',
+ 'Results:' => 'Treffer:',
+ 'No results found' => 'Keine Treffer gefunden',
+ 'Search' => 'Suche',
+ 'search' => 'Suche',
+ 'Menustructure' => 'Menüstruktur',
+ 'Parent' => 'Übergeordneter Menüpunkt',
+ 'Sort order' => 'Sortierreihenfolge',
+ 'Title' => 'Titel',
+ 'Show Menu Structure' => 'Menüstruktur anzeigen',
+ 'Manage the Menu structure' => 'Menüstruktur verwalten',
+ 'Manage Menustructure' => 'Menüstruktur verwalten',
+ 'Create new Menupoint' => 'Neuen Menüpunkt hinzufügen',
+ 'Manage Sitecontent' => 'Seiteninhalt verwalten',
+ 'Create new Sitecontent' => 'Neuen Seiteninhalt erstellen',
+ 'Create new sitecontent here' => 'Hier neuen Seiteninhalt erstellen',
+ 'Edit this sitecontent' => 'Diesen Seiteninhalt bearbeiten',
+ 'Sort' => 'Sortierung',
+ 'Content' => 'Inhalt',
+ 'Author' => 'Autor',
+ 'Createtime' => 'Erstellt am',
+ 'Updatetime' => 'Zuletzt geändert am',
+ 'Sitecontent' => 'Seiteninhalt',
+ 'Manage' => 'Verwaltung',
+ 'Root' => 'Wurzelebene',
+ 'View Menustructure' => 'Menüstruktur anzeigen',
+ 'Create new Menuentry' => 'Neuen Menüpunkt anlegen',
+ 'View Entry' => 'Menüpunkt anzeigen',
+ 'This Menuentry has the following Sitecontent' => 'Dieser Menüeintrag besitzt folgende Seiteninhalte',
+ 'This Menuentry has no Sitecontent yet' => 'Dieser Menüeintrag besitzt noch keine Seiteninhalte',
+ 'Welcome to your CMS' => 'Willkommen zum Content Management System',
+ 'Update menupoint' => 'Menüpunkt bearbeiten',
+ 'Create sitecontent' => 'Seiteninhalt erstellen',
+ 'Create menupoint' => 'Menüpunkt erstellen',
+ 'Save sitecontent' => 'Seiteninhalt speichern',
+ 'Save menupoint' => 'Menüpunkt speichern',
+ 'Create' => 'Erstellen',
+ 'Save' => 'Speichern',
+ 'Update' => 'Bearbeite',
+ 'Language' => 'Sprache',
+ '' => '',
+ '' => '',
+ '' => '',
+ '' => '',
+ '' => '',
+);
+?>
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;
+ }
+}
diff --git a/protected/modules/cms/models/Sitecontent.php b/protected/modules/cms/models/Sitecontent.php
new file mode 100644
index 0000000..17e6f0f
--- /dev/null
+++ b/protected/modules/cms/models/Sitecontent.php
@@ -0,0 +1,92 @@
+<?php
+
+class Sitecontent extends CActiveRecord
+{
+ public static function model($className=__CLASS__)
+ {
+ return parent::model($className);
+ }
+
+ public function primaryKey() {
+ return array('id', 'language');
+ }
+
+ public function beforeValidate() {
+ if(Yii::app()->controller->module->enableHtmlPurifier) {
+ $purifier = new CHtmlPurifier();
+ $this->content = $purifier->purify($this->content);
+ }
+ return parent::beforeValidate();
+ }
+
+ public function tableName()
+ {
+ return 'sitecontent';
+ }
+
+ public function rules()
+ {
+ return array(
+ array('position, title, language, depth', 'required'),
+ array('parent, depth, position, createtime, updatetime', 'numerical', 'integerOnly'=>true),
+ array('title, keywords, description', 'length', 'max'=>255),
+ array('content, title_url, title_browser', 'safe'),
+ array('title, keywords, description, content, language', 'safe', 'on'=>'search'),
+ );
+ }
+
+ public function relations()
+ {
+ return array(
+ 'oparent' => array(self::BELONGS_TO, 'Sitecontent', 'parent'),
+ 'childs' => array(self::HAS_MANY, 'Sitecontent', 'parent'),
+ );
+ }
+
+ public function attributeLabels()
+ {
+ return array(
+ 'id' => '#',
+ 'parent' => Yii::t('CmsModule.cms', 'Parent'),
+ 'position' => Yii::t('CmsModule.cms', 'Position'),
+ 'title' => Yii::t('CmsModule.cms', 'Title'),
+ 'title_url' => Yii::t('CmsModule.cms', 'URL title'),
+ 'title_browser' => Yii::t('CmsModule.cms', 'Browser title'),
+ 'content' => Yii::t('CmsModule.cms', 'Content'),
+ 'authorid' => Yii::t('CmsModule.cms', 'Authorid'),
+ 'createtime' => Yii::t('CmsModule.cms', 'Createtime'),
+ 'updatetime' => Yii::t('CmsModule.cms', 'Updatetime'),
+ 'language' => Yii::t('CmsModule.cms', 'Language'),
+ 'depth' => Yii::t('CmsModule.cms', 'Depth'),
+ );
+ }
+
+ public function search()
+ {
+ $criteria=new CDbCriteria;
+
+ $criteria->compare('id',$this->id);
+ $criteria->compare('position',$this->position);
+ $criteria->compare('language',$this->language);
+ $criteria->compare('title',$this->title,true);
+ $criteria->compare('keywords',$this->keywords,true);
+ $criteria->compare('description',$this->description,true);
+ $criteria->compare('content',$this->content,true);
+ $criteria->compare('authorid',$this->authorid);
+ $criteria->compare('createtime',$this->createtime);
+ $criteria->compare('updatetime',$this->updatetime);
+ //$criteria->compare('depth',$this->depth);
+
+ return new CActiveDataProvider('Sitecontent', array(
+ 'criteria'=>$criteria,
+ ));
+ }
+
+ public function beforeSave() {
+ if ($this->parent > 0){
+ $this->depth = $this->oparent->depth + 1;
+
+ }
+ return parent::beforeSave();
+ }
+}
diff --git a/protected/modules/cms/views/default/index.php b/protected/modules/cms/views/default/index.php
new file mode 100644
index 0000000..327a9e0
--- /dev/null
+++ b/protected/modules/cms/views/default/index.php
@@ -0,0 +1,21 @@
+<?php
+$this->breadcrumbs=array(
+ $this->module->id,
+);
+
+$this->menu = array(
+ array(
+ 'label' => Cms::t('Manage Sitecontent'),
+ 'url' => array('sitecontent/admin')
+ ),
+ array(
+ 'label' => Cms::t('Create new Sitecontent'),
+ 'url' => array('sitecontent/create')
+ ),
+);
+
+?>
+
+<h1> <?php echo Yii::t('CmsModule.cms', 'Welcome to your CMS'); ?> </h1>
+
+
diff --git a/protected/modules/cms/views/layouts/cms.php b/protected/modules/cms/views/layouts/cms.php
new file mode 100644
index 0000000..5398422
--- /dev/null
+++ b/protected/modules/cms/views/layouts/cms.php
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="language" content="en" />
+
+ <title><?php echo CHtml::encode($this->pageTitle); ?></title>
+</head>
+
+<body>
+ <?php $this->widget('zii.widgets.CBreadcrumbs', array(
+ 'links'=>$this->breadcrumbs,
+ )); ?><!-- breadcrumbs -->
+
+ <?php echo $content; ?>
+
+ <div style="float:right;">
+<?php
+ $this->widget('zii.widgets.CMenu',array(
+ 'items'=>$this->menu
+ )
+);
+?>
+ </div>
+
+ <div class="clear"> </div>
+
+ <div id="footer">
+ <p> CMS Module by thyseus@gmail.com </p>
+ <?php echo Yii::powered(); ?>
+ </div><!-- footer -->
+
+</div><!-- page -->
+
+</body>
+</html>
+
+<?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/form.css'); ?>
diff --git a/protected/modules/cms/views/sitecontent/_form.php b/protected/modules/cms/views/sitecontent/_form.php
new file mode 100644
index 0000000..6c8d056
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/_form.php
@@ -0,0 +1,105 @@
+<?php
+if(Yii::app()->getModule('cms')->rtepath != false)
+Yii::app()->clientScript-> registerScriptFile(Yii::app()->getModule('cms')->rtepath, CClientScript::POS_HEAD);
+if(Yii::app()->getModule('cms')->rteadapter != false)
+Yii::app()->clientScript-> registerScriptFile(Yii::app()->getModule('cms')->rteadapter, CClientScript::POS_HEAD);
+
+?>
+
+<div class="form">
+
+<?php $form=$this->beginWidget('CActiveForm', array(
+ 'id'=>'sitecontent-form',
+ 'enableAjaxValidation'=>true,
+ )); ?>
+
+<?php echo $form->errorSummary($model); ?>
+
+<div class="row">
+<?php echo $form->labelEx($model,'parent'); ?>
+<?php echo CHtml::activeDropDownList($model,
+ 'parent',
+ CHtml::listData(Sitecontent::model()->findAll(),
+ 'id',
+ 'title'),
+ array(
+ 'empty' => array(
+ '0' => ' - '))); ?>
+<?php echo $form->error($model,'header'); ?>
+</div>
+
+<div class="row" style="float:right;">
+<?php echo $form->labelEx($model,'position'); ?>
+<?php for($i = 0; $i < 10; $i++) $position[] = $i; ?>
+<?php echo CHtml::dropDownList('Sitecontent[position]',
+ $model->position,
+ $position); ?>
+<?php echo $form->error($model,'position'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'id'); ?>
+<?php echo $form->textField($model,'id',array('size'=>5,'maxlength'=>11)); ?>
+<?php echo $form->error($model,'id'); ?>
+</div>
+
+
+<div class="row">
+<?php echo $form->labelEx($model,'title'); ?>
+<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?>
+<?php echo $form->error($model,'title'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'keywords'); ?>
+<?php echo $form->textField($model,'keywords',array('size'=>60,'maxlength'=>255)); ?>
+<?php echo $form->error($model,'keywords'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'description'); ?>
+<?php echo $form->textField($model,'description',array('size'=>60,'maxlength'=>255)); ?>
+<?php echo $form->error($model,'description'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'title_browser'); ?>
+<?php echo $form->textField($model,'title_browser',array('size'=>60,'maxlength'=>80)); ?>
+<?php echo $form->error($model,'title_browser'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'title_url'); ?>
+<?php echo $form->textField($model,'title_url',array('size'=>60,'maxlength'=>80)); ?>
+<?php echo $form->error($model,'title_url'); ?>
+</div>
+
+<div class="row">
+<?php echo $form->labelEx($model,'language'); ?>
+<?php echo $form->dropDownList($model,'language',Yii::app()->controller->module->languages); ?>
+<?php echo $form->error($model,'language'); ?>
+</div>
+
+
+<div class="row">
+<?php echo $form->labelEx($model,'content'); ?>
+<?php $this->widget('application.extensions.extckeditor.ExtCKEditor', array(
+'model'=>$model,
+'attribute'=>'content', // model atribute
+'language'=>'DE', /* default lang, If not declared the language of the project will be used in case of using multiple languages */
+'editorTemplate'=>'full', // Toolbar settings (full, basic, advanced)
+)); ?>
+<?php //echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
+<?php //Yii::app()->clientScript->registerScript("ckeditor", "$('#Sitecontent_content').ckeditor();"); ?>
+<?php echo $form->error($model,'content'); ?>
+</div>
+
+<div class="row buttons">
+<?php echo CHtml::submitButton($model->isNewRecord
+ ? Yii::t('CmsModule.cms', 'Create sitecontent')
+ : Yii::t('CmsModule.cms', 'Save sitecontent')); ?>
+</div>
+
+<?php $this->endWidget(); ?>
+
+</div><!-- form -->
diff --git a/protected/modules/cms/views/sitecontent/_search.php b/protected/modules/cms/views/sitecontent/_search.php
new file mode 100644
index 0000000..e67934a
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/_search.php
@@ -0,0 +1,49 @@
+<div class="wide form">
+
+<?php $form=$this->beginWidget('CActiveForm', array(
+ 'action'=>Yii::app()->createUrl($this->route),
+ 'method'=>'get',
+)); ?>
+
+ <div class="row">
+ <?php echo $form->label($model,'id'); ?>
+ <?php echo $form->textField($model,'id'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'position'); ?>
+ <?php echo $form->textField($model,'position'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'title'); ?>
+ <?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'content'); ?>
+ <?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'authorid'); ?>
+ <?php echo $form->textField($model,'authorid'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'createtime'); ?>
+ <?php echo $form->textField($model,'createtime'); ?>
+ </div>
+
+ <div class="row">
+ <?php echo $form->label($model,'updatetime'); ?>
+ <?php echo $form->textField($model,'updatetime'); ?>
+ </div>
+
+ <div class="row buttons">
+ <?php echo CHtml::submitButton(Yii::t('App','Search')); ?>
+ </div>
+
+<?php $this->endWidget(); ?>
+
+</div><!-- search-form -->
diff --git a/protected/modules/cms/views/sitecontent/_short.php b/protected/modules/cms/views/sitecontent/_short.php
new file mode 100644
index 0000000..0352c04
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/_short.php
@@ -0,0 +1,34 @@
+<div class="view">
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
+ <?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('position')); ?>:</b>
+ <?php echo CHtml::encode($data->position); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:</b>
+ <?php echo CHtml::encode($data->title); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:</b>
+ <?php echo CHtml::encode($data->content); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('authorid')); ?>:</b>
+ <?php echo CHtml::encode($data->authorid); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('createtime')); ?>:</b>
+ <?php echo CHtml::encode($data->createtime); ?>
+ <br />
+
+ <?php /*
+ <b><?php echo CHtml::encode($data->getAttributeLabel('updatetime')); ?>:</b>
+ <?php echo CHtml::encode($data->updatetime); ?>
+ <br />
+
+ */ ?>
+
+</div>
diff --git a/protected/modules/cms/views/sitecontent/_view.php b/protected/modules/cms/views/sitecontent/_view.php
new file mode 100644
index 0000000..0352c04
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/_view.php
@@ -0,0 +1,34 @@
+<div class="view">
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
+ <?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('position')); ?>:</b>
+ <?php echo CHtml::encode($data->position); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?>:</b>
+ <?php echo CHtml::encode($data->title); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('content')); ?>:</b>
+ <?php echo CHtml::encode($data->content); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('authorid')); ?>:</b>
+ <?php echo CHtml::encode($data->authorid); ?>
+ <br />
+
+ <b><?php echo CHtml::encode($data->getAttributeLabel('createtime')); ?>:</b>
+ <?php echo CHtml::encode($data->createtime); ?>
+ <br />
+
+ <?php /*
+ <b><?php echo CHtml::encode($data->getAttributeLabel('updatetime')); ?>:</b>
+ <?php echo CHtml::encode($data->updatetime); ?>
+ <br />
+
+ */ ?>
+
+</div>
diff --git a/protected/modules/cms/views/sitecontent/admin.php b/protected/modules/cms/views/sitecontent/admin.php
new file mode 100644
index 0000000..4a5ab8c
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/admin.php
@@ -0,0 +1,71 @@
+<?php
+$this->breadcrumbs=array(
+ Cms::t('Sitecontent')=>array('index'),
+ Cms::t('Manage'),
+);
+
+$this->menu=array(
+ array(
+ 'label'=>Cms::t('Manage Sitecontent'),
+ 'url'=>array('sitecontent/admin')
+ ),
+ array(
+ 'label'=>Cms::t('Create new Sitecontent'),
+ 'url'=>array('create')),
+ );
+
+Yii::app()->clientScript->registerScript('search', "
+$('.search-button').click(function(){
+ $('.search-form').toggle();
+ return false;
+});
+$('.search-form form').submit(function(){
+ $.fn.yiiGridView.update('sitecontent-grid', {
+ data: $(this).serialize()
+ });
+ return false;
+});
+");
+?>
+
+<h2><?php echo Yii::t('CmsModule.cms', 'Manage Sitecontent'); ?></h2>
+
+<?php echo CHtml::link(Yii::t('App','Advanced Search'),'#',array('class'=>'search-button')); ?>
+<div class="search-form" style="display:none">
+<?php $this->renderPartial('_search',array(
+ 'model'=>$model,
+)); ?>
+</div><!-- search-form -->
+
+<?php
+$this->widget('zii.widgets.grid.CGridView', array(
+ 'id'=>'sitecontent-grid',
+ 'dataProvider'=>$model->search(),
+ 'filter'=>$model,
+ 'columns'=>array(
+ 'id',
+ array(
+ 'name' => 'language',
+ 'filter' => Yii::app()->controller->module->languages,
+ ),
+ 'title',
+ 'keywords',
+ 'description',
+ array(
+ 'name'=>'createtime',
+ 'value'=>'date(Yii::app()->controller->module->dateformat, $data->createtime)',
+ 'filter' => false,
+ ),
+ array(
+ 'name'=>'updatetime',
+ 'value'=>'date(Yii::app()->controller->module->dateformat, $data->updatetime)',
+ 'filter' => false,
+ ),
+ 'position',
+ array(
+ 'class'=>'CButtonColumn',
+ ),
+ ),
+ )); ?>
+
+<?php echo CHtml::link('New sitecontent', array('//cms/sitecontent/create')); ?>
diff --git a/protected/modules/cms/views/sitecontent/create.php b/protected/modules/cms/views/sitecontent/create.php
new file mode 100644
index 0000000..88ff27e
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/create.php
@@ -0,0 +1,21 @@
+<?php
+$this->breadcrumbs=array(
+ Yii::t('CmsModule.cms', 'Sitecontent')=>array('admin'),
+ Yii::t('CmsModule.cms', 'Create'),
+);
+
+$this->menu=array(
+ array(
+ 'label'=>Yii::t('CmsModule.cms', 'Manage Menustructure'),
+ 'url'=>array('menustructure/admin')
+ ),
+ array(
+ 'label'=>Yii::t('CmsModule.cms', 'Manage Sitecontent'),
+ 'url'=>array('sitecontent/admin')
+ ),
+);
+?>
+
+<h2><?php echo Yii::t('CmsModule.cms', 'Create new Sitecontent'); ?></h2>
+
+<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
diff --git a/protected/modules/cms/views/sitecontent/draw.php b/protected/modules/cms/views/sitecontent/draw.php
new file mode 100644
index 0000000..9c34a12
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/draw.php
@@ -0,0 +1,4 @@
+<h2><?php echo $sitecontent->title?></h2>
+<?php //echo CHtml::encode($sitecontent->content);
+echo $sitecontent->content;
+?>
diff --git a/protected/modules/cms/views/sitecontent/index.php b/protected/modules/cms/views/sitecontent/index.php
new file mode 100644
index 0000000..0d1f003
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/index.php
@@ -0,0 +1,25 @@
+<?php
+$this->breadcrumbs=array(
+ 'Sitecontents',
+);
+
+$this->menu=array(
+ array(
+ 'label'=>Yii::t('CmsModule.cms', 'Manage Menustructure'),
+ 'url'=>array('menustructure/admin')
+ ),
+ array(
+ 'label'=>Yii::t('CmsModule.cms', 'Manage Sitecontent'),
+ 'url'=>array('sitecontent/admin')
+ ),
+ array('label'=>Yii::t('App', 'Create').' Sitecontent', 'url'=>array('create')),
+ array('label'=>Yii::t('App', 'Manage').' Sitecontent', 'url'=>array('admin')),
+);
+?>
+
+<h2>Sitecontents</h2>
+
+<?php $this->widget('zii.widgets.CListView', array(
+ 'dataProvider'=>$dataProvider,
+ 'itemView'=>'_view',
+)); ?>
diff --git a/protected/modules/cms/views/sitecontent/results.php b/protected/modules/cms/views/sitecontent/results.php
new file mode 100644
index 0000000..ed55117
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/results.php
@@ -0,0 +1,19 @@
+<?php
+$this->breadcrumbs = array(Yii::t('CmsModule.cms', 'Search results'));
+
+if($results != array()) {
+ printf('<h2>%s %s</h2>',
+ count($results),
+ Yii::t('CmsModule.cms', 'Results:'));
+
+ echo '<ul>';
+ foreach($results as $result) {
+ printf('<li>%s</li>',
+ CHtml::link($result->title, array(
+ '//cms/sitecontent/view', 'id' => $result->id, 'highlight' => $search)));
+ }
+ echo '</ul>';
+} else {
+ echo Yii::t('CmsModule.cms', 'No results found');
+}
+?>
diff --git a/protected/modules/cms/views/sitecontent/update.php b/protected/modules/cms/views/sitecontent/update.php
new file mode 100644
index 0000000..5ed7e8d
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/update.php
@@ -0,0 +1,18 @@
+<?php
+$this->breadcrumbs=array(
+ Yii::t('CmsModule.cms', 'Sitecontent')=>array('admin'),
+ $model->id=>array('view','id'=>$model->id),
+ Yii::t('CmsModule.cms', 'Update'),
+);
+
+$this->menu=array(
+ array(
+ 'label'=>Yii::t('CmsModule.cms', 'Manage Sitecontent'),
+ 'url'=>array('sitecontent/admin')
+ ),
+);
+?>
+
+<h2><?php echo Yii::t('CmsModule.cms', 'Update');?> <?php echo $model->title; ?></h2>
+
+<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
diff --git a/protected/modules/cms/views/sitecontent/view.php b/protected/modules/cms/views/sitecontent/view.php
new file mode 100644
index 0000000..c75f610
--- /dev/null
+++ b/protected/modules/cms/views/sitecontent/view.php
@@ -0,0 +1,47 @@
+<?php
+if(isset($sc))
+ $this->pageTitle = $sc->title . ' - ' . Yii::app()->name;
+if(isset($menu))
+ $this->pageTitle = $menu->title. ' - ' . Yii::app()->name;
+
+if(Yii::app()->user->id == 1) // is admin
+{
+ if(is_object($sitecontent))
+ {
+ $this->renderPartial('draw', array('sitecontent' => $sitecontent));
+ echo "<br />";
+ echo CHtml::link(Yii::t('CmsModule.cms', 'Edit this sitecontent'),
+ array('/cms/sitecontent/update', 'id' => $sitecontent->id));
+ }
+ else if ($sitecontent == array())
+ {
+ echo CHtml::link(Yii::t('CmsModule.cms', 'Create new sitecontent here'),
+ array('/cms/sitecontent/create', 'position' => $menu->id));
+
+ } else if (is_array($sitecontent))
+ {
+ foreach($sitecontent as $sc)
+ {
+ $this->renderPartial('draw', array('sitecontent' => $sc));
+ echo "<br />";
+ echo CHtml::link(Yii::t('CmsModule.cms', 'Edit this sitecontent'),
+ array('/cms/sitecontent/update', 'id' => $sc->id));
+ }
+ }
+}
+else
+{
+ if(!is_null($sitecontent))
+ if(is_object($sitecontent))
+ $this->renderPartial('draw', array('sitecontent' => $sitecontent));
+ else
+ foreach($sitecontent as $sc)
+ {
+ $this->renderPartial('draw', array('sitecontent' => $sc));
+ }
+
+}
+
+if(isset($menu))
+ $this->breadcrumbs = array($menu->title);
+