Inheritance: extends Object
 /**
  * formAfterInput
  * 
  * @param CakeEvent $event
  * @return string
  */
 public function formAfterInput(CakeEvent $event)
 {
     if (!BcUtil::isAdminSystem()) {
         return $event->data['out'];
     }
     $View = $event->subject();
     if (!in_array($View->request->params['controller'], $this->targetController)) {
         return $event->data['out'];
     }
     if (!in_array($View->request->params['action'], $this->targetAction)) {
         return $event->data['out'];
     }
     if (!isset($View->request->data['KeywordConfig'])) {
         return $event->data['out'];
     }
     if (!$View->request->data['KeywordConfig']['status']) {
         return $event->data['out'];
     }
     // 固定ページ:入力欄の下にキーワード入力欄を表示する
     if ($event->data['fieldName'] == 'Page.description') {
         $event->data['out'] = $event->data['out'] . $View->element('Keyword.keyword_form');
     }
     // ブログ記事:記事タイトル入力欄の下にキーワード入力欄を表示する
     if ($event->data['fieldName'] == 'BlogPost.name') {
         $event->data['out'] = $event->data['out'] . $View->element('Keyword.keyword_form');
     }
     return $event->data['out'];
 }
 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     // 認証設定
     $this->BcAuth->allow('search', 'mobile_search', 'smartphone_search');
     if (!empty($this->request->params['admin'])) {
         $this->crumbs = array(array('name' => 'システム設定', 'url' => array('controller' => 'site_configs', 'action' => 'form')), array('name' => '検索インデックス管理', 'url' => array('controller' => 'search_indices', 'action' => 'index')));
     }
     if (!BcUtil::isAdminSystem()) {
         $Content = ClassRegistry::init('Content');
         $currentSite = BcSite::findCurrent(true);
         $url = '/';
         if ($this->request->params['action'] != 'search') {
             $prefix = str_replace('_search', '', $this->request->params['action']);
             if ($prefix == $currentSite->name) {
                 $url = '/' . $currentSite->alias . '/';
                 $this->request->params['action'] = 'search';
                 $this->action = 'search';
             }
         }
         $content = $Content->find('first', ['conditions' => ['Content.url' => $url], 'recursive' => 0]);
         $this->request->params['Content'] = $content['Content'];
         $this->request->params['Site'] = $content['Site'];
     }
 }
Example #3
0
 /**
  * ウィジェットエリアを表示する
  *
  * @param $no ウィジェットエリアNO
  * @param array $options オプション
  *  `subDir` (boolean) エレメントのパスについてプレフィックスによるサブディレクトリを追加するかどうか
  *  ※ その他のパラメータについては、View::element() を参照
  */
 public function show($no, $options = array())
 {
     $options = array_merge(array('subDir' => true), $options);
     $WidgetArea = ClassRegistry::init('WidgetArea');
     $widgetArea = $WidgetArea->find('first', array('conditions' => array('WidgetArea.id' => $no)));
     if (empty($widgetArea['WidgetArea']['widgets'])) {
         return;
     }
     $widgets = BcUtil::unserialize($widgetArea['WidgetArea']['widgets']);
     usort($widgets, array('BcWidgetAreaHelper', '_widgetSort'));
     foreach ($widgets as $key => $widget) {
         $key = key($widget);
         if ($widget[$key]['status']) {
             $params = array();
             $plugin = '';
             $params['widget'] = true;
             if (empty($_SESSION['Auth']['User']) && !isset($cache)) {
                 $params['cache'] = '+1 month';
             }
             $params = am($params, $widget[$key]);
             $params[$no . '_' . $widget[$key]['id']] = $no . '_' . $widget[$key]['id'];
             // 同じタイプのウィジェットでキャッシュを特定する為に必要
             if (!empty($params['plugin'])) {
                 $plugin = Inflector::camelize($params['plugin']) . '.';
                 unset($params['plugin']);
             }
             $this->_View->BcBaser->element($plugin . 'widgets/' . $widget[$key]['element'], $params, $options);
         }
     }
 }
 /**
  * Form After Submit
  *
  * フォームの保存ボタンの前後に、一覧、プレビュー、削除ボタンを配置する
  * プレビューを配置する場合は、設定にて、preview を true にする
  *
  * @param CakeEvent $event
  * @return string
  */
 public function formAfterSubmit(CakeEvent $event)
 {
     if (!BcUtil::isAdminSystem()) {
         return;
     }
     $View = $event->subject();
     $data = $View->request->data;
     if (!preg_match('/(AdminEditForm|AdminEditAliasForm)$/', $event->data['id'])) {
         return;
     }
     $output = $View->BcHtml->link('一覧に戻る', array('plugin' => '', 'admin' => true, 'controller' => 'contents', 'action' => 'index'), array('class' => 'button'));
     $setting = Configure::read('BcContents.items.' . $data['Content']['plugin'] . '.' . $data['Content']['type']);
     if (!empty($setting['preview']) && $data['Content']['type'] != 'ContentFolder') {
         $output .= "\n" . $View->BcForm->button('プレビュー', array('class' => 'button', 'id' => 'BtnPreview'));
     }
     $output .= $event->data['out'];
     if (empty($data['Content']['site_root'])) {
         if ($data['Content']['alias_id']) {
             $deleteText = '削除';
         } else {
             $deleteText = 'ゴミ箱へ移動';
         }
         $output .= $View->BcForm->button($deleteText, array('class' => 'button', 'id' => 'BtnDelete'));
     }
     return $output;
 }
 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->BcAuth->allow('add', 'captcha', 'smartphone_add', 'smartphone_captcha', 'get_token');
     if (BcUtil::isAdminSystem()) {
         $this->subMenuElements = array('blog_posts');
         $this->request->params['Content'] = $this->BcContents->getContent($this->request->params['pass'][0])['Content'];
         $this->Security->enabled = true;
         $this->Security->requireAuth('add');
     }
     $crumbs = array();
     if (!empty($this->params['pass'][1])) {
         $dbDatas = $this->BlogPost->find('first', ['conditions' => ['BlogPost.id' => $this->params['pass'][1]]]);
         if (!$dbDatas) {
             $this->notFound();
         }
         $this->blogPost = array('BlogPost' => $dbDatas['BlogPost']);
         $this->blogContent = array('BlogContent' => $dbDatas['BlogContent']);
         if (BcUtil::isAdminSystem()) {
             $crumbs[] = array('name' => $this->request->params['Content']['title'] . '設定', 'url' => array('controller' => 'blog_posts', 'action' => 'index', $this->blogContent['BlogContent']['id']));
             $crumbs[] = array('name' => $this->blogPost['BlogPost']['name'], 'url' => array('controller' => 'blog_posts', 'action' => 'edit', $this->blogContent['BlogContent']['id'], $this->blogPost['BlogPost']['id']));
         }
     } elseif (!empty($this->params['pass'][0])) {
         if (!in_array($this->request->action, ['captcha', 'smartphone_captcha', 'get_token'])) {
             $dbDatas = $this->BlogPost->BlogContent->find('first', ['conditions' => ['BlogContent.id' => $this->params['pass'][0]]]);
             $this->blogContent = array('BlogContent' => $dbDatas['BlogContent']);
             if (BcUtil::isAdminSystem()) {
                 $crumbs[] = array('name' => $this->request->params['Content']['title'] . '設定', 'url' => array('controller' => 'blog_posts', 'action' => 'index', $this->blogContent['BlogContent']['id']));
             }
         }
     }
     $this->crumbs = array_merge($this->crumbs, $crumbs);
 }
 public function testその他正常系()
 {
     // eye_catch_sizeチェック
     $data = array('thumb_width' => 1, 'thumb_height' => 1, 'mobile_thumb_width' => 1, 'mobile_thumb_height' => 1);
     $this->BlogContent->create(array('BlogContent' => array('eye_catch_size' => BcUtil::serialize($data))));
     $this->assertTrue($this->BlogContent->validates());
     $this->assertArrayNotHasKey('eye_catch_size', $this->BlogContent->validationErrors);
 }
 /**
  * After Render
  * 
  * @param CakeEvent $event
  */
 public function afterRender(CakeEvent $event)
 {
     if (BcUtil::isAdminSystem()) {
         return;
     }
     $View = $event->subject();
     $this->_execShortCode($View);
 }
