* theme forms in separate files.
* fixed problem with trimString function.
* fixed problem when it use jQuery in themes. {$("selector")} ->{$this->array['(\"selector\")']}
master
parent
316d2c2b6d
commit
b3b04187fb
|
|
@ -170,34 +170,41 @@ if ($user->isAuthenticated()) {
|
||||||
|
|
||||||
if (!isset($_GET['new'])) $_GET['new'] = 'post';
|
if (!isset($_GET['new'])) $_GET['new'] = 'post';
|
||||||
|
|
||||||
$theme->set('date',$date);
|
$form = new themes;
|
||||||
$theme->set('id_user',$_SESSION['user_id']);
|
$form->set('date',$date);
|
||||||
$theme->set('type',$_GET["new"]);
|
$form->set('id_user',$_SESSION['user_id']);
|
||||||
$theme->set('editBody',$body);
|
$form->set('type',$_GET["new"]);
|
||||||
|
$form->set('editBody',$body);
|
||||||
switch ($_GET["new"]) {
|
switch ($_GET["new"]) {
|
||||||
case "post":
|
case "post":
|
||||||
$theme->set('editTitle',$title);
|
$form->set('editTitle',$title);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_post.htm'));
|
||||||
break;
|
break;
|
||||||
case "photo":
|
case "photo":
|
||||||
$url = str_replace("../", $conf->urlGelato."/", $url);
|
$url = str_replace("../", $conf->urlGelato."/", $url);
|
||||||
$theme->set('editUrl',$url);
|
$form->set('editUrl',$url);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_photo.htm'));
|
||||||
break;
|
break;
|
||||||
case "quote":
|
case "quote":
|
||||||
$theme->set('editTitle',$title);
|
$form->set('editTitle',$title);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_quote.htm'));
|
||||||
break;
|
break;
|
||||||
case "url":
|
case "url":
|
||||||
$theme->set('editTitle',$title);
|
$form->set('editTitle',$title);
|
||||||
$theme->set('editUrl',$url);
|
$form->set('editUrl',$url);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_link.htm'));
|
||||||
break;
|
break;
|
||||||
case "conversation":
|
case "conversation":
|
||||||
$theme->set('editTitle',$title);
|
$form->set('editTitle',$title);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_conversation.htm'));
|
||||||
break;
|
break;
|
||||||
case "video":
|
case "video":
|
||||||
$theme->set('editUrl',$url);
|
$form->set('editUrl',$url);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_video.htm'));
|
||||||
break;
|
break;
|
||||||
case "mp3":
|
case "mp3":
|
||||||
$theme->set('editUrl',$url);
|
$form->set('editUrl',$url);
|
||||||
|
$theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_mp3.htm'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,275 +72,7 @@
|
||||||
<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>
|
<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}
|
||||||
{if {$type}=='post'}
|
{form}
|
||||||
<div>
|
|
||||||
<label for="title" style="display:block;">Title <span class="option">(optional)</span></label>
|
|
||||||
<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="description" style="display:block;">Body</label>
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="url" id="url" value="" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
description: "required"
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='photo'}
|
|
||||||
<div id="photo_upload">
|
|
||||||
<label for="description">Photo</label>
|
|
||||||
<br /><input type="file" name="photo" id="photo" accept="image/gif,image/jpeg,image/jpg,image/png"/>
|
|
||||||
<div style="font-size:11px; color:#666; margin-top:5px;">
|
|
||||||
Supports JPEG, GIF and PNG. <strong>Max size is 10 MB.</strong>
|
|
||||||
</div>
|
|
||||||
<div style="font-size:11px; color:#666; margin-top:5px;">
|
|
||||||
<a href="#" class="linkFrm">Use a URL instead</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="photo_url">
|
|
||||||
<label for="description">Photo URL</label>
|
|
||||||
<br /><input class="input-text" type="text" name="url" id="url" size="80" value="{editUrl}" />
|
|
||||||
<div style="font-size:11px; color:#666; margin-top:5px;">
|
|
||||||
<a href="#" class="linkFrm">Use a upload form instead</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="description" style="display:block;">Caption <span class="option">(optional)</span></label>
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="title" id="title" value="" />
|
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$('#photo_url').css('display','none');
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
photo: {
|
|
||||||
required: function() {
|
|
||||||
return ($('#photo_upload').css('display')!= 'none') ? true : false;
|
|
||||||
},
|
|
||||||
accept: "(jpe?g|gif|png)"
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
required: function() {
|
|
||||||
return ($('#photo_url').css('display')!= 'none') ? true : false;
|
|
||||||
},
|
|
||||||
url: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#photo_upload a.linkFrm").click( function() {
|
|
||||||
$('#photo_upload').css('display','none');
|
|
||||||
$('#photo_url').css('display','block');
|
|
||||||
$('#photo').val('');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$("#photo_url a.linkFrm").click( function() {
|
|
||||||
$('#photo_url').css('display','none');
|
|
||||||
$('#photo_upload').css('display','block');
|
|
||||||
$('#url').val('');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='quote'}
|
|
||||||
<div>
|
|
||||||
<label for="description">Quote</label>
|
|
||||||
<br /><textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="title">Source <span class="option">(optional)</span></label>
|
|
||||||
<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="url" id="url" value="" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
description: "required"
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='url'}
|
|
||||||
<div>
|
|
||||||
<label for="title">Name <span class="option">(optional)</span></label>
|
|
||||||
<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="url">URL</label>
|
|
||||||
<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div id="add_link_description" style="margin-top:5px;">
|
|
||||||
<a class="linkFrm" href="#" onclick="document.getElementById('link_description').style.display = ''; document.getElementById('add_link_description').style.display = 'none'; return false;" style="font-size:11px;">Add a description</a><br /><br />
|
|
||||||
</div>
|
|
||||||
<div id="link_description" style="display:none;">
|
|
||||||
<label for="description">Description</label><br />
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
url: {
|
|
||||||
required: true,
|
|
||||||
url: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='conversation'}
|
|
||||||
<div>
|
|
||||||
<label for="title">Title <span class="option">(optional)</span></label><br />
|
|
||||||
<input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="description">Conversation</label>
|
|
||||||
<div style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
|
|
||||||
<span style="font-weight: bold;">Example</span><br>
|
|
||||||
<span style="font-style: italic;">
|
|
||||||
Geek: Wow an open source tumblelog CMS!!.<br>
|
|
||||||
Normal: Tumble... what??<br>
|
|
||||||
Geek: Read the wikipedia!!
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="url" id="url" value="" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
description: "required"
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.parent().children("label"))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='video'}
|
|
||||||
<div>
|
|
||||||
<label for="url">Video URL</label>
|
|
||||||
<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
|
|
||||||
<div style="color: rgb(136, 136, 136); margin-bottom: 5px; font-size: 11px; font-weight: bold;">
|
|
||||||
This is the URL from the video sites YouTube, Vimeo, Yahoo, Daily Motion <br />
|
|
||||||
or even an Slide Share Presentation.<br />
|
|
||||||
<span style="font-size: 10px; font-weight: normal;">(ie. http://youtube.com/watch?v=HcBFLN9cli0)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="description">Caption <span class="option">(optional)</span></label><br />
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description" tabindex="2">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="title" id="title" value="" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
url: {
|
|
||||||
required: true,
|
|
||||||
url: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{elseif {$type}=='mp3'}
|
|
||||||
<div>
|
|
||||||
<label for="url">MP3 URL</label>
|
|
||||||
<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
|
|
||||||
<div style="color: rgb(136, 136, 136); margin-bottom: 5px; font-size: 11px; font-weight: bold;">
|
|
||||||
This is the MP3 file URL or a GoEar URL or an Odeo URL.<br>
|
|
||||||
<span style="font-size: 10px; font-weight: normal;">(ie. http://www.goear.com/listen.php?v=c0a2c85)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="description">Caption <span class="option">(optional)</span></label><br />
|
|
||||||
<textarea rows="12" cols="84" name="description" id="description" tabindex="2">{editBody}</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="title" id="title" value="" />
|
|
||||||
<input type="hidden" name="type" id="type" value="{type}" />
|
|
||||||
<input type="hidden" name="date" id="date" value="{date}" />
|
|
||||||
<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$("#autosave").validate({
|
|
||||||
rules: {
|
|
||||||
url: {
|
|
||||||
required: true,
|
|
||||||
url: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errorElement: "span",
|
|
||||||
errorClass: "validate_span",
|
|
||||||
errorPlacement: function(label, element) {
|
|
||||||
label.prependTo(element.prev())
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
|
<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
|
||||||
{__("Some HTML allowed")}:<br />
|
{__("Some HTML allowed")}:<br />
|
||||||
|
|
|
||||||
|
|
@ -487,12 +487,11 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
return $tmpStr;
|
return $tmpStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimString($string, $len = "") {
|
function trimString($string, $len=50) {
|
||||||
if($len>strlen($string) or $len<1 or strlen($string)<1) {
|
if($len>strlen(strip_tags($string)) or $len<1 or strlen(strip_tags($string))<1)
|
||||||
return strip_tags($string);
|
return strip_tags($string);
|
||||||
}
|
|
||||||
$string = strip_tags($string);
|
$string = strip_tags($string);
|
||||||
$len = (empty($len)) ? "50" : $len ;
|
|
||||||
return (strpos($string," ",$len))?substr_replace($string, "...", $len):$string;
|
return (strpos($string," ",$len))?substr_replace($string, "...", $len):$string;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -13,7 +13,7 @@ class themes{
|
||||||
var $vars=array(); //variable para apilar las variables que se asignan a la plantilla
|
var $vars=array(); //variable para apilar las variables que se asignan a la plantilla
|
||||||
|
|
||||||
function themes(){
|
function themes(){
|
||||||
#$this->l10n = l10n::getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set($name, $value){
|
function set($name, $value){
|
||||||
|
|
@ -46,6 +46,7 @@ class themes{
|
||||||
$this->registrar_vars();
|
$this->registrar_vars();
|
||||||
$this->__();
|
$this->__();
|
||||||
$this->eval_control_structures();
|
$this->eval_control_structures();
|
||||||
|
|
||||||
//evaluate All as PHP code
|
//evaluate All as PHP code
|
||||||
ob_start();eval($this->output);
|
ob_start();eval($this->output);
|
||||||
$this->output = stripslashes(ob_get_clean());
|
$this->output = stripslashes(ob_get_clean());
|
||||||
|
|
@ -67,9 +68,6 @@ class themes{
|
||||||
//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
|
//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']['$2']}",$this->output);
|
||||||
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$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
|
//sustituye las variables en el output del template
|
||||||
|
|
@ -90,13 +88,18 @@ class themes{
|
||||||
//replacing {$key} format by $this->vars['key']
|
//replacing {$key} format by $this->vars['key']
|
||||||
//replacing {$array.key} format by $this->vars['array']['key']
|
//replacing {$array.key} format by $this->vars['array']['key']
|
||||||
$patrones = array(
|
$patrones = array(
|
||||||
'/{\$([^ \.}]+)}/s',
|
#'/{\$([^ \.}]+)}/s',
|
||||||
'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
|
#'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
|
||||||
|
'/{\$(\w+)}/s',
|
||||||
|
'/{\$(\w+)\.(\w+)}/s',
|
||||||
|
'/\$(\W)/s'
|
||||||
);
|
);
|
||||||
$reemplazos = array(
|
$reemplazos = array(
|
||||||
"\$this->vars['$1']",
|
"\$this->vars['$1']",
|
||||||
"\$this->vars['$1']['$2']"
|
"\$this->vars['$1']['$2']",
|
||||||
|
"\\\\$$1"
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->output = preg_replace($patrones, $reemplazos, $this->output);
|
$this->output = preg_replace($patrones, $reemplazos, $this->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,6 @@ $theme = new themes;
|
||||||
|
|
||||||
$conversation = $register["description"];
|
$conversation = $register["description"];
|
||||||
|
|
||||||
$register["description"] = $register["description"];
|
|
||||||
|
|
||||||
$register["title"] = stripslashes($register["title"]);
|
$register["title"] = stripslashes($register["title"]);
|
||||||
$register["description"] = stripslashes($register["description"]);
|
$register["description"] = stripslashes($register["description"]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue