/** * Возвращает правильный web-адрес директории шаблонов * Если пользователь использует шаблон которого нет в плагине, то возвращает путь до шабона плагина 'default' * * @param string $sName Название плагина или его класс * @return string */ public static function GetTemplateWebPath($sName) { $sName = self::GetPluginCode($sName); if (!isset(self::$aTemplateWebPath[$sName])) { $aPaths = glob(Config::Get('path.application.plugins.server') . '/' . $sName . '/frontend/skin/*', GLOB_ONLYDIR); $sTemplateName = ($aPaths and in_array(Config::Get('view.skin'), array_map('basename', $aPaths))) ? Config::Get('view.skin') : 'default'; self::$aTemplateWebPath[$sName] = Router::GetFixPathWeb(Config::Get('path.application.plugins.web')) . "/{$sName}/frontend/skin/{$sTemplateName}/"; } return self::$aTemplateWebPath[$sName]; }
/** * Приводит путь до файла к единому виду * * @param $sFile * @param array $aParams * * @return string */ protected function NormalizeFilePath($sFile, $aParams = array()) { /** * По дефолту считаем, что это локальный абсолютный путь до файла: /var/www/site.com или c:\server\root\site.com */ $sProtocol = ''; $sPath = $sFile; $sSeparate = DIRECTORY_SEPARATOR; /** * Проверяем на URL https://site.com или http://site.com */ if (preg_match('#^(https?://)(.*)#i', $sFile, $aMatch)) { $sProtocol = $aMatch[1]; $sPath = $aMatch[2]; $sSeparate = '/'; /** * Если необходимо, то меняем протокол на https */ if (Router::GetIsSecureConnection() and strtolower($sProtocol) == 'http://' and Config::Get('module.asset.force_https')) { $sProtocol = 'https://'; } /** * Проверяем на //site.com */ } elseif (strpos($sFile, '//') === 0) { $sProtocol = '//'; $sPath = substr($sFile, 2); $sSeparate = '/'; /** * Проверяем на относительный путь без протокола и без первого слеша */ } elseif (strpos($sFile, '/') !== 0 and strpos($sFile, ':') === false) { /** * Считаем, что указывался путь относительно корня текущего шаблона */ $sSeparate = '/'; if (isset($aParams['plugin']) and $aParams['plugin']) { /** * Относительно шаблона плагина */ $sPath = Plugin::GetTemplateWebPath($aParams['plugin']) . $sFile; } else { $sPath = Router::GetFixPathWeb(Config::Get('path.skin.web')) . $sSeparate . $sFile; } return $sPath; } /** * Могут встречаться двойные слеши, поэтому делаем замену */ $sPath = preg_replace("#([\\\\/])+#", $sSeparate, $sPath); /** * Возвращаем результат */ return $sProtocol . $sPath; }
/** * Возвращает список дефолтных параметров * * @return array */ protected function getDefaultProperties() { if (file_exists(Config::Get('path.smarty.template') . DIRECTORY_SEPARATOR . 'og-default.png')) { $sImage = Config::Get('path.skin.web') . '/og-default.png'; } else { $sImage = Config::Get('path.framework.web') . '/frontend/common/images/ls-logo.png'; } return array('og:title' => $this->Viewer_GetHtmlTitle(), 'og:type' => 'website', 'og:image' => Router::GetFixPathWeb($sImage), 'og:url' => Router::GetPathWebCurrent(), 'og:site_name' => Config::Get('view.name')); }