From 48972a847fe48f5e2919caf1d777262c6f0121d8 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sun, 13 Nov 2011 14:14:06 +0100 Subject: Implemented the article list for the backend. --- ratatoeskr/backend/main.php | 104 +++++++++++++++++- .../cms_style/images/sortarrow_down_filled.png | Bin 0 -> 232 bytes .../cms_style/images/sortarrow_down_outline.png | Bin 0 -> 278 bytes ratatoeskr/cms_style/images/sortarrow_shape.svg | 91 ++++++++++++++++ .../cms_style/images/sortarrow_up_filled.png | Bin 0 -> 245 bytes .../cms_style/images/sortarrow_up_outline.png | Bin 0 -> 278 bytes .../templates/src/systemtemplates/articles.html | 119 ++++++++++++++------- .../src/systemtemplates/tags_overview.html | 2 +- ratatoeskr/translations/en.php | 10 +- 9 files changed, 282 insertions(+), 44 deletions(-) create mode 100644 ratatoeskr/cms_style/images/sortarrow_down_filled.png create mode 100644 ratatoeskr/cms_style/images/sortarrow_down_outline.png create mode 100644 ratatoeskr/cms_style/images/sortarrow_shape.svg create mode 100644 ratatoeskr/cms_style/images/sortarrow_up_filled.png create mode 100644 ratatoeskr/cms_style/images/sortarrow_up_outline.png (limited to 'ratatoeskr') diff --git a/ratatoeskr/backend/main.php b/ratatoeskr/backend/main.php index 4caa654..a6df9ec 100644 --- a/ratatoeskr/backend/main.php +++ b/ratatoeskr/backend/main.php @@ -504,12 +504,112 @@ $backend_subactions = url_action_subactions(array( $ste->vars["submenu"] = "articles"; $ste->vars["pagetitle"] = $translation["menu_articles"]; - + if(isset($_POST["delete"]) and ($_POST["really_delete"] == "yes")) + { + foreach($_POST["article_multiselect"] as $article_urlname) + { + try + { + $article = Article::by_urlname($article_urlname); + $article->delete(); + } + catch(DoesNotExistError $e) + { + continue; + } + } + + $ste->vars["success"] = $translation["articles_deleted"]; + } $articles = Article::all(); /* Filtering */ - #if(isset) + $filterquery = array(); + if(!empty($_GET["filter_urlname"])) + { + $searchfor = strtolower($_GET["filter_urlname"]); + $articles = array_filter($articles, function($a) use ($searchfor) { return strpos(strtolower($a->urlname), $searchfor) !== False; }); + $filterquery[] = "filter_urlname=" . urlencode($_GET["filter_urlname"]); + $ste->vars["filter_urlname"] = $_GET["filter_urlname"]; + } + if(!empty($_GET["filter_tag"])) + { + $searchfor = $_GET["filter_tag"]; + $articles = array_filter($articles, function($a) use ($searchfor) { foreach($a->tags as $t) { if($t->name==$searchfor) return True; } return False; }); + $filterquery[] = "filter_tag=" . urlencode($searchfor); + $ste->vars["filter_tag"] = $searchfor; + } + if(!empty($_GET["filter_section"])) + { + $searchfor = $_GET["filter_section"]; + $articles = array_filter($articles, function($a) use ($searchfor) { return $a->section->name == $searchfor; }); + $filterquery[] = "filter_section=" . urlencode($searchfor); + $ste->vars["filter_section"] = $searchfor; + } + $ste->vars["filterquery"] = implode("&", $filterquery); + + /* Sorting */ + if(isset($_GET["sort_asc"])) + { + switch($_GET["sort_asc"]) + { + case "date": + $ste->vars["sortquery"] = "sort_asc=date"; + $ste->vars["sort_asc_date"] = True; + $ste->vars["sorting"] = array("dir" => "asc", "by" => "date"); + usort($articles, function($a, $b) { return intcmp($a->timestamp, $b->timestamp); }); + break; + case "section": + $ste->vars["sortquery"] = "sort_asc=section"; + $ste->vars["sort_asc_section"] = True; + $ste->vars["sorting"] = array("dir" => "asc", "by" => "section"); + usort($articles, function($a, $b) { return strcmp($a->section->name, $b->section->name); }); + break; + case "urlname": + $ste->vars["sortquery"] = "sort_asc=urlname"; + default: + $ste->vars["sort_asc_urlname"] = True; + $ste->vars["sorting"] = array("dir" => "asc", "by" => "urlname"); + usort($articles, function($a, $b) { return strcmp($a->urlname, $b->urlname); }); + break; + } + } + elseif(isset($_GET["sort_desc"])) + { + switch($_GET["sort_desc"]) + { + case "date": + $ste->vars["sortquery"] = "sort_desc=date"; + $ste->vars["sort_desc_date"] = True; + $ste->vars["sorting"] = array("dir" => "desc", "by" => "date"); + usort($articles, function($a, $b) { return intcmp($b->timestamp, $a->timestamp); }); + break; + case "section": + $ste->vars["sortquery"] = "sort_desc=section"; + $ste->vars["sort_desc_section"] = True; + $ste->vars["sorting"] = array("dir" => "desc", "by" => "section"); + usort($articles, function($a, $b) { return strcmp($b->section->name, $a->section->name); }); + break; + case "urlname": + $ste->vars["sortquery"] = "sort_desc=urlname"; + $ste->vars["sort_desc_urlname"] = True; + $ste->vars["sorting"] = array("dir" => "desc", "by" => "urlname"); + usort($articles, function($a, $b) { return strcmp($b->urlname, $a->urlname); }); + break; + default: + $ste->vars["sort_asc_urlname"] = True; + $ste->vars["sorting"] = array("dir" => "asc", "by" => "urlname"); + usort($articles, function($a, $b) { return strcmp($a->urlname, $b->urlname); }); + break; + } + } + else + { + $ste->vars["sort_asc_urlname"] = True; + $ste->vars["sorting"] = array("dir" => "asc", "by" => "urlname"); + usort($articles, function($a, $b) { return strcmp($a->urlname, $b->urlname); }); + } $ste->vars["articles"] = array_map(function($article) { $avail_langs = array(); diff --git a/ratatoeskr/cms_style/images/sortarrow_down_filled.png b/ratatoeskr/cms_style/images/sortarrow_down_filled.png new file mode 100644 index 0000000..d88adc2 Binary files /dev/null and b/ratatoeskr/cms_style/images/sortarrow_down_filled.png differ diff --git a/ratatoeskr/cms_style/images/sortarrow_down_outline.png b/ratatoeskr/cms_style/images/sortarrow_down_outline.png new file mode 100644 index 0000000..191c21e Binary files /dev/null and b/ratatoeskr/cms_style/images/sortarrow_down_outline.png differ diff --git a/ratatoeskr/cms_style/images/sortarrow_shape.svg b/ratatoeskr/cms_style/images/sortarrow_shape.svg new file mode 100644 index 0000000..3e38bed --- /dev/null +++ b/ratatoeskr/cms_style/images/sortarrow_shape.svg @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/ratatoeskr/cms_style/images/sortarrow_up_filled.png b/ratatoeskr/cms_style/images/sortarrow_up_filled.png new file mode 100644 index 0000000..afceedd Binary files /dev/null and b/ratatoeskr/cms_style/images/sortarrow_up_filled.png differ diff --git a/ratatoeskr/cms_style/images/sortarrow_up_outline.png b/ratatoeskr/cms_style/images/sortarrow_up_outline.png new file mode 100644 index 0000000..a4dfdd9 Binary files /dev/null and b/ratatoeskr/cms_style/images/sortarrow_up_outline.png differ diff --git a/ratatoeskr/templates/src/systemtemplates/articles.html b/ratatoeskr/templates/src/systemtemplates/articles.html index 051f3ff..edcd1d1 100644 --- a/ratatoeskr/templates/src/systemtemplates/articles.html +++ b/ratatoeskr/templates/src/systemtemplates/articles.html @@ -1,44 +1,83 @@ -
Example for errors
-
Example for notice
-
Example for success
+ $success + +
$success
+
+
+ $error + +
$error
+
+
- - - - - - - - - - - $articles - - - - - - - - - - - - - - - - - -
 
$article[urlname] - - ?{~{$i|eq|0}||, }$lang - - %Y-%m-%d %H:%M:%S - - ?{~{$i|eq|0}||, } $tag - - $article[section][name]
+
+
+ : + + + + + +
+
+ +
+ + + + + + + + + + + $articles + + + + + + + + + + + + + + + + + +
  + + <ste:get_translation for='sort_asc' /> + <ste:get_translation for='sort_desc' /> + + + <ste:get_translation for='sort_asc' /> + <ste:get_translation for='sort_desc' /> + + + <ste:get_translation for='sort_asc' /> + <ste:get_translation for='sort_desc' /> +
$article[urlname] + + ?{~{$i|eq|0}||, }$lang + + %Y-%m-%d %H:%M:%S + + ?{~{$i|eq|0}||, } $tag + + $article[section][name]
+
+ + +
+
diff --git a/ratatoeskr/templates/src/systemtemplates/tags_overview.html b/ratatoeskr/templates/src/systemtemplates/tags_overview.html index 29288e7..7d2ecc0 100644 --- a/ratatoeskr/templates/src/systemtemplates/tags_overview.html +++ b/ratatoeskr/templates/src/systemtemplates/tags_overview.html @@ -12,7 +12,7 @@
- +
diff --git a/ratatoeskr/translations/en.php b/ratatoeskr/translations/en.php index 7cf3d51..dfd3195 100644 --- a/ratatoeskr/translations/en.php +++ b/ratatoeskr/translations/en.php @@ -84,7 +84,15 @@ $translation = array( "available_languages" => "Available languages", "tags" => "Tags", "section" => "Section", - "no_articles" => "No articles stored." + "no_articles" => "No articles stored.", + "delete" => "Delete", + "articles_deleted" => "Articles deleted.", + "sort_asc" => "ascending", + "sort_desc" => "descending", + "filter" => "Filter", + "filter_urlname" => "by URL name", + "filter_tag" => "by tag", + "filter_section" => "by section" ); ?> -- cgit v1.2.3-70-g09d2