* Added themes class from Flavor (Converted to PHP4).

* Changed plantillas.class.php by themes.class.php on public zone.
* Added new tumblr template in only one file.
* deleted parts of old tumblr theme.
master
Victor De la Rocha 2008-10-25 09:39:45 +00:00
parent c7fd8be234
commit d4f4e72049
18 changed files with 462 additions and 400 deletions

View File

@ -13,7 +13,7 @@ Author URI: http://www.mis-algoritmos.com
/*Default values*/
var $total_pages = null;
var $limit = null;
var $target = "";
var $target = "";
var $page = 1;
var $adjacents = 2;
var $showCounter = false;
@ -29,22 +29,22 @@ Author URI: http://www.mis-algoritmos.com
/*****/
var $calculate = false;
#Total items
function items($value){$this->total_pages = intval($value);}
#how many items to show per page
function limit($value){$this->limit = intval($value);}
#Page to sent the page value
function target($value){$this->target = $value;}
#Current page
function currentPage($value){$this->page = intval($value);}
#How many adjacent pages should be shown on each side of the current page?
function adjacents($value){$this->adjacents = intval($value);}
#show counter?
function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
@ -67,7 +67,7 @@ Author URI: http://www.mis-algoritmos.com
}
$this->urlF=$value;
}
var $pagination;
function pagination(){}
@ -76,18 +76,23 @@ Author URI: http://www.mis-algoritmos.com
if($this->calculate())
echo "<div class=\"$this->className\">$this->pagination</div>";
}
function getPagination(){
if(!$this->calculate)
if($this->calculate())
return "<div class=\"$this->className\">$this->pagination</div>";
}
function get_pagenum_link($id){
//if(strpos($this->target,'?')===false)
if($this->urlF)
return str_replace($this->urlF,$id,$this->target);
else
return "$this->target?$this->parameterName=$id";
//else
//else
//return "$this->target&$this->parameterName=$id";
}
function calculate(){
$this->pagination = "";
$this->calculate == true;
@ -97,7 +102,7 @@ Author URI: http://www.mis-algoritmos.com
echo "Especificaste un wildcard para sustituir, pero no existe en el target<br />";
$error = true;
}elseif($this->urlF and $this->urlF == '%' and strpos($this->target,$this->urlF)===false){
echo "Es necesario especificar en el target el comodin % para sustituir el número de página<br />";
echo "Es necesario especificar en el target el comodin % para sustituir el n<EFBFBD>mero de p<>gina<br />";
$error = true;
}
if($this->total_pages == null){
@ -109,35 +114,35 @@ Author URI: http://www.mis-algoritmos.com
$error = true;
}
if($error)return false;
$n = trim($this->nextT.' '.$this->nextI);
$p = trim($this->prevI.' '.$this->prevT);
/* Setup vars for query. */
if($this->page)
if($this->page)
$start = ($this->page - 1) * $this->limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($this->page == 0) $this->page = 1; //if no page var is given, default to 1.
$prev = $this->page - 1; //previous page is page - 1
$next = $this->page + 1; //next page is page + 1
$lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
if($lastpage > 1){
//anterior button
if($this->page > 1)
$this->pagination .= "<a href=\"".$this->get_pagenum_link($prev)."\">$p</a>";
else
$this->pagination .= "<span class=\"disabled\">$p</span>";
//pages
//pages
if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
for ($counter = 1; $counter <= $lastpage; $counter++){
if ($counter == $this->page)

114
classes/themes.class.php Normal file
View File

@ -0,0 +1,114 @@
<?php
/*
Class name: Themes
Class autor: Victor De la Rocha http//mis-algoritmos.com/themes-class
Email: vyk2rr [at] gmail [dot] com
*/
class themes{
var $registry;
var $path;
var $l10n;
var $output;
var $vars=array(); //variable para apilar las variables que se asignan a la plantilla
function themes(){
#$this->l10n = l10n::getInstance();
}
function set($name, $value){
$this->vars[$name] = $value;
return true;
}
function remove($name) {
unset($this->vars[$name]);
return true;
}
//obtiene el contenido del tema ya con todos los valores sutituidos en las variables.
function fetch($file){
$this->exec($file);
return $this->output;
}
//muestra el contenido del tema ya con todos los valroes sustituidos en las variables.
function display($file){
$this->exec($file);
echo $this->output;
}
//corre el proceso de sustitucion de valores en las variables del theme y retorna todo en la variable $this->output para ser devuelto por: fetch o display
function exec($file){
$this->file = $file;
$output = file_get_contents($file);
$this->output = $output;
$this->registrar_vars();
$this->__();
$this->eval_control_structures();
//evaluate All as PHP code
ob_start();eval($this->output);
$this->output = ob_get_clean();
}
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);
//Converting the {__(\'word\')} format to {__('word')}
#$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
}
//sustituye las variables en el output del template
function registrar_vars(){
foreach($this->vars as $k=>$v){
//pre($this->vars);
if(is_array($v)){
//Si es un arreglo, se intenta procesar un nivel mas adentro para sustituir en el theme por lo que tenga: nombredearreglo.dato
foreach($v as $_k=>$_v)
if(!is_array($_v))
$this->output = str_replace('{'.$k.'.'.$_k.'}',$_v,$this->output);
}else{
// sustituimos directamente las variables {$variable}
$this->output = str_replace('{'.$k.'}',$v,$this->output);
}
}
//replacing {$key} format by $this->vars['key']
//replacing {$array.key} format by $this->vars['array']['key']
$patrones = array(
'/{\$([^ \.}]+)}/s',
'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
);
$reemplazos = array(
"\$this->vars['$1']",
"\$this->vars['$1']['$2']"
);
$this->output = preg_replace($patrones, $reemplazos, $this->output);
}
//Utiliza gettext
function __(){
$patron = "/{__\((?:'|\")([^\)]+?)(?:'|\")\)}/s";
preg_match_all($patron,$this->output,$out);
foreach($out[1] as $k=>$v){
$this->output = str_replace("{__('$v')}",$this->l10n->__($v),$this->output);
}
}
}
?>

View File

@ -55,14 +55,15 @@ if($installed) {
require_once($configFile);
}
require_once("classes/configuration.class.php");
require_once("classes/textile.class.php");
require_once("classes/gelato.class.php");
require_once("classes/templates.class.php");
require_once("classes/pagination.class.php");
require_once("classes/user.class.php");
require_once("classes/comments.class.php");
require_once("classes/feeds.class.php");
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'configuration.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'textile.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gelato.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'pagination.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'user.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'comments.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'feeds.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'mysql_connection.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'streams.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gettext.class.php');

309
index.php
View File

@ -17,10 +17,9 @@ if(!defined('entry'))define('entry', true);
require_once('entry.php');
global $user, $tumble, $conf;
$template = new plantillas($conf->template);
$theme = new themes;
// My approach to MVC
if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']);
if (isset($_GET["post"])) {
@ -34,8 +33,10 @@ $template = new plantillas($conf->template);
} else {
$id_post = NULL;
}
}
}
$theme->set('id_post',$id_post);
if (isset($_GET["page"])) {
$page_num = $_GET["page"];
} else {
@ -45,16 +46,16 @@ $template = new plantillas($conf->template);
$page_num = NULL;
}
}
$gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
$gelato_includes .= "\t<meta name=\"generator\" content=\"gelato ".codeName()." (".version().")\" />\n";
$gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n";
$gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato.($conf->urlFriendly?"/rss/":"/rss.php")."\"/>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/lightbox.css\" />\n";
$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/lightbox.css\" />\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/jquery.js\"></script>\n";
$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/lightbox.js\"></script>";
$page_title = $conf->title;
$page_title_divisor = " &raquo; "; // it should be set in configuration
$page_title_len = 50; // it should be set in configuration
@ -71,236 +72,212 @@ $template = new plantillas($conf->template);
$page_title_data = $register["title"];
}
$page_title_data = strip_tags($textile->TextileThis($page_title_data));
if (!empty($page_title_data)) {
if (!empty($page_title_data)) {
$page_title .= $page_title_divisor.stripslashes($page_title_data);
}
}
$input = array("{Gelato_includes}","{Title}", "{Page_Title}", "{Description}", "{URL_Tumble}", "{Template_name}");
$output = array($gelato_includes, $conf->title, $page_title, $conf->description, $conf->urlGelato, $conf->template);
$template->cargarPlantilla($input, $output, "template_header");
$template->mostrarPlantilla();
if ($user->isAuthenticated()) {
$input = array("{User}", "{URL_Tumble}");
$output = array($_SESSION["user_login"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_isadmin");
$template->mostrarPlantilla();
}
if (!$id_post) {
$theme->set('Gelato_includes',$gelato_includes);
$theme->set('Title',$conf->title);
$theme->set('Page_Title',$page_title);
$theme->set('Description',$conf->description);
$theme->set('URL_Tumble',$conf->urlGelato);
$theme->set('Template_name',$conf->template);
$theme->set('isAuthenticated',$user->isAuthenticated());
if($user->isAuthenticated()){
$theme->set('User',$_SESSION["user_login"]);
$theme->set('URL_Tumble',$conf->urlGelato);
}
$rows = array();
if(!$id_post){
$limit=$conf->postLimit;
if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric?
$from = (($page_num-1) * $limit);
} else {
$from = 0;
}
$rs = $tumble->getPosts($limit, $from);
if ($tumble->contarRegistros()>0) {
$dateTmp = null;
while($register = mysql_fetch_array($rs)) {
$dateTmp = null;
while($register = mysql_fetch_assoc($rs)) {
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; }
$strEnd=($conf->urlFriendly) ? "/" : "";
$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
$conversation = $register["description"];
$register["description"] = $register["description"];
$register["title"] = stripslashes($register["title"]);
$register["description"] = stripslashes($register["description"]);
switch ($tumble->getType($register["id_post"])) {
$register["description"] = stripslashes($register["description"]);
$postType = $tumble->getType($register["id_post"]);
$row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink;
$theme->set('postType',$postType);
switch ($postType){
case "1":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato, );
$template->cargarPlantilla($input, $output, "template_regular_post");
$template->mostrarPlantilla();
$row['Title'] = $register["title"];
$row['Body'] = $register["description"];
break;
case "2":
case "2":
$fileName = "uploads/".getFileName($register["url"]);
$x = @getimagesize($fileName);
if ($x[0] > 500) {
$x = @getimagesize($fileName);
if ($x[0] > 500) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
} else {
} else {
$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
}
$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_photo");
$template->mostrarPlantilla();
$row['PhotoURL'] = $photoPath;
$row['PhotoAlt'] = strip_tags($register["description"]);
$row['Caption'] = $register["description"];
$row['Effect'] = $effect;
break;
case "3":
$input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_quote");
$template->mostrarPlantilla();
$row['Quote'] = $register["description"];
$row['Source'] = $register["title"];
break;
case "4":
if($conf->shorten_links){
$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
}
$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_url");
$template->mostrarPlantilla();
$row['URL'] = $register["url"];
$row['Name'] = $register["title"];
$row['Description'] = $register["description"];
break;
case "5":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($conversation), $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_conversation");
$template->mostrarPlantilla();
$row['Title'] = $register["title"];
$row['Conversation'] = $tumble->formatConversation($conversation);
break;
case "6":
$input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video");
$template->mostrarPlantilla();
$row['Video'] = $tumble->getVideoPlayer($register["url"]);
$row['Caption'] = $register["description"];
break;
case "7":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3");
$template->mostrarPlantilla();
$row['Mp3'] = $tumble->getMp3Player($register["url"]);
$row['Caption'] = $register["description"];
break;
}
$comment = new comments();
$noComments = $comment->countComments($register["id_post"]);
$user = new user();
$username = $user->getUserByID($register["id_user"]);
$input = array("{Permalink}", "{User}", "{Comments_Number}");
$output = array($permalink, $username["name"], $noComments);
$template->cargarPlantilla($input, $output, "template_details");
$template->mostrarPlantilla();
$row['User'] = $username["name"];
$row['Comments_Number'] = $noComments;
$rows[] = $row;
}
$theme->set('rows',$rows);
$p = new pagination;
$p->Items($tumble->getPostsNumber());
$p->limit($limit);
if($conf->urlFriendly){
$p->urlFriendly('[...]');
$p->target($conf->urlGelato."/page/[...]");
}else
$p->target($conf->urlGelato);
$p->currentPage(isset($page_num) ? $page_num : 1);
$p->show();
$theme->set('pagination',$p->getPagination());
} else {
$template->renderizaEtiqueta("No posts in this tumblelog.", "div","error");
}
} else {
$register = $tumble->getPost($id_post);
$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
$strEnd=($conf->urlFriendly) ? "/" : "";
$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
$conversation = $register["description"];
$register["description"] = $register["description"];
$register["title"] = stripslashes($register["title"]);
$register["description"] = stripslashes($register["description"]);
switch ($tumble->getType($register["id_post"])) {
$row['Date_Added'] = $formatedDate;
$row['Permalink'] = $permalink;
$postType = $tumble->getType($register["id_post"]);
$theme->set('postType',$postType);
switch ($postType) {
case "1":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Body}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_regular_post");
$template->mostrarPlantilla();
$row['Title'] = $register["title"];
$row['Body'] = $register["description"];
break;
case "2":
$fileName = "uploads/".getFileName($register["url"]);
$x = @getimagesize($fileName);
if ($x[0] > 500) {
$x = @getimagesize($fileName);
if ($x[0] > 500) {
$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
} else {
$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
}
$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_photo");
$template->mostrarPlantilla();
$row['PhotoURL'] = $photoPath;
$row['PhotoAlt'] = strip_tags($register["description"]);
$row['Caption'] = $register["description"];
$row['Effect'] = $effect;
break;
case "3":
$input = array("{Date_Added}", "{Permalink}", "{Quote}", "{Source}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["description"], $register["title"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_quote");
$template->mostrarPlantilla();
$row['Quote'] = $register["description"];
$row['Source'] = $register["title"];
break;
case "4":
if($conf->shorten_links){
$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
}
$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_url");
$template->mostrarPlantilla();
$row['URL'] = $register["url"];
$row['Name'] = $register["title"];
$row['Description'] = $register["description"];
break;
case "5":
$input = array("{Date_Added}", "{Permalink}", "{Title}", "{Conversation}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $register["title"], $tumble->formatConversation($conversation), $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_conversation");
$template->mostrarPlantilla();
break;
case "6":
$input = array("{Date_Added}", "{Permalink}", "{Video}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getVideoPlayer($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_video");
$template->mostrarPlantilla();
break;
case "7":
$input = array("{Date_Added}", "{Permalink}", "{Mp3}", "{Caption}", "{URL_Tumble}");
$output = array($formatedDate, $permalink, $tumble->getMp3Player($register["url"]), $register["description"], $conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_mp3");
$template->mostrarPlantilla();
break;
$row['Title'] = $register["title"];
$row['Conversation'] = $tumble->formatConversation($conversation);
break;
case "6":
$row['Video'] = $tumble->getVideoPlayer($register["url"]);
$row['Caption'] = $register["description"];
break;
case "7":
$row['Mp3'] = $tumble->getMp3Player($register["url"]);
$row['Caption'] = $register["description"];
break;
}
if ($conf->allowComments) {
$comment = new comments();
$rsComments = $comment->getComments($register["id_post"]);
$user = new user();
$username = $user->getUserByID($register["id_user"]);
$row['User'] = $username["name"];
$textile = new Textile();
if (empty($register["title"])) {
if (!empty($register["description"])) {
@ -312,31 +289,37 @@ $template = new plantillas($conf->template);
$postTitle = $register["title"];
}
$postTitle = strip_tags($textile->TextileThis($postTitle));
$input = array("{Comments_Number}", "{Post_Title}");
$output = array($comment->countComments($register["id_post"]), $postTitle);
$template->precargarPlantillaConBloque($input, $output, "template_comments", "comments");
$row['Post_Title'] = $postTitle;
$row['Comments_Number'] = $comment->countComments($register["id_post"]);
$rows[] = $row;
$theme->set('rows',$rows);
$comments = array();
while($rowComment = mysql_fetch_assoc($rsComments)) {
$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
$input = array("{Id_Comment}", "{Comment_Author}", "{Date}", "{Comment}");
$output = array($rowComment["id_comment"], $commentAuthor, gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime)), $rowComment["content"]);
$template->cargarPlantillaConBloque($input, $output, "template_comments", "comments");
$answers['Id_Comment'] = $rowComment["id_comment"];
$answers['Comment_Author'] = $commentAuthor;
$answers['Date'] = gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime));
$answers['Comment'] = $rowComment["content"];
$comments[] = $answers;
}
$template->mostrarPlantillaConBloque();
$input = array("{User_Cookie}", "{Email_Cookie}", "{Web_Cookie}", "{Id_Post}", "{Form_Action}", "{Date_Added}");
$output = array(isset($_COOKIE['cookie_gel_user'])?$_COOKIE['cookie_gel_user']:'', isset($_COOKIE['cookie_gel_email'])?$_COOKIE['cookie_gel_email']:'', isset($_COOKIE['cookie_gel_web'])?$_COOKIE['cookie_gel_web']:'', $register["id_post"], $conf->urlGelato."/admin/comments.php", gmmktime());
$template->cargarPlantilla($input, $output, "template_comment_post");
$template->mostrarPlantilla();
$theme->set('comments',$comments);
$whois['User_Cookie'] = isset($_COOKIE['cookie_gel_user'])?$_COOKIE['cookie_gel_user']:'';
$whois['Email_Cookie'] = isset($_COOKIE['cookie_gel_email'])?$_COOKIE['cookie_gel_email']:'';
$whois['Web_Cookie'] = isset($_COOKIE['cookie_gel_web'])?$_COOKIE['cookie_gel_web']:'';
$whois['Id_Post'] = $register["id_post"];
$theme->set('Date_Added',gmmktime());
$theme->set('Form_Action',$conf->urlGelato."/admin/comments.php");
$theme->set('whois',$whois);
}
}
$input = array("{URL_Tumble}");
$output = array($conf->urlGelato);
$template->cargarPlantilla($input, $output, "template_footer");
$template->mostrarPlantilla();
?>
$theme->set('URL_Tumble',$conf->urlGelato);
$theme->display(Absolute_Path.'themes/'.$conf->template.'/index.htm');
?>

166
themes/tumblr/index.htm Normal file
View File

@ -0,0 +1,166 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
{Gelato_includes}
<title>{Page_Title}</title>
<!--[if IE]>
<style type="text/css">
div.post div.quote span.quote big.quote {
line-height: 40px;
}
</style>
<![endif]-->
</head>
<body>
<div id="container">
<a href="{URL_Tumble}/rss.php"><img src="{URL_Tumble}/themes/{Template_name}/img/rss.gif" id="rss" alt="RSS" title="RSS" /></a>
<h1><a href="{URL_Tumble}/">{Title}</a></h1>
<div id="description">
{Description}
</div>
{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/Edit my posts</a>&nbsp;&nbsp;
<a target="_top" href="{URL_Tumble}/admin/close.php">Sign out</a>
</div>
{/if}
{block {$rows} as {$row}}
<div class="date">
{$row.Date_Added}
</div>
{if {$postType}==1}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="regular">
<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Body}
</div>
</div>
{elseif {$postType}==2}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="photo">
<a {$row.Effect}><img src="{$row.PhotoURL}" alt="{$row.PhotoAlt}" /></a><br/>
<div class="caption">{$row.Caption}</div>
</div>
</div>
{elseif {$postType}==3}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<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>
</div>
{elseif {$postType}==4}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="link">
&#187; <a href="{$row.URL}">{$row.Name}</a>
<div class="description">{$row.Description}</div>
</div>
</div>
{elseif {$postType}==5}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="conversation">
...<h2><a href="{$row.Permalink}">{$row.Title}</a></h2>
{$row.Conversation}
</div>
</div>
{elseif {$postType}==6}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="video">
{$row.Video}
<div class="caption">{$row.Caption}</div>
</div>
</div>
{elseif {$postType}==7}
<div class="post">
<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="video">
{$row.Mp3}
<div class="caption">{$row.Caption}</div>
</div>
</div>
{/if}
<div class="totalComments">
<h3>Posted by {$row.User} - <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) comments</a></h3>
</div>
{/block}
{if {$id_post}}
<div class="containerComments">
<h3 id="comments">{$row.Comments_Number} answers to &#8220;{$row.Post_Title}&#8221;</h3>
<ol class="commentlist">
{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;
{$comment.Comment_Author} said:
</cite>
<br />
<span class="timestampComment"> at {$comment.Date}</span><br /><br />
{$comment.Comment}
<br /><br />
</li>
{/block}
</ol>
</div>
<div class="containerFormComments">
<h3 id="respond">Add your comment</h3>
<form action="{Form_Action}" method="post" name="commentForm" id="commentForm">
<p>
<label for="username">
<small>Name:</small>
</label>
<input name="username" id="username" value="{whois.User_Cookie}" size="22" tabindex="1" type="text" />
</p>
<p>
<label for="email">
<small>E-mail:</small>
</label>
<input name="email" id="email" value="{whois.Email_Cookie}" size="22" tabindex="2" type="text" />
</p>
<p>
<label for="web">
<small>Website:</small>
</label>
<input name="web" id="web" value="{whois.Web_Cookie}" size="22" tabindex="3" type="text" />
</p>
<p>
<textarea name="content" id="content" cols="100" rows="10" tabindex="4"></textarea>
</p>
<p>
<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;"><a href="http://hobix.com/textile/">Textile</a> syntax is supported.</span>
<p>
<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
</p>
<p>
<input name="id_post" id="id_post" value="{id_post}" type="hidden" />
<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
</p>
</form>
</div>
{else}
{pagination}
{/if}
</div>
<div id="footer">
subscribe via <a href="{URL_Tumble}/rss.php">rss</a> &nbsp;/&nbsp;
powered by <a href="http://www.gelatocms.com/">gelato cms</a>
</div>
</body>
</html>

View File

@ -1,36 +0,0 @@
<div class="containerFormComments">
<h3 id="respond">Add your comment</h3>
<form action="{Form_Action}" method="post" name="commentForm" id="commentForm">
<p>
<label for="username">
<small>Name:</small>
</label>
<input name="username" id="username" value="{User_Cookie}" size="22" tabindex="1" type="text" />
</p>
<p>
<label for="email">
<small>E-mail:</small>
</label>
<input name="email" id="email" value="{Email_Cookie}" size="22" tabindex="2" type="text" />
</p>
<p>
<label for="web">
<small>Website:</small>
</label>
<input name="web" id="web" value="{Web_Cookie}" size="22" tabindex="3" type="text" />
</p>
<p>
<textarea name="content" id="content" cols="100" rows="10" tabindex="4"></textarea>
</p>
<p>
<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;"><a href="http://hobix.com/textile/">Textile</a> syntax is supported.</span>
<p>
<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
</p>
<p>
<input name="id_post" id="id_post" value="{Id_Post}" type="hidden" />
<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
</p>
</form>
</div>

View File

@ -1,17 +0,0 @@
<div class="containerComments">
<h3 id="comments">{Comments_Number} answers to &#8220;{Post_Title}&#8221;</h3>
<ol class="commentlist">
[bloque: comments]
<li class="alt" id="comment-{Id_Comment}">
<cite>
<a href="#comment-{Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;
{Comment_Author} said:
</cite>
<br />
<span class="timestampComment"> at {Date}</span><br /><br />
{Comment}
<br /><br />
</li>
[/bloque: comments]
</ol>
</div>

View File

@ -1,16 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="conversation">
<h2><a href="{Permalink}">{Title}</a></h2>
{Conversation}
</div>
</div>

View File

@ -1,3 +0,0 @@
<div class="totalComments">
<h3>Posted by {User} - <a href="{Permalink}#comments">( {Comments_Number} ) comments</a></h3>
</div>

View File

@ -1,8 +0,0 @@
</div>
<div id="footer">
subscribe via <a href="{URL_Tumble}/rss.php">rss</a> &nbsp;/&nbsp;
powered by <a href="http://www.gelatocms.com/">gelato cms</a>
</div>
</body>
</html>

View File

@ -1,23 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
{Gelato_includes}
<title>{Page_Title}</title>
<!--[if IE]>
<style type="text/css">
div.post div.quote span.quote big.quote {
line-height: 40px;
}
</style>
<![endif]-->
</head>
<body>
<div id="container">
<a href="{URL_Tumble}/rss.php"><img src="{URL_Tumble}/themes/{Template_name}/img/rss.gif" id="rss" alt="RSS" title="RSS" /></a>
<h1><a href="{URL_Tumble}/">{Title}</a></h1>
<div id="description">
{Description}
</div>

View File

@ -1,5 +0,0 @@
<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/Edit my posts</a>&nbsp;&nbsp;
<a target="_top" href="{URL_Tumble}/admin/close.php">Sign out</a>
</div>

View File

@ -1,16 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="video">
{Mp3}
<div class="caption">{Caption}</div>
</div>
</div>

View File

@ -1,20 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="photo">
<a {Effect}><img src="{PhotoURL}" alt="{PhotoAlt}" /></a><br/>
<div class="caption">{Caption}</div>
</div>
</div>

View File

@ -1,18 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="quote">
<span class="quote">
<big class="quote"><a href="{Permalink}">&#147;</a></big> {Quote}
</span>
<div class="source">&mdash; {Source}</div>
</div>
</div>

View File

@ -1,13 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="regular">
<h2><a href="{Permalink}">{Title}</a></h2>
{Body}
</div>
</div>

View File

@ -1,16 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="link">
&#187; <a href="{URL}">{Name}</a>
<div class="description">{Description}</div>
</div>
</div>

View File

@ -1,16 +0,0 @@
<div class="date">
{Date_Added}
</div>
<div class="post">
<a href="{Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
<div class="video">
{Video}
<div class="caption">{Caption}</div>
</div>
</div>