public function Init()
 {
     E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . "assets/css/style.css");
     // Добавление своего CSS
     E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/script.js");
     // Добавление своего JS
     //E::ModuleViewer()->AddMenu('blog',Plugin::GetTemplateDir(__CLASS__).'menu.blog.tpl'); // например, задаем свой вид меню
 }
Beispiel #2
0
 /**
  * Инициализация плагина
  */
 public function Init()
 {
     $this->Viewer_Assign("sTemplatePathEstheme", Plugin::GetTemplatePath(__CLASS__));
     E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . "assets/css/style.min.css");
     E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/jquery.color.js");
     E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/colorPicker.js");
     E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/develop/esTheme.js");
 }
 public function TplTopicShowEnd($aParams)
 {
     if ((!isset($aParams['bTopicList']) || !$aParams['bTopicList']) && isset($aParams['topic']) || isset($aParams['oTopic'])) {
         if (isset($aParams['topic'])) {
             E::ModuleViewer()->Assign('oTopic', $aParams['topic']);
         }
         E::ModuleViewer()->Assign('aWidgetParams', Config::Get('plugin.similartopics.widget_showtopic'));
         return E::ModuleViewer()->Fetch(Plugin::GetTemplateDir(__CLASS__) . 'tpls/widgets/widget.similartopics_bottom.tpl');
     }
     return null;
 }
 public function RegisterHook()
 {
     // Хуки для меню
     $this->AddHook('module_menu_createmenu_after', 'onAfterModuleMenuCreate');
     $this->AddHook('module_menu_resetmenu_after', 'onAfterModuleMenuReset');
     $this->AddHook('new_sandbox_count', 'newSandboxCount');
     $this->AddHook('render_init_start', 'renderInitStart');
     $this->AddHook('comment_add_after', 'clearSandboxCache');
     $this->AddHookTemplate('menu_profile_created_item', Plugin::GetTemplateDir(__CLASS__) . '/tpls/menu_profile_created_item.tpl');
     $this->AddHookTemplate('menu_blog_blog_item', Plugin::GetTemplateDir(__CLASS__) . '/tpls/menu_blog_item.tpl');
 }
Beispiel #5
0
 /**
  * Устанавливает какой шаблон выводить
  *
  * @param string $sTemplate Путь до шаблона относительно каталога шаблонов экшена
  */
 protected function SetTemplateAction($sTemplate)
 {
     if (substr($sTemplate, -4) != '.tpl') {
         $sTemplate = $sTemplate . '.tpl';
     }
     $sActionTemplatePath = $sTemplate;
     if (!F::File_IsLocalDir($sActionTemplatePath)) {
         // If not absolute path then defines real path of template
         $aDelegates = E::ModulePlugin()->GetDelegationChain('action', $this->GetActionClass());
         foreach ($aDelegates as $sAction) {
             if (preg_match('/^(Plugin([\\w]+)_)?Action([\\w]+)$/i', $sAction, $aMatches)) {
                 // for LS-compatibility
                 $sActionNameOriginal = $aMatches[3];
                 // New-style action templates
                 $sActionName = strtolower($sActionNameOriginal);
                 $sTemplatePath = E::ModulePlugin()->GetDelegate('template', 'actions/' . $sActionName . '/action.' . $sActionName . '.' . $sTemplate);
                 $sActionTemplatePath = $sTemplatePath;
                 if (!empty($aMatches[1])) {
                     $aPluginTemplateDirs = array(Plugin::GetTemplateDir($sAction));
                     if (basename($aPluginTemplateDirs[0]) !== 'default') {
                         $aPluginTemplateDirs[] = dirname($aPluginTemplateDirs[0]) . '/default/';
                     }
                     if ($sTemplatePath = F::File_Exists('tpls/' . $sTemplatePath, $aPluginTemplateDirs)) {
                         $sActionTemplatePath = $sTemplatePath;
                         break;
                     }
                     if ($sTemplatePath = F::File_Exists($sTemplatePath, $aPluginTemplateDirs)) {
                         $sActionTemplatePath = $sTemplatePath;
                         break;
                     }
                     // LS-compatibility
                     if (E::ModulePlugin()->IsActivePlugin('ls')) {
                         $sLsTemplatePath = E::ModulePlugin()->GetDelegate('template', 'actions/Action' . ucfirst($sActionName) . '/' . $sTemplate);
                         if ($sTemplatePath = F::File_Exists($sLsTemplatePath, $aPluginTemplateDirs)) {
                             $sActionTemplatePath = $sTemplatePath;
                             break;
                         }
                         $sLsTemplatePath = E::ModulePlugin()->GetDelegate('template', 'actions/Action' . ucfirst($sActionNameOriginal) . '/' . $sTemplate);
                         if ($sTemplatePath = F::File_Exists($sLsTemplatePath, $aPluginTemplateDirs)) {
                             $sActionTemplatePath = $sTemplatePath;
                             break;
                         }
                     }
                 }
             }
         }
     }
     $this->sActionTemplate = $sActionTemplatePath;
 }
