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 ++++++--- ratatoeskr/translations/de.php | 2 ++ ratatoeskr/translations/en.php | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) 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( diff --git a/ratatoeskr/translations/de.php b/ratatoeskr/translations/de.php index 66c68d8..ecf94b8 100644 --- a/ratatoeskr/translations/de.php +++ b/ratatoeskr/translations/de.php @@ -33,6 +33,8 @@ $translation = array( "comment_form_name" => "Dein Name", "comment_form_mail" => "Deine E-Mailadresse", "comment_form_text" => "Dein Kommentar (Markdown Format)", + "comment_form_submit" => "Kommentar senden", + "comment_form_preview" => "Vorschau", "page_prev" => "<-- vorherige Seite", "page_next" => "nächste Seite -->", "e404_details" => "Die Seite [[URL]] konte nicht gefunden werden. Das tut uns leid.", diff --git a/ratatoeskr/translations/en.php b/ratatoeskr/translations/en.php index 27374c6..b2755fc 100644 --- a/ratatoeskr/translations/en.php +++ b/ratatoeskr/translations/en.php @@ -33,6 +33,8 @@ $translation = array( "comment_form_name" => "Your name", "comment_form_mail" => "Your E-Mailaddress", "comment_form_text" => "Your comment (Markdown format)", + "comment_form_submit" => "Submit comment", + "comment_form_preview" => "Preview", "page_prev" => "<-- previous page", "page_next" => "next page -->", "e404_details" => "The page [[URL]] could not be found. Sorry.", -- 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(+) 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(-) 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 From 64c43443cef210b3c7c35c8be048193ac78858a3 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 6 Jun 2012 18:25:58 +0200 Subject: Default template now uses new features. --- .../templates/src/usertemplates/standard.html | 118 +++++++++------------ 1 file changed, 51 insertions(+), 67 deletions(-) diff --git a/ratatoeskr/templates/src/usertemplates/standard.html b/ratatoeskr/templates/src/usertemplates/standard.html index c4d1eb9..ef0862e 100644 --- a/ratatoeskr/templates/src/usertemplates/standard.html +++ b/ratatoeskr/templates/src/usertemplates/standard.html @@ -1,72 +1,56 @@ - - $current[section] - - -
-

$article[title]

- $article[excerpt] - -
-
- - -
-
+ + +
+

$article[title]

+ $article[excerpt] + +
+
+ + +
- - $current[article] - -
-

$current[article][title]

- - $current[article][text] - - $current[article][comments_allowed] - -

Comments ()

- -
-

Name: $comment[author]

-

Date: %d. %B %Y, %H:%M

- $comment[text] -
-
- ?{$current[commented]|Comment sucessfully stored!|} - ?{$current[comment_fail]|Comment could not be stored: $current[comment_fail]|} - $current[comment_prev] - -

Comment preview

-
$current[comment_prev]
-
-
- - Name:
- Mail:
- Text (Markdown):
-
- - -
-
-
-
-
-
+ +
+

$article[title]

+ + $article[text] + + $article[comments_allowed] + +

Comments ()

+ +
+

Name: $comment[author]

+

Date: %d. %B %Y, %H:%M

+ $comment[text] +
+
+ ?{$current[commented]|Comment sucessfully stored!|} + ?{$current[comment_fail]|Comment could not be stored: $current[comment_fail]|} + $current[comment_prev] + +

Comment preview

+
$current[comment_prev]
+
+
+ +
+
+
+
- - $current[tag] - - -
-

$article[title]

- $article[excerpt] - -
-
- - -
-
+ + +
+

$article[title]

+ $article[excerpt] + +
+
+ + +
-- cgit v1.2.3-70-g09d2 From 4c5700e7f61380b82997566e1e29b947e5fb73d0 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 6 Jun 2012 21:54:24 +0200 Subject: Removed debug stuff from standard.html template. --- ratatoeskr/templates/src/usertemplates/standard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ratatoeskr/templates/src/usertemplates/standard.html b/ratatoeskr/templates/src/usertemplates/standard.html index ef0862e..ef78001 100644 --- a/ratatoeskr/templates/src/usertemplates/standard.html +++ b/ratatoeskr/templates/src/usertemplates/standard.html @@ -16,7 +16,7 @@

$article[title]

- $article[text] + $article[text] $article[comments_allowed] -- cgit v1.2.3-70-g09d2