Merge pull request #581 from fermionic/20130112-backport-red-smarty-improvements

fixes and tweaks to Smarty processing
This commit is contained in:
friendica 2013-01-12 12:28:14 -08:00
commit 8b643d4c88
29 changed files with 64 additions and 66 deletions

View file

@ -622,7 +622,6 @@ if(! class_exists('App')) {
*/ */
if(!isset($this->page['htmlhead'])) if(!isset($this->page['htmlhead']))
$this->page['htmlhead'] = ''; $this->page['htmlhead'] = '';
$tpl = get_markup_template('head.tpl');
// If we're using Smarty, then doing replace_macros() will replace // If we're using Smarty, then doing replace_macros() will replace
// any unrecognized variables with a blank string. Since we delay // any unrecognized variables with a blank string. Since we delay
@ -633,6 +632,7 @@ if(! class_exists('App')) {
else else
$stylesheet = '$stylesheet'; $stylesheet = '$stylesheet';
$tpl = get_markup_template('head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array( $this->page['htmlhead'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!! '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
'$local_user' => local_user(), '$local_user' => local_user(),
@ -1381,8 +1381,6 @@ if(! function_exists('profile_sidebar')) {
} }
$tpl = get_markup_template('profile_vcard.tpl');
$p = array(); $p = array();
foreach($profile as $k => $v) { foreach($profile as $k => $v) {
$k = str_replace('-','_',$k); $k = str_replace('-','_',$k);
@ -1392,6 +1390,7 @@ if(! function_exists('profile_sidebar')) {
if($a->theme['template_engine'] === 'internal') if($a->theme['template_engine'] === 'internal')
$location = template_escape($location); $location = template_escape($location);
$tpl = get_markup_template('profile_vcard.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$profile' => $p, '$profile' => $p,
'$connect' => $connect, '$connect' => $connect,

View file

@ -489,12 +489,12 @@ function get_template_file($a, $filename, $root = '') {
if($root !== '' && $root[strlen($root)-1] !== '/') if($root !== '' && $root[strlen($root)-1] !== '/')
$root = $root . '/'; $root = $root . '/';
if(file_exists($root . "view/theme/$theme/$filename")) if(file_exists("{$root}view/theme/$theme/$filename"))
$template_file = $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")) 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"; $template_file = "{$root}view/theme/{$a->theme_info["extends"]}/$filename";
else else
$template_file = $root . "view/$filename"; $template_file = "{$root}view/$filename";
return $template_file; return $template_file;
}} }}

View file

@ -4,8 +4,6 @@
function display_init(&$a) { function display_init(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
killme();
return; return;
} }
@ -17,6 +15,11 @@ function display_init(&$a) {
function display_content(&$a, $update = 0) { 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/bbcode.php");
require_once('include/security.php'); require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');

View file

@ -220,16 +220,15 @@ function group_content(&$a) {
} }
} }
$context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click on a contact to add or remove.'); $context['$desc'] = t('Click on a contact to add or remove.');
if($change) { if($change) {
$context['$groupeditor'] = $groupeditor;
$tpl = get_markup_template('groupeditor.tpl'); $tpl = get_markup_template('groupeditor.tpl');
echo replace_macros($tpl, $context); echo replace_macros($tpl, $context);
killme(); killme();
} }
$context['$groupedit_info'] = $groupeditor;
return replace_macros($tpl, $context); return replace_macros($tpl, $context);
} }

View file

