parse() публичный статический Метод

public static parse ( $css )
Пример #1
0
 /**
  * [ADMIN] 固定ページ情報編集
  *
  * @param int $id (page_id)
  * @return void
  */
 public function admin_edit($id)
 {
     if (!$id && empty($this->request->data)) {
         $this->setMessage('無効なIDです。', true);
         $this->redirect(['action' => 'index']);
     }
     if (empty($this->request->data)) {
         $this->request->data = $this->Page->read(null, $id);
     } else {
         $isChangedStatus = $this->Content->isChangedStatus($id, $this->request->data);
         if (empty($this->request->data['Page']['page_type'])) {
             $this->request->data['Page']['page_type'] = 1;
         }
         // EVENT Pages.beforeEdit
         $event = $this->dispatchEvent('beforeEdit', ['data' => $this->request->data]);
         if ($event !== false) {
             $this->request->data = $event->result === true ? $event->data['data'] : $event->result;
         }
         $this->Page->set($this->request->data);
         if ($data = $this->Page->save()) {
             // タイトル、URL、公開状態が更新された場合、全てビューキャッシュを削除する
             if ($isChangedStatus) {
                 clearViewCache();
             } else {
                 clearViewCache($this->request->data['Content']['url']);
             }
             // 完了メッセージ
             $this->setMessage('固定ページ「' . $this->request->data['Content']['name'] . '」を更新しました。', false, true);
             // EVENT Pages.afterEdit
             $this->dispatchEvent('afterEdit', ['data' => $data]);
             // 同固定ページへリダイレクト
             $this->redirect(['action' => 'edit', $id]);
         } else {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         }
     }
     // 公開リンク
     $publishLink = '';
     if ($this->request->data['Content']['url']) {
         $publishLink = $this->request->data['Content']['url'];
     }
     // エディタオプション
     $editorOptions = ['editorDisableDraft' => false];
     if (!empty($this->siteConfigs['editor_styles'])) {
         App::uses('CKEditorStyleParser', 'Vendor');
         $CKEditorStyleParser = new CKEditorStyleParser();
         $editorOptions = array_merge($editorOptions, ['editorStylesSet' => 'default', 'editorStyles' => ['default' => $CKEditorStyleParser->parse($this->siteConfigs['editor_styles'])]]);
     }
     // ページテンプレートリスト
     $pageTemplateList = $this->Page->getPageTemplateList($this->request->data['Content']['id'], $this->siteConfigs['theme']);
     $this->set(compact('editorOptions', 'pageTemplateList', 'publishLink'));
     if (!empty($this->request->data['Content']['title'])) {
         $this->pageTitle = '固定ページ情報編集:' . $this->request->data['Content']['title'];
     } else {
         $this->pageTitle = '固定ページ情報編集:' . Inflector::Classify($this->request->data['Content']['name']);
     }
     $this->help = 'pages_form';
     $this->render('form');
 }