Beispiel #6
0
 public function Init()
 {
     $this->Viewer_AppendScript(Plugin::GetTemplateDir(__CLASS__) . 'assets/js/smiles.js');
     $this->Viewer_AppendStyle(Plugin::GetTemplateDir(__CLASS__) . 'assets/css/smiles.css');
 }
Beispiel #7
0
 public function TopicShow($aVars)
 {
     $this->Viewer_Assign('oTopic', $aVars['topic']);
     return $this->Viewer_Fetch(Plugin::GetTemplateDir(__CLASS__) . 'tpls/best_comment.tpl');
 }
 public function Init()
 {
     $this->Viewer_AppendScript(Plugin::GetTemplateDir(__CLASS__) . "assets/js/qa.js");
     // Добавление своего JS
 }
 /**
  * Инициализация плагина
  */
 public function Init()
 {
     E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . 'assets/css/similartopics.css');
     return true;
 }
Beispiel #10
0
 /**
  * Plugin Initialization
  *
  * @return void
  */
 public function Init()
 {
     E::ModuleViewer()->AppendScript(Plugin::GetTemplateDir(__CLASS__) . 'assets/js/seopack.js');
     E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . 'assets/css/seopack.css');
 }
Beispiel #11
0
 /**
  * Display content of sitemap and save it in cache
  *
  * @param string       $sCacheKey
  * @param string|array $xData
  * @param string       $sTemplate
  */
 protected function _displaySitemap($sCacheKey, $xData, $sTemplate = 'sitemap.tpl')
 {
     E::ModuleViewer()->SetResponseHeader('Content-type', 'application/xml; charset=utf-8');
     if (is_array($xData)) {
         $sTemplate = Plugin::GetTemplateDir('sitemap') . 'tpls/' . $sTemplate;
         $sSiteMapContent = E::ModuleViewer()->Fetch($sTemplate, array('aData' => $xData));
         $sPeriod = C::Get();
         foreach ($xData as $aItem) {
             if (!empty($aItem['changefreq'])) {
                 if (in_array($aItem['changefreq'], $this->aPeriods)) {
                     $sPeriod = $this->aPeriods[$aItem['changefreq']];
                 }
             }
         }
         if (!$sPeriod) {
             $sPeriod = 'P1D';
         }
         //$this->_setCache($sCacheKey, $sSiteMapContent, $sPeriod);
     } else {
         $sSiteMapContent = $xData;
     }
     E::ModuleViewer()->Flush($sSiteMapContent);
     exit;
 }
Beispiel #12
0
 public function TemplateFormAddTopic()
 {
     return $this->Fetch(Plugin::GetTemplateDir('PluginLs') . 'inc.form_topic_add_end.tpl');
 }
Beispiel #13
0
 /**
  * Admin menu hook
  *
  * @return string
  */
 public function hook_admin_menu()
 {
     return E::ModuleViewer()->Fetch(Plugin::GetTemplateDir(__CLASS__) . 'tpls/admin_menu.tpl');
 }
