diff --git a/boot.php b/boot.php index d8bc174b4..640fef541 100644 --- a/boot.php +++ b/boot.php @@ -969,16 +969,7 @@ if(! function_exists('login')) { $a->module = 'login'; } - - $includes = array( - '$field_input' => 'field_input.tpl', - '$field_password' => 'field_password.tpl', - '$field_openid' => 'field_openid.tpl', - '$field_checkbox' => 'field_checkbox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$dest_url' => $dest_url, '$logout' => t('Logout'), @@ -997,6 +988,7 @@ if(! function_exists('login')) { '$lostpass' => t('Forgot your password?'), '$lostlink' => t('Password Reset'), + )); call_hooks('login_hook',$o); @@ -1348,15 +1340,10 @@ if(! function_exists('profile_sidebar')) { $tpl = get_markup_template('profile_vcard.tpl'); - $includes = array( - '$diaspora_vcard' => 'diaspora_vcard.tpl' - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - if($a->theme['template_engine'] === 'internal') $location = template_escape($location); - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, '$wallmessage' => $wallmessage, diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index 2a294e9e2..9ad14ad8a 100644 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -5,20 +5,24 @@ require_once("library/Smarty/libs/Smarty.class.php"); class FriendicaSmarty extends Smarty { public $filename; - public $root; function __construct() { parent::__construct(); $a = get_app(); + $theme = current_theme(); - //$this->root = $_SERVER['DOCUMENT_ROOT'] . '/'; - $this->root = ''; + // setTemplateDir can be set to an array, which Smarty will parse in order. + // The order is thus very important here + $template_dirs = array('theme' => "view/theme/$theme/smarty3/"); + if( x($a->theme_info,"extends") ) + $template_dirs = $template_dirs + array('extends' => "view/theme/".$a->theme_info["extends"]."/smarty3/"); + $template_dirs = $template_dirs + array('base' => 'view/smarty3/'); + $this->setTemplateDir($template_dirs); - $this->setTemplateDir($this->root . 'view/smarty3/'); - $this->setCompileDir($this->root . 'view/smarty3/compiled/'); - $this->setConfigDir($this->root . 'view/smarty3/config/'); - $this->setCacheDir($this->root . 'view/smarty3/cache/'); + $this->setCompileDir('view/smarty3/compiled/'); + $this->setConfigDir('view/smarty3/config/'); + $this->setCacheDir('view/smarty3/cache/'); $this->left_delimiter = $a->smarty3_ldelim; $this->right_delimiter = $a->smarty3_rdelim; @@ -28,7 +32,7 @@ class FriendicaSmarty extends Smarty { if($template) { return $this->fetch('string:' . $template); } - return $this->fetch('file:' . $this->root . $this->filename); + return $this->fetch('file:' . $this->filename); } } diff --git a/include/text.php b/include/text.php index 0591390a8..628da1c1b 100644 --- a/include/text.php +++ b/include/text.php @@ -499,21 +499,6 @@ function get_template_file($a, $filename, $root = '') { return $template_file; }} -if(! function_exists("set_template_includes")) { -function set_template_includes($engine, $includes) { - if($engine === 'smarty3') { - $a = get_app(); - foreach($includes as $name=>$path) { -// $sm_includes[$name] = $_SERVER['DOCUMENT_ROOT'] . '/' . get_template_file($a, 'smarty3/' . $path); - $sm_includes[$name] = get_template_file($a, 'smarty3/' . $path); - } - return $sm_includes; - } - else { - return $includes; - } -}} - diff --git a/mod/admin.php b/mod/admin.php index c951dd8b9..0381fcf4c 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -455,16 +455,7 @@ function admin_page_site(&$a) { ); $t = get_markup_template("admin_site.tpl"); - - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - '$field_input' => 'field_input.tpl', - '$field_select' => 'field_select.tpl', - '$field_textarea' => 'field_textarea.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - return replace_macros($t, $includes + array( + return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Site'), '$submit' => t('Submit'), @@ -1144,14 +1135,7 @@ readable."); } } - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - '$field_input' => 'field_input.tpl', - '$field_select' => 'field_select.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - return replace_macros($t, $includes + array( + return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Logs'), '$submit' => t('Submit'), @@ -1210,14 +1194,7 @@ function admin_page_remoteupdate(&$a) { } $tpl = get_markup_template("admin_remoteupdate.tpl"); - - $includes = array( - '$field_input' => 'field_input.tpl', - '$field_password' => 'field_password.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - return replace_macros($tpl, $includes + array( + return replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(true), '$submit' => t("Update now"), '$close' => t("Close"), diff --git a/mod/contacts.php b/mod/contacts.php index 1a57afbf5..6e62ec8ef 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -346,12 +346,7 @@ function contacts_content(&$a) { $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$header' => t('Contact Editor'), '$tab_str' => $tab_str, '$submit' => t('Submit'), @@ -576,13 +571,7 @@ function contacts_content(&$a) { } $tpl = get_markup_template("contacts-template.tpl"); - - $includes = array( - '$contact_template' => 'contact_template.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $total, diff --git a/mod/filer.php b/mod/filer.php index c811ba6e2..4e79f337d 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -24,14 +24,9 @@ function filer_content(&$a) { $filetags = get_pconfig(local_user(),'system','filetags'); $filetags = file_tag_file_to_list($filetags,'file'); $filetags = explode(",", $filetags); + $tpl = get_markup_template("filer_dialog.tpl"); - - $includes = array( - '$field_combobox' => 'field_combobox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o = replace_macros($tpl,$includes + array( + $o = replace_macros($tpl, array( '$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$submit' => t('Save'), )); diff --git a/mod/group.php b/mod/group.php index f5a37819e..13a899ed9 100644 --- a/mod/group.php +++ b/mod/group.php @@ -83,13 +83,7 @@ function group_content(&$a) { $tpl = get_markup_template('group_edit.tpl'); - $includes = array( - '$field_input' => 'field_input.tpl', - '$groupeditortpl' => 'groupeditor.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $context = $includes + array( + $context = array( '$submit' => t('Submit'), ); diff --git a/mod/install.php b/mod/install.php index ab6d7d204..91b5e3d2d 100755 --- a/mod/install.php +++ b/mod/install.php @@ -220,14 +220,7 @@ function install_content(&$a) { $tpl = get_markup_template('install_db.tpl'); - - $includes = array( - '$field_input' => 'field_input.tpl', - '$field_password' => 'field_password.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$title' => $install_title, '$pass' => t('Database connection'), '$info_01' => t('In order to install Friendica we need to know how to connect to your database.'), @@ -267,13 +260,7 @@ function install_content(&$a) { $timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles'); $tpl = get_markup_template('install_settings.tpl'); - - $includes = array( - '$field_input' => 'field_input.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$title' => $install_title, '$pass' => t('Site settings'), diff --git a/mod/message.php b/mod/message.php index 7ca3fba70..26275ceab 100644 --- a/mod/message.php +++ b/mod/message.php @@ -497,12 +497,6 @@ function message_content(&$a) { $tpl = get_markup_template('mail_display.tpl'); - $includes = array( - '$mail_conv' => 'mail_conv.tpl', - '$prv_message' => 'prv_message.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - if($a->theme['template_engine'] === 'internal') { $subjtxt_e = template_escape($message['title']); } @@ -510,7 +504,7 @@ function message_content(&$a) { $subjtxt_e = $message['title']; } - $o = replace_macros($tpl, $includes + array( + $o = replace_macros($tpl, array( '$thread_id' => $a->argv[1], '$thread_subject' => $message['title'], '$thread_seen' => $seen, diff --git a/mod/nogroup.php b/mod/nogroup.php index 885ba62c6..24d99a59b 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -55,13 +55,7 @@ function nogroup_content(&$a) { } $tpl = get_markup_template("nogroup-template.tpl"); - - $includes = array( - '$contact_template' => 'contact_template.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$header' => t('Contacts who are not members of a group'), '$contacts' => $contacts, '$paginate' => paginate($a), diff --git a/mod/notifications.php b/mod/notifications.php index 03a39a268..128317eb4 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -145,12 +145,7 @@ function notifications_content(&$a) { $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $notif_content .= replace_macros($sugg,$includes + array( + $notif_content .= replace_macros($sugg, array( '$str_notifytype' => t('Notification type: '), '$notify_type' => t('Friend Suggestion'), '$intro_id' => $rr['intro_id'], @@ -196,12 +191,7 @@ function notifications_content(&$a) { )); } - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $notif_content .= replace_macros($tpl,$includes + array( + $notif_content .= replace_macros($tpl, array( '$str_notifytype' => t('Notification type: '), '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')), '$dfrn_text' => $dfrn_text, @@ -226,12 +216,7 @@ function notifications_content(&$a) { else info( t('No introductions.') . EOL); - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('Notifications'), '$tabs_data' => $tabs, '$notif_content' => $notif_content, @@ -317,12 +302,7 @@ function notifications_content(&$a) { $notif_content = t('No more network notifications.'); } - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('Network Notifications'), '$tabs_data' => $tabs, '$notif_content' => $notif_content, @@ -352,12 +332,7 @@ function notifications_content(&$a) { $notif_content .= t('No more system notifications.'); } - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('System Notifications'), '$tabs_data' => $tabs, '$notif_content' => $notif_content, @@ -452,12 +427,7 @@ function notifications_content(&$a) { $notif_content = t('No more personal notifications.'); } - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('Personal Notifications'), '$tabs_data' => $tabs, '$notif_content' => $notif_content, @@ -538,12 +508,7 @@ function notifications_content(&$a) { $notif_content = t('No more home notifications.'); } - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('Home Notifications'), '$tabs_data' => $tabs, '$notif_content' => $notif_content, diff --git a/mod/notify.php b/mod/notify.php index 3abc1185c..6ff437a38 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -61,12 +61,7 @@ function notify_content(&$a) { $notif_content .= t('No more system notifications.'); } - $includes = array( - '$common_tabs' => 'common_tabs.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($notif_tpl,$includes + array( + $o .= replace_macros($notif_tpl, array( '$notif_header' => t('System Notifications'), '$tabs_data' => '', // $tabs, '$notif_content' => $notif_content, diff --git a/mod/photos.php b/mod/photos.php index 8ac4d8590..7035c6690 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1679,13 +1679,7 @@ function photos_content(&$a) { } $tpl = get_markup_template('photos_recent.tpl'); - - $includes = array( - '$photo_top' => 'photo_top.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl,$includes + array( + $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), '$can_post' => $can_post, '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'), diff --git a/mod/poco.php b/mod/poco.php index abe2c8e35..ae5f0cef4 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -147,13 +147,7 @@ function poco_init(&$a) { if($format === 'xml') { header('Content-type: text/xml'); - - $includes = array( - '$poco_entry_xml' => 'poco_entry_xml.tpl' - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify($includes + array('$response' => $ret))); + echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify(array('$response' => $ret))); http_status_exit(500); } if($format === 'json') { diff --git a/mod/settings.php b/mod/settings.php index 09a45f832..dbdd40bc3 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -554,13 +554,7 @@ function settings_content(&$a) { if(($a->argc > 2) && ($a->argv[2] === 'add')) { $tpl = get_markup_template("settings_oauth_edit.tpl"); - - $includes = array( - '$field_input' => 'field_input.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), @@ -586,13 +580,7 @@ function settings_content(&$a) { $app = $r[0]; $tpl = get_markup_template("settings_oauth_edit.tpl"); - - $includes = array( - '$field_input' => 'field_input.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), @@ -675,13 +663,7 @@ function settings_content(&$a) { $tpl = get_markup_template("settings_features.tpl"); - - $includes = array( - '$field_yesno' => 'field_yesno.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, @@ -733,16 +715,7 @@ function settings_content(&$a) { } - $includes = array( - '$field_checkbox' => 'field_checkbox.tpl', - '$field_input' => 'field_input.tpl', - '$field_select' => 'field_select.tpl', - '$field_custom' => 'field_custom.tpl', - '$field_password' => 'field_password.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Connector Settings'), @@ -832,15 +805,7 @@ function settings_content(&$a) { } $tpl = get_markup_template("settings_display.tpl"); - - $includes = array( - '$field_themeselect' => 'field_themeselect.tpl', - '$field_checkbox' => 'field_checkbox.tpl', - '$field_input' => 'field_input.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o = replace_macros($tpl, $includes + array( + $o = replace_macros($tpl, array( '$ptitle' => t('Display Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), @@ -926,13 +891,7 @@ function settings_content(&$a) { $pageset_tpl = get_markup_template('pagetypes.tpl'); - - $includes = array( - '$field_radio' => 'field_radio.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $pagetype = replace_macros($pageset_tpl,$includes + array( + $pagetype = replace_macros($pageset_tpl, array( '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, t('This account is a normal personal profile'), ($a->user['page-flags'] == PAGE_NORMAL)), @@ -1053,17 +1012,7 @@ function settings_content(&$a) { require_once('include/group.php'); $group_select = mini_group_select(local_user(),$a->user['def_gid']); - $includes = array( - '$field_password' => 'field_password.tpl', - '$field_input' => 'field_input.tpl', - '$field_custom' => 'field_custom.tpl', - '$field_checkbox' => 'field_checkbox.tpl', - '$field_yesno' => 'field_yesno.tpl', - '$field_intcheckbox' => 'field_intcheckbox.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($stpl,$includes + array( + $o .= replace_macros($stpl, array( '$ptitle' => t('Account Settings'), '$submit' => t('Submit'), diff --git a/mod/uimport.php b/mod/uimport.php index d28198f69..6cca08cda 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -60,13 +60,7 @@ function uimport_content(&$a) { $tpl = get_markup_template("uimport.tpl"); - - $includes = array( - '$field_custom' => 'field_custom.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - return replace_macros($tpl, $includes + array( + return replace_macros($tpl, array( '$regbutt' => t('Import'), '$import' => array( 'title' => t("Move account"), diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index f54a76be4..8e261e711 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -72,13 +72,7 @@ function viewcontacts_content(&$a) { $tpl = get_markup_template("viewcontact_template.tpl"); - - $includes = array( - '$contact_template' => 'contact_template.tpl', - ); - $includes = set_template_includes($a->theme['template_engine'], $includes); - - $o .= replace_macros($tpl, $includes + array( + $o .= replace_macros($tpl, array( '$title' => t('View Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a), diff --git a/view/admin_logs.tpl b/view/admin_logs.tpl index db1b00c11..b777cf420 100644 --- a/view/admin_logs.tpl +++ b/view/admin_logs.tpl @@ -4,9 +4,9 @@