/** * 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); } } }
* 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 = '/';
/** * ブログテンプレートを取得 * * コンボボックスのソースとして利用 * * @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; }
/** * コンテンツ保存フォームを設定する * * @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; }
/** * メールテンプレートを取得 * * コンボボックスのソースとして利用 * * @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; }