Beispiel #14
0
 /**
  * Returns dir of template widget
  *
  * @return mixed
  */
 public function GetDir()
 {
     $sDir = $this->getProp('_dir');
     if (is_null($sDir)) {
         $sDir = $this->GetParam('dir');
         if ($sPlugin = $this->GetPluginId()) {
             $sDir = F::File_NormPath(Plugin::GetTemplateDir($sPlugin) . '/' . $sDir);
         }
         $this->setProp('_dir', $sDir);
     }
     return $sDir;
 }
 public function RegisterHook()
 {
     $this->AddHookTemplate('form_add_blog_end', Plugin::GetTemplateDir(__CLASS__) . '/tpls/hook_form_add_blog_end.tpl');
 }
Beispiel #16
0
/**
 * Plugin for Smarty
 *
 * @param   array                    $aParams
 * @param   Smarty_Internal_Template $oSmartyTemplate
 *
 * @return  string|null
 */
function smarty_function_widget_exec($aParams, $oSmartyTemplate)
{
    if (!isset($aParams['name'])) {
        trigger_error('Parameter "name" does not define in {widget ...} function', E_USER_WARNING);
        return null;
    }
    $sWidgetName = $aParams['name'];
    $sPlugin = !empty($aParams['plugin']) ? $aParams['plugin'] : '';
    $aWidgetParams = isset($aParams['params']) ? array_merge($aParams['params'], $aParams) : $aParams;
    $sWidget = ucfirst(basename($sWidgetName));
    $sTemplate = '';
    $sDelegatedClass = E::ModulePlugin()->GetDelegate('widget', $sWidget);
    if ($sDelegatedClass == $sWidget) {
        // Пробуем получить делегата по старинке, для совместимости с LS
        // * LS-compatible * //
        $sDelegatedClass = E::ModulePlugin()->GetDelegate('block', $sWidget);
    }
    // Если делегатов нет, то определаем класс виджета
    if ($sDelegatedClass == $sWidget) {
        // Проверяем наличие класса виджета штатными средствами
        $sWidgetClass = E::ModuleWidget()->FileClassExists($sWidget, $sPlugin, true);
        if ($sWidgetClass) {
            // Проверяем делегирование найденного класса
            $sWidgetClass = E::ModulePlugin()->GetDelegate('widget', $sWidgetClass);
            if ($sPlugin) {
                $sPluginTplDir = Plugin::GetTemplateDir($sPlugin);
                $sTemplate = $sPluginTplDir . 'tpls/widgets/widget.' . $sWidgetName . '.tpl';
                if ($sFound = F::File_Exists('/widgets/widget.' . $sWidgetName . '.tpl', array($sPluginTplDir . 'tpls/', $sPluginTplDir))) {
                    $sTemplate = $sFound;
                } else {
                    // * LS-compatible * //
                    $sLsTemplate = Plugin::GetTemplateDir($sPlugin) . '/blocks/block.' . $sWidgetName . '.tpl';
                    if (F::File_Exists($sLsTemplate)) {
                        $sTemplate = $sLsTemplate;
                    }
                }
            } else {
                $sTemplate = E::ModulePlugin()->GetDelegate('template', 'widgets/widget.' . $sWidgetName . '.tpl');
                $sTemplate = F::File_Exists($sTemplate, $oSmartyTemplate->smarty->getTemplateDir());
                if (!$sTemplate) {
                    // * LS-compatible * //
                    $sLsTemplate = E::ModulePlugin()->GetDelegate('template', 'blocks/block.' . $sWidgetName . '.tpl');
                    if (F::File_Exists($sLsTemplate, $oSmartyTemplate->smarty->getTemplateDir())) {
                        $sTemplate = $sLsTemplate;
                    }
                }
            }
        } else {
            // * LS-compatible * //
            // Класс не найден
            if ($sPlugin) {
                // Если класс виджета не найден, то пытаемся по старинке задать класс "LS-блока"
                $sWidgetClass = 'Plugin' . ucfirst($sPlugin) . '_Block' . $sWidget;
            } else {
                // Если класс виджета не найден, то пытаемся по старинке задать класс "LS-блока"
                $sWidgetClass = 'Block' . $sWidget;
            }
            // Проверяем делигирование найденного класса
            $sWidgetClass = E::ModulePlugin()->GetDelegate('block', $sWidgetClass);
            if (!$sTemplate) {
                $sLsTemplate = E::ModulePlugin()->GetDelegate('template', 'blocks/block.' . $sWidgetName . '.tpl');
                if (F::File_Exists($sLsTemplate, $oSmartyTemplate->smarty->getTemplateDir())) {
                    $sTemplate = $sLsTemplate;
                }
            }
        }
    } else {
        $sWidgetClass = $sDelegatedClass;
    }
    // * Подключаем необходимый обработчик
    /** @var Widget $oWidgetHandler */
    $oWidgetHandler = new $sWidgetClass($aWidgetParams);
    // * Запускаем обработчик
    $sResult = $oWidgetHandler->Exec();
    // Если обработчик ничего не вернул, то рендерим шаблон
    if (!$sResult && $sTemplate) {
        if ($aWidgetParams) {
            $oSmartyTemplate->smarty->assign('aWidgetParams', $aWidgetParams);
        }
        $sResult = $oSmartyTemplate->smarty->fetch($sTemplate);
    }
    return $sResult;
}
 public function Init()
 {
     $sTemplateDir = Plugin::GetTemplateDir(__CLASS__);
     E::ModuleViewer()->AppendScript($sTemplateDir . "assets/js/betterspoilers.js");
     E::ModuleViewer()->AppendStyle($sTemplateDir . "assets/css/betterspoilers.css");
 }
