From 609c45e791fe23217decbc6e07f44a1f9a9afc93 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Sat, 12 Jan 2013 05:58:54 -0700 Subject: [PATCH] fixes and tweaks to Smarty processing --- boot.php | 5 ++--- include/text.php | 10 +++++----- mod/display.php | 7 +++++-- mod/group.php | 3 +-- mod/message.php | 2 +- mod/profiles.php | 7 +++++-- object/Item.php | 8 +------- view/contacts-template.tpl | 4 ++-- view/group_edit.tpl | 4 ++-- view/mail_display.tpl | 4 ++-- view/nogroup-template.tpl | 4 ++-- view/photos_recent.tpl | 4 ++-- view/poco_xml.tpl | 4 ++-- view/smarty3/contacts-template.tpl | 4 ++-- view/smarty3/group_edit.tpl | 4 ++-- view/smarty3/mail_display.tpl | 4 ++-- view/smarty3/nogroup-template.tpl | 4 ++-- view/smarty3/photos_recent.tpl | 4 ++-- view/smarty3/poco_xml.tpl | 4 ++-- view/smarty3/viewcontact_template.tpl | 4 ++-- view/theme/diabook/mail_display.tpl | 4 ++-- view/theme/diabook/smarty3/mail_display.tpl | 4 ++-- view/theme/frost-mobile/contacts-template.tpl | 4 ++-- view/theme/frost-mobile/smarty3/contacts-template.tpl | 4 ++-- view/theme/frost/contacts-template.tpl | 4 ++-- view/theme/frost/smarty3/contacts-template.tpl | 4 ++-- view/theme/quattro/mail_display.tpl | 4 ++-- view/theme/quattro/smarty3/mail_display.tpl | 4 ++-- view/viewcontact_template.tpl | 4 ++-- 29 files changed, 64 insertions(+), 66 deletions(-) diff --git a/boot.php b/boot.php index 7d02ba9e04..5fca45a3bf 100644 --- a/boot.php +++ b/boot.php @@ -622,7 +622,6 @@ if(! class_exists('App')) { */ if(!isset($this->page['htmlhead'])) $this->page['htmlhead'] = ''; - $tpl = get_markup_template('head.tpl'); // If we're using Smarty, then doing replace_macros() will replace // any unrecognized variables with a blank string. Since we delay @@ -633,6 +632,7 @@ if(! class_exists('App')) { else $stylesheet = '$stylesheet'; + $tpl = get_markup_template('head.tpl'); $this->page['htmlhead'] = replace_macros($tpl,array( '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!! '$local_user' => local_user(), @@ -1381,8 +1381,6 @@ if(! function_exists('profile_sidebar')) { } - $tpl = get_markup_template('profile_vcard.tpl'); - $p = array(); foreach($profile as $k => $v) { $k = str_replace('-','_',$k); @@ -1392,6 +1390,7 @@ if(! function_exists('profile_sidebar')) { if($a->theme['template_engine'] === 'internal') $location = template_escape($location); + $tpl = get_markup_template('profile_vcard.tpl'); $o .= replace_macros($tpl, array( '$profile' => $p, '$connect' => $connect, diff --git a/include/text.php b/include/text.php index 628da1c1b2..aa3fc000a0 100644 --- a/include/text.php +++ b/include/text.php @@ -489,12 +489,12 @@ function get_template_file($a, $filename, $root = '') { if($root !== '' && $root[strlen($root)-1] !== '/') $root = $root . '/'; - if(file_exists($root . "view/theme/$theme/$filename")) - $template_file = $root . "view/theme/$theme/$filename"; - elseif (x($a->theme_info,"extends") && file_exists($root . "view/theme/".$a->theme_info["extends"]."/$filename")) - $template_file = $root . "view/theme/".$a->theme_info["extends"]."/$filename"; + if(file_exists("{$root}view/theme/$theme/$filename")) + $template_file = "{$root}view/theme/$theme/$filename"; + elseif (x($a->theme_info,"extends") && file_exists("{$root}view/theme/{$a->theme_info["extends"]}/$filename")) + $template_file = "{$root}view/theme/{$a->theme_info["extends"]}/$filename"; else - $template_file = $root . "view/$filename"; + $template_file = "{$root}view/$filename"; return $template_file; }} diff --git a/mod/display.php b/mod/display.php index 2e0b8216a4..5c23559c5c 100644 --- a/mod/display.php +++ b/mod/display.php @@ -4,8 +4,6 @@ function display_init(&$a) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { - notice( t('Public access denied.') . EOL); - killme(); return; } @@ -17,6 +15,11 @@ function display_init(&$a) { function display_content(&$a, $update = 0) { + if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + notice( t('Public access denied.') . EOL); + return; + } + require_once("include/bbcode.php"); require_once('include/security.php'); require_once('include/conversation.php'); diff --git a/mod/group.php b/mod/group.php index 13a899ed96..cef4371e94 100644 --- a/mod/group.php +++ b/mod/group.php @@ -220,16 +220,15 @@ function group_content(&$a) { } } + $context['$groupeditor'] = $groupeditor; $context['$desc'] = t('Click on a contact to add or remove.'); if($change) { - $context['$groupeditor'] = $groupeditor; $tpl = get_markup_template('groupeditor.tpl'); echo replace_macros($tpl, $context); killme(); } - $context['$groupedit_info'] = $groupeditor; return replace_macros($tpl, $context); } diff --git a/mod/message.php b/mod/message.php index 057797ddda..885cdcd629 100644 --- a/mod/message.php +++ b/mod/message.php @@ -516,7 +516,7 @@ function message_content(&$a) { '$to' => t('To:'), '$showinputs' => '', '$subject' => t('Subject:'), - '$subjtxt' => template_escape($message['title']), + '$subjtxt' => $subjtxt_e, '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$yourmessage' => t('Your message:'), '$text' => '', diff --git a/mod/profiles.php b/mod/profiles.php index 1fc1f484a3..f517478a1a 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -6,8 +6,6 @@ function profiles_init(&$a) { nav_set_selected('profiles'); if(! local_user()) { - notice( t('Permission denied.') . EOL); - killme(); return; } @@ -565,6 +563,11 @@ function profile_activity($changed, $value) { function profiles_content(&$a) { + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + $o = ''; if(($a->argc > 1) && (intval($a->argv[1]))) { diff --git a/object/Item.php b/object/Item.php index 0ea9954b0a..e9f114b84d 100644 --- a/object/Item.php +++ b/object/Item.php @@ -497,13 +497,7 @@ class Item extends BaseObject { return false; } - if($a->theme['template_engine'] === 'smarty3') { - $template_file = get_template_file($a, 'smarty3/' . $this->available_templates[$name]); - } - else { - $template_file = $this->available_templates[$name]; - } - $this->template = $template_file; + $this->template = $this->available_templates[$name]; } /** diff --git a/view/contacts-template.tpl b/view/contacts-template.tpl index 69e3202c37..ecb342bf44 100644 --- a/view/contacts-template.tpl +++ b/view/contacts-template.tpl @@ -14,8 +14,8 @@ $tabs -{{ for $contacts as $c }} - {{ inc contact_template.tpl with $contact=$c }}{{ endinc }} +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} {{ endfor }}
diff --git a/view/group_edit.tpl b/view/group_edit.tpl index 35d2981118..2fa2b1a552 100644 --- a/view/group_edit.tpl +++ b/view/group_edit.tpl @@ -15,9 +15,9 @@ -{{ if $groupedit_info }} +{{ if $groupeditor }}
- {{ inc groupeditor.tpl with $groupeditor=$groupedit_info }}{{ endinc }} + {{ inc groupeditor.tpl }}{{ endinc }}
{{ endif }} {{ if $desc }}
$desc
{{ endif }} diff --git a/view/mail_display.tpl b/view/mail_display.tpl index 396aa46c0a..b328d32a27 100644 --- a/view/mail_display.tpl +++ b/view/mail_display.tpl @@ -1,6 +1,6 @@ -{{ for $mails as $mail_item }} - {{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} +{{ for $mails as $mail }} + {{ inc mail_conv.tpl }}{{endinc}} {{ endfor }} {{ if $canreply }} diff --git a/view/nogroup-template.tpl b/view/nogroup-template.tpl index f27f158f5d..dd00ed097a 100644 --- a/view/nogroup-template.tpl +++ b/view/nogroup-template.tpl @@ -1,7 +1,7 @@

$header

-{{ for $contacts as $c }} - {{ inc contact_template.tpl with $contact=$c }}{{ endinc }} +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} {{ endfor }}
diff --git a/view/photos_recent.tpl b/view/photos_recent.tpl index 7ae3540245..1df78cb7be 100644 --- a/view/photos_recent.tpl +++ b/view/photos_recent.tpl @@ -4,8 +4,8 @@ {{ endif }}
-{{ for $photos as $ph }} - {{ inc photo_top.tpl with $photo=$ph }}{{ endinc }} +{{ for $photos as $photo }} + {{ inc photo_top.tpl }}{{ endinc }} {{ endfor }}
diff --git a/view/poco_xml.tpl b/view/poco_xml.tpl index 394f6afcf8..9549b695d1 100644 --- a/view/poco_xml.tpl +++ b/view/poco_xml.tpl @@ -9,8 +9,8 @@ {{ if $response.totalResults }} -{{ for $response.entry as $ent }} -{{ inc poco_entry_xml.tpl with $entry=$ent }}{{ endinc }} +{{ for $response.entry as $entry }} +{{ inc poco_entry_xml.tpl }}{{ endinc }} {{ endfor }} {{ else }} diff --git a/view/smarty3/contacts-template.tpl b/view/smarty3/contacts-template.tpl index 4ab0241a64..66f3f5c87b 100644 --- a/view/smarty3/contacts-template.tpl +++ b/view/smarty3/contacts-template.tpl @@ -19,8 +19,8 @@ {{$tabs}} -{{foreach $contacts as $c}} - {{include file="contact_template.tpl" contact=$c}} +{{foreach $contacts as $contact}} + {{include file="contact_template.tpl"}} {{/foreach}}
diff --git a/view/smarty3/group_edit.tpl b/view/smarty3/group_edit.tpl index a4b8f5906a..b7b14eba37 100644 --- a/view/smarty3/group_edit.tpl +++ b/view/smarty3/group_edit.tpl @@ -20,9 +20,9 @@ -{{if $groupedit_info}} +{{if $groupeditor}}
- {{include file="groupeditor.tpl" groupeditor=$groupedit_info}} + {{include file="groupeditor.tpl"}}
{{/if}} {{if $desc}}
{{$desc}}
{{/if}} diff --git a/view/smarty3/mail_display.tpl b/view/smarty3/mail_display.tpl index 1e4c0c74de..23d05bdeb8 100644 --- a/view/smarty3/mail_display.tpl +++ b/view/smarty3/mail_display.tpl @@ -4,8 +4,8 @@ * *}} -{{foreach $mails as $mail_item}} - {{include file="mail_conv.tpl" mail=$mail_item}} +{{foreach $mails as $mail}} + {{include file="mail_conv.tpl"}} {{/foreach}} {{if $canreply}} diff --git a/view/smarty3/nogroup-template.tpl b/view/smarty3/nogroup-template.tpl index dd045d7da1..7d103a655b 100644 --- a/view/smarty3/nogroup-template.tpl +++ b/view/smarty3/nogroup-template.tpl @@ -5,8 +5,8 @@ *}}