Example #8
0
 /**
  * 偽装ログイン処理
  * 
  * @param $id ユーザーIDとユーザーグループID
  * - 1 システム管理者
  * - 2 サイト運営
  */
 public function login($id)
 {
     session_id('baser');
     // 適当な文字列を与え強制的にコンソール上でセッションを有効にする
     $this->Favorite->setSession(new SessionComponent(new ComponentCollection()));
     $prefix = BcUtil::authSessionKey('admin');
     $this->Favorite->_Session->write('Auth.' . $prefix . '.id', $id);
     $this->Favorite->_Session->write('Auth.' . $prefix . '.user_group_id', $id);
 }
 /**
  * ログイン状態にする
  *
  * @return void
  */
 protected function _login()
 {
     $User = ClassRegistry::init('User');
     $user = $User->find('first', array('conditions' => array('User.id' => 1)));
     unset($user['User']['password']);
     $this->BcBaser->set('user', $user['User']);
     $user['User']['UserGroup'] = $user['UserGroup'];
     $sessionKey = BcUtil::authSessionKey('admin');
     $_SESSION['Auth'][$sessionKey] = $user['User'];
 }
Example #10
0
 /**
  * ログインユーザーのデータを取得する
  * 
  * @return array
  */
 public static function loginUser()
 {
     $Session = new CakeSession();
     $sessionKey = BcUtil::getLoginUserSessionKey();
     $user = $Session->read('Auth.' . $sessionKey);
     if (!$user) {
         if (!empty($_SESSION['Auth'][$sessionKey])) {
             $user = $_SESSION['Auth'][$sessionKey];
         }
     }
     return $user;
 }
Example #11
0
 /**
  * フォルダのテンプレートリストを取得する
  *
  * @param $contentId
  * @param $theme
  * @return array
  */
 public function getFolderTemplateList($contentId, $theme)
 {
     $folderTemplates = BcUtil::getTemplateList('ContentFolders', '', $theme);
     if ($contentId != 1) {
         $parentTemplate = $this->getParentTemplate($contentId, 'folder');
         $searchKey = array_search($parentTemplate, $folderTemplates);
         if ($searchKey !== false) {
             unset($folderTemplates[$searchKey]);
         }
         array_unshift($folderTemplates, array('' => '親フォルダの設定に従う(' . $parentTemplate . ')'));
     }
     return $folderTemplates;
 }