Beispiel #18
0
 public function Init()
 {
     E::ModuleViewer()->AppendStyle(Plugin::GetTemplateDir(__CLASS__) . "assets/css/style.css");
     return TRUE;
 }
Beispiel #19
0
 public function DisableSmiles()
 {
     $oViewer = $this->Viewer_GetLocalViewer();
     return $oViewer->Fetch(Plugin::GetTemplateDir(__CLASS__) . 'tpls/disable_smiles.tpl');
 }
Beispiel #20
0
 /**
  * Выполняет загрузку необходимых (возможно даже системных :)) переменных в шаблонизатор
  */
 public function VarAssign()
 {
     // * Загружаем весь $_REQUEST, предварительно обработав его функцией F::HtmlSpecialChars()
     $aRequest = $_REQUEST;
     F::HtmlSpecialChars($aRequest);
     $this->Assign('_aRequest', $aRequest);
     // * Параметры стандартной сессии
     // TODO: Убрать! Не должно этого быть на страницах сайта
     $this->Assign('_sPhpSessionName', session_name());
     $this->Assign('_sPhpSessionId', session_id());
     // * Загружаем роутинг с учетом правил rewrite
     $aRouter = array();
     $aPages = Config::Get('router.page');
     if (!$aPages || !is_array($aPages)) {
         throw new Exception('Router rules is underfined.');
     }
     foreach ($aPages as $sPage => $aAction) {
         $aRouter[$sPage] = R::GetPath($sPage);
     }
     $this->Assign('aRouter', $aRouter);
     // * Загружаем виджеты
     $this->Assign('aWidgets', $this->GetWidgets());
     // * Загружаем HTML заголовки
     $this->Assign('sHtmlTitle', $this->GetHtmlTitle());
     $this->Assign('sHtmlKeywords', $this->GetHtmlKeywords());
     $this->Assign('sHtmlDescription', $this->GetHtmlDescription());
     $this->Assign('aHtmlHeadFiles', $this->aHtmlHeadFiles);
     $this->Assign('aHtmlRssAlternate', $this->aHtmlRssAlternate);
     $this->Assign('sHtmlCanonical', $this->sHtmlCanonical);
     $this->Assign('aHtmlHeadTags', $this->aHtmlHeadTags);
     $this->Assign('aJsAssets', E::ModuleViewerAsset()->GetPreparedAssetLinks());
     // * Загружаем список активных плагинов
     $aPlugins = E::GetActivePlugins();
     $this->Assign('aPluginActive', array_fill_keys(array_keys($aPlugins), true));
     // * Загружаем пути до шаблонов плагинов
     $aPluginsTemplateUrl = array();
     $aPluginsTemplateDir = array();
     /** @var Plugin $oPlugin */
     foreach ($aPlugins as $sPlugin => $oPlugin) {
         $sDir = Plugin::GetTemplateDir(get_class($oPlugin));
         if ($sDir) {
             $this->oSmarty->addTemplateDir(array($sDir . 'tpls/', $sDir), $oPlugin->GetName(false));
             $aPluginsTemplateDir[$sPlugin] = $sDir;
             $aPluginsTemplateUrl[$sPlugin] = Plugin::GetTemplateUrl(get_class($oPlugin));
         }
     }
     if (E::ActivePlugin('ls')) {
         // LS-compatible //
         $this->Assign('aTemplateWebPathPlugin', $aPluginsTemplateUrl);
         $this->Assign('aTemplatePathPlugin', $aPluginsTemplateDir);
     }
     $sSkinTheme = $this->GetConfigTheme();
     if (!$sSkinTheme) {
         $sSkinTheme = 'default';
     }
     // Проверка существования темы
     if ($this->CheckTheme($sSkinTheme)) {
         $this->oSmarty->compile_id = $sSkinTheme;
     }
     $this->Assign('sSkinTheme', $sSkinTheme);
 }
