From: stevetruckstuff Date: Fri, 24 Feb 2006 22:32:11 +0000 (+0000) Subject: Incoproated template config file. Templates can now include their own javascript... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=444521363b142dd4c935eb7ec158c84c842587ff;p=squirrelmail.git Incoproated template config file. Templates can now include their own javascript files. Also, if a template pack does not incorporate a specific template, the default template will be used instead. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10826 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/class/template/template.class.php b/class/template/template.class.php index 9d307b44..9b413a32 100755 --- a/class/template/template.class.php +++ b/class/template/template.class.php @@ -42,6 +42,29 @@ class Template */ var $template_dir = ''; + /** + * Template files provided by this template set + * + * @var array + */ + var $templates_provided = array(); + + /** + * Javascript files required by the template + * + * @var array + */ + var $required_js_files = array(); + + /** + * Javascript files provided by the template. If a JS file is required, but + * not provided, the js file by the same name will be included from the + * default template directory. + * + * @var array + */ + var $provided_js_files = array(); + /** * Constructor * @@ -49,6 +72,15 @@ class Template */ function Template($sTplDir) { $this->template_dir = $sTplDir; + + // Pull in the tempalte config file + include ($this->template_dir . 'template.php'); + $this->templates_provided = is_array($templates_provided) ? $templates_provided : array(); + $this->required_js_files = is_array($required_js_files) ? $required_js_files : array(); + $this->provided_js_files = is_array($provided_js_files) ? $provided_js_files: array(); + +# echo 'Template Dir: '.$this->template_dir.': '; +# var_dump($this->templates_provided); } @@ -161,9 +193,12 @@ class Template */ function display($file) { + // Pull in our config file $t = &$this->values; // place values array directly in scope + + $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file; ob_start(); - include($this->template_dir.$file); + include($template); ob_end_flush(); } @@ -177,12 +212,30 @@ class Template { ob_start(); $t = &$this->values; // place values array directly in scope - include($this->template_dir.$file); + + $template = in_array($file, $this->templates_provided) ? $this->template_dir . $file : SM_PATH .'templates/default/'. $file; + include($template); $contents = ob_get_contents(); ob_end_clean(); return $contents; } + /** + * Return paths to the required javascript files. Used when generating page + * header. + * + * @return array $paths + */ + function getJavascriptIncludes () { + $paths = array(); + foreach ($this->required_js_files as $file) { + if (in_array($file, $this->provided_js_files)) + $paths[] = './'.$this->template_dir.'js/'.basename($file); + else $paths[] = SM_PATH .'templates/default/js/'.basename($file); + } + + return $paths; + } } ?> diff --git a/images/themes/template/theme.php b/images/themes/template/theme.php index a0624869..b5a0dd46 100644 --- a/images/themes/template/theme.php +++ b/images/themes/template/theme.php @@ -9,5 +9,5 @@ * @package squirrelmail * @subpackage themes */ - $icon_themes[] = array('NAME'=>_("Template Default"),'PATH'=> $sTplDir.'images/'); + $icon_themes[] = array('NAME'=>_("Template Default"),'PATH'=> 'template'); ?> \ No newline at end of file diff --git a/templates/default/left_main.tpl b/templates/default/left_main.tpl index 242e7780..43e26a8a 100644 --- a/templates/default/left_main.tpl +++ b/templates/default/left_main.tpl @@ -2,38 +2,36 @@ /** * left_main.tpl * - * Basic template to the left main window. The following variables are - * avilable in this template: + * Basic template to the left main window. + * + * The following variables are avilable in this template: * $clock - formatted string containing last refresh - * $mailbox_listing - string containing HTML to display default mailbox - * tree - * $location_of_bar - string "left" or "right" indicating where the frame - * is located. Currently only used in - * left_main_advanced.tpl - * $left_size - width of left column in pixels. Currently - * only used in left_main_advanced. tpl - * $imapConnection - IMAP connection handle. Needed to allow plugins to - * read the mailbox. - * $icon_theme_path - Path to the desired icon theme. If the user/admin - * has disabled icons, this will be NULL. - * - * $unread_notification_enabled - Boolean TRUE if the user wants to see - * unread message count on mailboxes - * $unread_notification_cummulative - Boolean TRUE if the user has enabled - * cummulative message counts. - * $unread_notification_allFolders - Boolean TRUE if the user wants to see - * unread message count on ALL folders or just the - * mailbox. - * $unread_notification_displayTotal - Boolean TRUE if the user wants to - * see the total number of messages in addition to the - * unread message count. - * $collapsable_folders_enabled - Boolean TRUE if the user has enabled - * collapsable folders. - * $use_special_folder_color - Boolean TRUE if the use has chosen to tag - * "Special" folders in a different color. - * $message_recycling_enabled - Boolean TRUE if messages that get deleted - * go to the Trash folder. FALSE if they are - * permanently deleted. + * $settings - Array containing user perferences needed by this + * template. Indexes are as follows: + * $settings['imapConnection'] - IMAP connection handle. Needed to + * allow plugins to read the mailbox. + * $settings['iconThemePath'] - Path to the desired icon theme. If + * the user has disabled icons, this will be NULL. + * $settings['templateDirectory'] - contains the path to the current + * template directory. This may be needed by third + * party packages that don't integrate easily. + * $settings['unreadNotificationEnabled'] - Boolean TRUE if the user + * wants to see unread message count on mailboxes + * $settings['unreadNotificationCummulative'] - Boolean TRUE if the + * user has enabled cummulative message counts. + * $settings['unreadNotificationAllFolders'] - Boolean TRUE if the + * user wants to see unread message count on ALL + * folders or just the Inbox. + * $settings['unreadNotificationDisplayTotal'] - Boolean TRUE if the + * user wants to see the total number of messages in + * addition to the unread message count. + * $settings['collapsableFoldersEnabled'] - Boolean TRUE if the user + * has enabled collapsable folders. + * $settings['useSpecialFolderColor'] - Boolean TRUE if the use has + * chosen to tag "Special" folders in a different color + * $settings['messageRecyclingEnabled'] - Boolean TRUE if messages + * that get deleted go to the Trash folder. FALSE if + * they are permanently deleted. * * $mailboxes - Associative array of current mailbox structure. * Provided so template authors know what they have to @@ -47,39 +45,32 @@ * mailbox. Elements are: * 'Target' = target frame for link * 'URL' = target URL for link - * $a['IsRecent'] = boolean TRUE if mailbox is tagged "recent" - * $a['IsSpecial'] = boolean TRUE if mailbox is tagged "special" - * $a['IsRoot'] = boolean TRUE if mailbox is the root mailbox - * $a['IsNoSelect'] = boolean TRUE if mailbox is tagged "noselect" - * $a['IsInbox'] = boolean TRUE if mailbox is the Inbox. - * $a['IsSent'] = boolean TRUE if mailbox is the Sent box - * $a['IsTrash'] = boolean TRUE if mailbox is the Trash box - * $a['IsDraft'] = boolean TRUE if mailbox is the Draft box - * $a['IsNoInferiors'] = boolean TRUE of mailbox is tagged "no - * inferiors" - * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently - * collapsed - * - * $a['CollapseLink'] = array containg elements needed to - * expand/collapse the mailbox. Elements are: - * 'Target' = target frame for link - * 'URL' = target URL for link - * 'Icon' = the icon to use, based on - * user prefs + * $a['IsRecent'] = boolean TRUE if the mailbox is tagged "recent" + * $a['IsSpecial'] = boolean TRUE if the mailbox is tagged "special" + * $a['IsRoot'] = boolean TRUE if the mailbox is the root mailbox + * $a['IsNoSelect'] = boolean TRUE if the mailbox is tagged "noselect" + * $a['IsCollapsed'] = boolean TRUE if the mailbox is currently collapsed + * $a['CollapseLink'] = array containg elements needed to expand/collapse + * the mailbox. Elements are: + * 'Target' = target frame for link + * 'URL' = target URL for link + * 'Icon' = the icon to use, based on user prefs * $a['ChildBoxes'] = array containing this same data structure for - * each child folder/mailbox. - * $a ['CummulativeMessageCount'] = integer of total messages in all - * folders in this mailbox, exlcuding trash - * folders. - * $a ['CummulativeUnreadCount'] = integer of total unseen messages - * in all folders in this mailbox, excluding - * trash folders. + * each child folder/mailbox of the current + * mailbox. + * $a['CummulativeMessageCount'] = integer of total messages in all + * folders in this mailbox, exlcuding + * trash folders. + * $a['CummulativeUnreadCount'] = integer of total unseen messages + * in all folders in this mailbox, + * excluding trash folders. * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail * @subpackage templates + * @author Steve Brown */ // include required files @@ -264,21 +255,6 @@ function buildMailboxTree ($box, $settings, $indent_factor=0) { // Retrieve the template vars extract($t); -/* - * Build an array to pass user prefs to the function that builds the tree in - * order to avoid using globals, which are dirty, filthy things in templates. :) - */ -$settings = array(); -$settings['imapConnection'] = $imapConnection; -$settings['iconThemePath'] = $icon_theme_path; -$settings['unreadNotificationEnabled'] = $unread_notification_enabled; -$settings['unreadNotificationAllFolders'] = $unread_notification_allFolders; -$settings['unreadNotificationDisplayTotal'] = $unread_notification_displayTotal; -$settings['unreadNotificationCummulative'] = $unread_notification_cummulative; -$settings['useSpecialFolderColor'] = $use_special_folder_color; -$settings['messageRecyclingEnabled'] = $message_recycling_enabled; -$settings['collapsableFoldersEnabled'] = $collapsable_folders_enabled; - ?>
diff --git a/templates/default/left_main_advanced.tpl b/templates/default/left_main_advanced.tpl deleted file mode 100644 index 1bebd474..00000000 --- a/templates/default/left_main_advanced.tpl +++ /dev/null @@ -1,383 +0,0 @@ - - - - - -
- -
- - - - -
-
-
-
-
- - - - - -
- - - - -
-
- - [] -
-
- -
- -
\ No newline at end of file