Example #12
0
 /**
  * アクセス権があるかチェックする
  * 
  * @param array $check
  */
 public function isPermitted($check)
 {
     if (!$this->_Session) {
         return true;
     }
     $url = $check[key($check)];
     $prefix = BcUtil::authSessionKey('admin');
     $userGroupId = $this->_Session->read('Auth.' . $prefix . '.user_group_id');
     if ($userGroupId == Configure::read('BcApp.adminGroupId')) {
         return true;
     }
     $Permission = ClassRegistry::init('Permission');
     return $Permission->check($url, $userGroupId);
 }
 /**
  * [ADMIN] 管理者ダッシュボードページを表示する
  *
  * @return void
  */
 public function admin_index()
 {
     $this->pageTitle = '管理者ダッシュボード';
     $panels = [];
     $panels['Core'] = BcUtil::getTemplateList('Elements/admin/dashboard', '', $this->siteConfigs['theme']);
     $plugins = CakePlugin::loaded();
     if ($plugins) {
         foreach ($plugins as $plugin) {
             $panels[$plugin] = BcUtil::getTemplateList('Elements/admin/dashboard', $plugin, $this->siteConfigs['theme']);
         }
     }
     $this->set('panels', $panels);
     $this->help = 'dashboard_index';
 }
 /**
  * blogBlogPostBeforeRender
  * 
  * @param CakeEvent $event
  */
 public function blogBlogPostsBeforeRender(CakeEvent $event)
 {
     if (!BcUtil::isAdminSystem()) {
         return;
     }
     $View = $event->subject();
     if (in_array($View->request->params['action'], $this->targetAction)) {
         $this->setUpModel();
         $data = $this->KeywordConfigModel->find('first', array('conditions' => array('KeywordConfig.model' => 'BlogContent', 'KeywordConfig.content_id' => $View->viewVars['blogContent']['BlogContent']['id'])));
         if ($data) {
             $View->request->data['KeywordConfig'] = $data['KeywordConfig'];
         }
     }
 }
 public function afterLayout(CakeEvent $event)
 {
     $View = $event->subject();
     if (!BcUtil::isAdminSystem() || $View->name == 'CakeError') {
         return;
     }
     $this->BcHtml = $View->BcHtml;
     if (isset($View->BcCkeditor)) {
         if (preg_match_all("/(editor_[a-z0-9_]*?)\\s*?=\\s*?CKEDITOR\\.replace/s", $View->output, $matches)) {
             /* ckeditor_uploader.js を読み込む */
             $jscode = $this->BcHtml->scriptBlock("var baseUrl ='" . $View->request->base . "/';");
             $jscode .= $this->BcHtml->scriptBlock("var adminPrefix ='" . Configure::read('Routing.prefixes.0') . "';");
             $jscode .= $this->BcHtml->script('Uploader.admin/libs/ckeditor_uploader');
             $View->output = str_replace('</head>', $jscode . '</head>', $View->output);
             /* CSSを読み込む */
             // 適用の優先順位の問題があるので、bodyタグの直後に読み込む
             $css = $this->BcHtml->css('Uploader.uploader');
             $View->output = str_replace('</body>', $css . '</body>', $View->output);
             /* VIEWのCKEDITOR読込部分のコードを書き換える */
             foreach ($matches[1] as $match) {
                 $jscode = $this->__getCkeditorUploaderScript($match);
                 $pattern = "/<script type=\"text\\/javascript\">[\\s\n]*?\\/\\/<\\!\\[CDATA\\[[\\s\n]*?([\$]\\(window\\)\\.load.+?" . $match . "\\s=\\sCKEDITOR\\.replace.*?)\\/\\/\\]\\]>\n*?<\\/script>/s";
                 $output = preg_replace($pattern, $this->BcHtml->scriptBlock("\$1" . $jscode), $View->output);
                 if (!is_null($output)) {
                     $View->output = $output;
                 }
             }
             /* 通常の画像貼り付けダイアログを画像アップローダーダイアログに変換する */
             $pattern = "/(CKEDITOR\\.replace.*?\"toolbar\".*?)\"Image\"(.*?);/is";
             $View->output = preg_replace($pattern, "\$1" . '"BaserUploader"' . "\$2;", $View->output);
         }
     }
     if (!empty($View->request->params['prefix']) && $View->request->params['prefix'] == 'mobile') {
         /* モバイル画像に差し替える */
         $aMatch = "/<array([^>]*?)href=\"([^>]*?)\"([^>]*?)><img([^>]*?)\\/><\\/a>/is";
         $imgMatch = "/<img([^>]*?)src=\"([^>]*?)\"([^>]*?)\\/>/is";
         $View->output = preg_replace_callback($aMatch, array($this, "__mobileImageAnchorReplace"), $View->output);
         $View->output = preg_replace_callback($imgMatch, array($this, "__mobileImageReplace"), $View->output);
     }
 }
 /**
  * afterSave
  *
  * @param CakeEvent $event
  * @return boolean
  */
 public function afterSave(CakeEvent $event)
 {
     $model = $event->subject;
     $modelName = $model->name;
     $modelId = null;
     $revision = null;
     $limit = null;
     if (array_key_exists($modelName, Configure::read('RevisionControl.models')) && $model->data[$modelName]['id']) {
         $modelId = $model->data[$modelName]['id'];
         $limit = Configure::read('RevisionControl.limit');
         $revisionControlMdl = ClassRegistry::init('RevisionControl.RevisionControl');
         // 最新リビジョン番号を取得
         $prevData = $revisionControlMdl->find('first', array('conditions' => array('model_name' => $modelName, 'model_id' => $modelId), 'order' => 'revision desc'));
         if (isset($prevData['RevisionControl']['revision'])) {
             $revision = intval($prevData['RevisionControl']['revision']) + 1;
         } else {
             $revision = 1;
         }
         // タイムスタンプデータを削除
         $revData = array('RevisionControl' => array('model_name' => $modelName, 'model_id' => $modelId, 'revision' => $revision, 'deta_object' => serialize($model->data)));
         // 更新ユーザ情報を追加
         $user = BcUtil::loginUser();
         if ($user) {
             $revData['RevisionControl']['user_id'] = $user['id'];
         }
         // 保存
         $revisionControlMdl->save($revData, false);
         // リビジョン制限オーバーデータの削除
         if ($limit) {
             $revisionList = $revisionControlMdl->find('all', array('conditions' => array('model_name' => $modelName, 'model_id' => $modelId), 'order' => 'revision desc'));
             $i = 0;
             foreach ($revisionList as $data) {
                 if (++$i > $limit) {
                     $revisionControlMdl->delete(intval($data['RevisionControl']['id']));
                 }
             }
         }
     }
     return true;
 }
 /**
  * beforeLayout
  *
  * @param CakeEvent $event
  * @return boolean
  */
 public function beforeLayout(CakeEvent $event)
 {
     if (BcUtil::isAdminSystem()) {
         return true;
     }
     $View = $event->subject;
     // ユーザ(サイト制作者)定義CSSの自動読込
     $userCssList = array();
     // themeのcss優先
     if (file_exists(WWW_ROOT . 'theme' . DS . Configure::read('BcSite.theme') . DS . 'css' . DS . 'bge_style.css')) {
         $userCssList[] = "bge_style.css";
         // themeになく、webroot/cssにあれば読込
     } elseif (file_exists(WWW_ROOT . 'css' . DS . 'bge_style.css')) {
         $userCssList[] = "bge_style.css";
         // themeになく、webroot/cssにもない場合、プラグイン標準のファイルを読み込む
     } else {
         $userCssList[] = 'BurgerEditor.bge_style';
     }
     // colorbox用スタイル
     $userCssList[] = 'BurgerEditor.colorbox';
     if ($userCssList) {
         $View->BcBaser->css($userCssList, array('inline' => false));
     }
     // JSの自動読込
     $jsList = array();
     // デバックモードの場合は圧縮前のJSを読み込む
     if (Configure::read('debug')) {
         $jsList[] = 'BurgerEditor.bge_modules/bge_functions.js';
     } else {
         $jsList[] = 'BurgerEditor.bge_modules/bge_functions.min.js';
     }
     // jquery.colorbox.jsの自動読み込み
     $jsList[] = 'BurgerEditor.bge_modules/jquery.colorbox-min.js';
     // google map APIの読込
     $jsList[] = '//maps.google.com/maps/api/js?sensor=false';
     if ($jsList) {
         $View->BcBaser->js($jsList, false);
     }
     return true;
 }
    /**
     * 
     */
    public function beforeRender(CakeEvent $event)
    {
        if (BcUtil::isAdminSystem()) {
            return;
        }
        $View = $event->subject();
        if (!empty($View->BcBaser)) {
            $View->BcBaser->js('Suggest.jquery.autocomplete', false);
            $View->BcBaser->css('Suggest.jquery.autocomplete', array('inline' => false));
            $url = $View->BcBaser->getUrl('/suggest/suggest/ajax_keyword');
            $script = <<<DOC_END
\$(document).ready(function(){
    \$('#ContentQ').autocomplete('{$url}',{
\t\tscroll:false,
\t\tonItemSelect:function(){
\t\t\t\$("#ContentSearchForm").submit();
\t\t}
\t});
});
DOC_END;
            $View->BcHtml->scriptBlock($script, array('inline' => false));
        }
    }
