/**
  * [ADMIN] 設定編集
  */
 public function admin_form()
 {
     $this->pageTitle = 'テーマ設定';
     $this->help = 'theme_configs_form';
     if (empty($this->request->data)) {
         $this->request->data = array('ThemeConfig' => $this->ThemeConfig->findExpanded());
     } else {
         $this->ThemeConfig->set($this->request->data);
         if (!$this->ThemeConfig->validates()) {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         } else {
             $this->ThemeConfig->updateColorConfig($this->request->data);
             $data = $this->ThemeConfig->saveImage($this->request->data);
             $data = $this->ThemeConfig->deleteImage($data);
             foreach ($data['ThemeConfig'] as $key => $value) {
                 if (preg_match('/main_image_[0-9]_delete/', $key)) {
                     unset($data['ThemeConfig'][$key]);
                 }
             }
             if ($this->ThemeConfig->saveKeyValue($data)) {
                 clearViewCache();
                 $this->setMessage('システム設定を保存しました。');
                 $this->redirect(array('action' => 'form'));
             } else {
                 $this->setMessage('保存中にエラーが発生しました。', true);
             }
         }
     }
 }
 /**
  * コンテンツを更新する
  *
  * @return void
  */
 public function admin_edit($entityId)
 {
     $this->pageTitle = 'リンク編集';
     if (!$this->request->data) {
         $this->request->data = $this->ContentLink->read(null, $entityId);
     } else {
         if ($this->ContentLink->save($this->request->data)) {
             clearViewCache();
             $this->setMessage("リンク「{$this->request->data['Content']['title']}」を更新しました。", false, true);
             $this->redirect(array('plugin' => '', 'controller' => 'content_links', 'action' => 'edit', $entityId));
         } else {
             $this->setMessage('保存中にエラーが発生しました。入力内容を確認してください。', true, true);
         }
     }
     $this->set('publishLink', $this->request->data['Content']['url']);
 }
 /**
  * コンテンツを更新する
  *
  * @return void
  */
 public function admin_edit($entityId)
 {
     $this->pageTitle = 'フォルダ編集';
     if (!$this->request->data) {
         $this->request->data = $this->ContentFolder->read(null, $entityId);
     } else {
         if ($this->ContentFolder->save($this->request->data)) {
             clearViewCache();
             $this->setMessage("フォルダ「{$this->request->data['Content']['title']}」を更新しました。", false, true);
             $this->redirect(array('plugin' => '', 'controller' => 'content_folders', 'action' => 'edit', $entityId));
         } else {
             $this->setMessage('保存中にエラーが発生しました。入力内容を確認してください。', true, true);
         }
     }
     $this->set('folderTemplateList', $this->ContentFolder->getFolderTemplateList($this->request->data['Content']['id'], $this->siteConfigs['theme']));
     $this->set('pageTemplateList', $this->Page->getPageTemplateList($this->request->data['Content']['id'], $this->siteConfigs['theme']));
     $this->set('publishLink', $this->request->data['Content']['url']);
 }
Example #4
0
 /**
  * 並び替えを更新する [AJAX]
  *
  * @return bool
  */
 public function admin_ajax_update_sort()
 {
     if ($this->request->data) {
         if ($this->Plugin->changePriority($this->request->data['Sort']['id'], $this->request->data['Sort']['offset'])) {
             clearViewCache();
             clearDataCache();
             echo true;
         } else {
             $this->ajaxError(500, '一度リロードしてから再実行してみてください。');
         }
     } else {
         $this->ajaxError(500, '無効な処理です。');
     }
     exit;
 }
Example #5
0
 /**
  * 一括非公開
  * 
  * @param array $ids
  * @return boolean
  * @access protected 
  */
 protected function _batch_unpublish($ids)
 {
     if ($ids) {
         foreach ($ids as $id) {
             $this->_changeStatus($id, false);
         }
     }
     clearViewCache();
     return true;
 }
