getTemplateDir() public method

Get template directories
public getTemplateDir ( $index = null ) : array | string
return array | string list of template directories, or directory of $index
Esempio n. 1
0
 /**
  * modify resource_name according to resource handlers specifications
  *
  * @param  Smarty  $smarty        Smarty instance
  * @param  string  $resource_name resource_name to make unique
  * @param  boolean $isConfig      flag for config resource
  *
  * @return string unique resource name
  */
 public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
 {
     if ($isConfig) {
         if (!isset($smarty->_joined_config_dir)) {
             $smarty->getTemplateDir(null, true);
         }
         return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name;
     } else {
         if (!isset($smarty->_joined_template_dir)) {
             $smarty->getTemplateDir();
         }
         return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name;
     }
 }
Esempio n. 2
0
 /**
  * Loads page.
  */
 private function loadPage()
 {
     $this->lang = new Language("SF Global");
     $this->langPages = new Language("Pages lang");
     $currLang = $this->url->getCurrentLanguage();
     $this->lang->loadLang($this->config->get('main_lang_dir') . $currLang . "/{$currLang}.php");
     $this->langPages->loadLang($this->config->get('main_lang_dir') . $currLang . "/{$currLang}_pages.php");
     $currPageName = $this->url->getCurrentPageName();
     $actualPageName = $this->langPages->getIndex($currPageName);
     if ($actualPageName === null) {
         $actualPageName = $currPageName;
     }
     $tplDir = $this->tplEngine->getTemplateDir(0);
     $this->loadClassCheckInterface('component_loader', 'Framework\\Core\\FrameworkClasses\\Components\\IComponentLoader');
     $this->loadClassCheckInterface('page_loader', 'Framework\\Core\\FrameworkClasses\\Routing\\IPageLoader');
     $componentLoader = new SFComponentLoader($this->config->get('app_dir') . 'components/output/', $tplDir . 'out_components/', $this->config->get('output_components'), $this->config->get('out_comp_ns'), $this->config->get('logic_components'), $this->config->get('logic_comp_ns'), $this->tplEngine, $this->config->get('config_type'), $this->url->getCurrentLanguage(), $this->config->get('wrap_components'), $this->config->get('logic_components_dir'), $this->config->get('output_components_options'), $this->dbFactory, $this->config->get('common_output_components'), $this->config->get('current_page'), $this->logger, $this);
     $ajaxLevel = $this->getAjaxLevel();
     $loadSpecificComponent = false;
     if (!is_numeric($ajaxLevel)) {
         $loadSpecificComponent = $ajaxLevel;
     }
     $pageLoader = new PageLoader($this->config->get('pages'), $this->config->get('pages_out_components'), $this->config->get('pages_templates'), $this->config->get('empty_page_index'), $this->config->get('maintenance_mode'), $this->tplEngine, $tplDir . 'pages/', $componentLoader, $this->logger, $this->url, $this->config->get('output_components_url'), $this->config->get('pages_url'), $loadSpecificComponent);
     $pageLoader->pageNotFoundPage = $this->config->get('page_not_found_page');
     $pageLoader->pageMaintenance = $this->config->get('page_maintenance');
     $header = "";
     $content = $pageLoader->getCurrentPageContent($actualPageName, $header);
     if ($loadSpecificComponent !== false || $ajaxLevel == 2) {
         $ajaxData = array('content' => $content, 'header' => $header);
         $this->outputJsonEncoded($ajaxData);
     }
     $header = $this->genHeaderIndex() . $header;
     $this->tplEngine->assign('header', $header);
     // assign to the main tpl
     $this->tplEngine->assign('mainContent', $content);
 }
Esempio n. 3
0
 /**
  * @param string $sTemplate
  * @param bool $bException
  *
  * @return bool|void
  * @throws Exception
  */
 protected function _tplTemplateExists($sTemplate, $bException = false)
 {
     if (!$this->oSmarty) {
         $this->_tplInit();
     }
     $bResult = $this->oSmarty->templateExists($sTemplate);
     $sSkin = $this->GetConfigSkin();
     if (!$bResult && $bException) {
         $sMessage = 'Can not find the template "' . $sTemplate . '" in skin "' . $sSkin . '"';
         if ($aTpls = $this->GetSmartyObject()->template_objects) {
             if (is_array($aTpls)) {
                 $sMessage .= ' (from: ';
                 foreach ($aTpls as $oTpl) {
                     $sMessage .= $oTpl->template_resource . '; ';
                 }
                 $sMessage .= ')';
             }
         }
         $sMessage .= '. ';
         $oSkin = E::ModuleSkin()->GetSkin($sSkin);
         if ((!$oSkin || $oSkin->GetCompatible() != 'alto') && !E::ActivePlugin('ls')) {
             $sMessage .= 'Probably you need to activate plugin "Ls".';
         }
         // записываем доп. информацию - пути к шаблонам Smarty
         $sErrorInfo = 'Template Dirs: ' . implode('; ', $this->oSmarty->getTemplateDir());
         $this->_error($sMessage, $sErrorInfo);
         return false;
     }
     if ($bResult && ($sResult = $this->_getTemplatePath($sSkin, $sTemplate))) {
         $sTemplate = $sResult;
     }
     return $bResult ? $sTemplate : $bResult;
 }
 /**
  * Compile all template or config files
  *
  * @param \Smarty $smarty
  * @param  string $extension     template file name extension
  * @param  bool   $force_compile force all to recompile
  * @param  int    $time_limit    set maximum execution time
  * @param  int    $max_errors    set maximum allowed errors
  * @param bool    $isConfig      flag true if called for config files
  *
  * @return int number of template files compiled
  */
 protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors, $isConfig = false)
 {
     // switch off time limit
     if (function_exists('set_time_limit')) {
         @set_time_limit($time_limit);
     }
     $_count = 0;
     $_error_count = 0;
     $sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
     // loop over array of source directories
     foreach ($sourceDir as $_dir) {
         $_dir_1 = new RecursiveDirectoryIterator($_dir);
         $_dir_2 = new RecursiveIteratorIterator($_dir_1);
         foreach ($_dir_2 as $_fileinfo) {
             $_file = $_fileinfo->getFilename();
             if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if (!substr_compare($_file, $extension, -strlen($extension)) == 0) {
                 continue;
             }
             if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) {
                 $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
             }
             echo "\n<br>", $_dir, '---', $_file;
             flush();
             $_start_time = microtime(true);
             $_smarty = clone $smarty;
             $_smarty->force_compile = $force_compile;
             try {
                 /* @var Smarty_Internal_Template $_tpl */
                 $_tpl = new $smarty->template_class($_file, $_smarty);
                 $_tpl->caching = Smarty::CACHING_OFF;
                 $_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
                 if ($_tpl->mustCompile()) {
                     $_tpl->compileTemplateSource();
                     $_count++;
                     echo ' compiled in  ', microtime(true) - $_start_time, ' seconds';
                     flush();
                 } else {
                     echo ' is up to date';
                     flush();
                 }
             } catch (Exception $e) {
                 echo "\n<br>        ------>Error: ", $e->getMessage(), "<br><br>\n";
                 $_error_count++;
             }
             // free memory
             unset($_tpl);
             $_smarty->_clearTemplateCache();
             if ($max_errors !== null && $_error_count == $max_errors) {
                 echo "\n<br><br>too many errors\n";
                 exit;
             }
         }
     }
     echo "\n<br>";
     return $_count;
 }
