/**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = PhotoTemplate::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#2
0
 public function addPhotogalery($body)
 {
     preg_match_all('/\\{myphotogalery id=(\\d+)\\}/', $body, $matches);
     if (!empty($matches)) {
         $url_to_img = '/uploads/filestorage/photo/elements/';
         foreach ($matches[1] as $id) {
             //Получаем шаблон активной фотогалереи
             if ($template_photogalery = PhotoTemplate::model()->find('active=1')) {
                 $photoContent = '';
                 foreach (PhotoElements::model()->findAll('parent_id=' . (int) $id . ' AND status=1') as $data) {
                     $url_to_full_image = $url_to_img . 'large-' . $data->id . '.' . $data->image;
                     $url_to_small_image = $url_to_img . 'small-' . $data->id . '.' . $data->image;
                     $photoContent .= $template_photogalery->val;
                     $photoContent = str_replace('%url_to_full_image%', $url_to_full_image, $photoContent);
                     $photoContent = str_replace("%url_to_small_image%", $url_to_small_image, $photoContent);
                 }
                 $body = str_replace("{myphotogalery id=" . $id . "}", $photoContent, $body);
             }
         }
     }
     return $body;
 }
示例#3
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.PhotoTemplate");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = PhotoTemplate::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'photo-template-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => $labels["active"], 'name' => "active", 'value' => '$data->active==1?"Активен":"Не активет"'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<?php 
echo '<a class="btn btn-primar" href="/admin/' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/create">Добавить</a>';