{{$header}}

-{{foreach $contacts as $c}} - {{include file="contact_template.tpl" contact=$c}} +{{foreach $contacts as $contact}} + {{include file="contact_template.tpl"}} {{/foreach}}
diff --git a/view/smarty3/photos_recent.tpl b/view/smarty3/photos_recent.tpl index 8b890b1bd4..cb2411df34 100644 --- a/view/smarty3/photos_recent.tpl +++ b/view/smarty3/photos_recent.tpl @@ -9,8 +9,8 @@ {{/if}}
-{{foreach $photos as $ph}} - {{include file="photo_top.tpl" photo=$ph}} +{{foreach $photos as $photo}} + {{include file="photo_top.tpl"}} {{/foreach}}
diff --git a/view/smarty3/poco_xml.tpl b/view/smarty3/poco_xml.tpl index 90b6821f91..b8cd8fc081 100644 --- a/view/smarty3/poco_xml.tpl +++ b/view/smarty3/poco_xml.tpl @@ -14,8 +14,8 @@ {{if $response.totalResults}} -{{foreach $response.entry as $ent}} -{{include file="poco_entry_xml.tpl" entry=$ent}} +{{foreach $response.entry as $entry}} +{{include file="poco_entry_xml.tpl"}} {{/foreach}} {{else}} diff --git a/view/smarty3/viewcontact_template.tpl b/view/smarty3/viewcontact_template.tpl index 40283b8e9d..a9837c7f9b 100644 --- a/view/smarty3/viewcontact_template.tpl +++ b/view/smarty3/viewcontact_template.tpl @@ -5,8 +5,8 @@ *}}