Beispiel #21
0
 /**
  * Returns full path to email templates by name and plugin
  *
  * @param  string        $sName   Template name
  * @param  string|object $xPlugin Name or class of plugin
  *
  * @return string
  */
 public function GetTemplatePath($sName, $xPlugin = null)
 {
     if ($xPlugin) {
         $sPluginName = Plugin::GetPluginName($xPlugin);
     } else {
         $sPluginName = '';
     }
     $sCacheKey = 'template_path_' . $sName . '-' . $sPluginName;
     if (false === ($sResult = E::ModuleCache()->Get($sCacheKey, 'tmp'))) {
         $bFound = false;
         if ($sPluginName) {
             $sDir = Plugin::GetTemplateDir($sPluginName) . $this->sDir . '/';
         } else {
             $sDir = F::File_NormPath(E::ModuleViewer()->GetTemplateDir() . '/' . $this->sDir . '/');
         }
         // Find template by current language
         $sLangDir = $sDir . E::ModuleLang()->GetLang();
         if (is_dir($sLangDir)) {
             $sResult = $sLangDir . '/' . $sName;
             $bFound = true;
         }
         if (!$bFound) {
             // Find by aliases of current language
             if ($aAliases = E::ModuleLang()->GetLangAliases()) {
                 foreach ($aAliases as $sAlias) {
                     if (is_dir($sLangDir = $sDir . $sAlias)) {
                         $sResult = $sLangDir . '/' . $sName;
                         $bFound = true;
                         break;
                     }
                 }
             }
         }
         if (!$bFound) {
             // Find template by default language
             $sLangDir = $sDir . E::ModuleLang()->GetDefaultLang();
             if (is_dir($sLangDir)) {
                 $sResult = $sLangDir . '/' . $sName;
                 $bFound = true;
             }
         }
         if (!$bFound) {
             // Find by aliases of default language
             if ($aAliases = E::ModuleLang()->GetDefaultLangAliases()) {
                 foreach ($aAliases as $sAlias) {
                     if (is_dir($sLangDir = $sDir . $sAlias)) {
                         $sResult = $sLangDir . '/' . $sName;
                         $bFound = true;
                         break;
                     }
                 }
             }
         }
         if (!$bFound) {
             $sResult = $sDir . E::ModuleLang()->GetLangDefault() . '/' . $sName;
         }
         if (is_dir($sResult)) {
             E::ModuleCache()->Set($sResult, $sCacheKey, array(), 'P30D', 'tmp');
         }
     }
     return $sResult;
 }