@ -516,7 +516,7 @@ function message_content(&$a) {
'$to' => t('To:'), '$to' => t('To:'),
'$showinputs' => '', '$showinputs' => '',
'$subject' => t('Subject:'), '$subject' => t('Subject:'),
'$subjtxt' => template_escape($message['title']), '$subjtxt' => $subjtxt_e,
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
'$yourmessage' => t('Your message:'), '$yourmessage' => t('Your message:'),
'$text' => '', '$text' => '',

View file

@ -6,8 +6,6 @@ function profiles_init(&$a) {
nav_set_selected('profiles'); nav_set_selected('profiles');
if(! local_user()) { if(! local_user()) {
notice( t('Permission denied.') . EOL);
killme();
return; return;
} }
@ -565,6 +563,11 @@ function profile_activity($changed, $value) {
function profiles_content(&$a) { function profiles_content(&$a) {
if(! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$o = ''; $o = '';
if(($a->argc > 1) && (intval($a->argv[1]))) { if(($a->argc > 1) && (intval($a->argv[1]))) {

View file

@ -497,13 +497,7 @@ class Item extends BaseObject {
return false; return false;
} }
if($a->theme['template_engine'] === 'smarty3') { $this->template = $this->available_templates[$name];
$template_file = get_template_file($a, 'smarty3/' . $this->available_templates[$name]);
}
else {
$template_file = $this->available_templates[$name];
}
$this->template = $template_file;
} }
/** /**

View file

@ -14,8 +14,8 @@
$tabs $tabs
{{ for $contacts as $c }} {{ for $contacts as $contact }}
{{ inc contact_template.tpl with $contact=$c }}{{ endinc }} {{ inc contact_template.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -15,9 +15,9 @@
</div> </div>
{{ if $groupedit_info }} {{ if $groupeditor }}
<div id="group-update-wrapper"> <div id="group-update-wrapper">
{{ inc groupeditor.tpl with $groupeditor=$groupedit_info }}{{ endinc }} {{ inc groupeditor.tpl }}{{ endinc }}
</div> </div>
{{ endif }} {{ endif }}
{{ if $desc }}<div id="group-edit-desc">$desc</div>{{ endif }} {{ if $desc }}<div id="group-edit-desc">$desc</div>{{ endif }}

View file

@ -1,6 +1,6 @@
{{ for $mails as $mail_item }} {{ for $mails as $mail }}
{{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} {{ inc mail_conv.tpl }}{{endinc}}
{{ endfor }} {{ endfor }}
{{ if $canreply }} {{ if $canreply }}

View file

@ -1,7 +1,7 @@
<h1>$header</h1> <h1>$header</h1>
{{ for $contacts as $c }} {{ for $contacts as $contact }}
{{ inc contact_template.tpl with $contact=$c }}{{ endinc }} {{ inc contact_template.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -4,8 +4,8 @@
{{ endif }} {{ endif }}
<div class="photos"> <div class="photos">
{{ for $photos as $ph }} {{ for $photos as $photo }}
{{ inc photo_top.tpl with $photo=$ph }}{{ endinc }} {{ inc photo_top.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
</div> </div>
<div class="photos-end"></div> <div class="photos-end"></div>

View file

@ -9,8 +9,8 @@
{{ if $response.totalResults }} {{ if $response.totalResults }}
{{ for $response.entry as $ent }} {{ for $response.entry as $entry }}
{{ inc poco_entry_xml.tpl with $entry=$ent }}{{ endinc }} {{ inc poco_entry_xml.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
{{ else }} {{ else }}
<entry></entry> <entry></entry>

View file

@ -19,8 +19,8 @@
{{$tabs}} {{$tabs}}
{{foreach $contacts as $c}} {{foreach $contacts as $contact}}
{{include file="contact_template.tpl" contact=$c}} {{include file="contact_template.tpl"}}
{{/foreach}} {{/foreach}}
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -20,9 +20,9 @@
</div> </div>
{{if $groupedit_info}} {{if $groupeditor}}
<div id="group-update-wrapper"> <div id="group-update-wrapper">
{{include file="groupeditor.tpl" groupeditor=$groupedit_info}} {{include file="groupeditor.tpl"}}
</div> </div>
{{/if}} {{/if}}
{{if $desc}}<div id="group-edit-desc">{{$desc}}</div>{{/if}} {{if $desc}}<div id="group-edit-desc">{{$desc}}</div>{{/if}}

View file

@ -4,8 +4,8 @@
* *
*}} *}}
{{foreach $mails as $mail_item}} {{foreach $mails as $mail}}
{{include file="mail_conv.tpl" mail=$mail_item}} {{include file="mail_conv.tpl"}}
{{/foreach}} {{/foreach}}
{{if $canreply}} {{if $canreply}}

View file

@ -5,8 +5,8 @@
*}} *}}
<h1>{{$header}}</h1> <h1>{{$header}}</h1>
{{foreach $contacts as $c}} {{foreach $contacts as $contact}}
{{include file="contact_template.tpl" contact=$c}} {{include file="contact_template.tpl"}}
{{/foreach}} {{/foreach}}
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -9,8 +9,8 @@
{{/if}} {{/if}}
<div class="photos"> <div class="photos">
{{foreach $photos as $ph}} {{foreach $photos as $photo}}
{{include file="photo_top.tpl" photo=$ph}} {{include file="photo_top.tpl"}}
{{/foreach}} {{/foreach}}
</div> </div>
<div class="photos-end"></div> <div class="photos-end"></div>

View file

@ -14,8 +14,8 @@
{{if $response.totalResults}} {{if $response.totalResults}}
{{foreach $response.entry as $ent}} {{foreach $response.entry as $entry}}
{{include file="poco_entry_xml.tpl" entry=$ent}} {{include file="poco_entry_xml.tpl"}}
{{/foreach}} {{/foreach}}
{{else}} {{else}}
<entry></entry> <entry></entry>

View file

@ -5,8 +5,8 @@
*}} *}}
<h3>{{$title}}</h3> <h3>{{$title}}</h3>
{{foreach $contacts as $c}} {{foreach $contacts as $contact}}
{{include file="contact_template.tpl" contact=$c}} {{include file="contact_template.tpl"}}
{{/foreach}} {{/foreach}}
<div id="view-contact-end"></div> <div id="view-contact-end"></div>

View file

@ -3,9 +3,9 @@
<a href="message/dropconv/$thread_id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a> <a href="message/dropconv/$thread_id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a>
</div> </div>
{{ for $mails as $mail_item }} {{ for $mails as $mail }}
<div id="tread-wrapper-$mail_item.id" class="tread-wrapper"> <div id="tread-wrapper-$mail_item.id" class="tread-wrapper">
{{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} {{ inc mail_conv.tpl }}{{endinc}}
</div> </div>
{{ endfor }} {{ endfor }}

View file

@ -8,9 +8,9 @@
<a href="message/dropconv/{{$thread_id}}" onclick="return confirmDelete();" title="{{$delete}}" class="mail-delete icon s22 delete"></a> <a href="message/dropconv/{{$thread_id}}" onclick="return confirmDelete();" title="{{$delete}}" class="mail-delete icon s22 delete"></a>
</div> </div>
{{foreach $mails as $mail_item}} {{foreach $mails as $mail}}
<div id="tread-wrapper-{{$mail_item.id}}" class="tread-wrapper"> <div id="tread-wrapper-{{$mail_item.id}}" class="tread-wrapper">
{{include file="mail_conv.tpl" mail=$mail_item}} {{include file="mail_conv.tpl"}}
</div> </div>
{{/foreach}} {{/foreach}}

View file

@ -15,8 +15,8 @@ $tabs
<div id="contacts-display-wrapper"> <div id="contacts-display-wrapper">
{{ for $contacts as $c }} {{ for $contacts as $contact }}
{{ inc contact_template.tpl with $contact=$c }}{{ endinc }} {{ inc contact_template.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
</div> </div>
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -20,8 +20,8 @@
<div id="contacts-display-wrapper"> <div id="contacts-display-wrapper">
{{foreach $contacts as $c}} {{foreach $contacts as $contact}}
{{include file="contact_template.tpl" contact=$c}} {{include file="contact_template.tpl"}}
{{/foreach}} {{/foreach}}
</div> </div>
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -15,8 +15,8 @@ $tabs
<div id="contacts-display-wrapper"> <div id="contacts-display-wrapper">
{{ for $contacts as $c }} {{ for $contacts as $contact }}
{{ inc contact_template.tpl with $contact=$c }}{{ endinc }} {{ inc contact_template.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
</div> </div>
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -20,8 +20,8 @@
<div id="contacts-display-wrapper"> <div id="contacts-display-wrapper">
{{foreach $contacts as $c}} {{foreach $contacts as $contact}}
{{include file="contact_template.tpl" contact=$c}} {{include file="contact_template.tpl"}}
{{/foreach}} {{/foreach}}
</div> </div>
<div id="contact-edit-end"></div> <div id="contact-edit-end"></div>

View file

@ -3,9 +3,9 @@
<a href="message/dropconv/$thread_id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a> <a href="message/dropconv/$thread_id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a>
</div> </div>
{{ for $mails as $mail_item }} {{ for $mails as $mail }}
<div id="tread-wrapper-$mail_item.id" class="tread-wrapper"> <div id="tread-wrapper-$mail_item.id" class="tread-wrapper">
{{ inc mail_conv.tpl with $mail=$mail_item }}{{endinc}} {{ inc mail_conv.tpl }}{{endinc}}
</div> </div>
{{ endfor }} {{ endfor }}

View file

@ -8,9 +8,9 @@
<a href="message/dropconv/{{$thread_id}}" onclick="return confirmDelete();" title="{{$delete}}" class="mail-delete icon s22 delete"></a> <a href="message/dropconv/{{$thread_id}}" onclick="return confirmDelete();" title="{{$delete}}" class="mail-delete icon s22 delete"></a>
</div> </div>
{{foreach $mails as $mail_item}} {{foreach $mails as $mail}}
<div id="tread-wrapper-{{$mail_item.id}}" class="tread-wrapper"> <div id="tread-wrapper-{{$mail_item.id}}" class="tread-wrapper">
{{include file="mail_conv.tpl" mail=$mail_item}} {{include file="mail_conv.tpl"}}
</div> </div>
{{/foreach}} {{/foreach}}

View file

@ -1,7 +1,7 @@
<h3>$title</h3> <h3>$title</h3>
{{ for $contacts as $c }} {{ for $contacts as $contact }}
{{ inc contact_template.tpl with $contact=$c }}{{ endinc }} {{ inc contact_template.tpl }}{{ endinc }}
{{ endfor }} {{ endfor }}
<div id="view-contact-end"></div> <div id="view-contact-end"></div>