* Changes on class themes.

- Bug fixed with {ifelse ...}
- Added {header ...}
* Fixed Dreamscape & tumblr theme.
master
Victor De la Rocha 2008-11-29 08:21:13 +00:00
parent 2e6b24f3a5
commit 756faf3220
5 changed files with 108 additions and 86 deletions

View File

@ -18,7 +18,7 @@
Lightbox.fileLoadingImage = "css/images/loading.gif";
Lightbox.fileBottomNavCloseImage = "css/images/closelabel.gif";
</script>
{if {$conf.richText}}
{if $conf.richText}
<script src="{conf.urlGelato}/admin/scripts/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(nicEditors.allTextAreas);
@ -56,23 +56,23 @@
<ul class="menu">
<h3>{__("New Post")}</h3>
<li {if {$new}=="conversation"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=conversation"><img src="css/images/comments.png" alt="New chat" /> {__("Chat")}</a></li>
<li {if {$new}=="quote"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=quote"><img src="css/images/quote.png" alt="New qoute" /> {__("Quote")}</a></li>
<li {if {$new}=="url"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=url"><img src="css/images/world.png" alt="New link" /> {__("Link")}</a></li>
<li {if {$new}=="mp3"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=mp3"><img src="css/images/music.png" alt="New audio" /> {__("Audio")}</a></li>
<li {if {$new}=="video"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=video"><img src="css/images/film.png" alt="New video" /> {__("Video")}</a></li>
<li {if {$new}=="photo"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=photo"><img src="css/images/image.png" alt="New picture" /> {__("Picture")}</a></li>
<li {if {$new}=="post" or {$new}==null}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=post"><img src="css/images/page.png" alt="New post" /> {__("Regular")}</a></li>
<li {if $new=="conversation"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=conversation"><img src="css/images/comments.png" alt="New chat" /> {__("Chat")}</a></li>
<li {if $new=="quote"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=quote"><img src="css/images/quote.png" alt="New qoute" /> {__("Quote")}</a></li>
<li {if $new=="url"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=url"><img src="css/images/world.png" alt="New link" /> {__("Link")}</a></li>
<li {if $new=="mp3"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=mp3"><img src="css/images/music.png" alt="New audio" /> {__("Audio")}</a></li>
<li {if $new=="video"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=video"><img src="css/images/film.png" alt="New video" /> {__("Video")}</a></li>
<li {if $new=="photo"}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=photo"><img src="css/images/image.png" alt="New picture" /> {__("Picture")}</a></li>
<li {if $new=="post" or $new==null}class="selected"{/if}><a href="{conf.urlGelato}/admin/index.php?new=post"><img src="css/images/page.png" alt="New post" /> {__("Regular")}</a></li>
</ul>
<p>&nbsp;</p>
{if {$information}}<div class="information" id="update">{information}</div><br />{/if}
{if {$action.deleted} or {$action.modified} or {$action.added}}<div class="exito" id="divMessages">{exito}</div>{/if}
{if {$error}}<div class="error"><strong>{error}</div>{/if}
{if $information}<div class="information" id="update">{information}</div><br />{/if}
{if $action.deleted or $action.modified or $action.added}<div class="exito" id="divMessages">{exito}</div>{/if}
{if $error}<div class="error"><strong>{error}</div>{/if}
<form action="index.php" method="post" {if {$new}=='photo'}enctype="multipart/form-data"{/if} name="frmAdd" id="autosave" class="newpost">
<form action="index.php" method="post" {if $new=='photo'}enctype="multipart/form-data"{/if} name="frmAdd" id="autosave" class="newpost">
<fieldset>
{if {$postId}}<input type="hidden" name="id_post" id="id_post" value="{postId}" />{/if}
{if $postId}<input type="hidden" name="id_post" id="id_post" value="{postId}" />{/if}
{form}
<p>
<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
@ -90,7 +90,7 @@
</span>
</p>
<p>
<input class="btn" type="submit" id="publish" name="btnAdd" value="{if {$isEdition}}Modify{else}Create{/if} post" />
<input class="btn" type="submit" id="publish" name="btnAdd" value="{if $isEdition}Modify{else}Create{/if} post" />
</p>
</fieldset>
</form>
@ -109,33 +109,33 @@
<li class="selected"><a>{__("Posts")}</a></li>
</ul>
{if !{$isEdition}}
{if {$Posts_Number}}
{block {$rows} as {$row}}
{if !$isEdition}
{if $Posts_Number}
{block $rows as $row}
<div class="entry">
<div class="info"><span class="compact"><a href="{$row.Permalink}">Link</a>&nbsp;<a href="{conf.urlGelato}/admin/index.php?edit={$row.Id_Post}" title="{__('Edit this post')}" class="help"><img src="{conf.urlGelato}/admin/css/images/edit.png" alt=""/></a>&nbsp;<a href="{conf.urlGelato}/admin/index.php?delete={$row.Id_Post}" title="{__('Delete this post')}" class="help"><img src="{conf.urlGelato}/admin/css/images/delete.png" alt="" title="" onclick="return confirm('{__('Delete this post, really?')}');"/></a></span>
<p>{$row.Date_Added}</p>
</div>
<div class="post">
{if {$row.postType}=='post'}
{if $row.postType=='post'}
<span class="option"><a href="{$row.Permalink}">{$row.Title}</a></span>
<p>{$row.Body}</p>
{elseif {$row.postType}=='photo'}
{elseif $row.postType=='photo'}
<span class="option">{$row.Caption}</span>
<p><a {Effect}><img src="{$row.PhotoURL}" alt="{$row.PhotoAlt}" /></a></a></p>
{elseif {$row.postType}=='quote'}
{elseif $row.postType=='quote'}
<span class="option">&mdash; {$row.Source}</span>
<p><big class="quote"><a href="{$row.Permalink}">&#147;</a></big> {$row.Quote}</p>
{elseif {$row.postType}=='url'}
{elseif $row.postType=='url'}
<span class="option">&#187; <a href="{$row.URL}">{$row.Name}</a></span>
<p>{$row.Description}</p>
{elseif {$row.postType}=='conversation'}
{elseif $row.postType=='conversation'}
<span class="option">{$row.Title}</span>
<div class="conversation">{$row.Conversation}</div>
{elseif {$row.postType}=='video'}
{elseif $row.postType=='video'}
<span class="option">{$row.Caption}</span>
<p><img src="{conf.urlGelato}/admin/css/images/film.png" alt="Watch video" />&nbsp;<a href="{$row.Permalink}">{__('Watch')}</a></p>
{elseif {$row.postType}=='mp3'}
{elseif $row.postType=='mp3'}
<span class="option">{$row.Caption}</span>
<p><img src="{conf.urlGelato}/admin/css/images/music.png" alt="Play song" />&nbsp;<a href="{$row.Permalink}">{__('Play')}</a></p>
{/if}

View File

@ -53,21 +53,41 @@ class themes{
}
function eval_control_structures(){
//finding IFs sentences and converting to php code
$this->output = "echo \"".addslashes($this->output)."\";";
$this->output = preg_replace_callback("/{if ([^}]+)}/",create_function('$arr','return "\";if(".stripslashes($arr[1])."){echo\"";'),$this->output);
$this->output = preg_replace("/{else}/","\";}else{echo\"",$this->output);
$this->output = preg_replace_callback("/{elseif ([^}]+)}/",create_function('$arr','return "\";}elseif(".stripslashes($arr[1])."){echo\"";'),$this->output);
$this->output = preg_replace("/{\/if}/","\";} echo \"",$this->output);
//finding FOREACHs or BLOCKs sentences and converting to php code
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)=>[\$]([^}]+)}/",create_function('$arr','return "\";foreach(".stripslashes($arr[1])." as ".stripslashes($arr[2])."=>\$this->vars[\'".stripslashes($arr[3])."\']){echo\"";'),$this->output);
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)}/",create_function('$arr','return "\";foreach(".stripslashes($arr[1])." as ".stripslashes($arr[2])."){echo\"";'),$this->output);
$this->output = preg_replace("/{\/block}/","\";} echo \"",$this->output);
//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']['$2']}",$this->output);
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
//finding {header *}
preg_match_all("/{header ([^}]+?)}/s",$this->output,$out);
$headers = '';
foreach ($out[1] as $o)
$headers .= "header('$o');\n";
$this->output = preg_replace("/{header [^}]+?}/s","",$this->output);
//fake scape
$this->output = $this->quotemeta($this->output);
$this->output = str_replace('\"','\\"',trim($this->output));
$this->output = "echo \"".str_replace('"','\"',trim($this->output))."\";";
#$this->output = preg_replace("/\n+/s","\n",$this->output);
$this->output = $headers.trim($this->output);
//finding IFs sentences and converting to php code
#$this->output = preg_replace_callback("/{if ([^}]+)}/",create_function('$arr','return "\";if(".stripslashes($arr[1])."){echo\"";'),$this->output);
$this->output = preg_replace_callback("/{if ([^}]+)}/",create_function('$arr','return "\";if(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'),$this->output);
$this->output = preg_replace("/{else}/","\";}else{echo\"",$this->output);
$this->output = preg_replace_callback("/{elseif ([^}]+)}/",create_function('$arr','return "\";}elseif(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9]+)\\\'\]\.([a-zA-Z0-9]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'),$this->output);
$this->output = preg_replace("/{\/if}/","\";} echo \"",$this->output);
//finding FOREACHs or BLOCKs sentences and converting to php code
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)=>[\$]([^}]+)}/",create_function('$arr','return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."=>\$this->vars[\'".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[3]))."\']){echo\"";'),$this->output);
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)}/",create_function('$arr','return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."){echo\"";'),$this->output);
$this->output = preg_replace("/{\/block}/","\";} echo \"",$this->output);
//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
//$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']['$2']}",$this->output);
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
//Convertin the {__(\'word\')} format to {__('word')}
#$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
}
//sustituye las variables en el output del template
@ -87,21 +107,23 @@ class themes{
//replacing {$key} format by $this->vars['key']
//replacing {$array.key} format by $this->vars['array']['key']
$patrones = array(
#'/{\$([^ \.}]+)}/s',
#'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
'/{\$(\w+)}/s',
'/{\$(\w+)\.(\w+)}/s',
'/\$(\W)/s'
$patrones = array(
'/{\$([^ \.}]+)}/s',
'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
);
$reemplazos = array(
"{\$this->vars['$1']}",
"{\$this->vars['$1']['$2']}"
);
$reemplazos = array(
"\$this->vars['$1']",
"\$this->vars['$1']['$2']",
"\\\\$$1"
);
$this->output = preg_replace($patrones, $reemplazos, $this->output);
}
function quotemeta($str){
$chars = array(/*'.',*/ "\\", /*'+',*/ /*'*',*/ /*'?',*/ /*'[',*/ /*'^',*/ /*']',*/ /*'(',*/ /* '$' Por el momento no validar este*/);
foreach($chars as $char)
$this->output = str_replace($char,"\\$char",$this->output);
return $this->output;
}
//Utiliza gettext
function __(){

View File

@ -312,6 +312,6 @@ $theme = new themes;
$theme->set('rows',$rows);
}
$theme->set('URL_Tumble',$conf->urlGelato);
$theme->set('URL_Tumble',$conf->urlGelato);
$theme->display(Absolute_Path.'themes/'.$conf->template.'/index.htm');
?>
?>

View File

@ -48,70 +48,70 @@
<div id="description">
{Description}
</div>
{if {$error}}
{if $error}
<div class="error">{$error}</div>
{else}
{block {$rows} as {$row}}
{block $rows as $row}
<div class="post">
<div class="permalink"><a href="{$row.Permalink}">•</a></div>
<div class="date">
{$row.Date_Added}
</div>
{if {$row.postType}=='post'}
{if $row.postType=='post'}
<div class="regular">
<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Body}
</div>
{elseif {$row.postType}=='photo'}
{elseif $row.postType=='photo'}
<div class="photo">
<a {$row.Effect}><img src="{$row.PhotoURL}" alt="{$row.PhotoAlt}"></a>
<div class="caption">
{$row.Caption}
</div>
</div>
{elseif {$row.postType}=='quote'}
{elseif $row.postType=='quote'}
<div class="quote">
<span class="quote">
<big class="quote">“</big> <a href="{$row.Permalink}">{$row.Quote}</a>
</span>
<span class="source">{$row.Source}</span>
</div>
{elseif {$row.postType}=='url'}
{elseif $row.postType=='url'}
<div class="link">
<a href="{$row.URL}" class="link" >{$row.Name}</a>
<div class="description">{$row.Description}</div>
</div>
{elseif {$row.postType}=='conversation'}
{elseif $row.postType=='conversation'}
<div class="conversation">
...<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Conversation}
</div>
{elseif {$row.postType}=='video'}
{elseif $row.postType=='video'}
<div class="video">
{$row.Video}
<div class="caption">{$row.Caption}</div>
</div>
{elseif {$row.postType}=='mp3'}
{elseif $row.postType=='mp3'}
<div class="video">
{$row.Mp3}
<div class="caption">{$row.Caption}</div>
</div>
{/if}
</div>
{if !{$id_post}}
{if !$id_post}
<div class="totalComments">
<h3>{__("Posted by")} {$row.User} {if {$allowComments}}- <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) {__("comments")}{/if}</a></h3>
<h3>{__("Posted by")} {$row.User} {if $allowComments}- <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) {__("comments")}{/if}</a></h3>
</div>
{/if}
{/block}
{if {$id_post}}
{if {$row.Comments_Number}>0}
{if $id_post}
{if $row.Comments_Number>0}
<div class="containerComments">
<h3 id="comments">{$row.Comments_Number} {__("answers to")} &#8220;{$row.Post_Title}&#8221;</h3>
<ol class="commentlist">
{block {$comments} as {$comment}}
{block $comments as $comment}
<li class="alt" id="comment-{$comment.Id_Comment}">
<cite>
<a href="#comment-{$comment.Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;
@ -127,7 +127,7 @@
</div>
{/if}
{if {$allowComments}}
{if $allowComments}
<div class="containerFormComments">
<h3 id="respond">{__("Add your comment")}</h3>
@ -185,4 +185,4 @@
</div>
</body>
</html>
</html>

