aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-06-06 17:41:38 +0200
committerKevin Chabowski <kevin@kch42.de>2012-06-06 17:41:38 +0200
commit9f4d651f873b5138dfa6fa43cb0c671316ea38c3 (patch)
tree1f3dfc56fe686fc5272c5c09f69ce342f38b2d35
parent56196c68fdbef92c6d24f100e52530e07ac01822 (diff)
downloadratatoeskr-cms-9f4d651f873b5138dfa6fa43cb0c671316ea38c3.tar.gz
ratatoeskr-cms-9f4d651f873b5138dfa6fa43cb0c671316ea38c3.tar.bz2
ratatoeskr-cms-9f4d651f873b5138dfa6fa43cb0c671316ea38c3.zip
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.
-rw-r--r--ratatoeskr/frontend.php57
1 files 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 <article_transform_ste>.
*
* 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, <ARTICLE_STATUS_>).
- * 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], <page_prev> and <page_next>. (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, <ARTICLE_STATUS_>).
+ * 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], <page_prev> and <page_next>. (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