From 71e6e63f2712d2075eca7fff5a45c73f1cfa383f Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Mon, 21 May 2012 23:11:02 +0200 Subject: ste:comment_form can now generate a previewbtn by default. --- ratatoeskr/frontend.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ratatoeskr/frontend.php') diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 0bc083b..038485a 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -392,8 +392,9 @@ $ste->register_tag("article_comments", function($ste, $params, $sub) * Generates a HTML form tag that allows the visitor to write a comment. * * Parameters: - * article - (mandatory) The name of the variable, where the article is stored at. - * default - (optional) If not empty, a default formular with the mandatory fields will be generated. + * article - (mandatory) The name of the variable, where the article is stored at. + * default - (optional) If not empty, a default formular with the mandatory fields will be generated. + * previewbtn - (optional) If not empty and default form is choosen, a preview button will also be generated. * * Tag Content: * The tag's content will be written into the HTML form tag. @@ -446,11 +447,13 @@ $ste->register_tag("comment_form", function($ste, $params, $sub) $form_header = "
"; + $previewbtn = $ste->evalbool(@$params["previewbtn"]) ? " " : ""; + if($ste->evalbool(@$params["default"])) $form_body = "

{$translation["comment_form_name"]}:

{$translation["comment_form_mail"]}:

{$translation["comment_form_text"]}:

-

"; +

$previewbtn

"; else { $ste->vars["current"]["oldcomment"] = array( -- cgit v1.2.3-70-g09d2 From 56196c68fdbef92c6d24f100e52530e07ac01822 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 1 Jun 2012 11:35:13 +0200 Subject: Implemented on_* tags. UNTESTED! on_article / on_tag / on_section will execute and return its content, if currently a(n) article / tag / section is requested. --- ratatoeskr/frontend.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'ratatoeskr/frontend.php') diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 038485a..13fd14a 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -654,6 +654,55 @@ $ste->register_tag("title", function($ste, $params, $sub) return "$pagetitle"; }); +function make_on_anything_tag($field) +{ + return function($ste, $params, $sub) use ($field) + { + if($ste->evalbool($ste->vars["current"][$field])) + { + if(!empty($params["var"])) + $ste->set_var_by_name($params["var"], $ste->vars["current"][$field]); + return $sub($ste); + } + }; +} + +/* + * STETag: on_article + * Execute tag content, if currently an article is requested. + * + * Parameters: + * var - (optional) If set, the article will be stored in the variable with that name (see for sub-fields). + * + * Returns: + * The executed tag content, if an article was requested. + */ +$ste->register_tag("on_article", make_on_anything_tag("article")); + +/* + * STETag: on_tag + * Execute tag content, if currently a tag is requested. + * + * Parameters: + * var - (optional) If set, the tag will be stored in the variable with that name (see for sub-fields). + * + * Returns: + * The executed tag content, if a tag was requested. + */ +$ste->register_tag("on_tag", make_on_anything_tag("tag")); + +/* + * STETag: on_section + * Execute tag content, if currently a section is requested. + * + * Parameters: + * var - (optional) If set, the section will be stored in the variable with that name (see for sub-fields). + * + * Returns: + * The executed tag content, if a section was requested. + */ +$ste->register_tag("on_section", make_on_anything_tag("section")); + /* * STEVar: $current * Holds information about the current page in the frontend (the part of the webpage, the visitor sees). -- cgit v1.2.3-70-g09d2 From 9f4d651f873b5138dfa6fa43cb0c671316ea38c3 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 6 Jun 2012 17:41:38 +0200 Subject: articles_get can take section/tag as a var now. * For better cooperation with the on_* tags (which are tested now). * Should also reduce the number of SQL-Queries if used correctly and therefore improve performance. --- ratatoeskr/frontend.php | 57 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'ratatoeskr/frontend.php') diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 13fd14a..76b0afc 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -158,18 +158,20 @@ function comment_transform_ste($comment) * The fields of an article can be looked up at . * * Parameters: - * var - (mandatory) The name of the variable, where the current article should be stored at. - * id - (optional) Filter by ID. - * urlname - (optional) Filter by urlname. - * section - (optional) Filter by section (section name). - * status - (optional) Filter by status (numeric, ). - * tag - (optional) Filter by tag (tag name). - * sort - (optional) How to sort. Format: "fieldname direction" where fieldname is one of [id, urlname, title, timestamp] and direction is one of [asc, desc]. - * perpage - (optional) How many articles should be shown per page (default unlimited). - * page - (optional) On which page are we (starting with 1). Useful in combination with $current[page], and . (Default: 1) - * maxpage - (optional) (variable name) If given, the number of pages are stored in this variable. - * skip - (optional) How many articles should be skipped? (Default: none) - * count - (optional) How many articles to output. (Default unlimited) + * var - (mandatory) The name of the variable, where the current article should be stored at. + * id - (optional) Filter by ID. + * urlname - (optional) Filter by urlname. + * section - (optional) Filter by section (section name). + * sectionvar - (optional) Filter by section (Name of variable that contains a section). + * status - (optional) Filter by status (numeric, ). + * tag - (optional) Filter by tag (tag name). + * tagvar - (optional) Filter by tag (Name of variable that contains a tag). + * sort - (optional) How to sort. Format: "fieldname direction" where fieldname is one of [id, urlname, title, timestamp] and direction is one of [asc, desc]. + * perpage - (optional) How many articles should be shown per page (default unlimited). + * page - (optional) On which page are we (starting with 1). Useful in combination with $current[page], and . (Default: 1) + * maxpage - (optional) (variable name) If given, the number of pages are stored in this variable. + * skip - (optional) How many articles should be skipped? (Default: none) + * count - (optional) How many articles to output. (Default unlimited) * * Tag Content: * The tag's content will be executed for every article. The current article will be written to the variable specified by the var parameter before. @@ -183,27 +185,32 @@ $ste->register_tag("articles_get", function($ste, $params, $sub) if(!isset($params["var"])) throw new \ste\RuntimeError("Parameter var is needed in article_get!"); - if(isset($params["section"])) - { - try - { - $params["section"] = Section::by_name($params["section"]); - } - catch(NotFoundError $e) - { - unset($params["section"]); - } - } $criterias = array("langavail" => $lang, "onlyvisible" => True); if(isset($params["id"])) $criterias["id"] = $params["id"]; if(isset($params["urlname"])) $criterias["urlname"]; - if(isset($params["section"])) - $criterias["section"] = $params["section"]; if(isset($params["status"])) $criterias["status"] = $params["status"]; + if(isset($params["sectionvar"])) + { + $sectionvar = $ste->get_var_by_name($params["sectionvar"]); + $criterias["section"] = $sectionvar["__obj"]; + } + else if(isset($params["section"])) + { + try + { + $criterias["section"] = Section::by_name($params["section"]); + } + catch(DoesNotExistError $e) {} + } + if(isset($params["tagvar"])) + { + $tagvar = $ste->get_var_by_name($params["tagvar"]); + $criterias["tag"] = $tagvar["__obj"]; + } if(isset($params["tag"])) { try -- cgit v1.2.3-70-g09d2