Esempio n. 5
0
 public function smartyNodePorts(Smarty $hook_data)
 {
     $template_dirs = $hook_data->getTemplateDir();
     $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSNodePortsPlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates';
     array_unshift($template_dirs, $plugin_templates);
     $hook_data->setTemplateDir($template_dirs);
     return $hook_data;
 }
Esempio n. 6
0
 /**
  * Inserts plugin templates dir at beginning of smarty template dir list
  */
 public static function insertDefaultTemplateDir(Smarty $smarty)
 {
     $template_dirs = $smarty->getTemplateDir();
     $reflector = new ReflectionClass(get_called_class());
     $plugin_templates = dirname($reflector->getFileName()) . DIRECTORY_SEPARATOR . 'templates';
     array_unshift($template_dirs, $plugin_templates);
     $smarty->setTemplateDir($template_dirs);
 }
 /**
  * Compile all template files
  *
  * @param  string $extension     template file name extension
  * @param  bool   $force_compile force all to recompile
  * @param  int    $time_limit    set maximum execution time
  * @param  int    $max_errors    set maximum allowed errors
  * @param  Smarty $smarty        Smarty instance
  *
  * @return integer number of template files compiled
  */
 public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
 {
     // switch off time limit
     if (function_exists('set_time_limit')) {
         @set_time_limit($time_limit);
     }
     $smarty->force_compile = $force_compile;
     $_count = 0;
     $_error_count = 0;
     // loop over array of template directories
     foreach ($smarty->getTemplateDir() as $_dir) {
         $_compileDirs = new RecursiveDirectoryIterator($_dir);
         $_compile = new RecursiveIteratorIterator($_compileDirs);
         foreach ($_compile as $_fileinfo) {
             $_file = $_fileinfo->getFilename();
             if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if (!substr_compare($_file, $extension, -strlen($extension)) == 0) {
                 continue;
             }
             if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
                 $_template_file = $_file;
             } else {
                 $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
             }
             echo '<br>', $_dir, '---', $_template_file;
             flush();
             $_start_time = microtime(true);
             try {
                 $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
                 if ($_tpl->mustCompile()) {
                     $_tpl->compileTemplateSource();
                     $_count++;
                     echo ' compiled in  ', microtime(true) - $_start_time, ' seconds';
                     flush();
                 } else {
                     echo ' is up to date';
                     flush();
                 }
             } catch (Exception $e) {
                 echo 'Error: ', $e->getMessage(), "<br><br>";
                 $_error_count++;
             }
             // free memory
             $smarty->template_objects = array();
             $_tpl->smarty->template_objects = array();
             $_tpl = null;
             if ($max_errors !== null && $_error_count == $max_errors) {
                 echo '<br><br>too many errors';
                 exit;
             }
         }
     }
     return $_count;
 }
Esempio n. 8
0
 public function smartyCashImportOKBS(Smarty $hook_data)
 {
     $template_dirs = $hook_data->getTemplateDir();
     $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates';
     $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir');
     if (!empty($custom_templates_dir) && file_exists($plugin_templates . DIRECTORY_SEPARATOR . $custom_templates_dir) && !is_file($plugin_tempaltes . DIRECTORY_SEPARATOR . $custom_templates_dir)) {
         $plugin_templates = PLUGINS_DIR . DIRECTORY_SEPARATOR . LMSCustomersAgePlugin::PLUGIN_DIRECTORY_NAME . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $custom_templates_dir;
     }
     array_unshift($template_dirs, $plugin_templates);
     $hook_data->setTemplateDir($template_dirs);
     return $hook_data;
 }
Esempio n. 9
0
/**
 * Includes a file in template. Handy for adding html files to tpl files
 *
 * @param array $Params The parameters passed into the function.
 * The parameters that can be passed to this function are as follows.
 * - <b>name</b>: The name of the file.
 * @param Smarty $Smarty The smarty object rendering the template.
 * @return string The rendered asset.
 */
