Exemple #1
0
 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;
 }
Exemple #2
0
 public function getTitle()
 {
     return LIVE_EDIT ? API::liveEdit($this->model->title, $this->editLink) : $this->model->title;
 }
Exemple #3
0
 public function getText()
 {
     return LIVE_EDIT ? API::liveEdit($this->model->text, $this->editLink, 'div') : $this->model->text;
 }