Пример #2
0
 /**
  * [ADMIN] 編集処理
  *
  * @param int $blogContentId
  * @param int $id
  * @return void
  * @access public
  */
 public function admin_edit($blogContentId, $id)
 {
     if (!$blogContentId || !$id) {
         $this->setMessage('無効な処理です。', true);
         $this->redirect(array('controller' => 'blog_contents', 'action' => 'index'));
     }
     if (empty($this->request->data)) {
         $this->request->data = $this->BlogPost->read(null, $id);
     } else {
         if (!empty($this->request->data['BlogPost']['posts_date'])) {
             $this->request->data['BlogPost']['posts_date'] = str_replace('/', '-', $this->request->data['BlogPost']['posts_date']);
         }
         /*			 * * BlogPosts.beforeEdit ** */
         $event = $this->dispatchEvent('beforeEdit', array('data' => $this->request->data));
         if ($event !== false) {
             $this->request->data = $event->result === true ? $event->data['data'] : $event->result;
         }
         // データを保存
         if ($this->BlogPost->saveAll($this->request->data)) {
             clearViewCache();
             /*				 * * BlogPosts.afterEdit ** */
             $this->dispatchEvent('afterEdit', array('data' => $this->BlogPost->read(null, $id)));
             $this->setMessage('記事「' . $this->request->data['BlogPost']['name'] . '」を更新しました。', false, true);
             $this->redirect(array('action' => 'edit', $blogContentId, $id));
         } else {
             $this->setMessage('エラーが発生しました。内容を確認してください。', true);
         }
     }
     // 表示設定
     $user = $this->BcAuth->user();
     $editable = false;
     $blogCategoryId = '';
     $currentCatOwner = '';
     if (isset($this->request->data['BlogPost']['blog_category_id'])) {
         $blogCategoryId = $this->request->data['BlogPost']['blog_category_id'];
     }
     if (!$blogCategoryId) {
         $currentCatOwner = $this->siteConfigs['root_owner_id'];
     } else {
         if (empty($this->request->data['BlogCategory']['owner_id'])) {
             $data = $this->BlogPost->BlogCategory->find('first', array('conditions' => array('BlogCategory.id' => $this->request->data['BlogPost']['blog_category_id']), 'recursive' => -1));
             $currentCatOwner = $data['BlogCategory']['owner_id'];
         }
     }
     $editable = $currentCatOwner == $user['user_group_id'] || $user['user_group_id'] == Configure::read('BcApp.adminGroupId') || !$currentCatOwner;
     $categories = $this->BlogPost->getControlSource('blog_category_id', array('blogContentId' => $this->blogContent['BlogContent']['id'], 'rootEditable' => $this->checkRootEditable(), 'blogCategoryId' => $blogCategoryId, 'userGroupId' => $user['user_group_id'], 'postEditable' => $editable, 'empty' => '指定しない'));
     if ($this->request->data['BlogPost']['status']) {
         $this->set('publishLink', '/' . $this->blogContent['BlogContent']['name'] . '/archives/' . $this->request->data['BlogPost']['no']);
     }
     $editorOptions = array('editorDisableDraft' => false);
     if (!empty($this->siteConfigs['editor_styles'])) {
         App::uses('CKEditorStyleParser', 'Vendor');
         $CKEditorStyleParser = new CKEditorStyleParser();
         $editorStyles = array('default' => $CKEditorStyleParser->parse($this->siteConfigs['editor_styles']));
         $editorOptions = array_merge($editorOptions, array('editorStylesSet' => 'default', 'editorStyles' => $editorStyles));
     }
     $this->set('hasNewCategoryAddablePermission', $this->BlogPost->BlogCategory->hasNewCategoryAddablePermission($user['user_group_id'], $blogContentId));
     $this->set('currentCatOwnerId', $currentCatOwner);
     $this->set('editable', $editable);
     $this->set('categories', $categories);
     $this->set('previewId', $this->request->data['BlogPost']['id']);
     $this->set('users', $this->BlogPost->User->getUserList());
     $this->set('editorOptions', $editorOptions);
     $this->pageTitle = '[' . $this->blogContent['BlogContent']['title'] . '] 記事編集: ' . $this->request->data['BlogPost']['name'];
     $this->help = 'blog_posts_form';
     $this->render('form');
 }