function smarty_function_include_file($Params, &$Smarty)
{
    $Name = ltrim(val('name', $Params), '/');
    if (strpos($Name, '..') !== false) {
        return '<!-- Error, moving up directory path not allowed -->';
    }
    if (isUrl($Name)) {
        return '<!-- Error, urls are not allowed -->';
    }
    $filename = rtrim($Smarty->getTemplateDir(), '/') . '/' . $Name;
    if (!file_exists($filename)) {
        return '<!-- Error, file does not exist -->';
    }
    return file_get_contents($filename);
}
Esempio n. 10
0
/**
 * Wrapper for @see Router::reverse(). Additional params are _fullurl and _https, for links with https-protocol and
 * absolute urls. Define the route name with _name and everything else is used as arguments, you may also specify all
 * arguments at once using the 'arguments' param.
 *
 * @package FeM\sPof\template\smartyPlugins
 * @author dangerground
 * @since 1.0
 *
 * @api
 *
 * @throws FeM\sPof\exception\SmartyTemplateException
 *
 * @param array $params
 * @param Smarty $smarty
 *
 * @return string
 */
function smarty_function_route($params, &$smarty)
{
    // get array elements as single params
    if (isset($params['arguments']) && is_array($params['arguments'])) {
        $params = array_merge($params['arguments'], $params);
        unset($params['arguments']);
    }
    $arguments = $params;
    unset($arguments['_name']);
    $fullurl = isset($arguments['_fullurl']) ? $arguments['_fullurl'] : false;
    unset($arguments['_fullurl']);
    $https = isset($arguments['_https']) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'on' ? $arguments['_https'] : true;
    unset($arguments['_https']);
    try {
        $server = FeM\sPof\Config::get('server');
        $basedir = 'https://' . $_SERVER['SERVER_NAME'] . $server['path'];
        return ($fullurl ? $https ? $basedir : preg_replace('#^https#', 'http', $basedir) : '') . \FeM\sPof\Router::reverse($params['_name'], $arguments);
    } catch (\InvalidArgumentException $e) {
        throw new \FeM\sPof\exception\SmartyTemplateException(__FUNCTION__ . ': ' . $e->getMessage(), $smarty->getTemplateDir()[0] . $smarty->template_resource, $e);
    }
}
 /**
  * get Smarty property in template context
  *
  * @param string $property_name property name
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (empty($this->template_resource)) {
                 throw new SmartyException("Unable to parse resource name \"{$this->template_resource}\"");
             }
             $this->source = Smarty_Resource::source($this);
             // cache template object under a unique ID
             // do not cache eval resources
             if ($this->source->type != 'eval') {
                 $this->smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $this->smarty->getTemplateDir()) . $this->template_resource . $this->cache_id . $this->compile_id)] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smarty_Template_Cached')) {
                 include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
             }
             $this->cached = new Smarty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
             // FIXME: routing of template -> smarty attributes
         // FIXME: routing of template -> smarty attributes
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
     }
     throw new SmartyException("template property '{$property_name}' does not exist.");
 }
Esempio n. 12
0
 /**
  * Retrieve the current template directory
  *
  * @return array
  */
 public function getScriptPaths()
 {
     return $this->_smarty->getTemplateDir();
 }
 /**
  * Get template's unique ID
  *
  * @param Smarty $smarty        Smarty object
  * @param string $resource_name template name
  * @param string $cache_id      cache id
  * @param string $compile_id    compile id
  * @return string filepath of cache file
  */
 protected function getTemplateUid(Smarty $smarty, $resource_name, $cache_id, $compile_id)
 {
     $uid = '';
     if (isset($resource_name)) {
         $tpl = new $smarty->template_class($resource_name, $smarty);
         if ($tpl->source->exists) {
             $uid = $tpl->source->uid;
         }
         // remove from template cache
         unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
     }
     return $uid;
 }
Esempio n. 14
0
 /**
  * Gets the template root directory for this Template object.
  *
  * @return string
  */
 function get_template_dir()
 {
     return $this->smarty->getTemplateDir();
 }
Esempio n. 15
0
/**
 * Get list of templates that should be overridden by addons
 *
 * @param  string $resource_name    Base template name
 * @param  Smarty $view             Templater object
 *
 * @return string Overridden template name
 */
function fn_addon_template_overrides($resource_name, &$view)
{
    static $init = array();
    $o_name = 'template_overrides_' . AREA;
    $template_dir = rtrim($view->getTemplateDir(0), '/') . '/';
    if (!isset($init[$o_name])) {
        Registry::registerCache($o_name, array('addons'), Registry::cacheLevel('static'));
        if (!Registry::isExist($o_name)) {
            $template_overrides = array();
            foreach (Registry::get('addons') as $a => $_settings) {
                $odir = $template_dir . 'addons/' . $a . '/overrides';
                if ($_settings['status'] == 'A' && is_dir($odir)) {
                    $tpls = fn_get_dir_contents($odir, false, true, '', '', true);
                    foreach ($tpls as $k => $t) {
                        $tpl_hash = md5($t);
                        if (empty($template_overrides[$tpl_hash])) {
                            $template_overrides[$tpl_hash] = $template_dir . 'addons/' . $a . '/overrides/' . $t;
                        }
                    }
                }
            }
            if (empty($template_overrides)) {
                $template_overrides['plug'] = true;
            }
            Registry::set($o_name, $template_overrides);
        }
        $init[$o_name] = true;
    }
    return Registry::ifGet($o_name . '.' . md5($resource_name), $resource_name);
}
 /**
  * Empty cache for a specific template
  *
  * @param Smarty  $_template     template object
  * @param string  $resource_name template name
  * @param string  $cache_id      cache id
  * @param string  $compile_id    compile id
  * @param integer $exp_time      expiration time (number of seconds, not timestamp)
  * @return integer number of cache files deleted
  */
 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $_cache_id = isset($cache_id) ? preg_replace('![^\\w\\|]+!', '_', $cache_id) : null;
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
     $_dir = $smarty->getCacheDir();
     $_dir_length = strlen($_dir);
     if (isset($_cache_id)) {
         $_cache_id_parts = explode('|', $_cache_id);
         $_cache_id_parts_count = count($_cache_id_parts);
         if ($smarty->use_sub_dirs) {
             foreach ($_cache_id_parts as $id_part) {
                 $_dir .= $id_part . DS;
             }
         }
     }
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = true;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         if ($tpl->source->exists) {
             $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
         } else {
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
             return 0;
         }
     }
     $_count = 0;
     $_time = time();
     if (file_exists($_dir)) {
         $_cacheDirs = new RecursiveDirectoryIterator($_dir);
         $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($_cache as $_file) {
             if (substr($_file->getBasename(), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             // directory ?
             if ($_file->isDir()) {
                 if (!$_cache->isDot()) {
                     // delete folder if empty
                     @rmdir($_file->getPathname());
                 }
             } else {
                 $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
                 $_parts_count = count($_parts);
                 // check name
                 if (isset($resource_name)) {
                     if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
                         continue;
                     }
                 }
                 // check compile id
                 if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
                     continue;
                 }
                 // check cache id
                 if (isset($_cache_id)) {
                     // count of cache id parts
                     $_parts_count = isset($_compile_id) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
                     if ($_parts_count < $_cache_id_parts_count) {
                         continue;
                     }
                     for ($i = 0; $i < $_cache_id_parts_count; $i++) {
                         if ($_parts[$i] != $_cache_id_parts[$i]) {
                             continue 2;
                         }
                     }
                 }
                 // expired ?
                 if (isset($exp_time) && $_time - @filemtime($_file) < $exp_time) {
                     continue;
                 }
                 $_count += @unlink((string) $_file) ? 1 : 0;
             }
         }
     }
     return $_count;
 }