{{$title}}

-{{foreach $contacts as $c}} - {{include file="contact_template.tpl" contact=$c}} +{{foreach $contacts as $contact}} + {{include file="contact_template.tpl"}} {{/foreach}}
diff --git a/view/theme/diabook/mail_display.tpl b/view/theme/diabook/mail_display.tpl index 5d16bd32bb..2b680ae428 100644 --- a/view/theme/diabook/mail_display.tpl +++ b/view/theme/diabook/mail_display.tpl @@ -3,9 +3,9 @@ -{{ for $mails as $mail_item }} +{{ for $mails as $mail }}
- {{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} + {{ inc mail_conv.tpl }}{{endinc}}
{{ endfor }} diff --git a/view/theme/diabook/smarty3/mail_display.tpl b/view/theme/diabook/smarty3/mail_display.tpl index b8c2aea523..dc1fbbc6f5 100644 --- a/view/theme/diabook/smarty3/mail_display.tpl +++ b/view/theme/diabook/smarty3/mail_display.tpl @@ -8,9 +8,9 @@ -{{foreach $mails as $mail_item}} +{{foreach $mails as $mail}}
- {{include file="mail_conv.tpl" mail=$mail_item}} + {{include file="mail_conv.tpl"}}
{{/foreach}} diff --git a/view/theme/frost-mobile/contacts-template.tpl b/view/theme/frost-mobile/contacts-template.tpl index c7e3ca899d..76254c1ca8 100644 --- a/view/theme/frost-mobile/contacts-template.tpl +++ b/view/theme/frost-mobile/contacts-template.tpl @@ -15,8 +15,8 @@ $tabs
-{{ for $contacts as $c }} - {{ inc contact_template.tpl with $contact=$c }}{{ endinc }} +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} {{ endfor }}
diff --git a/view/theme/frost-mobile/smarty3/contacts-template.tpl b/view/theme/frost-mobile/smarty3/contacts-template.tpl index 5ca4eb6a94..b9162c2e9e 100644 --- a/view/theme/frost-mobile/smarty3/contacts-template.tpl +++ b/view/theme/frost-mobile/smarty3/contacts-template.tpl @@ -20,8 +20,8 @@
-{{foreach $contacts as $c}} - {{include file="contact_template.tpl" contact=$c}} +{{foreach $contacts as $contact}} + {{include file="contact_template.tpl"}} {{/foreach}}
diff --git a/view/theme/frost/contacts-template.tpl b/view/theme/frost/contacts-template.tpl index 326c9d7892..de89b5371e 100644 --- a/view/theme/frost/contacts-template.tpl +++ b/view/theme/frost/contacts-template.tpl @@ -15,8 +15,8 @@ $tabs
-{{ for $contacts as $c }} - {{ inc contact_template.tpl with $contact=$c }}{{ endinc }} +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} {{ endfor }}
diff --git a/view/theme/frost/smarty3/contacts-template.tpl b/view/theme/frost/smarty3/contacts-template.tpl index b804db35a5..de33d141bb 100644 --- a/view/theme/frost/smarty3/contacts-template.tpl +++ b/view/theme/frost/smarty3/contacts-template.tpl @@ -20,8 +20,8 @@
-{{foreach $contacts as $c}} - {{include file="contact_template.tpl" contact=$c}} +{{foreach $contacts as $contact}} + {{include file="contact_template.tpl"}} {{/foreach}}
diff --git a/view/theme/quattro/mail_display.tpl b/view/theme/quattro/mail_display.tpl index 5d16bd32bb..2b680ae428 100644 --- a/view/theme/quattro/mail_display.tpl +++ b/view/theme/quattro/mail_display.tpl @@ -3,9 +3,9 @@ -{{ for $mails as $mail_item }} +{{ for $mails as $mail }}
- {{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} + {{ inc mail_conv.tpl }}{{endinc}}
{{ endfor }} diff --git a/view/theme/quattro/smarty3/mail_display.tpl b/view/theme/quattro/smarty3/mail_display.tpl index b8c2aea523..dc1fbbc6f5 100644 --- a/view/theme/quattro/smarty3/mail_display.tpl +++ b/view/theme/quattro/smarty3/mail_display.tpl @@ -8,9 +8,9 @@ -{{foreach $mails as $mail_item}} +{{foreach $mails as $mail}}
- {{include file="mail_conv.tpl" mail=$mail_item}} + {{include file="mail_conv.tpl"}}
{{/foreach}} diff --git a/view/viewcontact_template.tpl b/view/viewcontact_template.tpl index 714bf03fa7..d6f01643ea 100644 --- a/view/viewcontact_template.tpl +++ b/view/viewcontact_template.tpl @@ -1,7 +1,7 @@

$title

-{{ for $contacts as $c }} - {{ inc contact_template.tpl with $contact=$c }}{{ endinc }} +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} {{ endfor }}