コード例 #1
0
ファイル: PageController.php プロジェクト: oakcms/oakcms
 public function actionView($slug, $slugMenu = null)
 {
     $model = $this->findModel($slug);
     if ($menu = MenuItems::find()->joinWith(['translations'])->andWhere(['{{%menu_items}}.disable_breadcrumbs' => 0])->andWhere(['or', ['{{%menu_items_lang}}.url' => 'page/' . $slug], ['{{%menu_items_lang}}.url' => '/page/' . $slug], ['{{%menu_items_lang}}.url' => \yii\helpers\Url::to(['/system/default']) . 'page/' . $slug]])->one()) {
         /*if(($mParent = $menu->parents(1)->one())) {
               $arr = explode('/', $mParent->url);
               var_dump($arr);
               if(end($arr) != $slugMenu)
                   throw new NotFoundHttpException('The requested page does not exist.');
           }*/
         $breadcrumbs = Menu::getBreadcrumbsById($menu->id);
     } else {
         $breadcrumbs = Menu::getBreadcrumbs('page/' . $slug);
     }
     return $this->render('view', ['breadcrumbs' => $breadcrumbs, 'model' => $model]);
 }
コード例 #2
0
ファイル: _form.php プロジェクト: oakcms/oakcms
echo $form->field($model, 'where_to_place')->dropDownList(\app\modules\text\models\Text::getWereToPlace());
?>

                <div class="form-group field-text-links">
                    <label class="col-md-3 control-label" for="text-links"><?php 
echo Yii::t('text', 'Links');
?>
</label>
                    <div class="col-md-9">
                        <div class="checkbox well well-sm">
                            <div class="container-fluid">
                                <div class="row">
                                    <?php 
$menus = \app\modules\menu\models\Menu::find()->all();
foreach ($menus as $menu) {
    $cats = \app\modules\menu\models\MenuItems::cats($menu->id);
    ?>
                                        <div class="col-sm-6">
                                            <b><?php 
    echo $menu->title;
    ?>
</b><br>
                                            <?php 
    foreach ($cats as $cat) {
        ?>
                                                <label style="padding-left:  <?php 
        echo $cat->depth * 20;
        ?>
px;">
                                                    <input type="checkbox" name="Text[links][]" <?php 
        echo $model->links !== null && in_array($cat->id, $model->links) ? "checked" : "";
コード例 #3
0
ファイル: Text.php プロジェクト: oakcms/oakcms
 public function api_get($id_slug, $id = false)
 {
     if (($texts = $this->findText($id_slug, $id)) === null) {
         return $this->notFound($id_slug);
     }
     foreach ($texts as $text) {
         $return = '';
         $blocks = '';
         if (isset($text->where_to_place)) {
             switch ($text->where_to_place) {
                 case '0':
                     $return = true;
                     break;
                 case '-':
                     $return = false;
                     break;
                 case '1':
                     $arr = [];
                     foreach ($text->links as $item) {
                         $menu = MenuItems::findOne($item);
                         if ($menu !== null) {
                             $arr[] = Url::to([trim($menu->url)]);
                         }
                     }
                     if (in_array(Url::to(), $arr)) {
                         $return = true;
                     } else {
                         $return = false;
                     }
                     break;
                 case '-1':
                     $arr = [];
                     foreach ($text->links as $item) {
                         $menu = MenuItems::findOne($item);
                         if ($menu !== null) {
                             $arr[] = Url::to([trim($menu->url)]);
                         }
                     }
                     if (!in_array(Url::to(), $arr)) {
                         $return = true;
                     } else {
                         $return = false;
                     }
                     break;
                 default:
                     $return = false;
                     break;
             }
             if ($return) {
                 if (is_file($file = Yii::getAlias('@frontendTemplate/modules/text/views/frontend/layouts/' . $text->layout . '/plugin.php'))) {
                     $params = (require $file);
                 } else {
                     $params = (require Yii::getAlias('@app/modules/text/views/frontend/layouts/' . $text->layout . '/plugin.php'));
                 }
                 $text['output'] = Yii::$app->view->renderFile($params['viewFile'], ['model' => $text], true);
                 $blocks .= LIVE_EDIT ? API::liveEdit($text['output'], Url::to(['/admin/text/default/update/', 'id' => $text['id']]), 'div') : $text['output'];
             } else {
                 $blocks = '';
             }
         }
     }
     return $blocks;
 }