function my_template_handler_file($resource_type, $resource_name, &$template_source, &$template_timestamp, Smarty $smarty)
{
    return $smarty->getTemplateDir(0) . 'helloworld.tpl';
}
 /**
  * diagnose Smarty setup
  * If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
  *
  * @param \Smarty $smarty
  * @param  array  $errors array to push results into rather than outputting them
  *
  * @return bool status, true if everything is fine, false else
  */
 public static function testInstall(Smarty $smarty, &$errors = null)
 {
     $status = true;
     if ($errors === null) {
         echo "<PRE>\n";
         echo "Smarty Installation test...\n";
         echo "Testing template directory...\n";
     }
     $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
     // test if all registered template_dir are accessible
     foreach ($smarty->getTemplateDir() as $template_dir) {
         $_template_dir = $template_dir;
         $template_dir = realpath($template_dir);
         // resolve include_path or fail existence
         if (!$template_dir) {
             if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_template_dir)) {
                 // try PHP include_path
                 if ($_stream_resolve_include_path) {
                     $template_dir = stream_resolve_include_path($_template_dir);
                 } else {
                     $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty);
                 }
                 if ($template_dir !== false) {
                     if ($errors === null) {
                         echo "{$template_dir} is OK.\n";
                     }
                     continue;
                 } else {
                     $status = false;
                     $message = "FAILED: {$_template_dir} does not exist (and couldn't be found in include_path either)";
                     if ($errors === null) {
                         echo $message . ".\n";
                     } else {
                         $errors['template_dir'] = $message;
                     }
                     continue;
                 }
             } else {
                 $status = false;
                 $message = "FAILED: {$_template_dir} does not exist";
                 if ($errors === null) {
                     echo $message . ".\n";
                 } else {
                     $errors['template_dir'] = $message;
                 }
                 continue;
             }
         }
         if (!is_dir($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } elseif (!is_readable($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } else {
             if ($errors === null) {
                 echo "{$template_dir} is OK.\n";
             }
         }
     }
     if ($errors === null) {
         echo "Testing compile directory...\n";
     }
     // test if registered compile_dir is accessible
     $__compile_dir = $smarty->getCompileDir();
     $_compile_dir = realpath($__compile_dir);
     if (!$_compile_dir) {
         $status = false;
         $message = "FAILED: {$__compile_dir} does not exist";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_dir($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_readable($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not readable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_writable($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not writable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } else {
         if ($errors === null) {
             echo "{$_compile_dir} is OK.\n";
         }
     }
     if ($errors === null) {
         echo "Testing plugins directory...\n";
     }
     // test if all registered plugins_dir are accessible
     // and if core plugins directory is still registered
     $_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
     $_core_plugins_available = false;
     foreach ($smarty->getPluginsDir() as $plugin_dir) {
         $_plugin_dir = $plugin_dir;
         $plugin_dir = realpath($plugin_dir);
         // resolve include_path or fail existence
         if (!$plugin_dir) {
             if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_plugin_dir)) {
                 // try PHP include_path
                 if ($_stream_resolve_include_path) {
                     $plugin_dir = stream_resolve_include_path($_plugin_dir);
                 } else {
                     $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty);
                 }
                 if ($plugin_dir !== false) {
                     if ($errors === null) {
                         echo "{$plugin_dir} is OK.\n";
                     }
                     continue;
                 } else {
                     $status = false;
                     $message = "FAILED: {$_plugin_dir} does not exist (and couldn't be found in include_path either)";
                     if ($errors === null) {
                         echo $message . ".\n";
                     } else {
                         $errors['plugins_dir'] = $message;
                     }
                     continue;
                 }
             } else {
                 $status = false;
                 $message = "FAILED: {$_plugin_dir} does not exist";
                 if ($errors === null) {
                     echo $message . ".\n";
                 } else {
                     $errors['plugins_dir'] = $message;
                 }
                 continue;
             }
         }
         if (!is_dir($plugin_dir)) {
             $status = false;
             $message = "FAILED: {$plugin_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif (!is_readable($plugin_dir)) {
             $status = false;
             $message = "FAILED: {$plugin_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
             $_core_plugins_available = true;
             if ($errors === null) {
                 echo "{$plugin_dir} is OK.\n";
             }
         } else {
             if ($errors === null) {
                 echo "{$plugin_dir} is OK.\n";
             }
         }
     }
     if (!$_core_plugins_available) {
         $status = false;
         $message = "WARNING: Smarty's own libs/plugins is not available";
         if ($errors === null) {
             echo $message . ".\n";
         } elseif (!isset($errors['plugins_dir'])) {
             $errors['plugins_dir'] = $message;
         }
     }
     if ($errors === null) {
         echo "Testing cache directory...\n";
     }
     // test if all registered cache_dir is accessible
     $__cache_dir = $smarty->getCacheDir();
     $_cache_dir = realpath($__cache_dir);
     if (!$_cache_dir) {
         $status = false;
         $message = "FAILED: {$__cache_dir} does not exist";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_dir($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_readable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not readable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_writable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not writable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } else {
         if ($errors === null) {
             echo "{$_cache_dir} is OK.\n";
         }
     }
     if ($errors === null) {
         echo "Testing configs directory...\n";
     }
     // test if all registered config_dir are accessible
     foreach ($smarty->getConfigDir() as $config_dir) {
         $_config_dir = $config_dir;
         // resolve include_path or fail existence
         if (!$config_dir) {
             if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_config_dir)) {
                 // try PHP include_path
                 if ($_stream_resolve_include_path) {
                     $config_dir = stream_resolve_include_path($_config_dir);
                 } else {
                     $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty);
                 }
                 if ($config_dir !== false) {
                     if ($errors === null) {
                         echo "{$config_dir} is OK.\n";
                     }
                     continue;
                 } else {
                     $status = false;
                     $message = "FAILED: {$_config_dir} does not exist (and couldn't be found in include_path either)";
                     if ($errors === null) {
                         echo $message . ".\n";
                     } else {
                         $errors['config_dir'] = $message;
                     }
                     continue;
                 }
             } else {
                 $status = false;
                 $message = "FAILED: {$_config_dir} does not exist";
                 if ($errors === null) {
                     echo $message . ".\n";
                 } else {
                     $errors['config_dir'] = $message;
                 }
                 continue;
             }
         }
         if (!is_dir($config_dir)) {
             $status = false;
             $message = "FAILED: {$config_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['config_dir'] = $message;
             }
         } elseif (!is_readable($config_dir)) {
             $status = false;
             $message = "FAILED: {$config_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['config_dir'] = $message;
             }
         } else {
             if ($errors === null) {
                 echo "{$config_dir} is OK.\n";
             }
         }
     }
     if ($errors === null) {
         echo "Testing sysplugin files...\n";
     }
     // test if sysplugins are available
     $source = SMARTY_SYSPLUGINS_DIR;
     if (is_dir($source)) {
         $expectedSysplugins = array('smartycompilerexception.php' => true, 'smartyexception.php' => true, 'smarty_cacheresource.php' => true, 'smarty_cacheresource_custom.php' => true, 'smarty_cacheresource_keyvaluestore.php' => true, 'smarty_data.php' => true, 'smarty_internal_block.php' => true, 'smarty_internal_cacheresource_file.php' => true, 'smarty_internal_compilebase.php' => true, 'smarty_internal_compile_append.php' => true, 'smarty_internal_compile_assign.php' => true, 'smarty_internal_compile_block.php' => true, 'smarty_internal_compile_break.php' => true, 'smarty_internal_compile_call.php' => true, 'smarty_internal_compile_capture.php' => true, 'smarty_internal_compile_config_load.php' => true, 'smarty_internal_compile_continue.php' => true, 'smarty_internal_compile_debug.php' => true, 'smarty_internal_compile_eval.php' => true, 'smarty_internal_compile_extends.php' => true, 'smarty_internal_compile_for.php' => true, 'smarty_internal_compile_foreach.php' => true, 'smarty_internal_compile_function.php' => true, 'smarty_internal_compile_if.php' => true, 'smarty_internal_compile_include.php' => true, 'smarty_internal_compile_include_php.php' => true, 'smarty_internal_compile_insert.php' => true, 'smarty_internal_compile_ldelim.php' => true, 'smarty_internal_compile_nocache.php' => true, 'smarty_internal_compile_private_block_plugin.php' => true, 'smarty_internal_compile_private_foreachsection.php' => true, 'smarty_internal_compile_private_function_plugin.php' => true, 'smarty_internal_compile_private_modifier.php' => true, 'smarty_internal_compile_private_object_block_function.php' => true, 'smarty_internal_compile_private_object_function.php' => true, 'smarty_internal_compile_private_php.php' => true, 'smarty_internal_compile_private_print_expression.php' => true, 'smarty_internal_compile_private_registered_block.php' => true, 'smarty_internal_compile_private_registered_function.php' => true, 'smarty_internal_compile_private_special_variable.php' => true, 'smarty_internal_compile_rdelim.php' => true, 'smarty_internal_compile_section.php' => true, 'smarty_internal_compile_setfilter.php' => true, 'smarty_internal_compile_shared_inheritance.php' => true, 'smarty_internal_compile_while.php' => true, 'smarty_internal_configfilelexer.php' => true, 'smarty_internal_configfileparser.php' => true, 'smarty_internal_config_file_compiler.php' => true, 'smarty_internal_data.php' => true, 'smarty_internal_debug.php' => true, 'smarty_internal_extension_clear.php' => true, 'smarty_internal_extension_handler.php' => true, 'smarty_internal_method_addautoloadfilters.php' => true, 'smarty_internal_method_adddefaultmodifiers.php' => true, 'smarty_internal_method_append.php' => true, 'smarty_internal_method_appendbyref.php' => true, 'smarty_internal_method_assignbyref.php' => true, 'smarty_internal_method_assignglobal.php' => true, 'smarty_internal_method_clearallassign.php' => true, 'smarty_internal_method_clearallcache.php' => true, 'smarty_internal_method_clearassign.php' => true, 'smarty_internal_method_clearcache.php' => true, 'smarty_internal_method_clearcompiledtemplate.php' => true, 'smarty_internal_method_clearconfig.php' => true, 'smarty_internal_method_compileallconfig.php' => true, 'smarty_internal_method_compilealltemplates.php' => true, 'smarty_internal_method_configload.php' => true, 'smarty_internal_method_createdata.php' => true, 'smarty_internal_method_getautoloadfilters.php' => true, 'smarty_internal_method_getconfigvars.php' => true, 'smarty_internal_method_getdebugtemplate.php' => true, 'smarty_internal_method_getdefaultmodifiers.php' => true, 'smarty_internal_method_getglobal.php' => true, 'smarty_internal_method_getregisteredobject.php' => true, 'smarty_internal_method_getstreamvariable.php' => true, 'smarty_internal_method_gettags.php' => true, 'smarty_internal_method_gettemplatevars.php' => true, 'smarty_internal_method_loadfilter.php' => true, 'smarty_internal_method_loadplugin.php' => true, 'smarty_internal_method_mustcompile.php' => true, 'smarty_internal_method_registercacheresource.php' => true, 'smarty_internal_method_registerclass.php' => true, 'smarty_internal_method_registerdefaultconfighandler.php' => true, 'smarty_internal_method_registerdefaultpluginhandler.php' => true, 'smarty_internal_method_registerdefaulttemplatehandler.php' => true, 'smarty_internal_method_registerfilter.php' => true, 'smarty_internal_method_registerobject.php' => true, 'smarty_internal_method_registerplugin.php' => true, 'smarty_internal_method_registerresource.php' => true, 'smarty_internal_method_setautoloadfilters.php' => true, 'smarty_internal_method_setdebugtemplate.php' => true, 'smarty_internal_method_setdefaultmodifiers.php' => true, 'smarty_internal_method_unloadfilter.php' => true, 'smarty_internal_method_unregistercacheresource.php' => true, 'smarty_internal_method_unregisterfilter.php' => true, 'smarty_internal_method_unregisterobject.php' => true, 'smarty_internal_method_unregisterplugin.php' => true, 'smarty_internal_method_unregisterresource.php' => true, 'smarty_internal_nocache_insert.php' => true, 'smarty_internal_parsetree.php' => true, 'smarty_internal_parsetree_code.php' => true, 'smarty_internal_parsetree_dq.php' => true, 'smarty_internal_parsetree_dqcontent.php' => true, 'smarty_internal_parsetree_tag.php' => true, 'smarty_internal_parsetree_template.php' => true, 'smarty_internal_parsetree_text.php' => true, 'smarty_internal_resource_eval.php' => true, 'smarty_internal_resource_extends.php' => true, 'smarty_internal_resource_file.php' => true, 'smarty_internal_resource_php.php' => true, 'smarty_internal_resource_registered.php' => true, 'smarty_internal_resource_stream.php' => true, 'smarty_internal_resource_string.php' => true, 'smarty_internal_runtime_cachemodify.php' => true, 'smarty_internal_runtime_codeframe.php' => true, 'smarty_internal_runtime_filterhandler.php' => true, 'smarty_internal_runtime_foreach.php' => true, 'smarty_internal_runtime_getincludepath.php' => true, 'smarty_internal_runtime_inheritance.php' => true, 'smarty_internal_runtime_tplfunction.php' => true, 'smarty_internal_runtime_updatecache.php' => true, 'smarty_internal_runtime_updatescope.php' => true, 'smarty_internal_runtime_writefile.php' => true, 'smarty_internal_smartytemplatecompiler.php' => true, 'smarty_internal_template.php' => true, 'smarty_internal_templatebase.php' => true, 'smarty_internal_templatecompilerbase.php' => true, 'smarty_internal_templatelexer.php' => true, 'smarty_internal_templateparser.php' => true, 'smarty_internal_testinstall.php' => true, 'smarty_internal_undefined.php' => true, 'smarty_resource.php' => true, 'smarty_resource_custom.php' => true, 'smarty_resource_recompiled.php' => true, 'smarty_resource_uncompiled.php' => true, 'smarty_security.php' => true, 'smarty_template_cached.php' => true, 'smarty_template_compiled.php' => true, 'smarty_template_config.php' => true, 'smarty_template_resource_base.php' => true, 'smarty_template_source.php' => true, 'smarty_undefined_variable.php' => true, 'smarty_variable.php' => true);
         $iterator = new DirectoryIterator($source);
         foreach ($iterator as $file) {
             if (!$file->isDot()) {
                 $filename = $file->getFilename();
                 if (isset($expectedSysplugins[$filename])) {
                     unset($expectedSysplugins[$filename]);
                 }
             }
         }
         if ($expectedSysplugins) {
             $status = false;
             $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expectedSysplugins));
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['sysplugins'] = $message;
             }
         } elseif ($errors === null) {
             echo "... OK\n";
         }
     } else {
         $status = false;
         $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory';
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['sysplugins_dir_constant'] = $message;
         }
     }
     if ($errors === null) {
         echo "Testing plugin files...\n";
     }
     // test if core plugins are available
     $source = SMARTY_PLUGINS_DIR;
     if (is_dir($source)) {
         $expectedPlugins = array('block.textformat.php' => true, 'function.counter.php' => true, 'function.cycle.php' => true, 'function.fetch.php' => true, 'function.html_checkboxes.php' => true, 'function.html_image.php' => true, 'function.html_options.php' => true, 'function.html_radios.php' => true, 'function.html_select_date.php' => true, 'function.html_select_time.php' => true, 'function.html_table.php' => true, 'function.mailto.php' => true, 'function.math.php' => true, 'modifier.capitalize.php' => true, 'modifier.date_format.php' => true, 'modifier.debug_print_var.php' => true, 'modifier.escape.php' => true, 'modifier.regex_replace.php' => true, 'modifier.replace.php' => true, 'modifier.spacify.php' => true, 'modifier.truncate.php' => true, 'modifiercompiler.cat.php' => true, 'modifiercompiler.count_characters.php' => true, 'modifiercompiler.count_paragraphs.php' => true, 'modifiercompiler.count_sentences.php' => true, 'modifiercompiler.count_words.php' => true, 'modifiercompiler.default.php' => true, 'modifiercompiler.escape.php' => true, 'modifiercompiler.from_charset.php' => true, 'modifiercompiler.indent.php' => true, 'modifiercompiler.lower.php' => true, 'modifiercompiler.noprint.php' => true, 'modifiercompiler.string_format.php' => true, 'modifiercompiler.strip.php' => true, 'modifiercompiler.strip_tags.php' => true, 'modifiercompiler.to_charset.php' => true, 'modifiercompiler.unescape.php' => true, 'modifiercompiler.upper.php' => true, 'modifiercompiler.wordwrap.php' => true, 'outputfilter.trimwhitespace.php' => true, 'shared.escape_special_chars.php' => true, 'shared.literal_compiler_param.php' => true, 'shared.make_timestamp.php' => true, 'shared.mb_str_replace.php' => true, 'shared.mb_unicode.php' => true, 'shared.mb_wordwrap.php' => true, 'variablefilter.htmlspecialchars.php' => true);
         $iterator = new DirectoryIterator($source);
         foreach ($iterator as $file) {
             if (!$file->isDot()) {
                 $filename = $file->getFilename();
                 if (isset($expectedPlugins[$filename])) {
                     unset($expectedPlugins[$filename]);
                 }
             }
         }
         if ($expectedPlugins) {
             $status = false;
             $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expectedPlugins));
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins'] = $message;
             }
         } elseif ($errors === null) {
             echo "... OK\n";
         }
     } else {
         $status = false;
         $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory';
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['plugins_dir_constant'] = $message;
         }
     }
     if ($errors === null) {
         echo "Tests complete.\n";
         echo "</PRE>\n";
     }
     return $status;
 }
