Changeset 5123 for trunk/include
- Timestamp:
- Mar 13, 2010, 1:00:52 AM (14 years ago)
- Location:
- trunk/include
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/common.inc.php
r5021 r5123 159 159 or (defined('PWG_HELP') and PWG_HELP)) 160 160 {// Admin template 161 list($user['admin_template'], $user['admin_theme']) = 162 explode ('/', $conf['admin_layout']); 163 $template = new Template(PHPWG_ROOT_PATH.'admin/template/' 164 . $user['admin_template'], $user['admin_theme'] ); 161 $template = new Template(PHPWG_ROOT_PATH.'admin/themes', $conf['admin_theme']); 165 162 } 166 163 else 167 164 { // Classic template 168 $template = new Template(PHPWG_ROOT_PATH.'template/' 169 . $user['template'], $user['theme'] ); 165 $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme'] ); 170 166 } 171 167 -
trunk/include/config_default.inc.php
r5060 r5123 336 336 $conf['uniqueness_mode'] = 'md5sum'; 337 337 338 // Define default theme for your gallery 339 $conf['default_theme'] = 'Sylvia'; 340 338 341 // +-----------------------------------------------------------------------+ 339 342 // | metadata | … … 677 680 // +-----------------------------------------------------------------------+ 678 681 679 $conf['admin_ layout'] = 'goto/roma';682 $conf['admin_theme'] = 'roma'; 680 683 681 684 // should we load the active plugins ? true=Yes, false=No -
trunk/include/functions.inc.php
r5102 r5123 612 612 trigger_action('loading_lang'); 613 613 load_language('local.lang', '', array('no_fallback'=>true) ); 614 list($tmpl, $thm) = explode('/', get_default_template()); 615 $template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm); 614 $template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme()); 616 615 } 617 616 else 618 617 { 619 $template = new Template(PHPWG_ROOT_PATH.'t emplate/'.$user['template'], $user['theme']);618 $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']); 620 619 } 621 620 … … 711 710 712 711 /** 713 * returns available t emplate/theme712 * returns available themes 714 713 */ 715 714 function get_pwg_themes() … … 718 717 $themes = array(); 719 718 720 $template_dir = PHPWG_ROOT_PATH.'template'; 721 722 foreach (get_dirs($template_dir) as $template) 723 { 724 if ( $template != 'default' ) 725 { 726 foreach (get_dirs($template_dir.'/'.$template.'/theme') as $theme) 727 { 728 array_push($themes, $template.'/'.$theme); 729 } 730 } 719 $template_dir = PHPWG_ROOT_PATH.'themes'; 720 721 foreach (get_dirs($template_dir) as $theme) 722 { 723 if ( $theme != 'default' ) 724 { 725 array_push($themes, $theme); 726 } 731 727 } 732 728 -
trunk/include/functions_mail.inc.php
r5021 r5123 153 153 /** 154 154 * Returns an completed array template/theme 155 * completed with get_default_t emplate()155 * completed with get_default_theme() 156 156 * 157 157 * @params: 158 158 * - args: incompleted array of template/theme 159 * o template: template to use [default get_default_t emplate()]160 * o theme: template to use [default get_default_t emplate()]159 * o template: template to use [default get_default_theme()] 160 * o theme: template to use [default get_default_theme()] 161 161 */ 162 162 function get_array_template_theme($args = array()) … … 168 168 if (empty($args['template']) or empty($args['theme'])) 169 169 { 170 list($res['template'], $res['theme']) = explode('/', get_default_t emplate());170 list($res['template'], $res['theme']) = explode('/', get_default_theme()); 171 171 } 172 172 … … 190 190 * - email_format: mail format 191 191 * - args: function params of mail function: 192 * o template: template to use [default get_default_template()] 193 * o theme: template to use [default get_default_template()] 194 */ 195 function & get_mail_template($email_format, $args = array()) 196 { 197 $args = get_array_template_theme($args); 198 199 $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']); 200 $mail_template->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format); 192 * o template: template to use [default get_default_theme()] 193 * o theme: template to use [default get_default_theme()] 194 */ 195 function & get_mail_template($email_format, $theme='') 196 { 197 if (empty($theme)) 198 { 199 $theme = get_default_theme(); 200 } 201 202 $mail_template = new Template(PHPWG_ROOT_PATH.'themes', $theme, 'template/mail/'.$email_format); 203 201 204 return $mail_template; 202 205 } … … 418 421 $query = ' 419 422 SELECT 420 distinct language, t emplate423 distinct language, theme 421 424 FROM 422 425 '.USER_GROUP_TABLE.' as ug … … 443 446 while ($row = pwg_db_fetch_assoc($result)) 444 447 { 445 $row['template_theme'] = $row['template'];446 list($row['template'], $row['theme']) = explode('/', $row['template_theme']);447 448 $list[] = $row; 448 449 } … … 462 463 AND group_id = '.$group_id.' 463 464 AND language = \''.$elem['language'].'\' 464 AND t emplate = \''.$elem['template_theme'].'\'465 AND theme = \''.$elem['theme'].'\' 465 466 ;'; 466 467 … … 482 483 switch_lang_to($elem['language']); 483 484 484 $mail_template = get_mail_template($email_format, $elem );485 $mail_template = get_mail_template($email_format, $elem['theme']); 485 486 $mail_template->set_filename($tpl_shortname, $tpl_shortname.'.tpl'); 486 487 … … 498 499 'content' => $mail_template->parse($tpl_shortname, true), 499 500 'content_format' => $email_format, 500 'template' => $elem['template'],501 501 'theme' => $elem['theme'] 502 502 ) … … 525 525 * o content_format: format of mail content [default value 'text/plain'] 526 526 * o email_format: global mail format [default value $conf_mail['default_email_format']] 527 * o template: template to use [default get_default_template()] 528 * o theme: template to use [default get_default_template()] 527 * o theme: template to use [default get_default_theme()] 529 528 * 530 529 * @return boolean (Ok or not) … … 585 584 } 586 585 587 $args = array_merge($args, get_array_template_theme($args)); 586 if (empty($args['theme'])) 587 { 588 $args['theme'] = get_default_theme(); 589 } 588 590 589 591 $headers = 'From: '.$args['from']."\n"; … … 618 620 { 619 621 // key compose of indexes witch allow ti cache mail data 620 $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['t emplate'].'-'.$args['theme'];622 $cache_key = $content_type.'-'.$lang_info['code'].'-'.$args['theme']; 621 623 622 624 if (!isset($conf_mail[$cache_key])) 623 625 { 624 if (!isset($conf_mail[$cache_key]['t emplate']))626 if (!isset($conf_mail[$cache_key]['theme'])) 625 627 { 626 $conf_mail[$cache_key]['t emplate'] = get_mail_template($content_type);628 $conf_mail[$cache_key]['theme'] = get_mail_template($content_type); 627 629 } 628 630 629 $conf_mail[$cache_key]['t emplate']->set_filename('mail_header', 'header.tpl');630 $conf_mail[$cache_key]['t emplate']->set_filename('mail_footer', 'footer.tpl');631 632 $conf_mail[$cache_key]['t emplate']->assign(631 $conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl'); 632 $conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl'); 633 634 $conf_mail[$cache_key]['theme']->assign( 633 635 array( 634 636 //Header … … 653 655 if ($content_type == 'text/html') 654 656 { 655 if (is_file($conf_mail[$cache_key]['template']->get_template_dir().'/global-mail-css.tpl')) 657 /* 658 if (is_file($conf_mail[$cache_key]['theme']->get_template_dir().'/global-mail-css.tpl')) 656 659 { 657 $conf_mail[$cache_key]['t emplate']->set_filename('css', 'global-mail-css.tpl');658 $conf_mail[$cache_key]['t emplate']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');660 $conf_mail[$cache_key]['theme']->set_filename('css', 'global-mail-css.tpl'); 661 $conf_mail[$cache_key]['theme']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css'); 659 662 } 660 661 $root_abs_path = dirname(dirname(__FILE__)); 662 663 $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl'; 663 */ 664 665 $file = PHPWG_ROOT_PATH.'themes/'.$args['theme'].'/mail-css.tpl'; 664 666 if (is_file($file)) 665 667 { 666 $conf_mail[$cache_key]['t emplate']->set_filename('css', $file);667 $conf_mail[$cache_key]['t emplate']->assign_var_from_handle('MAIL_CSS', 'css');668 $conf_mail[$cache_key]['theme']->set_filename('css', realpath($file)); 669 $conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css'); 668 670 } 669 671 /* 670 672 $file = $root_abs_path.'/template-common/local-mail-css.tpl'; 671 673 if (is_file($file)) … … 674 676 $conf_mail[$cache_key]['template']->assign_var_from_handle('LOCAL_MAIL_CSS', 'css'); 675 677 } 678 */ 676 679 } 677 680 678 681 // what are displayed on the header of each mail ? 679 682 $conf_mail[$cache_key]['header'] = 680 $conf_mail[$cache_key]['t emplate']->parse('mail_header', true);683 $conf_mail[$cache_key]['theme']->parse('mail_header', true); 681 684 682 685 // what are displayed on the footer of each mail ? 683 686 $conf_mail[$cache_key]['footer'] = 684 $conf_mail[$cache_key]['t emplate']->parse('mail_footer', true);687 $conf_mail[$cache_key]['theme']->parse('mail_footer', true); 685 688 } 686 689 … … 714 717 $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n"; 715 718 } 716 717 719 718 720 //~ // Close boundary -
trunk/include/functions_user.inc.php
r5060 r5123 246 246 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; 247 247 248 list($user['template'], $user['theme']) = explode('/', $user['template']); 248 // Check user theme 249 if (!file_exists(PHPWG_ROOT_PATH.'themes/'.$user['theme'].'/themeconf.inc.php')) 250 { 251 $user['theme'] = $conf['default_theme']; 252 } 249 253 250 254 return $user; … … 842 846 * 843 847 */ 844 function get_default_t emplate()845 { 846 return get_default_user_value('t emplate', PHPWG_DEFAULT_TEMPLATE);848 function get_default_theme() 849 { 850 return get_default_user_value('theme', PHPWG_DEFAULT_TEMPLATE); 847 851 } 848 852 -
trunk/include/template.class.php
r5101 r5123 53 53 var $html_head_elements = array(); 54 54 55 function Template($root = ".", $theme= "" )55 function Template($root = ".", $theme= "", $path = "template") 56 56 { 57 57 global $conf, $lang_info; … … 78 78 } 79 79 80 $this->smarty->template_dir = array(); 80 81 if ( !empty($theme) ) 81 82 { 82 include($root.'/theme/'.$theme.'/themeconf.inc.php'); 83 $this->smarty->assign('themeconf', $themeconf); 83 $this->set_theme($root, $theme, $path); 84 84 } 85 85 86 86 $this->smarty->assign('lang_info', $lang_info); 87 88 $this->set_template_dir($root);89 87 90 88 if (!defined('IN_ADMIN') and isset($conf['extents_for_templates'])) … … 96 94 97 95 /** 98 * Sets the template root directory for this Template object. 99 * Revised from Piwigo 2.1 to add modeling support 100 */ 96 * Load theme's parameters. 97 */ 98 function set_theme($root, $theme, $path) 99 { 100 $this->set_template_dir($root.'/'.$theme.'/'.$path); 101 102 include($root.'/'.$theme.'/themeconf.inc.php'); 103 104 if (isset($themeconf['parent'])) 105 { 106 $this->set_theme($root, $themeconf['parent'], $path); 107 } 108 109 $tpl_var = array('name' => $themeconf['theme']); 110 if (file_exists($root.'/'.$theme.'/local_head.tpl')) 111 { 112 $tpl_var['local_head'] = realpath($root.'/'.$theme.'/local_head.tpl'); 113 } 114 $this->smarty->append('themes', $tpl_var); 115 $this->smarty->append('themeconf', $themeconf, true); 116 } 117 101 118 function set_template_dir($dir) 102 119 { 103 $modeling = $this->get_themeconf('modeling'); 104 if (!defined('IN_ADMIN') and ($modeling !== false)) 105 { // Modeling is active only on gallery side and never in admin 106 // Set the normal directory 107 $this->smarty->template_dir = array($dir); 108 // Modeling by theme parameter 109 $model = './template/' . $modeling; 110 if ( $model != './template/' and is_dir($model)) 111 { 112 $this->smarty->template_dir[] = $model; 113 } 114 // Default template directory 115 $this->smarty->template_dir[] = './template/default'; 116 } 117 else 118 { 119 $this->smarty->template_dir = $dir; 120 } 121 $real_dir = realpath($dir); 122 $compile_id = crc32( $real_dir===false ? $dir : $real_dir); 123 $this->smarty->compile_id = base_convert($compile_id, 10, 36 ); 120 $this->smarty->template_dir[] = $dir; 121 122 if (!isset($this->smarty->compile_id)) 123 { 124 $real_dir = realpath($dir); 125 $compile_id = crc32( $real_dir===false ? $dir : $real_dir); 126 $this->smarty->compile_id = base_convert($compile_id, 10, 36 ); 127 } 124 128 } 125 129 … … 197 201 function set_extents($filename_array, $dir='', $overwrite=true) 198 202 { 203 global $user; 204 199 205 if (!is_array($filename_array)) 200 206 { … … 221 227 222 228 if ((stripos(implode('',array_keys($_GET)), '/'.$param) !== false or $param == 'N/A') 223 and ( preg_match('/'.preg_quote($tpl,'/').'$/', $this->get_template_dir())or $tpl == 'N/A')229 and ($tpl == $user['theme'] or $tpl == 'N/A') 224 230 and (!isset($this->extents[$handle]) or $overwrite) 225 231 and file_exists($dir . $filename))
Note: See TracChangeset
for help on using the changeset viewer.