Пример #1
0
 /**
  * @todo use twig or introduce different escaping strategies for html/js/html_attributes/css etc.
  *
  * @return string htmlspecialchars encoded string
  */
 protected function escape($string)
 {
     return StringToolkit::escapeHtml($string);
 }
 /**
  * Returns a stylesheet link for the currently active theme and each styles.css file of each module that was used
  * in the current request.
  *
  * @return string with link tags to stylesheet files
  */
 protected function getStyleTags()
 {
     $tags = '';
     $current_theme = AgaviConfig::get('themes.default', 'honeybee');
     $theme_filename = AssetCompiler::THEME_MAIN_CSS_FILE;
     $theme_path = 'static/themes/' . $current_theme . '/' . $theme_filename;
     if (is_readable($theme_path)) {
         $tags .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />' . PHP_EOL, StringToolkit::escapeHtml($theme_path . '?cb=' . filemtime($theme_path)));
     } else {
         // TODO define callback to be called when configured/default honeybee theme is not available?
         $lm = $this->getContext()->getLoggerManager();
         $lm->logTo($lm->getDefaultLoggerName(), Logger::CRITICAL, __METHOD__, 'File of theme "' . $current_theme . '" not readable: ' . $theme_path);
     }
     $modules_path_prefix = "static/modules";
     if (AgaviConfig::get('requirejs.use_optimized', false)) {
         $modules_path_prefix = "static/modules-built";
     }
     if (isset(static::$modules[$this->current_output_type])) {
         foreach (static::$modules[$this->current_output_type] as $module) {
             $file = $modules_path_prefix . '/' . $module . '/' . AssetCompiler::MODULE_MAIN_CSS_FILE;
             if (is_readable($file)) {
                 $tags .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />' . PHP_EOL, StringToolkit::escapeHtml($file . '?cb=' . filemtime($file)));
             }
         }
     }
     return $tags;
 }