Example #6
0
 /**
  * テーマを適用する
  *
  * @param string $theme
  * @return void
  * @access public
  */
 function admin_apply($theme)
 {
     if (!$theme) {
         $this->notFound();
     }
     $siteConfig['SiteConfig']['theme'] = $theme;
     $SiteConfig = ClassRegistry::getObject('SiteConfig');
     $SiteConfig->saveKeyValue($siteConfig);
     clearViewCache();
     if (!$this->Page->createAllPageTemplate()) {
         $this->Session->setFlash('テーマ変更中にページテンプレートの生成に失敗しました。<br />「pages」フォルダに書き込み権限が付与されていない可能性があります。<br />テーマの適用をやり直すか、表示できないページについてページ管理より更新処理を行ってください。');
     } else {
         $this->Session->setFlash('テーマ「' . $theme . '」を適用しました。');
     }
     $this->redirect(array('action' => 'index'));
 }
 public function admin_file_upload()
 {
     clearViewCache();
     $hasError = false;
     if (!$_FILES) {
         $hasError = 'ファイルがアップロードされていません';
     }
     foreach ($_FILES as $name => $fileData) {
         if (!$name) {
             $hasError = 'アップロードに失敗しました';
         } else {
             if ($fileData["error"] == UPLOAD_ERR_INI_SIZE) {
                 $hasError = 'ファイル容量が大きすぎます';
             }
             // ファイル名チェック
             if (!$this->checkFileName($fileData["name"])) {
                 $hasError = "ファイル名は半角英数記号でアップロードしてください";
             }
             if ($fileData["error"] == UPLOAD_ERR_PARTIAL) {
                 $hasError = "ファイルが正しくアップロードされませんでした";
             }
         }
         if ($hasError) {
             break;
         }
     }
     // 何かしらエラー
     if ($hasError) {
         $result = array('error' => $hasError, 'data' => $hasError);
     } else {
         // 保存
         $uploaddir = BurgerEditorHelper::$otherFileBaseDir;
         foreach ($_FILES as $name => $fileData) {
             $filename = $fileData["name"];
             // 重複チェック
             if (file_exists($uploaddir . $filename)) {
                 $fileNum = 1;
                 while (1) {
                     $renameFile = $this->getFileNameNoExtension($filename) . '_' . $fileNum . '.' . $this->getExtension($filename);
                     if (!file_exists($uploaddir . $renameFile)) {
                         break;
                     }
                     $fileNum++;
                 }
                 $filename = $renameFile;
             }
             move_uploaded_file($fileData["tmp_name"], $uploaddir . $filename);
         }
         // ファイル読み直し
         BurgerEditorHelper::setSelfValue();
         $fileList = array();
         foreach (BurgerEditorHelper::$otherFileList as $filePath) {
             $fileList[] = array('name' => $this->mb_basename($filePath), 'url' => h(BurgerEditorHelper::$otherFileBaseURL . $this->mb_basename($filePath)));
         }
         $result = array('error' => $hasError, 'data' => $fileList);
     }
     Configure::write('debug', 0);
     $this->RequestHandler->setContent('json');
     $this->RequestHandler->respondAs('application/json; charset=UTF-8');
     echo json_encode($result);
     exit;
 }
 /**
  * [ADMIN] 削除処理
  *
  * @param int ID
  * @return void
  * @access public
  */
 function admin_delete($id = null)
 {
     /* 除外処理 */
     if (!$id) {
         $this->Session->setFlash('無効なIDです。');
         $this->redirect(array('action' => 'admin_index'));
     }
     // メッセージ用にデータを取得
     $post = $this->GlobalMenu->read(null, $id);
     /* 削除処理 */
     if ($this->GlobalMenu->del($id)) {
         clearViewCache();
         $message = 'グローバルメニュー「' . $post['GlobalMenu']['name'] . '」 を削除しました。';
         $this->Session->setFlash($message);
         $this->GlobalMenu->saveDbLog($message);
     } else {
         $this->Session->setFlash('データベース処理中にエラーが発生しました。');
     }
     $this->redirect(array('action' => 'index'));
 }