View File

@ -28,7 +28,7 @@
{Description}
</div>
{if {$isAuthenticated}}
{if $isAuthenticated}
<div style="padding:4px; border:solid 2px #bbb; display:inline; background-color:#ddd; position:absolute; top:3px; right:3px;">
<b>Hi, {User}.</b>&nbsp;&nbsp;
<a target="_top" href="{URL_Tumble}/admin/index.php">{__("Add or Edit my posts")}</a>&nbsp;&nbsp;
@ -36,65 +36,65 @@
</div>
{/if}
{if {$error}}
{if $error}
<div class="error">{$error}</div>
{else}
{block {$rows} as {$row}}
{block $rows as $row}
<div class="date">
{$row.Date_Added}
</div>
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
{if {$row.postType}=='post'}
{if $row.postType=='post'}
<div class="regular">
<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Body}
</div>
{elseif {$row.postType}=='photo'}
{elseif $row.postType=='photo'}
<div class="photo">
<a {$row.Effect}><img src="{$row.PhotoURL}" alt="{$row.PhotoAlt}" /></a><br/>
<div class="caption">{$row.Caption}</div>
</div>
{elseif {$row.postType}=='quote'}
{elseif $row.postType=='quote'}
<div class="quote">
<span class="quote"><big class="quote"><a href="{$row.Permalink}">&#147;</a></big> {$row.Quote}</span>
<div class="source">&mdash; {$row.Source}</div>
</div>
{elseif {$row.postType}=='url'}
{elseif $row.postType=='url'}
<div class="link">
&#187; <a href="{$row.URL}">{$row.Name}</a>
<div class="description">{$row.Description}</div>
</div>
{elseif {$row.postType}=='conversation'}
{elseif $row.postType=='conversation'}
<div class="conversation">
...<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Conversation}
</div>
{elseif {$row.postType}=='video'}
{elseif $row.postType=='video'}
<div class="video">
{$row.Video}
<div class="caption">{$row.Caption}</div>
</div>
{elseif {$row.postType}=='mp3'}
{elseif $row.postType=='mp3'}
<div class="video">
{$row.Mp3}
<div class="caption">{$row.Caption}</div>
</div>
{/if}
</div>
{if !{$id_post}}
{if !$id_post}
<div class="totalComments">
<h3>{__("Posted by")} {$row.User} {if {$allowComments}}- <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) {__("comments")}{/if}</a></h3>
<h3>{__("Posted by")} {$row.User} {if $allowComments}- <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) {__("comments")}{/if}</a></h3>
</div>
{/if}
{/block}
{if {$id_post}}
{if {$row.Comments_Number}>0}
{if $id_post}
{if $row.Comments_Number>0}
<div class="containerComments">
<h3 id="comments">{$row.Comments_Number} {__("answers to")} &#8220;{$row.Post_Title}&#8221;</h3>
<ol class="commentlist">
{block {$comments} as {$comment}}
{block $comments as $comment}
<li class="alt" id="comment-{$comment.Id_Comment}">
<cite>
<a href="#comment-{$comment.Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;
@ -110,7 +110,7 @@
</div>
{/if}
{if {$allowComments}}
{if $allowComments}
<div class="containerFormComments">
<h3 id="respond">{__("Add your comment")}</h3>
@ -165,4 +165,4 @@
{__("powered by")} <a href="http://www.gelatocms.com/">gelato cms</a>
</div>
</body>
</html>
</html>