Example #19
0
 /**
  * Step 5: 設定ファイルの生成
  * データベース設定ファイル[database.php]
  * インストールファイル[install.php]
  * 
  * @return void
  * @access public
  */
 public function step5()
 {
     $this->pageTitle = 'baserCMSのインストール完了!';
     Cache::config('default', array('engine' => 'File'));
     if (!BC_INSTALLED) {
         $installationData = $this->Session->read('Installation');
         $installationData['lastStep'] = true;
         checkTmpFolders();
         Configure::write('Cache.disable', false);
         // インストールファイルでセッションの保存方法を切り替える為、インストール情報をキャッシュに保存
         Cache::write('Installation', $installationData, 'default');
         // データベース設定を書き込む
         $this->BcManager->createDatabaseConfig($this->_readDbSetting());
         // インストールファイルを生成する
         $secritySalt = $this->Session->read('Installation.salt');
         $secrityCipherSeed = $this->Session->read('Installation.cipherSeed');
         $this->BcManager->createInstallFile($secritySalt, $secrityCipherSeed);
         //==================================================================
         // BcManagerComponent::createPageTemplates() を実行する際、
         // 固定ページでプラグインを利用している場合あり、プラグインがロードされていないとエラーになる為、
         // リダイレクト前にコアプラグインの有効化とテーマ保有のプラグインのインストールを完了させておく
         // =================================================================
         // データベースのデータを初期設定に更新
         $this->BcManager->executeDefaultUpdates($this->_readDbSetting(Cache::read('Installation', 'default')));
         // テーマを配置する
         $this->BcManager->deployTheme();
         $dbDataPattern = $this->Session->read('Installation.dbDataPattern');
         list($theme, $pattern) = explode('.', $dbDataPattern);
         loadSiteConfig();
         App::build(array('Plugin' => array_merge(array(BASER_THEMES . Configure::read('BcSite.theme') . DS . 'Plugin' . DS), App::path('Plugin'))));
         $themesPlugins = BcUtil::getCurrentThemesPlugins();
         if ($themesPlugins) {
             foreach ($themesPlugins as $plugin) {
                 $this->BcManager->installPlugin($plugin);
                 CakePlugin::load($plugin);
                 $this->BcManager->resetTables('plugin', $dbConfig = null, $plugin);
                 $this->BcManager->loadDefaultDataPattern('plugin', null, $pattern, $theme, $plugin);
             }
         }
         clearAllCache();
         if (function_exists('opcache_reset')) {
             opcache_reset();
         }
         $this->redirect('step5');
     } else {
         $installationData = Cache::read('Installation', 'default');
         if (empty($installationData['lastStep'])) {
             return;
         }
     }
     // ログイン
     $this->_login();
     // テーマに管理画面のアセットへのシンボリックリンクを作成する
     $this->BcManager->deployAdminAssets();
     // アップロード用初期フォルダを作成する
     $this->BcManager->createDefaultFiles();
     // エディタテンプレート用の画像を配置
     $this->BcManager->deployEditorTemplateImage();
     // Pagesファイルを生成する
     $this->BcManager->createPageTemplates();
     $this->Session->delete('InstallLastStep');
 }