Example #9
0
 /**
  * [ADMIN] サイト基本設定
  */
 public function admin_form()
 {
     $writableInstall = is_writable(APP . 'Config' . DS . 'install.php');
     if (empty($this->request->data)) {
         $this->request->data = $this->_getSiteConfigData();
     } else {
         $this->SiteConfig->set($this->request->data);
         if (!$this->SiteConfig->validates()) {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         } else {
             $mode = 0;
             $smartUrl = false;
             $siteUrl = $sslUrl = '';
             if (isset($this->request->data['SiteConfig']['mode'])) {
                 $mode = $this->request->data['SiteConfig']['mode'];
                 if ($mode > 0) {
                     clearAllCache();
                 }
             }
             if (isset($this->request->data['SiteConfig']['smart_url'])) {
                 $smartUrl = $this->request->data['SiteConfig']['smart_url'];
             }
             if (isset($this->request->data['SiteConfig']['ssl_url'])) {
                 $siteUrl = $this->request->data['SiteConfig']['site_url'];
                 if (!preg_match('/\\/$/', $siteUrl)) {
                     $siteUrl .= '/';
                 }
             }
             if (isset($this->request->data['SiteConfig']['ssl_url'])) {
                 $sslUrl = $this->request->data['SiteConfig']['ssl_url'];
                 if ($sslUrl && !preg_match('/\\/$/', $sslUrl)) {
                     $sslUrl .= '/';
                 }
             }
             $adminSsl = @$this->request->data['SiteConfig']['admin_ssl'];
             $mobile = @$this->request->data['SiteConfig']['mobile'];
             $smartphone = @$this->request->data['SiteConfig']['smartphone'];
             unset($this->request->data['SiteConfig']['id']);
             unset($this->request->data['SiteConfig']['mode']);
             unset($this->request->data['SiteConfig']['smart_url']);
             unset($this->request->data['SiteConfig']['site_url']);
             unset($this->request->data['SiteConfig']['ssl_url']);
             unset($this->request->data['SiteConfig']['admin_ssl']);
             unset($this->request->data['SiteConfig']['mobile']);
             unset($this->request->data['SiteConfig']['smartphone']);
             // DBに保存
             if ($this->SiteConfig->saveKeyValue($this->request->data)) {
                 $this->setMessage('システム設定を保存しました。');
                 // 環境設定を保存
                 if ($writableInstall) {
                     $this->BcManager->setInstallSetting('debug', $mode);
                     $this->BcManager->setInstallSetting('BcEnv.siteUrl', "'" . $siteUrl . "'");
                     $this->BcManager->setInstallSetting('BcEnv.sslUrl', "'" . $sslUrl . "'");
                     $this->BcManager->setInstallSetting('BcApp.adminSsl', $adminSsl ? 'true' : 'false');
                     $this->BcManager->setInstallSetting('BcApp.mobile', $mobile ? 'true' : 'false');
                     $this->BcManager->setInstallSetting('BcApp.smartphone', $smartphone ? 'true' : 'false');
                 }
                 if ($this->BcManager->smartUrl() != $smartUrl) {
                     $this->BcManager->setSmartUrl($smartUrl);
                 }
                 // キャッシュをクリア
                 if ($this->request->data['SiteConfig']['maintenance'] || $this->siteConfigs['google_analytics_id'] != $this->request->data['SiteConfig']['google_analytics_id'] || !$smartphone && Configure::read('BcApp.smartphone') || !$mobile && Configure::read('BcApp.mobile')) {
                     clearViewCache();
                 }
                 // リダイレクト
                 if ($this->BcManager->smartUrl() != $smartUrl) {
                     $adminPrefix = Configure::read('Routing.prefixes.0');
                     if ($smartUrl) {
                         $redirectUrl = $this->BcManager->getRewriteBase('/' . $adminPrefix . '/site_configs/form');
                     } else {
                         $redirectUrl = $this->BcManager->getRewriteBase('/index.php/' . $adminPrefix . '/site_configs/form');
                     }
                     header('Location: ' . FULL_BASE_URL . $redirectUrl);
                     exit;
                 } else {
                     $this->redirect(array('action' => 'form'));
                 }
             }
         }
     }
     /* スマートURL関連 */
     $apachegetmodules = function_exists('apache_get_modules');
     if ($apachegetmodules) {
         $rewriteInstalled = in_array('mod_rewrite', apache_get_modules());
     } else {
         $rewriteInstalled = -1;
     }
     if (BC_DEPLOY_PATTERN != 3) {
         $htaccess1 = ROOT . DS . '.htaccess';
     } else {
         $htaccess1 = docRoot() . DS . '.htaccess';
     }
     $htaccess2 = WWW_ROOT . '.htaccess';
     $writableHtaccess = is_writable($htaccess1);
     if ($htaccess1 != $htaccess2) {
         $writableHtaccess2 = is_writable($htaccess2);
     } else {
         $writableHtaccess2 = true;
     }
     $baseUrl = str_replace('/index.php', '', BC_BASE_URL);
     if ($writableInstall && $writableHtaccess && $writableHtaccess2 && $rewriteInstalled !== false) {
         $smartUrlChangeable = true;
     } else {
         $smartUrlChangeable = false;
     }
     $UserGroup = ClassRegistry::init('UserGroup');
     $userGroups = $UserGroup->find('list', array('fields' => array('UserGroup.id', 'UserGroup.title')));
     $disableSettingSmartUrl = array();
     $disableSettingInstallSetting = array();
     if (!$smartUrlChangeable) {
         $disableSettingSmartUrl = array('disabled' => 'disabled');
     }
     if (!$writableInstall) {
         $disableSettingInstallSetting = array('disabled' => 'disabled');
     }
     $this->set(compact('baseUrl', 'userGroups', 'rewriteInstalled', 'writableInstall', 'writableHtaccess', 'writableHtaccess2', 'smartUrlChangeable', 'disableSettingSmartUrl', 'disableSettingInstallSetting'));
     $this->subMenuElements = array('site_configs');
     $this->pageTitle = 'サイト基本設定';
     $this->help = 'site_configs_form';
 }
 /**
  * [ADMIN] 削除処理 (ajax)
  *
  * @param int $uploaderCategoryId
  * @param int $id
  * @return void
  */
 public function admin_ajax_delete($id = null)
 {
     $this->_checkSubmitToken();
     if (!$id) {
         $this->ajaxError(500, '無効な処理です。');
     }
     // 削除実行
     if ($this->_del($id)) {
         clearViewCache();
         exit(true);
     } else {
         exit;
     }
 }
Example #11
0
 /**
  * [ADMIN] 削除処理
  *
  * @param int ID
  * @return void
  * @access public
  */
 public function admin_delete($id = null)
 {
     /* 除外処理 */
     if (!$id) {
         $this->setMessage('無効なIDです。', true);
         $this->redirect(array('action' => 'index'));
     }
     // メッセージ用にデータを取得
     $post = $this->Menu->read(null, $id);
     /* 削除処理 */
     if ($this->Menu->delete($id)) {
         clearViewCache();
         $this->setMessage('メニュー「' . $post['Menu']['name'] . '」 を削除しました。', false, true);
     } else {
         $this->setMessage('データベース処理中にエラーが発生しました。', true);
     }
     $this->redirect(array('action' => 'index'));
 }
Example #12
0
 /**
  * 並び替えを更新する [AJAX]
  *
  * @access public
  * @return boolean
  */
 function admin_update_sort()
 {
     if ($this->data) {
         $this->setViewConditions('Page', array('action' => 'admin_index'));
         $conditions = $this->_createAdminIndexConditions($this->data);
         $this->Page->fileSave = false;
         $this->Page->contentSaving = false;
         if ($this->Page->changeSort($this->data['Sort']['id'], $this->data['Sort']['offset'], $conditions)) {
             clearViewCache();
             clearDataCache();
             echo true;
         } else {
             echo false;
         }
     } else {
         echo false;
     }
     exit;
 }
