aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2011-11-13 14:14:06 +0100
committerKevin Chabowski <kevin@kch42.de>2011-11-13 14:14:06 +0100
commit48972a847fe48f5e2919caf1d777262c6f0121d8 (patch)
tree6555a2680abae443f04b1ca321d7dbdaa1c4ced0 /ratatoeskr
parent89a19766be822f9d0c7f9d44096a33c5e5f03d27 (diff)
downloadratatoeskr-cms-48972a847fe48f5e2919caf1d777262c6f0121d8.tar.gz
ratatoeskr-cms-48972a847fe48f5e2919caf1d777262c6f0121d8.tar.bz2
ratatoeskr-cms-48972a847fe48f5e2919caf1d777262c6f0121d8.zip
Implemented the article list for the backend.
Diffstat (limited to 'ratatoeskr')
-rw-r--r--ratatoeskr/backend/main.php104
-rw-r--r--ratatoeskr/cms_style/images/sortarrow_down_filled.pngbin0 -> 232 bytes
-rw-r--r--ratatoeskr/cms_style/images/sortarrow_down_outline.pngbin0 -> 278 bytes
-rw-r--r--ratatoeskr/cms_style/images/sortarrow_shape.svg91
-rw-r--r--ratatoeskr/cms_style/images/sortarrow_up_filled.pngbin0 -> 245 bytes
-rw-r--r--ratatoeskr/cms_style/images/sortarrow_up_outline.pngbin0 -> 278 bytes
-rw-r--r--ratatoeskr/templates/src/systemtemplates/articles.html119
-rw-r--r--ratatoeskr/templates/src/systemtemplates/tags_overview.html2
-rw-r--r--ratatoeskr/translations/en.php10
9 files changed, 282 insertions, 44 deletions
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
--- /dev/null
+++ b/ratatoeskr/cms_style/images/sortarrow_down_filled.png
Binary files 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
--- /dev/null
+++ b/ratatoeskr/cms_style/images/sortarrow_down_outline.png
Binary files 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 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="8"
+ height="8"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.1 r9760"
+ sodipodi:docname="sortarrow_shape.svg"
+ inkscape:export-filename="/home/skadu42/ssh_con/mounts/skadu/home/skadu/public_html/ratatoeskr/images/sortarrow_up_outline.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible">
+ <path
+ id="path3764"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.839192"
+ inkscape:cx="-0.53826997"
+ inkscape:cy="2.6776922"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1680"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="26"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ empspacing="4"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true"
+ originx="0px"
+ originy="0px"
+ type="xygrid"
+ id="grid2985" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Ebene 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1044.3622)">
+ <path
+ style="fill:none;stroke:#323232;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 1,7 7,7 4,1 z"
+ id="path4844"
+ inkscape:connector-curvature="0"
+ transform="translate(0,1044.3622)"
+ sodipodi:nodetypes="cccc" />
+ </g>
+</svg>
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
--- /dev/null
+++ b/ratatoeskr/cms_style/images/sortarrow_up_filled.png
Binary files 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
--- /dev/null
+++ b/ratatoeskr/cms_style/images/sortarrow_up_outline.png
Binary files 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 @@
<ste:load name="master.html" />
<ste:block name="content">
- <div class="error">Example for errors</div>
- <div class="notice">Example for notice</div>
- <div class="success">Example for success</div>
+ <ste:if>$success
+ <ste:then>
+ <div class="success"><ste:escape>$success</ste:escape></div>
+ </ste:then>
+ </ste:if>
+ <ste:if>$error
+ <ste:then>
+ <div class="error"><ste:escape>$error</ste:escape></div>
+ </ste:then>
+ </ste:if>
- <table class="fullwidth listtab">
- <thead><tr>
- <th>&nbsp;</th>
- <th><ste:get_translation for="urlname" /></th>
- <th><ste:get_translation for="available_languages" /></th>
- <th><ste:get_translation for="date_time" /></th>
- <th><ste:get_translation for="tags" /></th>
- <th><ste:get_translation for="section" /></th>
- </tr></thead>
- <tbody>
- <ste:if>$articles
- <ste:then>
- <ste:foreach array="articles" value="article">
- <tr>
- <td><input type="checkbox" name="article_multiselect[]" value="$article[urlname]" /></td>
- <td><a href="$rel_path_to_root/backend/content/write/$article[urlname]">$article[urlname]</a></td>
- <td>
- <ste:foreach array="article[languages]" value="lang" counter="i">
- ?{~{$i|eq|0}||, }<a href="$rel_path_to_root/backend/content/write/$article[urlname]/$lang">$lang</a>
- </ste:foreach>
- </td>
- <td><ste:date timestamp="$article[date]">%Y-%m-%d %H:%M:%S</ste:date></td>
- <td>
- <ste:foreach array="article[tags]" value="tag" counter="i">
- ?{~{$i|eq|0}||, } <ste:escape>$tag</ste:escape>
- </ste:foreach>
- </td>
- <td><a href="$rel_path_to_root/backend/design/sections/$article[section][id]"><ste:escape>$article[section][name]</ste:escape></a></td>
- </tr>
- </ste:foreach>
- </ste:then>
- <ste:else>
- <tr><td colspan="6" style="text-align: center;"><em><ste:escape><ste:get_translation for="no_articles" /></ste:escape></em></td></tr>
- </ste:else>
- </ste:if>
- </tbody>
- </table>
+ <form action="$rel_path_to_root/backend/content/articles" method="GET" accept-charset="UTF-8">
+ <div>
+ <strong><ste:escape><ste:get_translation for="filter" /></ste:escape>:</strong>
+ <ste:escape><ste:get_translation for="filter_urlname" /></ste:escape> <input type="text" name="filter_urlname" value="<ste:escape>$filter_urlname</ste:escape>" />
+ <ste:escape><ste:get_translation for="filter_tag" /></ste:escape> <input type="text" name="filter_tag" value="<ste:escape>$filter_tag</ste:escape>" />
+ <ste:escape><ste:get_translation for="filter_section" /></ste:escape> <input type="text" name="filter_section" value="<ste:escape>$filter_section</ste:escape>" />
+ <input type="hidden" name="sort_$sorting[dir]" value="$sorting[by]" />
+ <input type="submit" />
+ </div>
+ </form>
+
+ <form action="$rel_path_to_root/backend/content/articles?$filterquery?{$filterquery|&|}$sortquery" method="POST">
+ <table class="fullwidth listtab">
+ <thead><tr>
+ <th>&nbsp;</th>
+ <th>
+ <ste:get_translation for="urlname" />
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_asc=urlname"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_up_?{$sort_asc_urlname|filled|outline}.png" alt="<ste:get_translation for='sort_asc' />" /></a>
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_desc=urlname"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_down_?{$sort_desc_urlname|filled|outline}.png" alt="<ste:get_translation for='sort_desc' />" /></a>
+ </th>
+ <th><ste:get_translation for="available_languages" /></th>
+ <th>
+ <ste:get_translation for="date_time" />
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_asc=date"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_up_?{$sort_asc_date|filled|outline}.png" alt="<ste:get_translation for='sort_asc' />" /></a>
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_desc=date"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_down_?{$sort_desc_date|filled|outline}.png" alt="<ste:get_translation for='sort_desc' />" /></a>
+ </th>
+ <th><ste:get_translation for="tags" /></th>
+ <th>
+ <ste:get_translation for="section" />
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_asc=section"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_up_?{$sort_asc_section|filled|outline}.png" alt="<ste:get_translation for='sort_asc' />" /></a>
+ <a href="$rel_path_to_root/backend/content/articles??{$filterquery|${filterquery}&|}sort_desc=section"><img src="$rel_path_to_root/ratatoeskr/cms_style/images/sortarrow_down_?{$sort_desc_section|filled|outline}.png" alt="<ste:get_translation for='sort_desc' />" /></a>
+ </th>
+ </tr></thead>
+ <tbody>
+ <ste:if>$articles
+ <ste:then>
+ <ste:foreach array="articles" value="article">
+ <tr>
+ <td><input type="checkbox" name="article_multiselect[]" value="$article[urlname]" /></td>
+ <td><a href="$rel_path_to_root/backend/content/write/$article[urlname]">$article[urlname]</a></td>
+ <td>
+ <ste:foreach array="article[languages]" value="lang" counter="i">
+ ?{~{$i|eq|0}||, }<a href="$rel_path_to_root/backend/content/write/$article[urlname]/$lang">$lang</a>
+ </ste:foreach>
+ </td>
+ <td><ste:date timestamp="$article[date]">%Y-%m-%d %H:%M:%S</ste:date></td>
+ <td>
+ <ste:foreach array="article[tags]" value="tag" counter="i">
+ ?{~{$i|eq|0}||, } <ste:escape>$tag</ste:escape>
+ </ste:foreach>
+ </td>
+ <td><a href="$rel_path_to_root/backend/design/sections/$article[section][id]"><ste:escape>$article[section][name]</ste:escape></a></td>
+ </tr>
+ </ste:foreach>
+ </ste:then>
+ <ste:else>
+ <tr><td colspan="6" style="text-align: center;"><em><ste:escape><ste:get_translation for="no_articles" /></ste:escape></em></td></tr>
+ </ste:else>
+ </ste:if>
+ </tbody>
+ </table>
+ <div>
+ <input type="submit" name="delete" value="<ste:escape><ste:get_translation for='delete' /></ste:escape>" />
+ <select name="really_delete">
+ <option value="no" selected="selected"><ste:escape><ste:get_translation for="notext_default" /></ste:escape></option>
+ <option value="yes"><ste:escape><ste:get_translation for="yestext_default" /></ste:escape></option>
+ </select>
+ </div>
+ </form>
</ste:block>
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 @@
</ste:if>
<form action="$rel_path_to_root/backend/content/tags" method="POST" accept-charset="UTF-8">
- <table>
+ <table class="listtab">
<thead>
<tr>
<th><ste:escape><ste:get_translation for="tag_name" /></ste:escape></th>
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"
);
?>