Beispiel #1
0
                        </div>
                    </div>
                </div>

                <!-- Подпункты (только для главных пунктов) -->
                <?php 
if ($subsections) {
    ?>
                  <h3 class="form-section">Подпункты</h3>
                    <div class="row">
                        <div class="col-md-5 col-lg-7">
                            <ol>
                                <?php 
    foreach ($subsections as $subsection) {
        echo "<li>";
        echo CHtml::link($subsection['title'], array(MenuLinks::model()->getModelName() . '/update/id/' . $subsection['id']));
        echo "</li>";
    }
    ?>
                            </ol>
                        </div>
                    </div>
                <?php 
}
?>

                

        
                </div>
                <?php 
Beispiel #2
0
 /**
  * Метод возвращает новый id для пункта меню
  */
 public static function getNewId()
 {
     $idAll = array();
     // получаем значения всех Id
     $all = MenuLinks::model()->findAll();
     foreach ($all as $one) {
         $idAll[] = $one["id"];
     }
     rsort($idAll);
     $max = array_shift($idAll);
     $idNew = ++$max;
     return $idNew;
 }
 public function getMainSections()
 {
     return Menu::model()->findByAttributes(array('name' => MenuLinks::model()->getMenuName()))->getSections();
 }
 public function actionCreate()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $this->layout = '//layouts/empty';
     } else {
         $this->layout = '//layouts/main';
     }
     Yii::app()->clientScript->registerCSSFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-switch/static/stylesheets/bootstrap-switch-metro.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-switch/static/js/bootstrap-switch.min.js', CClientScript::POS_BEGIN);
     Yii::app()->clientScript->registerScriptFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-touchspin/bootstrap.touchspin.js', CClientScript::POS_END);
     Yii::app()->clientScript->registerScript('initTouchSpin', "FormComponents.initTouchSpin();", CClientScript::POS_END);
     $model = new MenuLinks();
     $sections = $this->getMainSections();
     $parents[0] = 'Нет родителя';
     foreach ($sections as $section) {
         $parents[$section['id']] = $section['title'];
     }
     if (isset($_POST['MenuLinks'])) {
         // TODO
         /*if(!Yii::app()->user->checkAccess('Ti_Update')) 
                     {
                         $msg = "Неавторизованная попытка создания пункта меню";
                         $msg .= '; Пользователь: ' . ((Yii::app()->user->isGuest) ? 'Гость' : Yii::app()->user->getName());
                         $msg .= ' (' . Yii::app()->request->userHostAddress . ')';
                         $type = "4";
                         $aMessage = array(
                             "FullDateTime" => date("Y-m-d H:i:s").'.000',
                             "txt" => htmlspecialchars (str_replace('\\', '/', $msg)),
                             "ModuleName" => "SEDWeb",
                             "type" => $type,
                             "DeviceID" => "0"
                         );
                         $message = json_encode($aMessage);
                         //$message = '{"FullDateTime":"'.date("Y-m-d H:i:s").'.000","txt":"'. htmlspecialchars ($msg) .'","ModuleName":"SEDWeb","type":"'.$type.'","DeviceID":"0"}';
                         $exName = 'RAS';
                         Yii::app()->amqp->declareExchange($exName, $type = 'fanout', $passive = false, $durable = true, $auto_delete = false);
                         Yii::app()->amqp->publish_message($message, $exName, $routingKey = '', $content_type = 'text/plain', $app_id = yii::app()->name);
                         Yii::app()->amqp->closeConnection();
         
                         //$this->renderPartial('//layouts/error', array('message'=>'Доступ ограничен!'));
                         if(Yii::app()->request->isAjaxRequest)
                             $this->renderPartial('//layouts/error', array('message'=>'Доступ ограничен!'));
                         else
                             $this->render('//layouts/error', array('message'=>'Доступ ограничен!'));
                         return;
                     }*/
         $model->attributes = $_POST['MenuLinks'];
         // TODO поправить баг
         $model->controller = $_POST['MenuLinks']['controller'];
         $model->url = $_POST['MenuLinks']['url'];
         $model->icon = $_POST['MenuLinks']['icon'];
         /*if(is_numeric($_POST['MenuLinks']['is_visible']))
           {
               $model->is_visible = (bool) $_POST['MenuLinks']['is_visible'];
           }
           else
           {
               $model->is_visible = $_POST['MenuLinks']['is_visible'];
           }*/
         if ($_POST['MenuLinks']['is_visible'] == "Да") {
             $model->is_visible = true;
         } else {
             if ($_POST['MenuLinks']['is_visible'] == "Нет") {
                 $model->is_visible = false;
             } else {
                 $model->is_visible = $_POST['MenuLinks']['is_visible'];
             }
         }
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model, 'sections' => $parents));
 }
Beispiel #5
0
                    </div>
                </div>
            </div>

            <!-- Подпункты (только для главных пунктов) -->
            <?php 
if ($subsections) {
    ?>
                <h3 class="form-section">Подпункты</h3>
                <div class="row">
                    <div class="col-md-5 col-lg-7">
                        <ol>
                            <?php 
    foreach ($subsections as $subsection) {
        echo "<li style = 'padding-top:5px;'>";
        echo CHtml::link($subsection['title'], array(MenuLinks::model()->getModelName() . '/update/id/' . $subsection['id']), array('class' => 'btn default btn-xs', 'style' => ' color: #2980b9;'));
        echo "</li>";
    }
    ?>
                        </ol>
                    </div>
                </div>
            <?php 
}
?>
        </div>
            <?php 
echo CHtml::endForm();
?>
    </div>
</div>