Example #13
0
 /**
  * [ADMIN] サイト基本設定
  *
  * @return void
  * @access public
  */
 function admin_form()
 {
     if (empty($this->data)) {
         $this->data = $this->_getSiteConfigData();
     } else {
         $this->SiteConfig->set($this->data);
         if (!$this->SiteConfig->validates()) {
             $this->Session->setFlash('入力エラーです。内容を修正してください。');
         } else {
             $mode = 0;
             $smartUrl = false;
             $siteUrl = $sslUrl = $adminSslOn = '';
             if (isset($this->data['SiteConfig']['mode'])) {
                 $mode = $this->data['SiteConfig']['mode'];
             }
             if (isset($this->data['SiteConfig']['smart_url'])) {
                 $smartUrl = $this->data['SiteConfig']['smart_url'];
             }
             if (isset($this->data['SiteConfig']['ssl_url'])) {
                 $siteUrl = $this->data['SiteConfig']['site_url'];
                 if (!preg_match('/\\/$/', $siteUrl)) {
                     $siteUrl .= '/';
                 }
             }
             if (isset($this->data['SiteConfig']['ssl_url'])) {
                 $sslUrl = $this->data['SiteConfig']['ssl_url'];
                 if ($sslUrl && !preg_match('/\\/$/', $sslUrl)) {
                     $sslUrl .= '/';
                 }
             }
             $adminSslOn = $this->data['SiteConfig']['admin_ssl_on'];
             $mobile = $this->data['SiteConfig']['mobile'];
             $smartphone = $this->data['SiteConfig']['smartphone'];
             unset($this->data['SiteConfig']['id']);
             unset($this->data['SiteConfig']['mode']);
             unset($this->data['SiteConfig']['smart_url']);
             unset($this->data['SiteConfig']['site_url']);
             unset($this->data['SiteConfig']['ssl_url']);
             unset($this->data['SiteConfig']['admin_ssl_on']);
             unset($this->data['SiteConfig']['mobile']);
             unset($this->data['SiteConfig']['smartphone']);
             // DBに保存
             if ($this->SiteConfig->saveKeyValue($this->data)) {
                 $this->Session->setFlash('システム設定を保存しました。');
                 // 環境設定を保存
                 $this->writeDebug($mode);
                 $this->writeInstallSetting('Baser.siteUrl', "'" . $siteUrl . "'");
                 $this->writeInstallSetting('Baser.sslUrl', "'" . $sslUrl . "'");
                 $this->writeInstallSetting('Baser.adminSslOn', $adminSslOn ? 'true' : 'false');
                 $this->writeInstallSetting('Baser.mobile', $mobile ? 'true' : 'false');
                 $this->writeInstallSetting('Baser.smartphone', $smartphone ? 'true' : 'false');
                 if ($this->readSmartUrl() != $smartUrl) {
                     $this->writeSmartUrl($smartUrl);
                 }
                 // キャッシュをクリア
                 if ($this->siteConfigs['maintenance'] || $this->siteConfigs['theme'] != $this->data['SiteConfig']['theme'] || $this->siteConfigs['google_analytics_id'] != $this->data['SiteConfig']['google_analytics_id']) {
                     clearViewCache();
                 }
                 // ページテンプレートの生成
                 if ($this->siteConfigs['theme'] != $this->data['SiteConfig']['theme']) {
                     if (!$this->Page->createAllPageTemplate()) {
                         $this->Session->setFlash('テーマ変更中にページテンプレートの生成に失敗しました。<br />' . '表示できないページはページ管理より更新処理を行ってください。');
                     }
                 }
                 // リダイレクト
                 if ($this->readSmartUrl() != $smartUrl) {
                     if ($smartUrl) {
                         $redirectUrl = $this->getRewriteBase('/admin/site_configs/form');
                     } else {
                         $redirectUrl = $this->getRewriteBase('/index.php/admin/site_configs/form');
                     }
                     header('Location: ' . FULL_BASE_URL . $redirectUrl);
                     exit;
                 } else {
                     $this->redirect(array('action' => 'form'));
                 }
             }
         }
     }
     /* スマートURL関連 */
     $apachegetmodules = function_exists('apache_get_modules');
     if ($apachegetmodules) {
         $rewriteInstalled = in_array('mod_rewrite', apache_get_modules());
     } else {
         $rewriteInstalled = -1;
     }
     $writableInstall = is_writable(CONFIGS . 'install.php');
     if (DEPLOY_PATTERN != 3) {
         $htaccess1 = ROOT . DS . '.htaccess';
     } else {
         $htaccess1 = docRoot() . DS . '.htaccess';
     }
     $htaccess2 = WWW_ROOT . '.htaccess';
     $writableHtaccess = is_writable($htaccess1);
     if ($htaccess1 != $htaccess2) {
         $writableHtaccess2 = is_writable($htaccess2);
     } else {
         $writableHtaccess2 = true;
     }
     $baseUrl = str_replace('/index.php', '', baseUrl());
     if ($writableInstall && $writableHtaccess && $writableHtaccess2 && $rewriteInstalled !== false) {
         $smartUrlChangeable = true;
     } else {
         $smartUrlChangeable = false;
     }
     $UserGroup = ClassRegistry::init('UserGroup');
     $userGroups = $UserGroup->find('list', array('fields' => array('UserGroup.id', 'UserGroup.title')));
     $this->set('userGroups', $userGroups);
     $this->set('themes', $this->SiteConfig->getThemes());
     $this->set('rewriteInstalled', $rewriteInstalled);
     $this->set('writableInstall', $writableInstall);
     $this->set('writableHtaccess', $writableHtaccess);
     $this->set('writableHtaccess2', $writableHtaccess2);
     $this->set('baseUrl', $baseUrl);
     $this->set('smartUrlChangeable', $smartUrlChangeable);
     $this->subMenuElements = array('site_configs');
     $this->pageTitle = 'サイト基本設定';
 }
