/**
  * afterLayout
  *
  * @return void
  */
 public function afterLayout($layoutFile)
 {
     if (isset($this->request->params['ext']) && $this->request->params['ext'] == 'rss') {
         $rss = true;
     } else {
         $rss = false;
     }
     $site = BcSite::findCurrent();
     if (!$rss && $site->device == 'smartphone' && $this->_View->layoutPath != 'Emails' . DS . 'text') {
         if (empty($this->request->params['Site'])) {
             return;
         }
         // 内部リンクの自動変換
         if ($site->autoLink) {
             $bcBaseUrl = BC_BASE_URL;
             if ($this->_View->BcBaser->isSSL()) {
                 $bcBaseUrl = Configure::read('BcEnv.siteUrl');
             }
             $currentAlias = $this->request->params['Site']['alias'];
             // 一旦プレフィックスを除外
             $reg = '/a(.*?)href="' . preg_quote($bcBaseUrl, '/') . '(' . $currentAlias . '\\/([^\\"]*?))\\"/';
             $this->_View->output = preg_replace_callback($reg, array($this, '_removePrefix'), $this->_View->output);
             // プレフィックス追加
             $reg = '/a(.*?)href=\\"' . preg_quote($bcBaseUrl, '/') . '([^\\"]*?)\\"/';
             $this->_View->output = preg_replace_callback($reg, array($this, '_addPrefix'), $this->_View->output);
         }
     }
 }
 /**
  * beforeDispatch Event
  *
  * @param CakeEvent $event イベント
  * @return void|CakeResponse
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     if (!empty($request->params['Content'])) {
         return;
     } else {
         if ($this->_existController($request)) {
             return;
         }
     }
     $site = BcSite::findCurrent();
     if (!$site || !$site->enabled) {
         return;
     }
     $mainSite = $site->getMain();
     if (!$mainSite) {
         return;
     }
     $mainSiteUrl = '/' . preg_replace('/^' . $site->alias . '\\//', '', $request->url);
     if ($mainSite->alias) {
         $mainSiteUrl = '/' . $mainSite->alias . $mainSiteUrl;
     }
     if ($mainSiteUrl) {
         $request = new CakeRequest($mainSiteUrl);
         $params = Router::parse($request->url);
         $request->addParams($params);
         if ($this->_existController($request)) {
             $response->header('Location', $request->base . $mainSiteUrl);
             $response->statusCode(302);
             return $response;
         }
     }
     return;
 }
 /**
  * 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'];
     }
 }
 /**
  * beforeDispatch Event
  *
  * @param CakeEvent $event イベント
  * @return void|CakeResponse
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     $this->addDetectors($request);
     // アセットならスキップ
     if ($this->isAsset($request)) {
         Configure::write('BcRequest.asset', true);
         return;
     }
     // URLからエージェントを取得
     $site = BcSite::findCurrent(true);
     if ($site && $site->device) {
         /*
          * =========================================================
          * /m/files/... へのアクセスの場合、/files/... へ自動リダイレクト
          * CMSで作成するページ内のリンクは、モバイルでアクセスすると、
          * 自動的に、/m/ 付のリンクに書き換えられてしまう為、
          * files内のファイルへのリンクがリンク切れになってしまうので暫定対策。
          *
          * 2014/12/30 nakae bootstrap.phpから移行
          * =========================================================
          */
         $param = preg_replace('/^' . $site->alias . '\\//', '', $request->url);
         if (preg_match('/^files/', $param)) {
             $response->statusCode(301);
             $response->header('Location', "{$request->base}/{$param}");
             return $response;
         }
     }
     //bootstrapから移動する
     //Configure::write('BcRequest.isUpdater', $this->isUpdate($request));
     //Configure::write('BcRequest.isMaintenance', $this->isMaintenance($request));
 }
 /**
  * afterLayout
  *
  * @return void
  */
 public function afterLayout($layoutFile)
 {
     /* 出力データをSJISに変換 */
     $View = $this->_View;
     if (isset($this->request->params['ext']) && $this->request->params['ext'] == 'rss') {
         $rss = true;
     } else {
         $rss = false;
     }
     $site = BcSite::findCurrent(true);
     if (!$rss && $site && $site->device == 'mobile' && $View->layoutPath != 'Emails' . DS . 'text') {
         $View->output = str_replace('&', '&', $View->output);
         $View->output = str_replace('<', '<', $View->output);
         $View->output = str_replace('>', '>', $View->output);
         $View->response->charset('Shift_JIS');
         $View->output = mb_convert_kana($View->output, "rak", "UTF-8");
         $View->output = mb_convert_encoding($View->output, "SJIS-win", "UTF-8");
         // 内部リンクの自動変換
         if ($site->autoLink) {
             $currentAlias = $this->request->params['Site']['alias'];
             // 一旦プレフィックスを除外
             $reg = '/href="' . preg_quote(BC_BASE_URL, '/') . '(' . $currentAlias . '\\/([^\\"]*?))\\"/';
             $View->output = preg_replace_callback($reg, array($this, '_removeMobilePrefix'), $View->output);
             // プレフィックス追加
             $reg = '/href=\\"' . preg_quote(BC_BASE_URL, '/') . '([^\\"]*?)\\"/';
             $View->output = preg_replace_callback($reg, array($this, '_addMobilePrefix'), $View->output);
         }
         // XMLとして出力する場合、デバッグモードで出力する付加情報で、
         // ブラウザによってはXMLパースエラーとなってしまうので強制的にデバッグモードをオフ
         Configure::write('debug', 0);
     }
 }
 /**
  * Before Dispatch
  *
  * @param CakeEvent $event containing the request and response object
  * @return void
  */
 public function beforeDispatch(CakeEvent $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     if ($request->is('admin')) {
         return;
     }
     $subSite = BcSite::findCurrentSub();
     if (!is_null($subSite) && $subSite->shouldRedirects($request)) {
         $response->header('Location', $request->base . $subSite->makeUrl($request));
         $response->statusCode(302);
         return $response;
     }
 }
 /**
  * set up
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->BcContentsRoute = new BcContentsRoute('/', [], []);
     BcSite::flash();
 }
Beispiel #8
0
 /**
  * ページファイルのパスを取得する
  * 
  * @param array $data
  * @return string
  */
 public function getPageFilePath($data)
 {
     $path = APP . 'View' . DS . 'Pages' . DS;
     if (!is_dir($path)) {
         mkdir($path);
         chmod($path, 0777);
     }
     $url = $this->Content->createUrl($data['Content']['parent_id'], 'Core', 'ContentFolder');
     if ($url != '/') {
         if ($data['Content']['site_id'] != 0) {
             $site = BcSite::findByUrl($url);
             if ($site) {
                 $url = preg_replace('/^\\/' . preg_quote($site->alias, '/') . '\\//', '/' . $site->name . '/', $url);
             }
         }
         $urlAry = explode('/', preg_replace('/(^\\/|\\/$)/', '', $url));
         foreach ($urlAry as $value) {
             $path .= $value . DS;
             if (!is_dir($path)) {
                 mkdir($path, 0777);
                 chmod($path, 0777);
             }
         }
     }
     return $path . $data['Content']['name'] . Configure::read('BcApp.templateExt');
 }
 /**
  * After Render
  *
  * @param string $viewFile
  */
 public function afterRender($viewFile)
 {
     parent::afterRender($viewFile);
     if (BcUtil::isAdminSystem()) {
         return;
     }
     if (empty($this->request->params['Site'])) {
         return;
     }
     if (isset($this->request->params['Site']['name']) && is_null($this->request->params['Site']['name'])) {
         return;
     }
     if (isset($this->request->params['Site']['device']) && $this->request->params['Site']['device'] != '') {
         return;
     }
     // 別URLの場合、alternateを出力(スマートフォンのみ対応)
     $pureUrl = $this->BcContents->getPureUrl($this->request->url, $this->request->params['Site']['id']);
     $agent = BcAgent::find('smartphone');
     $subSite = BcSite::findCurrentSub(false, $agent);
     if (!$subSite) {
         return;
     }
     $url = $subSite->makeUrl(new CakeRequest($pureUrl));
     $this->_View->set('meta', $this->BcHtml->meta('canonical', $this->BcHtml->url($url, true), ['rel' => 'canonical', 'media' => 'only screen and (max-width: 640px)', 'type' => null, 'title' => null, 'inline' => false]));
 }
 /**
  * ビューを表示する
  *
  * @param mixed
  * @return void
  */
 public function display()
 {
     // CUSTOMIZE DELETE 2016/10/05 ryuring
     $path = func_get_args();
     // CUSTOMIZE ADD 2014/07/02 ryuring
     // >>>
     if ($this->request->params['Content']['alias_id']) {
         $urlTmp = $this->Content->field('url', ['Content.id' => $this->request->params['Content']['alias_id']]);
     } else {
         $urlTmp = $this->request->params['Content']['url'];
     }
     if ($this->request->params['Site']['alias']) {
         $site = BcSite::findByUrl($urlTmp);
         if ($site && $site->alias == $this->request->params['Site']['alias']) {
             $urlTmp = preg_replace('/^\\/' . preg_quote($site->alias, '/') . '\\//', '/' . $this->request->params['Site']['name'] . '/', $urlTmp);
         }
     }
     $urlTmp = preg_replace('/^\\//', '', $urlTmp);
     $path = explode('/', $urlTmp);
     $count = count($path);
     if (!$count) {
         $this->redirect('/');
     }
     $page = $subpage = $titleForLayout = null;
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $titleForLayout = Inflector::humanize($path[$count - 1]);
     }
     // <<<
     $this->set(array('page' => $page, 'subpage' => $subpage, 'title_for_layout' => $titleForLayout));
     // CUSTOMIZE ADD 2014/07/02 ryuring
     // >>>
     $previewCreated = false;
     if ($this->request->data) {
         if ($this->BcContents->preview == 'default') {
             $uuid = $this->_createPreviewTemplate($this->request->data);
             $this->set('previewTemplate', TMP . 'pages_preview_' . $uuid . $this->ext);
             $previewCreated = true;
         }
     }
     $page = $this->Page->find('first', ['conditions' => ['Page.id' => $this->request->params['Content']['entity_id']], 'recursive' => -1]);
     $template = $page['Page']['page_template'];
     $pagePath = implode('/', $path);
     if (!$template) {
         $ContentFolder = ClassRegistry::init('ContentFolder');
         $template = $ContentFolder->getParentTemplate($this->request->params['Content']['id'], 'page');
     }
     $this->set('pagePath', $pagePath);
     // <<<
     try {
         // CUSTOMIZE MODIFY 2014/07/02 ryuring
         // >>>
         //$this->render(implode('/', $path));
         // ---
         $this->render('templates/' . $template);
         if ($previewCreated) {
             @unlink(TMP . 'pages_preview_' . $uuid . $this->ext);
         }
         // <<<
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
 /**
  * 初期データを読み込む
  * 
  * @param string $dbDataPattern 初期データのパターン	
  * @param string $currentTheme テーマ名
  * @return bool
  */
 protected function _load_default_data_pattern($dbDataPattern, $currentTheme = '')
 {
     list($theme, $pattern) = explode('.', $dbDataPattern);
     if (!$this->BcManager->checkDefaultDataPattern($pattern, $theme)) {
         $this->setMessage('初期データのバージョンが違うか、初期データの構造が壊れています。', true);
         return false;
     }
     $excludes = array('plugins', 'dblogs', 'users');
     $User = ClassRegistry::init('User');
     /* データを削除する */
     $this->BcManager->resetAllTables(null, $excludes);
     $result = true;
     /* コアデータ */
     if (!$this->BcManager->loadDefaultDataPattern('default', null, $pattern, $theme, 'core', $excludes)) {
         $result = false;
         $this->log($dbDataPattern . " の初期データのロードに失敗しました。");
     }
     /* プラグインデータ */
     $corePlugins = Configure::read('BcApp.corePlugins');
     $plugins = array_merge($corePlugins, BcUtil::getCurrentThemesPlugins());
     foreach ($plugins as $plugin) {
         $this->BcManager->loadDefaultDataPattern('default', null, $pattern, $theme, $plugin, $excludes);
     }
     if (!$result) {
         /* 指定したデータセットでの読み込みに失敗した場合、コアのデータ読み込みを試みる */
         if (!$this->BcManager->loadDefaultDataPattern('default', null, 'default', 'core', 'core', $excludes)) {
             $this->log("コアの初期データのロードに失敗しました。");
             $result = false;
         }
         foreach ($corePlugins as $corePlugin) {
             if (!$this->BcManager->loadDefaultDataPattern('default', null, 'default', 'core', $corePlugin, $excludes)) {
                 $this->log("コアのプラグインの初期データのロードに失敗しました。");
                 $result = false;
             }
         }
         if ($result) {
             $this->setMessage('初期データの読み込みに失敗しましたので baserCMSコアの初期データを読み込みました。', true);
         } else {
             $this->setMessage('初期データの読み込みに失敗しました。データが不完全な状態です。正常に動作しない可能性があります。', true);
         }
     }
     clearAllCache();
     // メール受信テーブルの作成
     App::uses('MailMessage', 'Mail.Model');
     $MailMessage = new MailMessage();
     if (!$MailMessage->reconstructionAll()) {
         $this->log('メールプラグインのメール受信用テーブルの生成に失敗しました。');
         $result = false;
     }
     clearAllCache();
     ClassRegistry::flush();
     BcSite::flash();
     if ($currentTheme) {
         $siteConfigs = array('SiteConfig' => array('theme' => $currentTheme));
         $this->SiteConfig->saveKeyValue($siteConfigs);
     }
     if (!$this->Page->createAllPageTemplate()) {
         $result = false;
         $this->log('初期データの読み込み中にページテンプレートの生成に失敗しました。' . '「Pages」フォルダに書き込み権限が付与されていない可能性があります。' . '権限設定後、テーマの適用をやり直すか、表示できないページについて固定ページ管理より更新処理を行ってください。');
     }
     // システムデータの初期化
     // TODO $this->BcManager->initSystemData() は、$this->Page->createAllPageTemplate() の
     // 後に呼出さないと $this->Page の実体が何故か AppModel にすりかわってしまい、
     // createAllPageTemplate メソッドが呼び出せないので注意
     if (!$this->BcManager->initSystemData(null, array('excludeUsers' => true))) {
         $result = false;
         $this->log('システムデータの初期化に失敗しました。');
     }
     // ユーザーデータの初期化
     $UserGroup = ClassRegistry::init('UserGroup');
     $adminGroupId = $UserGroup->field('id', array('UserGroup.name' => 'admins'));
     $users = $User->find('all', array('recursive' => -1));
     foreach ($users as $user) {
         $user['User']['user_group_id'] = $adminGroupId;
         unset($user['User']['password']);
         if (!$User->save($user)) {
             $result = false;
             $this->log('ユーザーデータの初期化に失敗しました。手動で各ユーザーのユーザーグループの設定を行なってください。');
         }
         if (!$User->applyDefaultFavorites($user['User']['id'], $user['User']['user_group_id'])) {
             $result = false;
             $this->log('ユーザーのよく使う項目データの初期化に失敗しました。手動で各ユーザーのよく使う項目の設定を行なってください。');
         }
     }
     $Db = ConnectionManager::getDataSource('default');
     if ($Db->config['datasource'] == 'Database/BcPostgres') {
         $Db->updateSequence();
     }
     // システム基本設定の更新
     $siteConfigs = array('SiteConfig' => array('email' => $this->siteConfigs['email'], 'google_analytics_id' => $this->siteConfigs['google_analytics_id'], 'first_access' => null, 'version' => $this->siteConfigs['version']));
     $this->SiteConfig->saveKeyValue($siteConfigs);
     return $result;
 }
Beispiel #12
0
 /**
  * フィールド名を変更する
  *
  * @param array	$options [ new / old / table ]
  * @param array $column
  * @return boolean
  */
 public function renameField($options)
 {
     extract($options);
     if (!isset($new) || !isset($old)) {
         return false;
     }
     if (!isset($table)) {
         $table = $this->useTable;
     }
     $this->_schema = null;
     $db = ConnectionManager::getDataSource($this->useDbConfig);
     $options = ['new' => $new, 'old' => $old, 'table' => $table];
     $ret = $db->renameColumn($options);
     $this->deleteModelCache();
     ClassRegistry::flush();
     BcSite::flash();
     return $ret;
 }
 * baserCMS :  Based Website Development Project <http://basercms.net>
 * Copyright (c) baserCMS Users Community <http://basercms.net/community/>
 *
 * @copyright		Copyright (c) baserCMS Users Community
 * @link			http://basercms.net baserCMS Project
 * @package			Baser.View
 * @since			baserCMS v 4.0.0
 * @license			http://basercms.net/license/index.html
 */
/**
 * [ADMIN] 統合コンテンツフォーム
 */
$urlArray = explode('/', preg_replace('/(^\\/|\\/$)/', '', $this->request->data['Content']['url']));
unset($urlArray[count($urlArray) - 1]);
if ($this->request->data['Site']['same_main_url']) {
    $site = BcSite::findById($this->request->data['Site']['main_site_id']);
    array_shift($urlArray);
    if ($site->alias) {
        $urlArray = explode('/', $site->alias) + $urlArray;
    }
}
if ($this->request->data['Site']['use_subdomain']) {
    $host = $this->BcContents->getUrl('/' . $urlArray[0] . '/', true, $this->request->data['Site']['use_subdomain']);
    array_shift($urlArray);
} else {
    $host = $this->BcContents->getUrl('/', true, $this->request->data['Site']['use_subdomain']);
}
if ($this->request->data['Site']['alias']) {
    $checkUrl = '/' . $this->request->data['Site']['alias'] . '/';
} else {
    $checkUrl = '/';
 /**
  * コンテンツ保存フォームを設定する
  *
  * @param Controller $controller
  * @return void
  */
 public function settingForm(Controller $controller, $currentSiteId, $currentContentId = null)
 {
     // コントロールソースを設定
     $options = array();
     if ($controller->name == 'ContentFolders') {
         $options['excludeId'] = $currentContentId;
     }
     $data = $controller->request->data;
     $theme = $this->_Controller->siteConfigs['theme'];
     $site = BcSite::findById($data['Content']['site_id']);
     if ($site->theme) {
         $theme = $site->theme;
     }
     $templates = array_merge(BcUtil::getTemplateList('Layouts', '', $theme), BcUtil::getTemplateList('Layouts', $this->_Controller->plugin, $theme));
     if ($data['Content']['id'] != 1) {
         $parentTemplate = $this->getParentLayoutTemplate($data['Content']['id']);
         if (in_array($parentTemplate, $templates)) {
             unset($templates[$parentTemplate]);
         }
         array_unshift($templates, array('' => '親フォルダの設定に従う(' . $parentTemplate . ')'));
     }
     $data['Content']['name'] = urldecode($data['Content']['name']);
     $controller->set('layoutTemplates', $templates);
     $controller->set('parentContents', $controller->Content->getContentFolderList($currentSiteId, $options));
     $controller->set('authors', $controller->User->getUserList());
     $Site = ClassRegistry::init('Site');
     $site = $controller->Content->find('first', ['conditions' => ['Content.id' => $data['Content']['id']]]);
     if (!is_null($site['Site']['main_site_id'])) {
         $mainSiteId = $site['Site']['main_site_id'];
     } else {
         $mainSiteId = 0;
     }
     $siteList = ['' => ''] + $controller->Content->Site->getSiteList();
     $controller->set('sites', $siteList);
     $controller->set('mainSiteDisplayName', $siteList[0]);
     $data['Site'] = $site['Site'];
     $controller->set('mainSiteId', $mainSiteId);
     $controller->set('relatedContents', $Site->getRelatedContents($data['Content']['id']));
     $related = false;
     if ($data['Site']['relate_main_site'] && $data['Content']['main_site_content_id'] && $data['Content']['alias_id'] || $data['Site']['relate_main_site'] && $data['Content']['main_site_content_id'] && $data['Content']['type'] == 'ContentFolder') {
         $related = true;
     }
     $controller->set('related', $related);
     $controller->request->data = $data;
 }
Beispiel #15
0
 /**
  * ブログテンプレートを取得
  *
  * コンボボックスのソースとして利用
  *
  * @return array ブログテンプレート一覧
  * @todo 別のヘルパに移動
  */
 public function getBlogTemplates($siteId = 0)
 {
     $site = BcSite::findById($siteId);
     $theme = $this->BcBaser->siteConfig['theme'];
     if ($site->theme) {
         $theme = $site->theme;
     }
     $templatesPathes = array_merge(App::path('View', 'Blog'), App::path('View'));
     if ($theme) {
         array_unshift($templatesPathes, WWW_ROOT . 'theme' . DS . $theme . DS);
     }
     $_templates = array();
     foreach ($templatesPathes as $templatePath) {
         $templatePath .= 'Blog' . DS;
         $folder = new Folder($templatePath);
         $files = $folder->read(true, true);
         $foler = null;
         if ($files[0]) {
             if ($_templates) {
                 $_templates = am($_templates, $files[0]);
             } else {
                 $_templates = $files[0];
             }
         }
     }
     $excludes = Configure::read('BcAgent');
     $excludes = array_keys($excludes);
     $excludes[] = 'rss';
     $templates = array();
     foreach ($_templates as $template) {
         if (!in_array($template, $excludes)) {
             $templates[$template] = $template;
         }
     }
     return $templates;
 }
Beispiel #16
0
 /**
  * メールテンプレートを取得
  * 
  * コンボボックスのソースとして利用
  * 
  * @return array メールテンプレート一覧データ
  * @todo 他のヘルパに移動する
  */
 public function getMailTemplates($siteId = 0)
 {
     $site = BcSite::findById($siteId);
     $theme = $this->BcBaser->siteConfig['theme'];
     if ($site->theme) {
         $theme = $site->theme;
     }
     $templatesPathes = array_merge(App::path('View', 'Mail'), App::path('View'));
     if ($theme) {
         array_unshift($templatesPathes, WWW_ROOT . 'theme' . DS . $theme . DS);
     }
     $_templates = array();
     foreach ($templatesPathes as $templatesPath) {
         $templatesPath .= 'Emails' . DS . 'text' . DS;
         $Folder = new Folder($templatesPath);
         $files = $Folder->read(true, true);
         $Folder = null;
         if ($files[1]) {
             if ($_templates) {
                 $_templates = am($_templates, $files[1]);
             } else {
                 $_templates = $files[1];
             }
         }
     }
     $templates = array();
     $ext = Configure::read('BcApp.templateExt');
     $excludes = array('empty', 'installed' . $ext, 'mail_data' . $ext);
     foreach ($_templates as $template) {
         if (!in_array($template, $excludes)) {
             $template = basename($template, $ext);
             $templates[$template] = $template;
         }
     }
     return $templates;
 }
 /**
  * [PUBLIC] ブログアーカイブを表示する
  *
  * @param mixed	blog_post_id / type
  * @param mixed	blog_post_id / ""
  * @return void
  */
 public function archives()
 {
     // パラメーター処理
     $pass = $this->request->params['pass'];
     $type = $year = $month = $day = $id = '';
     $crumbs = $posts = array();
     $single = false;
     $posts = array();
     if ($pass[0] == 'category') {
         $type = 'category';
     } elseif ($pass[0] == 'author') {
         $type = 'author';
     } elseif ($pass[0] == 'tag') {
         $type = 'tag';
     } elseif ($pass[0] == 'date') {
         $type = 'date';
     }
     $crumbs[] = array('name' => $this->request->params['Content']['title'], 'url' => $this->request->params['Content']['url']);
     switch ($type) {
         /* カテゴリ一覧 */
         case 'category':
             $category = $pass[count($pass) - 1];
             if (empty($category)) {
                 //$this->notFound();
             }
             // ナビゲーションを設定
             $categoryId = $this->BlogCategory->field('id', array('BlogCategory.blog_content_id' => $this->contentId, 'BlogCategory.name' => urlencode($category)));
             if (!$categoryId) {
                 $this->notFound();
             }
             // 記事を取得
             $posts = $this->_getBlogPosts(array('conditions' => array('category' => urlencode($category))));
             $blogCategories = $this->BlogCategory->getPath($categoryId, array('name', 'title'));
             if (count($blogCategories) > 1) {
                 foreach ($blogCategories as $key => $blogCategory) {
                     if ($key < count($blogCategories) - 1) {
                         $crumbs[] = array('name' => $blogCategory['BlogCategory']['title'], 'url' => $this->request->params['Content']['url'] . '/archives/category/' . $blogCategory['BlogCategory']['name']);
                     }
                 }
             }
             $this->pageTitle = $blogCategories[count($blogCategories) - 1]['BlogCategory']['title'];
             $template = $this->blogContent['BlogContent']['template'] . DS . 'archives';
             $this->set('blogArchiveType', $type);
             break;
         case 'author':
             $author = h($pass[count($pass) - 1]);
             $posts = $this->_getBlogPosts(array('conditions' => array('author' => $author)));
             $data = $this->BlogPost->User->find('first', array('fields' => array('real_name_1', 'real_name_2', 'nickname'), 'conditions' => array('User.name' => $author)));
             App::uses('BcBaserHelper', 'View/Helper');
             $BcBaser = new BcBaserHelper(new View());
             $userName = $BcBaser->getUserName($data);
             $this->pageTitle = urldecode($userName);
             $template = $this->blogContent['BlogContent']['template'] . DS . 'archives';
             $this->set('blogArchiveType', $type);
             break;
             /* タグ別記事一覧 */
         /* タグ別記事一覧 */
         case 'tag':
             $tag = h($pass[count($pass) - 1]);
             if (empty($this->blogContent['BlogContent']['tag_use']) || empty($tag)) {
                 $this->notFound();
             }
             $posts = $this->_getBlogPosts(array('conditions' => array('tag' => $tag)));
             $this->pageTitle = urldecode($tag);
             $template = $this->blogContent['BlogContent']['template'] . DS . 'archives';
             $this->set('blogArchiveType', $type);
             break;
             /* 月別アーカイブ一覧 */
         /* 月別アーカイブ一覧 */
         case 'date':
             $year = h($pass[1]);
             $month = h(@$pass[2]);
             $day = h(@$pass[3]);
             if (!$year && !$month && !$day) {
                 $this->notFound();
             }
             $posts = $this->_getBlogPosts(array('conditions' => array('year' => $year, 'month' => $month, 'day' => $day)));
             $this->pageTitle = $year . '年';
             if ($month) {
                 $this->pageTitle .= $month . '月';
             }
             if ($day) {
                 $this->pageTitle .= $day . '日';
             }
             $template = $this->blogContent['BlogContent']['template'] . DS . 'archives';
             if ($day) {
                 $this->set('blogArchiveType', 'daily');
             } elseif ($month) {
                 $this->set('blogArchiveType', 'monthly');
             } else {
                 $this->set('blogArchiveType', 'yearly');
             }
             break;
             /* 単ページ */
         /* 単ページ */
         default:
             // プレビュー
             if ($this->BcContents->preview && !empty($this->request->data['BlogPost'])) {
                 $post = $this->BlogPost->createPreviewData($this->request->data);
             } else {
                 if (!empty($pass[0])) {
                     $id = $pass[0];
                 } else {
                     $this->notFound();
                 }
                 // コメント送信
                 if (isset($this->request->data['BlogComment'])) {
                     $this->add_comment($id);
                 }
                 $post = $this->_getBlogPosts(array('preview' => (bool) $this->BcContents->preview, 'conditions' => array('id' => $id)));
                 if (!empty($post[0])) {
                     $post = $post[0];
                 } else {
                     $this->notFound();
                 }
                 // 一覧系のページの場合、時限公開の記事が存在し、キャッシュがあると反映できないが、
                 // 詳細ページの場合は、記事の終了期間の段階でキャッシュが切れる前提となる為、キャッシュを利用する
                 // プレビューでは利用しない事。
                 // コメント送信時、キャッシュはクリアされるが、モバイルの場合、このメソッドに対してデータを送信する為、
                 // キャッシュがあるとデータが処理されないので、キャッシュは全く作らない設定とする
                 if (BcSite::findCurrent()->device != 'mobile') {
                     $this->BcContents->useViewCache = true;
                 }
             }
             if (BcUtil::isAdminUser()) {
                 $this->set('editLink', array('admin' => true, 'plugin' => 'blog', 'controller' => 'blog_posts', 'action' => 'edit', $post['BlogPost']['blog_content_id'], $post['BlogPost']['id']));
             }
             // ナビゲーションを設定
             if (!empty($post['BlogPost']['blog_category_id'])) {
                 $blogCategories = $this->BlogCategory->getPath($post['BlogPost']['blog_category_id'], array('name', 'title'));
                 if ($blogCategories) {
                     foreach ($blogCategories as $blogCategory) {
                         $crumbs[] = array('name' => $blogCategory['BlogCategory']['title'], 'url' => $this->request->params['Content']['url'] . '/archives/category/' . $blogCategory['BlogCategory']['name']);
                     }
                 }
             }
             $this->pageTitle = $post['BlogPost']['name'];
             $single = true;
             $template = $this->blogContent['BlogContent']['template'] . DS . 'single';
             if ($this->BcContents->preview) {
                 $this->blogContent['BlogContent']['comment_use'] = false;
             }
             $this->set('post', $post);
     }
     // 表示設定
     $this->crumbs = array_merge($this->crumbs, $crumbs);
     $this->set('single', $single);
     $this->set('posts', $posts);
     $this->set('year', $year);
     $this->set('month', $month);
     $this->render($template);
 }
 /**
  * データメンテナンス
  *
  * @param string $mode
  * @return void
  */
 public function admin_maintenance($mode = '')
 {
     switch ($mode) {
         case 'backup':
             set_time_limit(0);
             $this->_backupDb();
             break;
         case 'restore':
             set_time_limit(0);
             if (!$this->request->data) {
                 $this->notFound();
             }
             $messages = array();
             if ($this->_restoreDb($this->request->data)) {
                 $messages[] = 'データの復元が完了しました。';
                 $error = false;
             } else {
                 $messages[] = 'データの復元に失敗しました。ログの確認を行なって下さい。';
                 $error = true;
             }
             // Pageモデルがレストア処理でAppModelで初期化されClassRegistryにセットされている為
             ClassRegistry::flush();
             BcSite::flash();
             if (!$error && !$this->Page->createAllPageTemplate()) {
                 $messages[] = 'ページテンプレートの生成に失敗しました。<br />表示できないページはページ管理より更新処理を行ってください。';
             }
             if ($messages) {
                 $this->setMessage(implode('<br />', $messages), $error);
             }
             clearAllCache();
             $this->redirect(array('action' => 'maintenance'));
             break;
     }
     $this->pageTitle = 'データメンテナンス';
     $this->help = 'tools_maintenance';
 }
 /**
  * Reverse route
  *
  * @param array $url Array of parameters to convert to a string.
  * @return mixed either false or a string URL.
  */
 public function match($url)
 {
     // フロント以外のURLの場合にマッチしない
     if (!empty($url['admin'])) {
         return false;
     }
     // プラグイン確定
     if (empty($url['plugin'])) {
         $plugin = 'Core';
     } else {
         $plugin = Inflector::camelize($url['plugin']);
     }
     // アクション確定
     if (!empty($url['action'])) {
         $action = $url['action'];
     } else {
         $action = 'index';
     }
     $params = $url;
     unset($params['plugin']);
     unset($params['controller']);
     unset($params['action']);
     unset($params['entityId']);
     // コンテンツタイプ確定、できなければスルー
     $type = $this->_getContentTypeByParams($url);
     if ($type) {
         unset($params['action']);
     } else {
         $type = $this->_getContentTypeByParams($url, false);
     }
     if (!$type) {
         return false;
     }
     // エンティティID確定
     $entityId = $contentId = null;
     if (isset($url['entityId'])) {
         $entityId = $url['entityId'];
     } else {
         $request = Router::getRequest(true);
         if (!empty($request->params['entityId'])) {
             $entityId = $request->params['entityId'];
         }
         if (!empty($request->params['Content']['alias_id'])) {
             $contentId = $request->params['Content']['id'];
         }
     }
     // コンテンツ確定、できなければスルー
     if ($type == 'Page') {
         $pass = [];
         foreach ($params as $key => $param) {
             if (!is_string($key)) {
                 $pass[] = $param;
                 unset($params[$key]);
             }
         }
         $strUrl = '/' . implode('/', $pass);
     } else {
         $Content = ClassRegistry::init('Content');
         if ($contentId) {
             $conditions = ['Content.id' => $contentId];
         } else {
             $conditions = ['Content.plugin' => $plugin, 'Content.type' => $type, 'Content.entity_id' => $entityId];
         }
         $strUrl = $Content->field('url', $conditions);
     }
     if (!$strUrl) {
         return false;
     }
     // URL生成
     $site = BcSite::findByUrl($strUrl);
     if ($site && $site->useSubDomain) {
         $strUrl = preg_replace('/^\\/' . preg_quote($site->alias, '/') . '\\//', '/', $strUrl);
     }
     $pass = [];
     $named = [];
     $setting = Configure::read('BcContents.items.' . $plugin . '.' . $type);
     if (!$params) {
         if (empty($setting['omitViewAction']) && $setting['routes']['view']['action'] != $action) {
             $strUrl .= '/' . $action;
         }
     } else {
         if (empty($setting['omitViewAction'])) {
             $strUrl .= '/' . $action;
         }
         foreach ($params as $key => $param) {
             if (!is_numeric($key)) {
                 if ($key == 'page' && !$param) {
                     $param = 1;
                 }
                 if (!is_array($param)) {
                     $named[] = $key . ':' . $param;
                 }
             } else {
                 $pass[] = $param;
             }
         }
     }
     if ($pass) {
         $strUrl .= '/' . implode('/', $pass);
     }
     if ($named) {
         $strUrl .= '/' . implode('/', $named);
     }
     return $strUrl;
 }
Beispiel #20
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);
         }
     }
 }