Пример #3
0
 /**
  * [ADMIN] 固定ページ情報編集
  *
  * @param int $id (page_id)
  * @return void
  * @access public
  */
 public function admin_edit($id)
 {
     /* 除外処理 */
     if (!$id && empty($this->request->data)) {
         $this->setMessage('無効なIDです。', true);
         $this->redirect(array('action' => 'index'));
     }
     if (empty($this->request->data)) {
         $this->request->data = $this->Page->read(null, $id);
         $mobileIds = $this->PageCategory->getAgentCategoryIds('mobile');
         $smartphoneIds = $this->PageCategory->getAgentCategoryIds('smartphone');
         if (in_array($this->request->data['Page']['page_category_id'], $mobileIds)) {
             $this->request->data['Page']['page_type'] = 2;
         } elseif (in_array($this->request->data['Page']['page_category_id'], $smartphoneIds)) {
             $this->request->data['Page']['page_type'] = 3;
         } else {
             $this->request->data['Page']['page_type'] = 1;
         }
     } else {
         $before = $this->Page->find('first', array('conditions' => array('Page.id' => $id)));
         if (empty($this->request->data['Page']['page_type'])) {
             $this->request->data['Page']['page_type'] = 1;
         }
         /* 更新処理 */
         if ($this->request->data['Page']['page_type'] == 2 && !$this->request->data['Page']['page_category_id']) {
             $this->request->data['Page']['page_category_id'] = $this->PageCategory->getAgentId('mobile');
         } elseif ($this->request->data['Page']['page_type'] == 3 && !$this->request->data['Page']['page_category_id']) {
             $this->request->data['Page']['page_category_id'] = $this->PageCategory->getAgentId('smartphone');
         }
         $this->request->data['Page']['url'] = $this->Page->getPageUrl($this->request->data);
         /*			 * * Pages.beforeEdit ** */
         $event = $this->dispatchEvent('beforeEdit', array('data' => $this->request->data));
         if ($event !== false) {
             $this->request->data = $event->result === true ? $event->data['data'] : $event->result;
         }
         $this->Page->set($this->request->data);
         if ($this->Page->validates()) {
             if ($data = $this->Page->save(null, false)) {
                 // タイトル、URL、公開状態が更新された場合、全てビューキャッシュを削除する
                 $beforeStatus = $this->Page->isPublish($before['Page']['status'], $before['Page']['publish_begin'], $before['Page']['publish_end']);
                 $afterStatus = $this->Page->isPublish($this->request->data['Page']['status'], $this->request->data['Page']['publish_begin'], $this->request->data['Page']['publish_end']);
                 if ($beforeStatus != $afterStatus || $before['Page']['title'] != $this->request->data['Page']['title'] || $before['Page']['url'] != $this->request->data['Page']['url']) {
                     clearViewCache();
                 } else {
                     clearViewCache($this->request->data['Page']['url']);
                 }
                 // 完了メッセージ
                 $this->setMessage('固定ページ「' . $this->request->data['Page']['name'] . '」を更新しました。', false, true);
                 /*					 * * Pages.afterEdit ** */
                 $this->dispatchEvent('afterEdit', array('data' => $data));
                 // 同固定ページへリダイレクト
                 $this->redirect(array('action' => 'edit', $id));
             } else {
                 $this->setMessage('保存中にエラーが発生しました。', true);
             }
         } else {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         }
     }
     /* 表示設定 */
     $currentPageCategoryId = '';
     if (!empty($this->request->data['PageCategory']['id'])) {
         $currentPageCategoryId = $this->request->data['PageCategory']['id'];
     }
     if (empty($this->request->data['PageCategory']['id']) || $this->request->data['PageCategory']['name'] == 'mobile' || $this->request->data['PageCategory']['name'] == 'smartphone') {
         $currentCatOwnerId = $this->siteConfigs['root_owner_id'];
     } else {
         $currentCatOwnerId = $this->request->data['PageCategory']['owner_id'];
     }
     $categories = $this->getCategorySource($this->request->data['Page']['page_type'], array('currentOwnerId' => $currentCatOwnerId, 'currentPageCategoryId' => $currentPageCategoryId, 'own' => true, 'empty' => '指定しない'));
     $url = $this->Page->convertViewUrl($this->request->data['Page']['url']);
     if ($this->request->data['Page']['url']) {
         $this->set('publishLink', $url);
     }
     if (Configure::read('BcApp.mobile') && (!isset($this->siteConfigs['linked_pages_mobile']) || !$this->siteConfigs['linked_pages_mobile'])) {
         $reflectMobile = true;
     } else {
         $reflectMobile = false;
     }
     if (Configure::read('BcApp.smartphone') && (!isset($this->siteConfigs['linked_pages_smartphone']) || !$this->siteConfigs['linked_pages_smartphone'])) {
         $reflectSmartphone = true;
     } else {
         $reflectSmartphone = false;
     }
     $editorOptions = array('editorDisableDraft' => false);
     if (!empty($this->siteConfigs['editor_styles'])) {
         App::uses('CKEditorStyleParser', 'Vendor');
         $CKEditorStyleParser = new CKEditorStyleParser();
         $editorStyles = array('default' => $CKEditorStyleParser->parse($this->siteConfigs['editor_styles']));
         $editorOptions = array_merge($editorOptions, array('editorStylesSet' => 'default', 'editorStyles' => $editorStyles));
     }
     $this->set('currentCatOwnerId', $currentCatOwnerId);
     $this->set('categories', $categories);
     $this->set('editable', $this->checkCurrentEditable($currentPageCategoryId, $currentCatOwnerId));
     $this->set('previewId', $this->request->data['Page']['id']);
     $this->set('reflectMobile', $reflectMobile);
     $this->set('reflectSmartphone', $reflectSmartphone);
     $this->set('users', $this->Page->getControlSource('user_id'));
     $this->set('editorOptions', $editorOptions);
     $this->set('url', $url);
     $this->set('mobileExists', $this->Page->agentExists('mobile', $this->request->data));
     $this->set('smartphoneExists', $this->Page->agentExists('smartphone', $this->request->data));
     $this->set('rootMobileId', $this->PageCategory->getAgentId('mobile'));
     $this->set('rootSmartphoneId', $this->PageCategory->getAgentId('smartphone'));
     $this->subMenuElements = array('pages', 'page_categories');
     if (!empty($this->request->data['Page']['title'])) {
         $this->pageTitle = '固定ページ情報編集:' . $this->request->data['Page']['title'];
     } else {
         $this->pageTitle = '固定ページ情報編集:' . Inflector::Classify($this->request->data['Page']['name']);
     }
     $this->help = 'pages_form';
     $this->render('form');
 }