Example #14
0
 /**
  * [ADMIN] 削除処理
  *
  * @param int $blogContentId
  * @param int $id
  * @return void
  * @access public
  */
 function admin_delete($blogContentId, $id = null)
 {
     if (!$blogContentId || !$id) {
         $this->Session->setFlash('無効な処理です。');
         $this->redirect(array('controller' => 'blog_contents', 'action' => 'admin_index'));
     }
     // メッセージ用にデータを取得
     $post = $this->BlogPost->read(null, $id);
     // 削除実行
     if ($this->BlogPost->del($id)) {
         clearViewCache();
         $message = $post['BlogPost']['name'] . ' を削除しました。';
         $this->Session->setFlash($message);
         $this->BlogPost->saveDbLog($message);
     } else {
         $this->Session->setFlash('データベース処理中にエラーが発生しました。');
     }
     $this->redirect(array('action' => 'admin_index', $blogContentId));
 }
 /**
  * 並び替えを更新する [AJAX]
  *
  * @return bool
  */
 public function admin_ajax_update_sort()
 {
     $this->autoRender = false;
     if ($this->request->data) {
         if ($this->Plugin->changePriority($this->request->data['Sort']['id'], $this->request->data['Sort']['offset'])) {
             clearViewCache();
             clearDataCache();
             Configure::write('debug', 0);
             return true;
         } else {
             $this->ajaxError(500, '一度リロードしてから再実行してみてください。');
         }
     } else {
         $this->ajaxError(500, '無効な処理です。');
     }
     return false;
 }
Example #16
0
 /**
  * [ADMIN] 固定ページファイルを登録する
  *
  * @return void
  */
 public function admin_write_page_files()
 {
     $this->_checkSubmitToken();
     if ($this->Page->createAllPageTemplate()) {
         $this->setMessage('固定ページテンプレートの書き出しに成功しました。');
     } else {
         $this->setMessage('固定ページテンプレートの書き出しに失敗しました。<br />表示できないページは固定ページ管理より更新処理を行ってください。', true);
     }
     clearViewCache();
     $this->redirect(array('controller' => 'tools', 'action' => 'index'));
 }
Example #17
0
 /**
  * delete
  *
  * @param mixed $id ページID
  * @param boolean $cascade Set to true to delete records that depend on this record
  * @return boolean True on success
  */
 public function delete($id = null, $cascade = true)
 {
     // メッセージ用にデータを取得
     $page = $this->read(null, $id);
     /* 削除処理 */
     if (parent::delete($id, $cascade)) {
         // ページテンプレートを削除
         $this->delFile($page);
         // 公開状態だった場合、サイトマップのキャッシュを削除
         // 公開期間のチェックは行わず確実に削除
         if ($page['Page']['status']) {
             clearViewCache();
         }
         return true;
     } else {
         return false;
     }
 }
Example #18
0
 protected function _applyTheme($theme)
 {
     $plugins = BcUtil::getCurrentThemesPlugins();
     // テーマ梱包のプラグインをアンインストール
     foreach ($plugins as $plugin) {
         $this->BcManager->uninstallPlugin($plugin);
     }
     $siteConfig['SiteConfig']['theme'] = $theme;
     $this->SiteConfig->saveKeyValue($siteConfig);
     clearViewCache();
     $info = array();
     $themePath = BASER_THEMES . $theme . DS;
     $Folder = new Folder($themePath . 'Plugin');
     $files = $Folder->read(true, true, false);
     if (!empty($files[0])) {
         $info = array_merge($info, array('このテーマは下記のプラグインを同梱しています。'));
         foreach ($files[0] as $file) {
             $info[] = '	・' . $file;
         }
     }
     Configure::write('BcSite.theme', $theme);
     $plugins = BcUtil::getCurrentThemesPlugins();
     App::build(array('Plugin' => array_merge(array(BASER_THEMES . $theme . DS . 'Plugin' . DS), App::path('Plugin'))));
     // テーマ梱包のプラグインをインストール
     foreach ($plugins as $plugin) {
         $this->BcManager->installPlugin($plugin);
     }
     $path = BcUtil::getDefaultDataPath('Core', $theme);
     if (strpos($path, '/theme/' . $theme . '/') !== false) {
         if ($info) {
             $info = array_merge($info, array(''));
         }
         $info = array_merge($info, array('このテーマは初期データを保有しています。', 'Webサイトにテーマに合ったデータを適用するには、初期データ読込を実行してください。'));
     }
     if (!$this->Page->createAllPageTemplate()) {
         $message = array('テーマ変更中にページテンプレートの生成に失敗しました。', '「Pages」フォルダに書き込み権限が付与されていない可能性があります。', '権限設定後、テーマの適用をやり直すか、表示できないページについて固定ページ管理より更新処理を行ってください。');
         if ($info) {
             $message = array_merge($message, array(''), $info);
         }
         $this->setMessage(implode('<br />', $message), true);
     } else {
         $message = array('テーマ「' . $theme . '」を適用しました。');
         if ($info) {
             $message = array_merge($message, array(''), $info);
         }
         $this->setMessage(implode('<br />', $message));
     }
     return true;
 }
