Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'update' page.
  */
 public function actionCreate()
 {
     $model = new FaqElements();
     $modelAuthor = new FaqAuthor();
     $root = FaqRubrics::getRoot(new FaqRubrics());
     $catalog = $root->descendants()->findAll($root->id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // set attributes from get
     if (isset($_GET['FaqElements'])) {
         $model->attributes = $_GET['FaqElements'];
     }
     if (isset($_POST['FaqElements'])) {
         $model->attributes = $_POST['FaqElements'];
         if (isset($_POST['FaqAuthor'])) {
             $modelAuthor->attributes = $_POST['FaqAuthor'];
             $modelAuthor->save();
             $model->author_id = $modelAuthor->id;
         }
         if ($model->save()) {
             $url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
             $this->redirect($url);
         }
     }
     $this->render('create', array('model' => $model, 'root' => $root, 'catalog' => $catalog, 'modelAuthor' => $modelAuthor));
 }
 public function actionElement($param)
 {
     //Если прищли данные с формы
     if (isset($_POST['AddQuestion'])) {
         if (!empty($_POST['AddQuestion']['name']) && !empty($_POST['AddQuestion']['email']) && !empty($_POST['AddQuestion']['rubrics']) && !empty($_POST['AddQuestion']['question'])) {
             preg_match('|([a-z0-9_\\.\\-]{1,20})@([a-z0-9\\.\\-]{1,20})\\.([a-z]{2,4})|is', $_POST['AddQuestion']['email'], $match);
             if (!empty($match)) {
                 $model = FaqAuthor::model()->find('email LIKE "' . $_POST['AddQuestion']['email'] . '"');
                 if (!$model) {
                     $model = new FaqAuthor();
                 }
                 $model->name = $_POST['AddQuestion']['name'];
                 $model->email = $_POST['AddQuestion']['email'];
                 if ($model->save()) {
                     $modelElement = new FaqElements();
                     $modelElement->parent_id = (int) $_POST['AddQuestion']['rubrics'];
                     $modelElement->author_id = $model->id;
                     $modelElement->question = '<p>' . $_POST['AddQuestion']['question'] . '</p>';
                     $modelElement->save();
                 }
             }
         }
     }
     //Если параметр текст - это каталог, если число - элемент
     $paramArr = explode("/", $param);
     $paramArr = array_pop($paramArr);
     if (is_numeric($paramArr)) {
         //Число - это элемент
         $model = array();
         $model['elements'] = FaqElements::model()->find('id = ' . (int) $paramArr);
         $model['rubrics'] = FaqRubrics::model()->find('id = ' . $model['elements']->parent_id . ' AND level>1');
         //Титл и SEO
         $this->setSEO(Yii::app()->request->requestUri, 'Вопрос-ответ', $model['rubrics']);
         $render = 'view';
     } else {
         //Список  категории
         $model = array();
         $root = FaqRubrics::model()->find('url LIKE "' . $paramArr . '"');
         //Титл и SEO
         $this->setSEO(Yii::app()->request->requestUri, 'Вопрос-ответ', $root);
         if (empty($root)) {
             throw new CHttpException(404, 'The page can not be found.');
         }
         $model['rubrics'] = $root->descendants(1)->findAll($root->id);
         $model['elements'] = FaqElements::model()->findAll(array("condition" => "status!=0 AND parent_id = " . $root->id, "order" => "id DESC"));
         $render = 'list';
     }
     if (empty($model)) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $this->render($render, array('model' => $model));
 }
Example #3
0
    /**
     * @param $model - модель таблицы tbl_pages_tabs
     * Возращает HTML код блока вкладки
     */
    public function getTemplate($model)
    {
        $resultHTML = '';
        //Шаблоны
        $template = array(1 => '
                %description%
                %module_value%
            ', 2 => '
                %description%
                %module_value%
            ');
        //Общий шаблон
        switch ($model->site_module_id) {
            case 1:
                //Новости
                $template = array(1 => '
                        <div class="spisok">
                            <main class="all" role="main">
                                <div class="container">
                                    <h1 class="main-caption mg-bottom-24 caption-big">%title%</h1>
                                    %module_value%
                                </div>
                            </main>
                        </div>
                    ', 2 => '
                        <main class="all" role="main">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24">%title%</h2>
                            </div>
                        </main>
                        <div class="spisok fogr gray-bg">
                            <main class="all" role="main" style="padding-top:20px;">
                                <div class="container">
                                    %module_value%
                                </div>
                            </main>
                        </div>
                        ');
                break;
            case 6:
                //Статьи
                $template = array(1 => '
                        <div class="spisok">
                            <main class="all" role="main">
                                <div class="container">
                                    <h1 class="main-caption mg-bottom-24 caption-big">%title%</h1>
                                    %module_value%
                                </div>
                            </main>
                        </div>
                    ', 2 => '
                        <main class="all" role="main">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24">%title%</h2>
                            </div>
                        </main>
                        <div class="spisok fogr gray-bg">
                            <main class="all" role="main" style="padding-top:20px;">
                                <div class="container">
                                    %module_value%
                                </div>
                            </main>
                        </div>
                        ');
                break;
            case 16:
                //Отзывы
                $template = array(1 => '
                        <div class="spisok">
                            <main class="all" role="main">
                                <div class="container">
                                    <h1 class="main-caption mg-bottom-24 caption-big">%title%</h1>
                                    %module_value%
                                </div>
                            </main>
                        </div>
                    ', 2 => '
                        <main class="all" role="main">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24">%title%</h2>
                            </div>
                        </main>
                        <div class="spisok fogr gray-bg">
                            <main class="all" role="main" style="padding-top:20px;">
                                <div class="container">
                                    %module_value%
                                </div>
                            </main>
                        </div>
                        ');
                break;
            case 7:
                //Вопросы-ответы
                $template = array(1 => '
                        <div class="spisok">
                            <main class="all" role="main">
                                <div class="container faq" style="background: #ffffff;">
                                    <h1 class="main-caption mg-bottom-24 caption-big">%title%</h1>
                                    %module_value%
                                </div>
                            </main>
                        </div>
                    ', 2 => '
                        <main class="all" role="main">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24">%title%</h2>
                            </div>
                        </main>
                        <div class="spisok fogr gray-bg">
                            <main class="all" role="main" style="padding-top:20px;">
                                <div class="container faq">
                                    %module_value%
                                </div>
                            </main>
                        </div>
                        ');
                break;
            case 10:
                //Врачи
                $template = array(1 => '
                        <style>
                            #carusel20 .carusel-left {background-color: #fff;}
                            #carusel20 .carusel-right {background-color: #fff;}
                        </style>
                        <div class="doctor-slide">
		                    <main role="main" class="all" style="background:#fff">
                                <div class="container">
                                    <h2 class="main-caption mg-bottom-24">%title%</h2>
                                </div>
                            </main>
                            <div  class="gray-bg">
                                <main role="main" class="all">
                                    <div class="container">
                                        %description%
                                        <div id="carusel20_doc" class="owl-carousel owl-theme slider pos-relative mg-top-15">
                                            %module_value%
                                        </div>
                                    </div>
                                </main>
                            </div>
                        </div>
                    ', 2 => '
                        <div class="doctor-slide">
		                    <main role="main" class="all">
                                <div class="container">
                                    <h2 class="main-caption mg-bottom-24">%title%</h2>
                                </div>
                            </main>
                            <div  class="news-block gray-bg">
                                <main role="main" class="all">
                                    <div class="container">
                                        %description%
                                        <div id="carusel20_doc" class="owl-carousel owl-theme slider pos-relative mg-top-15">
                                            %module_value%
                                        </div>
                                    </div>
                                </main>
                            </div>
                        </div>
                    ');
                break;
            case 11:
                //Фотогалерея
                $template = array(1 => '
                        <style>
                            #carusel20 .carusel-left {background-color: #fff;}
                            #carusel20 .carusel-right {background-color: #fff;}
                            #carusel20_photo .owl-prev {margin-top:-80px;}
                            #carusel20_photo .owl-next {margin-top:-80px;}
                        </style>
                        <div class="doctor-slide">
		                    <main role="main" class="all" style="background:#fff">
                                <div class="container">
                                    <h2 class="main-caption mg-bottom-24 caption-big">%title%</h2>
                                </div>
                            </main>
                            <div  class="gray-bg">
                                <main role="main" class="all">
                                    <div class="container">
                                        %description%
                                        <div id="carusel20_photo" class="owl-carousel owl-theme slider pos-relative mg-top-15">
                                            %module_value%
                                        </div>
                                    </div>
                                </main>
                            </div>
                        </div>
                    ', 2 => '
                        <style>
                            #carusel20_photo .owl-prev {margin-top:-80px;}
                            #carusel20_photo .owl-next {margin-top:-80px;}
                        </style>
                        <div class="doctor-slide">
		                    <main role="main" class="all">
                                <div class="container">
                                    <h2 class="main-caption mg-bottom-24">%title%</h2>
                                </div>
                            </main>
                            <div  class="news-block gray-bg">
                                <main role="main" class="all">
                                    <div class="container">
                                        %description%
                                        <div id="carusel20_photo" class="owl-carousel owl-theme slider pos-relative mg-top-15">
                                            %module_value%
                                        </div>
                                    </div>
                                </main>
                            </div>
                        </div>
                    ');
                break;
            case 12:
                //До и После
                $template = array(1 => '
		                <main role="main" class="all" style="background:#fff">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24 caption-big">%title%</h2>
                            </div>
                        </main>
                        <div class="slide-after mg-bottom-20 mg-top-15">
                            <main class="all" role="main">
                                    %module_value%
                            </main>
                        </div>
                    ', 2 => '
                    <div  class="news-block gray-bg">
                    		                <main role="main" class="all">
                            <div class="container">
                                <h2 class="main-caption mg-bottom-24">%title%</h2>
                            </div>
                        </main>
                        <div class="slide-after mg-bottom-20 mg-top-15">
                            <main class="all" role="main">
                                %module_value%
                            </main>
                        </div>
                    </div>
                    ');
                break;
        }
        //Получаю темплейт для модуля
        $template_tmp = $template[$model->template_id];
        //Для врачей %module_value% - это карусель, для других вариантов - повторяем темплейт для каждого элемента
        $module_value_array = array();
        $module_count_elements = 0;
        foreach (explode("|", $model->site_module_value) as $data) {
            if (empty($data)) {
                continue;
            }
            ++$module_count_elements;
            $module_value_array[$data] = $data;
        }
        //Шаблоны элемента %module_value%
        switch ($model->site_module_id) {
            case 1:
                //Новости
                $tmp_module_value = '';
                foreach ($module_value_array as $value) {
                    if ($modelData = NewsGroup::model()->find('id in (' . $value . ') AND `status` = 1')) {
                        $i = 0;
                        $count = 5;
                        foreach (News::model()->findAll('group_id=' . $modelData->id . ' AND `status` = 1') as $modelElements) {
                            ++$i;
                            if ($i > $count) {
                                continue;
                            }
                            $tmp_module_value .= '
                            <div class="ot">
                                <span href="#">' . $modelData->name . ' - ' . date("d.m.Y", strtotime($modelElements->maindate)) . '</span></span><BR>
                                ' . $modelElements->name . '
                            ';
                            if (!empty($modelElements->brieftext)) {
                                $tmp_module_value .= '<BR>' . $modelElements->brieftext;
                            }
                            $tmp_module_value .= '</div>';
                        }
                        if ($i > 0) {
                            $tmp_module_value .= '<a class="all-otv" href="/news/' . $modelData->url . '">Все новости</a>';
                        }
                    }
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 6:
                //Статьи
                $tmp_module_value = '';
                foreach ($module_value_array as $value) {
                    if ($modelData = ArticleRubrics::model()->find('id in (' . $value . ') AND `status` = 1')) {
                        $i = 0;
                        $count = 5;
                        foreach (ArticleElements::model()->findAll('parent_id=' . $modelData->id . ' AND `status` = 1') as $modelElements) {
                            ++$i;
                            if ($i > $count) {
                                continue;
                            }
                            $tmp_module_value .= '
                            <div class="review_block">
                                <span>' . $modelElements->name . ' - ' . date("d.m.Y", strtotime($modelElements->maindate)) . '</span><BR>
                                <p>' . $modelElements->brieftext . '</p>
                            </div>';
                        }
                        if ($i > 0) {
                            $tmp_module_value .= '<a class="all-otv" style="margin-bottom:20px;" href="' . Yii::app()->request->requestUri . '/' . ($module_count_elements > 1 ? $modelData->url . '/' : '') . 'article">Все статьи</a>';
                        }
                    }
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 7:
                //Вопрос-ответ
                $tmp_module_value = '';
                foreach ($module_value_array as $value) {
                    if ($modelData = FaqRubrics::model()->find('id in (' . $value . ') AND `status` = 1')) {
                        $i = 0;
                        $count = 5;
                        foreach (FaqElements::model()->findAll('parent_id=' . $modelData->id . ' AND `status` = 1') as $modelElements) {
                            ++$i;
                            if ($i > $count) {
                                continue;
                            }
                            $modelAuthor = FaqAuthor::model()->findByPk($modelElements->author_id);
                            $tmp_module_value .= '
                                <article>
                                    <div class="question">
                                            <span href="#" style="color:#ed174f; font-size: 16px; font-weight: bold; margin-left: 20px;">' . $modelAuthor->name . '<span> / ' . $modelData->name . ' - ' . date("d.m.Y", strtotime($modelElements->question_data)) . '</span></span>
                                            <div class="q_data">
                                                ' . $modelElements->question . '
                                            </div>
                                    </div>
                                ';
                            if (!empty($modelElements->answer)) {
                                $tmp_module_value .= '<div class="unswer"><div class="u_data">' . $modelElements->answer . '</div></div>';
                            }
                            $tmp_module_value .= '</article>';
                        }
                        if ($i > 0) {
                            $tmp_module_value .= '<a class="all-otv" href="' . Yii::app()->request->requestUri . '/' . ($module_count_elements > 1 ? $modelData->url . '/' : '') . 'faq" style="position:relative; z-index:99999; margin-bottom:20px;">Все ответы</a>';
                        }
                    }
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 16:
                //Отзывы
                $tmp_module_value = '';
                foreach ($module_value_array as $value) {
                    if ($modelData = ReviewRubrics::model()->find('id in (' . $value . ') AND `status` = 1')) {
                        $i = 0;
                        $count = 5;
                        foreach (ReviewElements::model()->findAll('parent_id=' . $modelData->id . ' AND `status` = 1') as $modelElements) {
                            ++$i;
                            if ($i > $count) {
                                continue;
                            }
                            $modelAuthor = ReviewAuthor::model()->findByPk($modelElements->author_id);
                            $tmp_module_value .= '
                            <div class="review_block" style="padding: 10px; margin-bottom: 10px; margin-top:20px;">
                                <span href="#">' . $modelAuthor->name . '<span> / ' . $modelData->name . ' - ' . date("d.m.Y", strtotime($modelElements->review_data)) . '</span></span><BR>
                                <p>' . $modelElements->review . '</p>
                            </div>';
                        }
                        if ($i > 0) {
                            $tmp_module_value .= '<a class="all-otv" href="' . Yii::app()->request->requestUri . '/' . ($module_count_elements > 1 ? $modelData->url . '/' : '') . 'review" style="position:relative; z-index:99999; margin-bottom:20px;">Все отзывы</a>';
                        }
                    }
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 10:
                //Врачи
                $tmp_module_value = '';
                foreach (DoctorElements::model()->findAll('id in (' . implode(",", $module_value_array) . ')') as $data) {
                    $tmp_module_value .= '
                    <div class="item">
                            <div class="doctor">
                                <figure>
                                    ' . (!empty($data->image) ? '<img src="/uploads/filestorage/doctor/elements/medium-' . $data->id . '.' . $data->image . '">' : '') . '
                                </figure>
                                <h1>' . $data->name . '</h1>
                                <article style="margin-top:10px;" class="text-center">
                                    ' . $data->anonse . '
                                </article>
                            </div>
                    </div>
                ';
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 11:
                //Фотогалерея
                $tmp_module_value = '';
                foreach (PhotoElements::model()->findAll('parent_id in (' . implode(",", $module_value_array) . ')') as $data) {
                    $tmp_module_value .= '
                    <div class="item">
                            <div class="doctor">
                                <figure>
                                    ' . (!empty($data->image) ? '<a href="/photo/' . $data->parent->url . '">
                                    <div style="height: 212px; background: url(/uploads/filestorage/photo/elements/medium-' . $data->id . '.' . $data->image . ') 100% 100% no-repeat; background-size: cover;">
                                    </div>
                                    </a>' : '') . '
                                </figure>
                            </div>
                    </div>
                ';
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 12:
                //До и После
                $tmp_module_value = '';
                foreach (BeforeAfterRubrics::model()->findAll('id in (' . implode(",", $module_value_array) . ')') as $data) {
                    if ($modelImage = BeforeAfterElements::model()->find('parent_id=' . $data->id . ' ORDER BY on_main DESC')) {
                        //URL
                        $parent_url = array();
                        if (!empty($data)) {
                            $modelTop = BeforeAfterRubrics::model()->findByPk($data->id);
                            foreach ($modelTop->ancestors()->findAll('level>1') as $dataTop) {
                                $parent_url[] = $dataTop->url;
                            }
                            $parent_url[] = $modelTop->url;
                        }
                        $tmp_module_value .= '
                        <div class="container">
                            <a href="/before-after/' . (!empty($parent_url) ? implode("/", $parent_url) : '') . '"><h4>' . $data->name . '</h4></a>
                            <div class="spisok af-line">
                                <a href="/before-after/' . (!empty($parent_url) ? implode("/", $parent_url) : '') . '">
                                <div class="after">
                                    <figure>
                                        <img src="/uploads/filestorage/beforeafter/elements/medium2-before_' . $modelImage->id . '.' . $modelImage->before_photo . '">
                                        <figcaption> ДО </figcaption>
                                    </figure>
                                    <figure>
                                        <img src="/uploads/filestorage/beforeafter/elements/medium2-after_' . $modelImage->id . '.' . $modelImage->before_photo . '">
                                        <figcaption> ПОСЛЕ </figcaption>
                                    </figure>
                                </div>
                                </a>
                            </div>
                        </div>
                        ';
                    }
                }
                $resultHTML = $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            case 17:
                //HTML код
                $tmp_module_value = '';
                foreach (HtmlCode::model()->findAll('id in (' . implode(",", $module_value_array) . ') AND `status`=1') as $data) {
                    $tmp_module_value .= $data->code;
                }
                $resultHTML = $template_tmp;
                $title = '';
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
            default:
                $tmp_module_value = '';
                $tabel_name = $this->moduleID[$model->site_module_id];
                foreach (Yii::app()->db->createCommand()->select('*')->from($tabel_name)->queryAll() as $data) {
                    if (!isset($data['description']) || empty($data['description'])) {
                        continue;
                    }
                    $tmp_module_value .= $data['description'];
                }
                $resultHTML .= $template_tmp;
                $title = $model->title;
                $resultHTML = str_replace("%module_value%", $tmp_module_value, $resultHTML);
                break;
        }
        $resultHTML = str_replace("%title%", $title, $resultHTML);
        $resultHTML = str_replace("%description%", $model->description, $resultHTML);
        return $resultHTML;
    }
Example #4
0
<?php 
if ($model->isNewRecord) {
    echo '
    <div class="control-group">
        <label class="control-label required" for="FaqAuthor_name">
            ' . $form->label($model, "author_id") . '
            <span class="required">*</span>
        </label>
        <div class="controls">
            ' . $form->textField($modelAuthor, 'name', array('class' => 'span5', 'maxlength' => 450)) . '
        </div>
    </div>

    ';
} else {
    echo $form->dropDownListRow($model, "author_id", CHtml::listData(FaqAuthor::model()->findAll(), "id", "name"), array("empty" => "Не выбран", 'class' => 'span5'));
}
?>

<?php 
Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget');
echo $form->labelEx($model, 'question');
$this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'question', 'options' => array('lang' => 'ru', 'cleanOnPaste' => false, 'cleanStyleOnEnter' => true, 'cleanSpaces' => false, 'replaceDivs' => false, 'imageUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/imageUpload'), 'fileUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/fileUpload'), 'imageManagerJson' => Yii::app()->createAbsoluteUrl('/pages/pages/getImageLibray')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js')), 'filemanager' => array('js' => array('filemanager.js')), 'myphotogalery' => array('js' => array('myphotogalery.js')), 'imagemanager' => array('js' => array('imagemanager.js')))));
echo $form->labelEx($model, 'answer');
$this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'answer', 'options' => array('lang' => 'ru', 'cleanOnPaste' => false, 'cleanStyleOnEnter' => true, 'cleanSpaces' => false, 'replaceDivs' => false, 'imageUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/imageUpload'), 'fileUpload' => Yii::app()->createAbsoluteUrl('/pages/pages/fileUpload'), 'imageManagerJson' => Yii::app()->createAbsoluteUrl('/pages/pages/getImageLibray')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js')), 'filemanager' => array('js' => array('filemanager.js')), 'myphotogalery' => array('js' => array('myphotogalery.js')), 'imagemanager' => array('js' => array('imagemanager.js')))));
?>

<?php 
echo $form->DatePickerRow($model, 'question_data', array('options' => array('autoclose' => true, 'type' => 'Component', 'format' => 'yyyy-mm-dd'), 'htmlOptions' => array()));
?>
Example #5
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.FaqAuthor");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = FaqAuthor::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'faq-author-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'htmlOptions' => array('class' => 'content_table'), 'dataProvider' => $provider, 'filter' => $model, '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["email"], 'name' => "email"), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{link}', 'buttons' => array('link' => array('label' => 'Вопросы пользователя', 'options' => array('target' => '_blank'), 'url' => 'Yii::app()->createUrl("/faq/faq/index", array("FaqElements[author_id]"=>$data->id))')), 'htmlOptions' => array('style' => 'width: 80px')), 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')))));
?>

<div class="buttons">
    <a class="btn btn-primary" href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/create" style="margin-top:14px; float:left; margin-left:15px"> Добавить нового автора вопроса</a>
</div>
Example #6
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.Faq");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = FaqElements::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'faq-elements-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'htmlOptions' => array('class' => 'content_table'), 'dataProvider' => $provider, 'filter' => $model, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["parent_id"], 'name' => 'parent_id', 'value' => '$data->parent ? $data->parent->name : ""', 'filter' => CHtml::listData(FaqRubrics::model()->findAll(array('order' => 'name')), 'id', 'name')), array('header' => $labels["author_id"], 'name' => 'author_id', 'value' => '$data->author ? $data->author->name : ""', 'filter' => CHtml::listData(FaqAuthor::model()->findAll(array('order' => 'name')), 'id', 'name')), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('header' => $labels["question_data"], 'name' => "question_data"), 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')))));
?>

<div class="buttons">
    <a class="btn btn-primary" href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/create" style="margin-top:14px; float:left; margin-left:15px"> Добавить новый вопрос</a>
</div>

<script>
    //Меняем статус
    $(document).on('click', '.on-off-product', function(){
 /**
  * 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 = FaqAuthor::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }