From b3b04187fbf2b98c54f53d25db77c657e40da524 Mon Sep 17 00:00:00 2001 From: Victor De la Rocha Date: Thu, 30 Oct 2008 14:29:28 +0000 Subject: [PATCH] * theme forms in separate files. * fixed problem with trimString function. * fixed problem when it use jQuery in themes. {$("selector")} ->{$this->array['(\"selector\")']} --- admin/index.php | 33 +++-- admin/themes/admin/index.htm | 270 +---------------------------------- classes/functions.php | 9 +- classes/themes.class.php | 17 ++- index.php | 2 - 5 files changed, 35 insertions(+), 296 deletions(-) diff --git a/admin/index.php b/admin/index.php index bf3d247..bf5ae93 100644 --- a/admin/index.php +++ b/admin/index.php @@ -170,34 +170,41 @@ if ($user->isAuthenticated()) { if (!isset($_GET['new'])) $_GET['new'] = 'post'; - $theme->set('date',$date); - $theme->set('id_user',$_SESSION['user_id']); - $theme->set('type',$_GET["new"]); - $theme->set('editBody',$body); - + $form = new themes; + $form->set('date',$date); + $form->set('id_user',$_SESSION['user_id']); + $form->set('type',$_GET["new"]); + $form->set('editBody',$body); switch ($_GET["new"]) { 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; case "photo": $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; 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; case "url": - $theme->set('editTitle',$title); - $theme->set('editUrl',$url); + $form->set('editTitle',$title); + $form->set('editUrl',$url); + $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_link.htm')); break; 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; 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; 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; } diff --git a/admin/themes/admin/index.htm b/admin/themes/admin/index.htm index 10e5d8b..be99ca6 100644 --- a/admin/themes/admin/index.htm +++ b/admin/themes/admin/index.htm @@ -72,275 +72,7 @@
{if {$postId}}{/if} - {if {$type}=='post'} -
- -
-
-
- - -
- - - - - - - - {elseif {$type}=='photo'} -
- -
-
- Supports JPEG, GIF and PNG.  Max size is 10 MB. -
-
- Use a URL instead -
-
- -
- -
-
- Use a upload form instead -
-
- -
- - -
- - - - - - - - - {elseif {$type}=='quote'} -
- -
-
-
- -
-
- - - - - - - - {elseif {$type}=='url'} -
- -
-
-
- -
-
-
- - -
- - - - - - {elseif {$type}=='conversation'} -
-
- -
- -
- -
- Example
- - Geek: Wow an open source tumblelog CMS!!.
- Normal: Tumble... what??
- Geek: Read the wikipedia!! -
-
- -
- - - - - - - - {elseif {$type}=='video'} -
- -
-
- This is the URL from the video sites YouTube, Vimeo, Yahoo, Daily Motion
- or even an Slide Share Presentation.
- (ie. http://youtube.com/watch?v=HcBFLN9cli0) -
-
-
-
- -
- - - - - - - - {elseif {$type}=='mp3'} -
- -
-
- This is the MP3 file URL or a GoEar URL or an Odeo URL.
- (ie. http://www.goear.com/listen.php?v=c0a2c85) -
-
-
-
- -
- - - - - - - - {/if} - + {form}

{__("Some HTML allowed")}:
diff --git a/classes/functions.php b/classes/functions.php index b854b3b..a664252 100644 --- a/classes/functions.php +++ b/classes/functions.php @@ -487,12 +487,11 @@ if(!defined('entry') || !entry) die('Not a valid page'); return $tmpStr; } - function trimString($string, $len = "") { - if($len>strlen($string) or $len<1 or strlen($string)<1) { + function trimString($string, $len=50) { + if($len>strlen(strip_tags($string)) or $len<1 or strlen(strip_tags($string))<1) return 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; } ?> \ No newline at end of file diff --git a/classes/themes.class.php b/classes/themes.class.php index e688b64..c35f837 100644 --- a/classes/themes.class.php +++ b/classes/themes.class.php @@ -13,7 +13,7 @@ class themes{ var $vars=array(); //variable para apilar las variables que se asignan a la plantilla function themes(){ - #$this->l10n = l10n::getInstance(); + } function set($name, $value){ @@ -46,6 +46,7 @@ class themes{ $this->registrar_vars(); $this->__(); $this->eval_control_structures(); + //evaluate All as PHP code ob_start();eval($this->output); $this->output = stripslashes(ob_get_clean()); @@ -67,9 +68,6 @@ class themes{ //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 @@ -90,13 +88,18 @@ class themes{ //replacing {$key} format by $this->vars['key'] //replacing {$array.key} format by $this->vars['array']['key'] $patrones = array( - '/{\$([^ \.}]+)}/s', - '/{\$([^ \.}]+)\.([^ \.}]+)}/s' + #'/{\$([^ \.}]+)}/s', + #'/{\$([^ \.}]+)\.([^ \.}]+)}/s' + '/{\$(\w+)}/s', + '/{\$(\w+)\.(\w+)}/s', + '/\$(\W)/s' ); $reemplazos = array( "\$this->vars['$1']", - "\$this->vars['$1']['$2']" + "\$this->vars['$1']['$2']", + "\\\\$$1" ); + $this->output = preg_replace($patrones, $reemplazos, $this->output); } diff --git a/index.php b/index.php index ff96591..717aa34 100644 --- a/index.php +++ b/index.php @@ -112,8 +112,6 @@ $theme = new themes; $conversation = $register["description"]; - $register["description"] = $register["description"]; - $register["title"] = stripslashes($register["title"]); $register["description"] = stripslashes($register["description"]);