Example #19
0
 /**
  * [ADMIN] 固定ページ情報削除
  *
  * @param int $id (page_id)
  * @return void
  * @access public
  */
 function admin_ajax_delete($id = null)
 {
     if (!$id) {
         $this->ajaxError(500, '無効な処理です。');
     }
     $page = $this->Page->read(null, $id);
     if ($this->Page->del($id)) {
         clearViewCache($page['Page']['url']);
         $this->Page->saveDbLog('固定ページ: ' . $page['Page']['name'] . ' を削除しました。');
         echo true;
     }
     exit;
 }
 /**
 * 記事の追加
 *
 * @return	void
 * @access	public
 */
 public function add($blogID = null)
 {
     //除外処理
     if (empty($blogID)) {
         $blogID = $this->request->params['id'];
     }
     if (empty($blogID)) {
         $this->setMessage('無効なIDです。', true);
         $this->redirect(array('action' => 'index'));
     } else {
         $this->set('blogContentID', $blogID);
     }
     //ブログデータ取得
     $blogContentData = $this->BlogContent->find('first', array('conditions' => array('BlogContent.id' => $blogID)));
     $this->set('blogContentData', $blogContentData);
     //セレクトボックスの為に配列化する。
     $categoryOptions = $this->MobilePost->getCategoryOptions($blogID);
     $this->set('categoryOptions', $categoryOptions);
     //タグデータを取得する。
     $tagOptions = $this->MobilePost->getTagOptions();
     $this->set('tagOptions', $tagOptions);
     //モバイルポスト設定を取得する。
     $mobilePostConfig = $this->MobilePostConfig->find('first', array('conditions' => array('blog_content_id' => $blogID)));
     $this->set('mobilePostConfig', $mobilePostConfig);
     /* 投稿ボタン押下後 */
     if (!empty($this->request->data)) {
         /* ブログ保存の為の整形 */
         // 改行コードのタグ化
         if (!empty($this->request->data['BlogPost']['content'])) {
             $this->request->data['BlogPost']['content'] = nl2br($this->request->data['BlogPost']['content']);
         } else {
             $this->request->data['BlogPost']['content'] = '';
             //変数定義だけしないとエラーになる?
         }
         if (!empty($this->request->data['BlogPost']['detail'])) {
             $this->request->data['BlogPost']['detail'] = nl2br($this->request->data['BlogPost']['detail']);
         }
         //noを生成
         $this->request->data['BlogPost']['no'] = $this->BlogPost->getMax('no', array('BlogPost.blog_content_id' => $blogID)) + 1;
         //公開期日
         if (!empty($this->request->data['BlogPost']['publish_begin_date'])) {
             $this->request->data['BlogPost']['publish_begin'] = $this->request->data['BlogPost']['publish_begin_date'] . " " . $this->request->data['BlogPost']['publish_begin_time'];
         } else {
             $this->request->data['BlogPost']['publish_begin'] = null;
         }
         if (!empty($this->request->data['BlogPost']['publish_end_date'])) {
             $this->request->data['BlogPost']['publish_end'] = $this->request->data['BlogPost']['publish_end_date'] . " " . $this->request->data['BlogPost']['publish_end_time'];
         } else {
             $this->request->data['BlogPost']['publish_end'] = null;
         }
         //投稿日
         $this->request->data['BlogPost']['posts_date'] = $this->request->data['BlogPost']['posts_date_date'] . " " . $this->request->data['BlogPost']['posts_date_time'];
         //携帯投稿専用のデータ整形と画像の保存
         $mobileData = array();
         $mobileData = $this->MobilePost->saveMobilePostImg($this->request->data);
         //画像アップが本文の前か後かを確認する。
         if (!empty($mobileData['MobilePost']['file'])) {
             //画像URL整形
             $webrootPath = Router::fullbaseUrl() . $this->request->webroot;
             $saveURL = $webrootPath . '/files/mobile_post/' . $mobileData['MobilePost']['file'];
             $saveThumURL = $webrootPath . '/files/mobile_post/thum_' . $mobileData['MobilePost']['file'];
             $imgTag = "<div class='mobilePostImage'><a href='{$saveURL}' rel='colorbox' title=''><img src='{$saveThumURL}' /></a></div>";
             //画像の挿入箇所確認と挿入実行
             switch ($mobileData['MobilePost']['file_position']) {
                 case 0:
                     $this->request->data['BlogPost']['detail'] = $imgTag . $this->request->data['BlogPost']['detail'];
                     break;
                 case 1:
                     $this->request->data['BlogPost']['detail'] = $this->request->data['BlogPost']['detail'] . $imgTag;
                     break;
             }
         }
         //保存処理実行
         $this->BlogPost->create();
         if ($this->BlogPost->save($this->request->data, false)) {
             clearViewCache();
             //Viewキャッシュが残ってしまう。
             //直前に保存したレコードのIDのを取得
             $mobileData['MobilePost']['blog_post_id'] = $this->BlogPost->getLastInsertId();
             //保存実行
             if ($this->MobilePost->save($mobileData)) {
                 $this->setMessage('記事を追加しました。', true);
                 $this->redirect(array('action' => 'post_list', $mobileData['MobilePost']['blog_content_id']));
             } else {
                 $this->setMessage('MobilePostの保存処理に失敗しました。', true);
             }
         } else {
             $this->setMessage('保存処理に失敗しました。', true);
         }
     }
     //表示設定
     $this->pageTitle = $blogContentData['BlogContent']['title'] . 'の新規記事作成';
     $this->set('userID', $this->BcAuth->user('id'));
     $this->render('form');
 }
Example #21
0
 /**
  * テーマファイル編集
  *
  * @return void
  * @access public
  */
 public function admin_edit()
 {
     $args = $this->_parseArgs(func_get_args());
     extract($args);
     if (!isset($this->_tempalteTypes[$type])) {
         $this->notFound();
     }
     $filename = urldecode(basename($path));
     if (!$this->request->data) {
         $file = new File($fullpath);
         $pathinfo = pathinfo($fullpath);
         $this->request->data['ThemeFile']['name'] = urldecode(basename($file->name, '.' . $pathinfo['extension']));
         $this->request->data['ThemeFile']['type'] = $this->_getFileType(urldecode(basename($file->name)));
         $this->request->data['ThemeFile']['ext'] = $pathinfo['extension'];
         if ($this->request->data['ThemeFile']['type'] == 'text') {
             $this->request->data['ThemeFile']['contents'] = $file->read();
         }
     } else {
         $this->ThemeFile->set($this->request->data);
         if ($this->ThemeFile->validates()) {
             $oldPath = urldecode($fullpath);
             $newPath = dirname($fullpath) . DS . urldecode($this->request->data['ThemeFile']['name']);
             if ($this->request->data['ThemeFile']['ext']) {
                 $newPath .= '.' . $this->request->data['ThemeFile']['ext'];
             }
             $this->request->data['ThemeFile']['type'] = $this->_getFileType(basename($newPath));
             if ($this->request->data['ThemeFile']['type'] == 'text') {
                 $file = new File($oldPath);
                 if ($file->open('w')) {
                     $file->append($this->request->data['ThemeFile']['contents']);
                     $file->close();
                     unset($file);
                     $result = true;
                 } else {
                     $result = false;
                 }
             } else {
                 $result = true;
             }
             if ($oldPath != $newPath) {
                 rename($oldPath, $newPath);
             }
         } else {
             $result = false;
         }
         if ($result) {
             clearViewCache();
             $this->setMessage('ファイル ' . $filename . ' を更新しました。');
             $this->redirect(array_merge(array($theme, $plugin, $type), explode('/', dirname($path)), array(basename($newPath))));
         } else {
             $this->setMessage('ファイル ' . $filename . ' の更新に失敗しました。', true);
         }
     }
     $this->pageTitle = '[' . Inflector::camelize($theme) . '] ' . $this->_tempalteTypes[$type] . ' 編集: ' . $filename;
     $this->crumbs[] = array('name' => $this->_tempalteTypes[$type], 'url' => array('controller' => 'theme_files', 'action' => 'index', $theme, $type));
     $this->subMenuElements = array('theme_files');
     $this->set('currentPath', str_replace(ROOT, '', dirname($fullpath)) . DS);
     $this->set('theme', $theme);
     $this->set('plugin', $plugin);
     $this->set('type', $type);
     $this->set('path', $path);
     $this->help = 'theme_files_form';
     $this->render('form');
 }
Example #22
0
 /**
  * コメントを送信する
  *
  * @param int $id
  * @return void
  */
 public function add_comment($id)
 {
     // blog_post_idを取得
     $conditions = array('BlogPost.no' => $id, 'BlogPost.blog_content_id' => $this->contentId);
     $conditions = am($conditions, $this->BlogPost->getConditionAllowPublish());
     // 毎秒抽出条件が違うのでキャッシュしない
     $data = $this->BlogPost->find('first', array('conditions' => $conditions, 'fields' => array('BlogPost.id'), 'cache' => false, 'recursive' => -1));
     if (empty($data['BlogPost']['id'])) {
         $this->notFound();
     } else {
         $postId = $data['BlogPost']['id'];
     }
     if ($this->BlogPost->BlogComment->add($this->request->data, $this->contentId, $postId, $this->blogContent['BlogContent']['comment_approve'])) {
         $this->_sendCommentAdmin($postId, $this->request->data);
         // コメント承認機能を利用していない場合は、公開されているコメント投稿者にアラートを送信
         if (!$this->blogContent['BlogContent']['comment_approve']) {
             $this->_sendCommentContributor($postId, $this->request->data);
         }
         if ($this->blogContent['BlogContent']['comment_approve']) {
             $commentMessage = '送信が完了しました。送信された内容は確認後公開させて頂きます。';
         } else {
             $commentMessage = 'コメントの送信が完了しました。';
         }
         $this->request->data = null;
     } else {
         $commentMessage = 'コメントの送信に失敗しました。';
     }
     clearViewCache();
     $this->set('commentMessage', $commentMessage);
 }
Example #23
0
 /**
  * Viewキャッシュを削除する
  * TODO basics.php 295行目 $homesにバグ?あり
  * 			app/tmp/cache/views/のキャッシュファイルを複数回削除している
  * 
  * @param string $url
  * @param string $ext
  * @dataProvider clearViewCacheDataProvider
  */
 public function testClearViewCache($url, $ext)
 {
     $viewCachePath = CACHE . 'views' . DS;
     if ($url == '/' || $url == '/index' || $url == '/index.html' || $url == '/m/' || $url == '/m/index' || $url == '/m/index.html') {
         $cache = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext, true);
         // 削除実行
         clearViewCache($url, $ext);
     } elseif ($url) {
         // ダミーのキャッシュファイルを生成
         $cache = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext, true);
         $cacheHoge = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . '.hoge', true);
         if (preg_match('/\\/index$/', $url)) {
             $replacedUrl = preg_replace('/\\/index$/', '', $url);
             $replacedCache = new File($viewCachePath . DS . strtolower(Inflector::slug($replacedUrl)) . $ext, true);
         }
         // 削除実行
         clearViewCache($url, $ext);
         $this->assertTrue($cacheHoge->exists(), '指定されていない拡張子のファイルが削除されてしまいます');
         $cacheHoge->delete();
         $cacheHoge->close();
         if (preg_match('/\\/index$/', $url)) {
             $this->assertFalse($replacedCache->exists(), '置換された名前のキャッシュファイルを削除できません');
             $replacedCache->delete();
             $replacedCache->close();
         }
     } else {
         // ダミーのキャッシュファイルを生成
         $cache = new File($viewCachePath . DS . 'cache', true);
         $empty = new File($viewCachePath . DS . 'empty', true);
         // 削除実行
         clearViewCache($url, $ext);
         $this->assertTrue($empty->exists(), 'emptyファイルが削除されてしまいます');
         $empty->delete();
         $empty->close();
     }
     $this->assertFalse($cache->exists(), 'キャッシュを削除できません');
     $cache->delete();
     $cache->close();
 }