Esempio n. 19
0
 public function GetTemplateDir()
 {
     return $this->oSmarty->getTemplateDir();
 }
 /**
  * diagnose Smarty setup
  *
  * If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
  *
  * @param Smarty $smarty  Smarty instance to test
  * @param array  $errors array to push results into rather than outputting them
  * @return bool status, true if everything is fine, false else
  */
 public static function testInstall(Smarty $smarty, &$errors = null)
 {
     $status = true;
     if ($errors === null) {
         echo "<PRE>\n";
         echo "Smarty Installation test...\n";
         echo "Testing template directory...\n";
     }
     // test if all registered template_dir are accessible
     foreach ($smarty->getTemplateDir() as $template_dir) {
         if (!is_dir($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } elseif (!is_readable($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } else {
             if ($errors === null) {
                 echo "{$template_dir} is OK.\n";
             }
         }
     }
     if ($errors === null) {
         echo "Testing compile directory...\n";
     }
     // test if registered compile_dir is accessible
     $_compile_dir = $smarty->getCompileDir();
     if (!is_dir($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_readable($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not readable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_writable($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not writable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } else {
         if ($errors === null) {
             echo "{$_compile_dir} is OK.\n";
         }
     }
     if ($errors === null) {
         echo "Testing plugins directory...\n";
     }
     // test if all registered plugins_dir are accessible
     // and if core plugins directory is still registered
     $_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
     $_core_plugins_available = false;
     foreach ($smarty->getPluginsDir() as $plugin_dir) {
         if (!is_dir($plugin_dir)) {
             $status = false;
             $message = "FAILED: {$plugin_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif (!is_readable($plugin_dir)) {
             $status = false;
             $message = "FAILED: {$plugin_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins_dir'] = $message;
             }
         } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
             $_core_plugins_available = true;
         } else {
             if ($errors === null) {
                 echo "{$plugin_dir} is OK.\n";
             }
         }
     }
     if (!$_core_plugins_available) {
         $status = false;
         $message = "WARNING: Smarty's own libs/plugins is not available";
         if ($errors === null) {
             echo $message . ".\n";
         } elseif (!isset($errors['plugins_dir'])) {
             $errors['plugins_dir'] = $message;
         }
     }
     if ($errors === null) {
         echo "Testing cache directory...\n";
     }
     $_cache_dir = $smarty->getCacheDir();
     // test if all registered cache_dir is accessible
     if (!is_dir($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_readable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not readable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } elseif (!is_writable($_cache_dir)) {
         $status = false;
         $message = "FAILED: {$_cache_dir} is not writable";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['cache_dir'] = $message;
         }
     } else {
         if ($errors === null) {
             echo "{$_cache_dir} is OK.\n";
         }
     }
     if ($errors === null) {
         echo "Testing configs directory...\n";
     }
     // test if all registered config_dir are accessible
     foreach ($smarty->getConfigDir() as $config_dir) {
         if (!is_dir($config_dir)) {
             $status = false;
             $message = "FAILED: {$config_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['config_dir'] = $message;
             }
         } elseif (!is_readable($config_dir)) {
             $status = false;
             $message = "FAILED: {$config_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['config_dir'] = $message;
             }
         } else {
             if ($errors === null) {
                 echo "{$config_dir} is OK.\n";
             }
         }
     }
     if ($errors === null) {
         echo "Testing sysplugin files...\n";
     }
     // test if sysplugins are available
     $source = SMARTY_SYSPLUGINS_DIR;
     if (is_dir($source)) {
         $expected = array("smarty_cacheresource.php" => true, "smarty_cacheresource_custom.php" => true, "smarty_cacheresource_keyvaluestore.php" => true, "smarty_config_source.php" => true, "smarty_internal_cacheresource_file.php" => true, "smarty_internal_compile_append.php" => true, "smarty_internal_compile_assign.php" => true, "smarty_internal_compile_block.php" => true, "smarty_internal_compile_break.php" => true, "smarty_internal_compile_call.php" => true, "smarty_internal_compile_capture.php" => true, "smarty_internal_compile_config_load.php" => true, "smarty_internal_compile_continue.php" => true, "smarty_internal_compile_debug.php" => true, "smarty_internal_compile_eval.php" => true, "smarty_internal_compile_extends.php" => true, "smarty_internal_compile_for.php" => true, "smarty_internal_compile_foreach.php" => true, "smarty_internal_compile_function.php" => true, "smarty_internal_compile_if.php" => true, "smarty_internal_compile_include.php" => true, "smarty_internal_compile_include_php.php" => true, "smarty_internal_compile_insert.php" => true, "smarty_internal_compile_ldelim.php" => true, "smarty_internal_compile_nocache.php" => true, "smarty_internal_compile_private_block_plugin.php" => true, "smarty_internal_compile_private_function_plugin.php" => true, "smarty_internal_compile_private_modifier.php" => true, "smarty_internal_compile_private_object_block_function.php" => true, "smarty_internal_compile_private_object_function.php" => true, "smarty_internal_compile_private_print_expression.php" => true, "smarty_internal_compile_private_registered_block.php" => true, "smarty_internal_compile_private_registered_function.php" => true, "smarty_internal_compile_private_special_variable.php" => true, "smarty_internal_compile_rdelim.php" => true, "smarty_internal_compile_section.php" => true, "smarty_internal_compile_setfilter.php" => true, "smarty_internal_compile_while.php" => true, "smarty_internal_compilebase.php" => true, "smarty_internal_config.php" => true, "smarty_internal_config_file_compiler.php" => true, "smarty_internal_configfilelexer.php" => true, "smarty_internal_configfileparser.php" => true, "smarty_internal_data.php" => true, "smarty_internal_debug.php" => true, "smarty_internal_filter_handler.php" => true, "smarty_internal_function_call_handler.php" => true, "smarty_internal_get_include_path.php" => true, "smarty_internal_nocache_insert.php" => true, "smarty_internal_parsetree.php" => true, "smarty_internal_resource_eval.php" => true, "smarty_internal_resource_extends.php" => true, "smarty_internal_resource_file.php" => true, "smarty_internal_resource_registered.php" => true, "smarty_internal_resource_stream.php" => true, "smarty_internal_resource_string.php" => true, "smarty_internal_smartytemplatecompiler.php" => true, "smarty_internal_template.php" => true, "smarty_internal_templatebase.php" => true, "smarty_internal_templatecompilerbase.php" => true, "smarty_internal_templatelexer.php" => true, "smarty_internal_templateparser.php" => true, "smarty_internal_utility.php" => true, "smarty_internal_write_file.php" => true, "smarty_resource.php" => true, "smarty_resource_custom.php" => true, "smarty_resource_recompiled.php" => true, "smarty_resource_uncompiled.php" => true, "smarty_security.php" => true);
         $iterator = new DirectoryIterator($source);
         foreach ($iterator as $file) {
             if (!$file->isDot()) {
                 $filename = $file->getFilename();
                 if (isset($expected[$filename])) {
                     unset($expected[$filename]);
                 }
             }
         }
         if ($expected) {
             $status = false;
             $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expected));
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['sysplugins'] = $message;
             }
         } elseif ($errors === null) {
             echo "... OK\n";
         }
     } else {
         $status = false;
         $message = "FAILED: " . SMARTY_SYSPLUGINS_DIR . ' is not a directory';
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['sysplugins_dir_constant'] = $message;
         }
     }
     if ($errors === null) {
         echo "Testing plugin files...\n";
     }
     // test if core plugins are available
     $source = SMARTY_PLUGINS_DIR;
     if (is_dir($source)) {
         $expected = array("block.textformat.php" => true, "function.counter.php" => true, "function.cycle.php" => true, "function.fetch.php" => true, "function.html_checkboxes.php" => true, "function.html_image.php" => true, "function.html_options.php" => true, "function.html_radios.php" => true, "function.html_select_date.php" => true, "function.html_select_time.php" => true, "function.html_table.php" => true, "function.mailto.php" => true, "function.math.php" => true, "modifier.capitalize.php" => true, "modifier.date_format.php" => true, "modifier.debug_print_var.php" => true, "modifier.escape.php" => true, "modifier.regex_replace.php" => true, "modifier.replace.php" => true, "modifier.spacify.php" => true, "modifier.truncate.php" => true, "modifiercompiler.cat.php" => true, "modifiercompiler.count_characters.php" => true, "modifiercompiler.count_paragraphs.php" => true, "modifiercompiler.count_sentences.php" => true, "modifiercompiler.count_words.php" => true, "modifiercompiler.default.php" => true, "modifiercompiler.escape.php" => true, "modifiercompiler.from_charset.php" => true, "modifiercompiler.indent.php" => true, "modifiercompiler.lower.php" => true, "modifiercompiler.noprint.php" => true, "modifiercompiler.string_format.php" => true, "modifiercompiler.strip.php" => true, "modifiercompiler.strip_tags.php" => true, "modifiercompiler.to_charset.php" => true, "modifiercompiler.unescape.php" => true, "modifiercompiler.upper.php" => true, "modifiercompiler.wordwrap.php" => true, "outputfilter.trimwhitespace.php" => true, "shared.escape_special_chars.php" => true, "shared.literal_compiler_param.php" => true, "shared.make_timestamp.php" => true, "shared.mb_str_replace.php" => true, "shared.mb_unicode.php" => true, "shared.mb_wordwrap.php" => true, "variablefilter.htmlspecialchars.php" => true);
         $iterator = new DirectoryIterator($source);
         foreach ($iterator as $file) {
             if (!$file->isDot()) {
                 $filename = $file->getFilename();
                 if (isset($expected[$filename])) {
                     unset($expected[$filename]);
                 }
             }
         }
         if ($expected) {
             $status = false;
             $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expected));
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['plugins'] = $message;
             }
         } elseif ($errors === null) {
             echo "... OK\n";
         }
     } else {
         $status = false;
         $message = "FAILED: " . SMARTY_PLUGINS_DIR . ' is not a directory';
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['plugins_dir_constant'] = $message;
         }
     }
     if ($errors === null) {
         echo "Tests complete.\n";
         echo "</PRE>\n";
     }
     return $status;
 }
Esempio n. 21
0
 /**
  * @param null $index
  * @return array|string
  */
 public function getTemplateDir($index = null)
 {
     return $this->smarty->getTemplateDir($index);
 }