Beispiel #21
0
/**
 * URLにセッションIDを付加する
 * 既に付加されている場合は重複しない
 * 
 * @param mixed $url
 * @return mixed
 */
function addSessionId($url, $force = false)
{
    if (BcUtil::isAdminSystem()) {
        return $url;
    }
    $sessionId = session_id();
    if (!$sessionId) {
        return $url;
    }
    // use_trans_sid が有効になっている場合、2重で付加されてしまう
    $site = BcSite::findCurrent();
    if ($site && $site->device == 'mobile' && Configure::read('BcAgent.mobile.sessionId') && (!ini_get('session.use_trans_sid') || $force)) {
        if (is_array($url)) {
            $url["?"][session_name()] = $sessionId;
        } else {
            if (strpos($url, '?') !== false) {
                $args = array();
                $_url = explode('?', $url);
                if (!empty($_url[1])) {
                    if (strpos($_url[1], '&') !== false) {
                        $aryUrl = explode('&', $_url[1]);
                        foreach ($aryUrl as $pass) {
                            if (strpos($pass, '=') !== false) {
                                list($key, $value) = explode('=', $pass);
                                $args[$key] = $value;
                            }
                        }
                    } else {
                        if (strpos($_url[1], '=') !== false) {
                            list($key, $value) = explode('=', $_url[1]);
                            $args[$key] = $value;
                        }
                    }
                }
                $args[session_name()] = $sessionId;
                $pass = '';
                foreach ($args as $key => $value) {
                    if ($pass) {
                        $pass .= '&';
                    }
                    $pass .= $key . '=' . $value;
                }
                $url = $_url[0] . '?' . $pass;
            } else {
                $url .= '?' . session_name() . '=' . $sessionId;
            }
        }
    }
    return $url;
}
 /**
  * アップデートを実行する
  *
  * アップデートスクリプトを読み込む為、
  * よく使われるような変数名はダブらないように
  * アンダースコアを二つつける
  *
  * @param string $targetVersion
  * @param string $sourceVersion
  * @param string $plugin
  * @return boolean
  */
 protected function _update($plugin = '')
 {
     $targetVersion = $this->getBaserVersion($plugin);
     $sourceVersion = $this->getSiteVersion($plugin);
     $path = $this->_getUpdateFolder($plugin);
     $updaters = $this->_getUpdaters($plugin);
     if (!$plugin) {
         $name = 'baserCMSコア';
     } else {
         $name = $this->Plugin->field('title', array('name' => $plugin)) . 'プラグイン';
     }
     $this->setUpdateLog($name . ' ' . $targetVersion . ' へのアップデートを開始します。');
     if ($updaters) {
         asort($updaters);
         foreach ($updaters as $version => $updateVerPoint) {
             $this->setUpdateLog('アップデートプログラム ' . $version . ' を実行します。');
             ClassRegistry::flush();
             BcSite::flash();
             $this->_execScript($plugin, $version);
         }
     }
     ClassRegistry::flush();
     BcSite::flash();
     if (!isset($updaters['test'])) {
         if (!$plugin) {
             /* サイト基本設定にバージョンを保存 */
             $SiteConfigClass = ClassRegistry::init('SiteConfig');
             $SiteConfigClass->cacheQueries = false;
             $data['SiteConfig']['version'] = $targetVersion;
             $result = $SiteConfigClass->saveKeyValue($data);
         } else {
             // 1.6.7 では plugins テーブルの構造が変わったので、find でデータが取得できないのでスキップする
             // DB の再接続を行えば取得できるかも
             if ($targetVersion == '1.6.7') {
                 $result = true;
             } else {
                 $data = $this->Plugin->find('first', array('conditions' => array('name' => $plugin)));
                 $data['Plugin']['version'] = $targetVersion;
                 $result = $this->Plugin->save($data);
             }
         }
     } else {
         $result = true;
     }
     $this->BcManager->deployAdminAssets();
     $this->setUpdateLog($name . ' ' . $targetVersion . ' へのアップデートが完了しました。');
     return $result;
 }
Beispiel #23
0
/**
 * baserCMS :  Based Website Development Project <http://basercms.net>
 * Copyright (c) baserCMS Users Community <http://basercms.net/community/>
 *
 * @copyright		Copyright (c) baserCMS Users Community
 * @link			http://basercms.net baserCMS Project
 * @package			Feed.View
 * @since			baserCMS v 0.1.0
 * @license			http://basercms.net/license/index.html
 */
/**
 * [PUBLISH] フィード読み込みAJAX
 */
header("Content-type: text/javascript charset=UTF-8");
$this->BcBaser->cacheHeader(MONTH, 'js');
$site = BcSite::findCurrent();
?>
document.write('<div id="feeds<?php 
echo $id;
?>
"><?php 
echo $this->html->image('admin/ajax-loader.gif', array('alt' => 'loading now...', 'style' => 'display:block;margin:auto'));
?>
</div>');

// 読込み成功時の処理
var successCallback = function (response)
{
	if(response == 'false'){
		$("#feeds<?php 
echo $id;
Beispiel #24
0
 /**
  * set up
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Content = ClassRegistry::init('Content');
     BcSite::flash();
 }
Beispiel #25
0
 public static function flash()
 {
     self::$_sites = null;
 }