Example #24
0
 /**
  * [AJAX] ウィジェットを削除
  * 
  * @param int $widgetAreaId
  * @param int $id
  * @return void
  * @access public
  */
 public function admin_del_widget($widgetAreaId, $id)
 {
     $widgetArea = $this->WidgetArea->read(null, $widgetAreaId);
     if (!$widgetArea['WidgetArea']['widgets']) {
         exit;
     }
     $widgets = BcUtil::unserialize($widgetArea['WidgetArea']['widgets']);
     foreach ($widgets as $key => $widget) {
         $type = key($widget);
         if ($id == $widget[$type]['id']) {
             unset($widgets[$key]);
             break;
         }
     }
     if ($widgets) {
         $widgetArea['WidgetArea']['widgets'] = BcUtil::serialize($widgets);
     } else {
         $widgetArea['WidgetArea']['widgets'] = '';
     }
     $this->WidgetArea->set($widgetArea);
     if ($this->WidgetArea->save()) {
         echo true;
     }
     // 全てのキャッシュを削除しないと画面に反映できない。
     //clearViewCache('element_widget','');
     clearViewCache();
     exit;
 }
 /**
  * フィードのキャッシュを削除する
  *
  * @param string $feedConfigId
  * @param string $url
  * @return	void
  * @access	protected
  */
 protected function _clearViewCatch($feedConfigId, $url)
 {
     clearViewCache('/feed/index/' . $feedConfigId);
     clearViewCache('/feed/ajax/' . $feedConfigId);
     clearViewCache('/feed/cachetime/' . $feedConfigId);
     if (strpos($url, 'http') === false) {
         // 実際のキャッシュではSSLを利用しているかどうかわからないので、両方削除する
         clearCache($this->Feed->createCacheHash('', 'http://' . $_SERVER['HTTP_HOST'] . $this->base . $url), 'views', '.rss');
         clearCache($this->Feed->createCacheHash('', 'https://' . $_SERVER['HTTP_HOST'] . $this->base . $url), 'views', '.rss');
     } else {
         clearCache($this->Feed->createCacheHash('', $url), 'views', '.rss');
     }
 }
Example #26
0
 /**
  * フィードのキャッシュを削除する
  * TODO 第2引き数がない場合、全てのRSSのキャッシュを削除してしまう仕様となっているので
  * RSSキャッシュ保存名をURLのハッシュ文字列ではなく、feed_detail_idを元にした文字列に変更し、
  * feed_detail_idで指定して削除できるようにする
  *
  * @param	string	$feedConfigId
  * @param	string	$url
  * @return	void
  * @access	protected
  */
 function _clearCache($feedConfigId = '', $url = '')
 {
     if ($feedConfigId) {
         clearViewCache('/feed/index/' . $feedConfigId);
         clearViewCache('/feed/ajax/' . $feedConfigId);
         clearViewCache('/feed/cachetime/' . $feedConfigId);
     } else {
         clearViewCache('/feed/index');
         clearViewCache('/feed/ajax');
         clearViewCache('/feed/cachetime');
     }
     if ($url) {
         if (strpos($url, 'http') === false) {
             // 実際のキャッシュではSSLを利用しているかどうかわからないので、両方削除する
             clearCache($this->RssEx->__createCacheHash('', 'http://' . $_SERVER['HTTP_HOST'] . $this->base . $url), 'views', '.rss');
             clearCache($this->RssEx->__createCacheHash('', 'https://' . $_SERVER['HTTP_HOST'] . $this->base . $url), 'views', '.rss');
         } else {
             clearCache($this->RssEx->__createCacheHash('', $url), 'views', '.rss');
         }
     } else {
         clearViewCache(null, 'rss');
     }
 }
Example #27
0
if (!isConsole()) {
    $Session = new CakeSession();
    $Session->start();
}
/**
 * Viewのキャッシュ設定・ログの設定
 */
if (Configure::read('debug') == 0) {
    if (isset($_SESSION) && session_id()) {
        // 管理ユーザーでログインしている場合、ページ機能の編集ページへのリンクを表示する為、キャッシュをオフにする。
        // ただし、現在の仕様としては、セッションでチェックしているので、ブラウザを閉じてしまった場合、一度管理画面を表示する必要がある。
        // TODO ブラウザを閉じても最初から編集ページへのリンクを表示する場合は、クッキーのチェックを行い、認証処理を行う必要があるが、
        // セキュリティ上の問題もあるので実装は検討が必要。
        // bootstrapで実装した場合、他ページへの負荷の問題もある
        if (isset($_SESSION['Auth']['User'])) {
            Configure::write('Cache.check', false);
        }
    }
    Configure::write('Exception', array('handler' => 'ErrorHandler::handleException', 'renderer' => 'ExceptionRenderer', 'log' => false));
} else {
    Configure::write('Cache.check', false);
    clearViewCache();
}
/**
 * テーマヘルパーのパスを追加する 
 */
if (BC_INSTALLED || isConsole()) {
    $helperPaths = App::path('View/Helper');
    array_unshift($helperPaths, WWW_ROOT . 'theme' . DS . Configure::read('BcSite.theme') . DS . 'Helper' . DS);
    App::build(array('View/Helper' => $helperPaths));
}
Example #28
0
 /**
  * [ADMIN] 有効状態にする(AJAX)
  * 
  * @param int $id
  */
 public function admin_ajax_publish($id)
 {
     if (!$id) {
         $this->ajaxError(500, '無効な処理です。');
     }
     if ($this->_changeStatus($id, true)) {
         clearViewCache();
         exit(true);
     } else {
         $this->ajaxError(500, $this->{$this->modelClass}->validationErrors);
     }
     exit;
 }