From 8244efdb1db645bc5c72e9bd6a26cfbe8e3276c2 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 19 Jun 2013 10:33:29 +0200 Subject: [PATCH] Cleanup --- .../Templating/Smarty/AssetManager.class.php | 87 ---------- core/lib/Thelia/Admin/Templating/Template.php | 150 ------------------ templates/admin/default/home.tpl | 0 .../admin/default/includes/footer.inc.tpl | 13 -- .../admin/default/includes/header.inc.tpl | 24 --- templates/admin/default/includes/menu.tpl | 0 templates/admin/default/login.tpl | 35 ---- templates/admin/default/template.xml | 1 - templates/smarty-sample/index.html | 3 + 9 files changed, 3 insertions(+), 310 deletions(-) delete mode 100644 core/lib/Thelia/Admin/Templating/Smarty/AssetManager.class.php delete mode 100644 core/lib/Thelia/Admin/Templating/Template.php delete mode 100644 templates/admin/default/home.tpl delete mode 100644 templates/admin/default/includes/footer.inc.tpl delete mode 100644 templates/admin/default/includes/header.inc.tpl delete mode 100644 templates/admin/default/includes/menu.tpl delete mode 100644 templates/admin/default/login.tpl delete mode 100644 templates/admin/default/template.xml diff --git a/core/lib/Thelia/Admin/Templating/Smarty/AssetManager.class.php b/core/lib/Thelia/Admin/Templating/Smarty/AssetManager.class.php deleted file mode 100644 index be9d1589e..000000000 --- a/core/lib/Thelia/Admin/Templating/Smarty/AssetManager.class.php +++ /dev/null @@ -1,87 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Admin\Templating\Smarty; - -use Thelia\Template\Assets\AsseticManager; - -class AssetsManager extends AsseticManager { - - const ASSET_TYPE_AUTO = ''; - - private $assetic_manager; - - private $web_root; - private $path_relative_to_web_root; - - /** - * - * @param string $web_root the disk path to the web root - * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated - */ - public function __construct($web_root, $path_relative_to_web_root) { - - parent::__construct(); - - $this->web_root = $web_root; - $this->path_relative_to_web_root = $path_relative_to_web_root; - - $this->assetic_manager = new AsseticManager(); - } - - public function processSmartyPluginCall($assetType, $params, $content, \Smarty_Internal_Template $template, &$repeat) { - - // Opening tag (first call only) - if ($repeat) { - $file = $params['file']; - $filters = isset($params['filters']) ? $params['filters'] : ''; - $debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false; - - // Get template base path - $tpl_path = $template->source->filepath; - - // Get basedir - $tpl_dir = dirname($tpl_path); - - // Create absolute dir path - $asset_dir = realpath($tpl_dir.'/'.dirname($file)); - $asset_file = basename($file); - - if ($asset_dir === false) throw new \Exception("Failed to get real path of '".$tpl_dir.'/'.dirname($file)."'"); - - $url = $this->assetic_manager->asseticize( - $asset_dir.'/'.$asset_file, - $this->web_root."/".$this->path_relative_to_web_root, - $this->path_relative_to_web_root, - $assetType, - $filters, - $debug - ); - - $template->assign('asset_url', $url); - } - else if (isset($content)) { - return $content; - } - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Admin/Templating/Template.php b/core/lib/Thelia/Admin/Templating/Template.php deleted file mode 100644 index 99387367a..000000000 --- a/core/lib/Thelia/Admin/Templating/Template.php +++ /dev/null @@ -1,150 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Admin\Templating; - -use \Smarty; -use Thelia\Admin\Templating\Smarty\AssetsManager; - -// smarty configuration -class Template extends Smarty -{ - private $asset_manager; - - public function __construct() - { - parent::__construct(); - - $compile_dir = THELIA_ROOT . 'cache/smarty/compile'; - if (! is_dir($compile_dir)) @mkdir($compile_dir, 0777, true); - - $cache_dir = THELIA_ROOT . 'cache/smarty/cache'; - if (! is_dir($cache_dir)) @mkdir($cache_dir, 0777, true); - - $web_root = THELIA_WEB_DIR; - - $asset_dir_from_web_root = 'assets/admin/default'; // FIXME - - $this->asset_manager = new AssetsManager($web_root, $asset_dir_from_web_root); - - $this->setTemplateDir(__DIR__.'/../template/default'); // FIXME - a parametrer - - $this->setCompileDir($compile_dir); - $this->setCacheDir($cache_dir); - - // Register translation function 'intl' - $this->registerPlugin('function', 'intl', array($this, 'smartyTranslate')); - - // Register Thelia modules inclusion function 'thelia_module' - $this->registerPlugin('function', 'thelia_module', array($this, 'smartyTheliaModule')); - - // Register asset management blocks - $this->registerPlugin('block', 'stylesheets', array($this, 'smartyBlockStylesheets')); - $this->registerPlugin('block', 'javascripts', array($this, 'smartyBlockJavascripts')); - $this->registerPlugin('block', 'images', array($this, 'smartyBlockImages')); - - /* - $this->setConfigDir(GUESTBOOK_DIR . 'configs'); - */ - - // Set base config - $this->assign('lang', 'fr'); - - $this->assign('email', ''); - } - - public function smartyTranslate($params, &$smarty) - { - if (isset($params['l'])) { - $string = str_replace('\'', '\\\'', $params['l']); - } - else { - $string = ''; - } - - // TODO - - return "[$string]"; - } - - public function smartyTheliaModule($params, &$smarty) - { - // TODO - return ""; - } - - public function smartyBlockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat) - { - return $this->asset_manager->processSmartyPluginCall('js', $params, $content, $template, $repeat); - } - - public function smartyBlockImages($params, $content, \Smarty_Internal_Template $template, &$repeat) - { - return $this->asset_manager->processSmartyPluginCall(AssetsManager::ASSET_TYPE_AUTO, $params, $content, $template, $repeat); - } - - public function smartyBlockStylesheets($params, $content, \Smarty_Internal_Template $template, &$repeat) - { - return $this->asset_manager->processSmartyPluginCall('css', $params, $content, $template, $repeat); - } - - - public function render($templateName, $parameters) - { - $realTemplateName = $templateName . '.tpl'; - - /** - * Assign variables/objects to the templates. - * - * Description - * void assign(mixed var); - * void assign(string varname, mixed var, bool nocache); - * - * You can explicitly pass name/value pairs, or associative arrays - * containing the name/value pairs. - * - * If you pass the optional third nocache parameter of TRUE, the - * variable is assigned as nocache variable. See {@link http://www.smarty.net/docs/en/caching.cacheable.tpl#cacheability.variables} for details. - * - * Too learn more see {@link http://www.smarty.net/docs/en/api.assign.tpl} - */ - $this->smarty->assign($parameters); - - /** - * This returns the template output instead of displaying it. Supply a - * valid template resource type and path. As an optional second - * parameter, you can pass a $cache id, see the caching section for more - * information. - * - * As an optional third parameter, you can pass a $compile_id. This is - * in the event that you want to compile different versions of the same - * template, such as having separate templates compiled for different - * languages. You can also set the $compile_id variable once instead of - * passing this to each call to this function. - * - * Too learn more see {@link http://www.smarty.net/docs/en/api.fetch.tpl} - */ - - return $this->smarty->fetch($realTemplateName); - } -} -?> \ No newline at end of file diff --git a/templates/admin/default/home.tpl b/templates/admin/default/home.tpl deleted file mode 100644 index e69de29bb..000000000 diff --git a/templates/admin/default/includes/footer.inc.tpl b/templates/admin/default/includes/footer.inc.tpl deleted file mode 100644 index 3d0e58427..000000000 --- a/templates/admin/default/includes/footer.inc.tpl +++ /dev/null @@ -1,13 +0,0 @@ - {* Include required JS files *} - - {javascripts file='../assets/js/jquery.min.js'} - - {/javascripts} - - {javascripts file='../assets/bootstrap/js/bootstrap.min.js'} - - {/javascripts} - - {* TODO allow modules to include JS here *} - - \ No newline at end of file diff --git a/templates/admin/default/includes/header.inc.tpl b/templates/admin/default/includes/header.inc.tpl deleted file mode 100644 index fc19d6602..000000000 --- a/templates/admin/default/includes/header.inc.tpl +++ /dev/null @@ -1,24 +0,0 @@ - - - - {intl l='Thelia Back Office'}{if ! empty($page_title)} - {$page_title}{/if} - - {images file='../assets/img/favicon.ico'}{/images} - - - - {stylesheets file='../assets/css/*' filters='less,cssrewrite'} - - {/stylesheets} - - {stylesheets file='../assets/bootstrap/css/bootstrap.min.css' filters='cssrewrite'} - - {/stylesheets} - - {stylesheets file='../assets/bootstrap/css/bootstrap-responsive.min.css' filters='cssrewrite'} - - {/stylesheets} - - {* TODO allow modules to include CSS here *} - - \ No newline at end of file diff --git a/templates/admin/default/includes/menu.tpl b/templates/admin/default/includes/menu.tpl deleted file mode 100644 index e69de29bb..000000000 diff --git a/templates/admin/default/login.tpl b/templates/admin/default/login.tpl deleted file mode 100644 index 506e799c0..000000000 --- a/templates/admin/default/login.tpl +++ /dev/null @@ -1,35 +0,0 @@ -{$page_title={intl l='Thelia'}} -{include file='includes/header.inc.tpl'} - -
- - - -
- - {thelia_module action='index_top'} - -
-

{intl l='Thelia Back Office'}

- -
- - - - - - -
-
- -
- -
-
- - {thelia_module action='index_bottom'} -
- -{include file='includes/footer.inc.tpl'} \ No newline at end of file diff --git a/templates/admin/default/template.xml b/templates/admin/default/template.xml deleted file mode 100644 index b994f5362..000000000 --- a/templates/admin/default/template.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 4c9677c2d..f93dd3876 100644 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -65,6 +65,9 @@ An image from asset directory : {elseloop rel="catloop2"}

... but catloop2 is still empty :-)

{/elseloop} + {ifloop rel="catloop1"} +

... and catloop1 is still NOT empty :-)

+ {/ifloop}