Example #20
0
 /**
  * 現在のURLを正規化して取得する
  *
  * $this->request->here は、ビューキャッシュの命名規則に影響する為、
  * CacheHelper 等で、このメソッドを利用する事で、同一ページによる複数キャッシュの生成を防ぐ
  *
  * (例)
  * /news/ → /news/index
  * /company/ → /company/index
  *
  * @return string
  */
 public function normalizedHere()
 {
     $here = $this->here;
     if (!BcUtil::isAdminSystem() && $this->params['controller'] == 'pages') {
         if (!empty($this->params['pass']) && $this->params['pass'][count($this->params['pass']) - 1] == 'index' && !preg_match('/\\/index$/', $here)) {
             if (preg_match('/\\/$/', $here)) {
                 $here .= 'index';
             } else {
                 $here .= '/index';
             }
         }
         $here = preg_replace('/\\.html$/', '', $here);
     } else {
         if ($this->action == 'index') {
             list($here, ) = explode('?', $here);
             if (!empty($this->params['pass'])) {
                 foreach ($this->params['pass'] as $pass) {
                     $here = preg_replace('/\\/' . $pass . '$/', '', $here);
                 }
             }
             if (!preg_match('/\\/index$/', $here)) {
                 if (preg_match('/\\/$/', $here)) {
                     $here .= 'index';
                 } else {
                     $here .= '/index';
                 }
             }
         }
     }
     return $here;
 }
Example #21
0
 /**
  * データベースを初期化
  *
  * 既に存在するテーブルは上書きしない
  *
  * @param	array	データベース設定名
  * @param	string	プラグイン名
  * @return 	boolean
  */
 public function initDb($dbConfigName, $pluginName = '', $loadCsv = true, $filterTable = '', $filterType = '')
 {
     // 初期データフォルダを走査
     if (!$pluginName) {
         $path = BASER_CONFIGS . 'Schema';
     } else {
         $path = BcUtil::getSchemaPath($pluginName);
         if (!$path) {
             return true;
         }
     }
     if ($this->loadSchema($dbConfigName, $path, $filterTable, $filterType, array(), $dropField = false)) {
         if ($loadCsv) {
             $path = BcUtil::getDefaultDataPath($pluginName);
             if ($path) {
                 return $this->loadCsv($dbConfigName, $path);
             } else {
                 return true;
             }
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Example #22
0
/**
 * [ADMIN] ユーザー一覧 検索ボックス
 *
 * baserCMS :  Based Website Development Project <http://basercms.net>
 * Copyright 2008 - 2015, baserCMS Users Community <http://sites.google.com/site/baserusers/>
 *
 * @copyright		Copyright 2008 - 2015, baserCMS Users Community
 * @link			http://basercms.net baserCMS Project
 * @package			Baser.View
 * @since			baserCMS v 2.0.0
 * @license			http://basercms.net/license/index.html
 */
$priorities = array('0.1' => '0.1', '0.2' => '0.2', '0.3' => '0.3', '0.4' => '0.4', '0.5' => '0.5', '0.6' => '0.6', '0.7' => '0.7', '0.8' => '0.8', '0.9' => '0.9', '1.0' => '1.0');
$categories = am(array('none' => 'カテゴリなし'), BcUtil::unserialize($this->BcBaser->siteConfig['content_categories']));
$types = BcUtil::unserialize($this->BcBaser->siteConfig['content_types']);
?>

<?php 
echo $this->BcForm->create('Content', array('url' => array('action' => 'index')));
echo $this->BcForm->hidden('Content.open', array('value' => true));
?>
<p>
	<span><?php 
echo $this->BcForm->label('Content.type', 'タイプ');
?>
 <?php 
echo $this->BcForm->input('Content.type', array('type' => 'select', 'options' => $types, 'empty' => '指定なし'));
?>
</span>
	<span><?php 
Example #23
0
 /**
  * データベースをプラグインインストール前の状態に戻す
  * 
  * @param string $plugin プラグイン名
  * @return bool
  */
 public function resetDb($plugin)
 {
     $path = BcUtil::getSchemaPath($plugin);
     if (!$path) {
         return true;
     }
     $baserDb = ConnectionManager::getDataSource('baser');
     $baserDb->cacheSources = false;
     $baserListSources = $baserDb->listSources();
     $baserPrefix = $baserDb->config['prefix'];
     $pluginDb = ConnectionManager::getDataSource('plugin');
     $pluginDb->cacheSources = false;
     $pluginListSources = $pluginDb->listSources();
     $pluginPrefix = $pluginDb->config['prefix'];
     $Folder = new Folder($path);
     $files = $Folder->read(true, true);
     if (empty($files[1])) {
         return true;
     }
     $tmpdir = TMP . 'schemas' . DS;
     $result = true;
     foreach ($files[1] as $file) {
         $oldSchemaPath = '';
         if (preg_match('/^(.*?)\\.php$/', $file, $matches)) {
             $type = 'drop';
             $table = $matches[1];
             $File = new File($path . DS . $file);
             $data = $File->read();
             if (preg_match('/(public|var)\\s+\\$connection\\s+=\\s+\'([a-z]+?)\';/', $data, $matches)) {
                 $conType = $matches[2];
                 $listSources = ${$conType . 'ListSources'};
                 $prefix = ${$conType . 'Prefix'};
             } else {
                 continue;
             }
             $schemaPath = $tmpdir;
             if (preg_match('/^create_(.*?)\\.php$/', $file, $matches)) {
                 $type = 'drop';
                 $table = $matches[1];
                 if (!in_array($prefix . $table, $listSources)) {
                     continue;
                 }
                 copy($path . DS . $file, $tmpdir . $table . '.php');
             } elseif (preg_match('/^alter_(.*?)\\.php$/', $file, $matches)) {
                 $type = 'alter';
                 $table = $matches[1];
                 if (!in_array($prefix . $table, $listSources)) {
                     continue;
                 }
                 $corePlugins = implode('|', Configure::read('BcApp.corePlugins'));
                 if (preg_match('/^(' . $corePlugins . ')/', Inflector::camelize($table), $matches)) {
                     $pluginName = $matches[1];
                 }
                 $File = new File($path . DS . $file);
                 $data = $File->read();
                 $data = preg_replace('/class\\s+' . Inflector::camelize($table) . 'Schema/', 'class Alter' . Inflector::camelize($table) . 'Schema', $data);
                 $oldSchemaPath = $tmpdir . $file;
                 $File = new File($oldSchemaPath);
                 $File->write($data);
                 if ($conType == 'baser') {
                     $schemaPath = BcUtil::getSchemaPath() . DS;
                 } else {
                     $schemaPath = BcUtil::getSchemaPath($pluginName) . DS;
                 }
             } elseif (preg_match('/^drop_(.*?)\\.php$/', $file, $matches)) {
                 $type = 'create';
                 $table = $matches[1];
                 if (in_array($prefix . $table, $listSources)) {
                     continue;
                 }
                 copy($path . DS . $file, $tmpdir . $table . '.php');
             } else {
                 if (!in_array($prefix . $table, $listSources)) {
                     continue;
                 }
                 copy($path . DS . $file, $tmpdir . $table . '.php');
             }
             if ($conType == 'baser') {
                 $db = $baserDb;
             } else {
                 $db = $pluginDb;
             }
             if (!$db->loadSchema(array('type' => $type, 'path' => $schemaPath, 'file' => $table . '.php', 'dropField' => true, 'oldSchemaPath' => $oldSchemaPath))) {
                 $result = false;
             }
             @unlink($tmpdir . $table . '.php');
             if (file_exists($oldSchemaPath)) {
                 unlink($oldSchemaPath);
             }
         }
     }
     return $result;
 }
<div class="widget widget-site-search widgetsite-search-<?php 
    echo $id;
    ?>
">
<?php 
}
?>
		<?php 
echo $this->BcForm->create('Content', array('type' => 'get', 'action' => 'search', 'url' => $url));
?>
		<?php 
if (BcUtil::unserialize($this->BcBaser->siteConfig['content_categories'])) {
    ?>
		<div class="form-group form-group-sm">
			<?php 
    echo $this->BcForm->input('Content.c', array('type' => 'select', 'options' => BcUtil::unserialize($this->BcBaser->siteConfig['content_categories']), 'empty' => 'カテゴリー: 指定しない ', 'class' => 'form-control'));
    ?>
		<!-- /.form-group --></div>
		<?php 
}
?>
		<div class="form-inline">
			<div class="form-group form-group-sm">
				<?php 
echo $this->BcForm->input('Content.q', array('class' => 'form-control'));
?>
				<?php 
echo $this->BcForm->submit('検索', array('div' => false, 'class' => 'btn btn-default btn-sm'));
?>
			<!-- /.form-group --></div>
		<!-- /.form-inline --></div>
Example #25
0
 /**
  * アイキャッチサイズフィールドの値をフォーム用に変換する
  * 
  * @param array $data
  * @return array 
  */
 public function constructEyeCatchSize($data)
 {
     $eyeCatchSize = BcUtil::unserialize($data['BlogContent']['eye_catch_size']);
     $data['BlogContent']['eye_catch_size_thumb_width'] = $eyeCatchSize['thumb_width'];
     $data['BlogContent']['eye_catch_size_thumb_height'] = $eyeCatchSize['thumb_height'];
     $data['BlogContent']['eye_catch_size_mobile_thumb_width'] = $eyeCatchSize['mobile_thumb_width'];
     $data['BlogContent']['eye_catch_size_mobile_thumb_height'] = $eyeCatchSize['mobile_thumb_height'];
     return $data;
 }
Example #26
0
 /**
  * CSVファイルを書きだす
  *
  * @param string $configKeyName
  * @param string $path
  * @return boolean
  * @access protected
  */
 function _writeCsv($configKeyName, $plugin, $path, $exclude = array())
 {
     $pluginTables = array();
     if ($plugin != 'core') {
         $pluginPath = BcUtil::getSchemaPath($plugin);
         $Folder = new Folder($pluginPath);
         $files = $Folder->read(true, true, false);
         $pluginTables = $files[1];
         foreach ($pluginTables as $key => $pluginTable) {
             if (preg_match('/^(.+)\\.php$/', $pluginTable, $matches)) {
                 $pluginTables[$key] = $matches[1];
             } else {
                 unset($pluginTables[$key]);
             }
         }
     }
     $pluginKey = Inflector::underscore($plugin);
     $db = ConnectionManager::getDataSource($configKeyName);
     $db->cacheSources = false;
     $tables = $db->listSources();
     $result = true;
     foreach ($tables as $table) {
         if (preg_match("/^" . $db->config['prefix'] . "([^_].+)\$/", $table, $matches) && !preg_match("/^" . Configure::read('BcEnv.pluginDbPrefix') . "[^_].+\$/", $matches[1])) {
             $table = $matches[1];
             if (in_array($table, $exclude)) {
                 continue;
             }
             if ($pluginKey != 'core') {
                 // プラグインの場合は対象プラグイン名が先頭にない場合スキップ
                 //if (!preg_match("/^" . $pluginKey . "_([^_].+)$/", $table)) {
                 if (!in_array($table, $pluginTables)) {
                     // メールプラグインの場合、先頭に、「mail_」 がなくとも 末尾にmessagesがあれば対象とする
                     if ($pluginKey != 'mail') {
                         continue;
                     } elseif (!preg_match("/messages\$/", $table)) {
                         continue;
                     }
                 }
             }
             if (!$db->writeCsv(array('path' => $path . $table . '.csv', 'encoding' => 'SJIS', 'init' => false, 'plugin' => $plugin == 'core' ? null : $plugin))) {
                 $result = false;
             }
         }
     }
     return $result;
 }
Example #27
0
 /**
  * URLを取得する
  *
  * @param $url
  * @param bool $useSubDomain
  * @return string
  */
 public function getUrl($url, $full = false, $useSubDomain = false)
 {
     if ($useSubDomain && !is_array($url)) {
         $subDomain = '';
         $site = BcSite::findByUrl($url);
         $originUrl = $url;
         if ($site) {
             $subDomain = $site->alias;
             $originUrl = preg_replace('/^\\/' . preg_quote($site->alias, '/') . '\\//', '/', $url);
         }
         if ($originUrl == '/') {
             $urlArray = [];
         } else {
             $urlArray = explode('/', preg_replace('/(^\\/|\\/$)/', '', $originUrl));
         }
         if (preg_match('/\\/$/', $url) && count($urlArray) > 0) {
             $originUrl .= '/';
         }
         if ($full) {
             $fullUrl = fullUrl($originUrl);
             if (BcUtil::isAdminSystem()) {
                 if ($site->domainType == 1) {
                     $fullUrlArray = explode('//', $fullUrl);
                     return $fullUrlArray[0] . '//' . $subDomain . '.' . $fullUrlArray[1];
                 } elseif ($site->domainType == 2) {
                     $fullUrlArray = explode('//', $fullUrl);
                     $urlArray = explode('/', $fullUrlArray[1]);
                     unset($urlArray[0]);
                     if ($site->sameMainUrl) {
                         $mainSite = BcSite::findById($site->mainSiteId);
                         $subDomain = $mainSite->alias;
                     }
                     return $fullUrlArray[0] . '//' . $subDomain . '/' . implode('/', $urlArray);
                 }
             } else {
                 return $fullUrl;
             }
         } else {
             return Router::url($originUrl);
         }
     } else {
         if (BC_INSTALLED) {
             if (!is_array($url)) {
                 $site = BcSite::findByUrl($url);
                 if ($site && $site->sameMainUrl) {
                     $mainSite = BcSite::findById($site->mainSiteId);
                     $alias = $mainSite->alias;
                     if ($alias) {
                         $alias = '/' . $alias;
                     }
                     $url = $alias . $site->getPureUrl($url);
                 }
             }
         }
         if ($full) {
             return fullUrl($url);
         } else {
             return Router::url($url);
         }
     }
 }
Example #28
0
 /**
  * Parses a string URL into an array. If a plugin key is found, it will be copied to the
  * controller parameter
  *
  * @param string $url The URL to parse
  * @return mixed false on failure, or an array of request parameters
  */
 public function parse($url)
 {
     if (is_array($url)) {
         return false;
     }
     if (BcUtil::isAdminSystem($url)) {
         return false;
     }
     $request = Router::getRequest(true);
     //管理システムにログインしているかつプレビューの場合は公開状態のステータスは無視する
     $publish = true;
     if (!empty($request->query['preview']) || !empty($request->query['force'])) {
         $publish = false;
     }
     $sameUrl = false;
     $site = BcSite::findCurrentSub(true);
     if ($site) {
         // 同一URL対応
         $sameUrl = true;
         $checkUrl = $site->makeUrl($request);
         @header('Vary: User-Agent');
     } else {
         $site = BcSite::findCurrent(true);
         if (!is_null($site->name)) {
             if ($site->useSubDomain) {
                 $checkUrl = '/' . $site->alias . ($url ? $url : '/');
             } else {
                 $checkUrl = $url ? $url : '/';
             }
         } else {
             if (!empty($request->query['force']) && BcUtil::isAdminUser()) {
                 // =================================================================================================
                 // 2016/11/10 ryuring
                 // 別ドメインの際に、固定ページのプレビューで、正しくサイト情報を取得できない。
                 // そのため、文字列でリクエストアクションを送信し、URLでホストを判定する。
                 // =================================================================================================
                 $tmpSite = BcSite::findByUrl($url);
                 if (!is_null($tmpSite)) {
                     $site = $tmpSite;
                 }
             }
             $checkUrl = $url ? $url : '/';
         }
     }
     $content = $this->getContent($checkUrl, $publish, false, $sameUrl, $site->useSubDomain);
     if (!$content) {
         $content = $this->getContent($checkUrl, $publish, true, $sameUrl, $site->useSubDomain);
     }
     if (!$content) {
         return false;
     }
     // データが存在してもプレビューで管理システムにログインしていない場合はログイン画面に遷移
     if ((!empty($request->query['preview']) || !empty($request->query['force'])) && !BcUtil::loginUser()) {
         $_SESSION['Auth']['redirect'] = $_SERVER['REQUEST_URI'];
         header('Location: ' . topLevelUrl(false) . baseUrl() . Configure::read('BcAuthPrefix.admin.alias') . '/users/login');
         exit;
     }
     $Content = ClassRegistry::init('Content');
     if ($content['Content']['alias_id'] && !$Content->isPublishById($content['Content']['alias_id'])) {
         return false;
     }
     $request->params['Content'] = $content['Content'];
     $request->params['Site'] = $content['Site'];
     $url = $site->getPureUrl($url);
     $params = $this->getParams($url, $content['Content']['url'], $content['Content']['plugin'], $content['Content']['type'], $content['Content']['entity_id'], $site->alias);
     if ($params) {
         return $params;
     }
     return false;
 }
<?php

/**
 * [Config] PetitBlogCustomField
 *
 * @link			http://www.materializing.net/
 * @author			arata
 * @package			PetitBlogCustomField
 * @license			MIT
 */
/**
 * システムナビ
 */
if (BcUtil::isAdminUser()) {
    $config['BcApp.adminNavi.petit_blog_custom_field'] = array('name' => 'プチ・ブログカスタムフィールドプラグイン', 'contents' => array(array('name' => 'ブログカスタムフィールド一覧', 'url' => array('admin' => true, 'plugin' => 'petit_blog_custom_field', 'controller' => 'petit_blog_custom_fields', 'action' => 'index')), array('name' => 'ブログカスタムフィールド設定一覧', 'url' => array('admin' => true, 'plugin' => 'petit_blog_custom_field', 'controller' => 'petit_blog_custom_field_configs', 'action' => 'index'))));
}
/**
 * フィールド名設定
 * 
 */
$config['petitBlogCustomField.field_name'] = array(1 => array('name' => 'テキスト', 'name_2' => 'テキスト2', 'textarea' => 'テキストエリア', 'radio' => 'ラジオ', 'select' => 'セレクト', 'date' => '日付', 'text_sub_1' => 'サブテキスト01', 'text_sub_2' => 'サブテキスト02', 'text_sub_3' => 'サブテキスト03', 'text_sub_4' => 'サブテキスト04', 'text_sub_5' => 'サブテキスト05', 'text_sub_6' => 'サブテキスト06', 'text_sub_7' => 'サブテキスト07', 'text_sub_8' => 'サブテキスト08', 'text_sub_9' => 'サブテキスト09', 'text_sub_10' => 'サブテキスト10'));
/**
 * プチ・カスタムフィールドデフォルト設定
 * 
 */
/**
 * ラジオ設定
 * 
 */
$config['petitBlogCustomField.status'] = array(1 => array(0 => 'この記事でカスタム項目を利用しない', 1 => 'この記事でカスタム項目を利用する'));
/**
Example #30
0
 /**
  * テーブルをリセットする
  * 
  * @param type $dbConfigKeyName
  * @param type $dbConfig
  * @return boolean 
  */
 public function resetTables($dbConfigKeyName = 'baser', $dbConfig = null, $plugin = 'core', $excludes = array())
 {
     $db = $this->_getDataSource($dbConfigKeyName, $dbConfig);
     $dbConfig = $db->config;
     $db->reconnect();
     $sources = $db->listSources();
     $result = true;
     $pluginTables = array();
     if ($plugin != 'core') {
         $path = BcUtil::getSchemaPath($plugin);
         $Folder = new Folder($path);
         $files = $Folder->read(true, true, false);
         if (empty($files[1])) {
             return true;
         }
         foreach ($files[1] as $file) {
             if (preg_match('/\\.php$/', $file)) {
                 $pluginTables[] = preg_replace('/\\.php/', '', $file);
             }
         }
     }
     foreach ($sources as $source) {
         if (preg_match("/^" . $dbConfig['prefix'] . "([^_].+)\$/", $source, $matches)) {
             $table = $matches[1];
             if ($plugin == 'core') {
                 if (preg_match("/^" . Configure::read('BcEnv.pluginDbPrefix') . "/", $table)) {
                     continue;
                 }
             } else {
                 // プラグインの場合は対象プラグイン名が先頭にない場合スキップ
                 if (!in_array($table, $pluginTables)) {
                     // メールプラグインの場合、先頭に、「mail_」 がなくとも 末尾にmessagesがあれば対象とする
                     if ($plugin != 'Mail') {
                         continue;
                     } elseif (!preg_match("/messages\$/", $table)) {
                         continue;
                     }
                 }
             }
             if (!in_array($table, $excludes)) {
                 if (!$db->truncate($table)) {
                     $result = false;
                 }
             }
         }
     }
     return $result;
 }