summaryrefslogtreecommitdiff
path: root/code/admin/ajax.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <lpouzenc@gmail.com>2013-10-29 18:42:08 +0100
committerLudovic Pouzenc <lpouzenc@gmail.com>2013-10-29 18:42:08 +0100
commitc98515883097467896a3f46b755c8cb892fe8961 (patch)
treebe2e4f5450e9bc9cf692e8dfac7c9780eaa7019b /code/admin/ajax.php
downloadeditablesite-c98515883097467896a3f46b755c8cb892fe8961.tar.gz
editablesite-c98515883097467896a3f46b755c8cb892fe8961.tar.bz2
editablesite-c98515883097467896a3f46b755c8cb892fe8961.zip
Import initial avec une arbrescence éclatée
Diffstat (limited to 'code/admin/ajax.php')
-rw-r--r--code/admin/ajax.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/code/admin/ajax.php b/code/admin/ajax.php
new file mode 100644
index 0000000..0893843
--- /dev/null
+++ b/code/admin/ajax.php
@@ -0,0 +1,63 @@
+<?php
+ require_once('utils.php');
+ need_auth();
+
+ function load_page_props($path) {
+ return load_ini_page_props($path);
+ }
+
+ function load_media_props($path) {
+ return array(
+ 'media_title' => 'test title',
+ 'media_description' => 'test descr',
+ 'media_keywords' => 'test, keyword',
+ );
+ }
+
+ function save_page_props($path) {
+ //TODO : Should validate props here also...
+ $props=load_page_props($path);
+
+ foreach ( array('page_title', 'page_description', 'page_keywords') as $k ) {
+ if ( array_key_exists($k,$_GET) ) $props[$k]=$_GET[$k];
+ }
+
+ $ini_path="content/$path/props.ini";
+ return write_ini_file($props, $ini_path, false);
+ }
+
+ function save_media_props($path) {
+ return FALSE;
+ }
+
+ // URL params clean-up
+ $action=sanitize($_GET, 'action', '/[^a-z_]+/', 'none'); /* Could be : load_page_props, load_media_props... */
+ $path=sanitize($_GET, 'path', '/[^a-z0-9\/]+/', ''); // Never put \. in this regex
+
+ switch($action) {
+ case 'load_page_props':
+ $res = load_page_props($path);
+ break;
+ case 'load_media_props':
+ $res = load_media_props($path);
+ break;
+ case 'save_page_props':
+ if ( save_page_props($path) ) {
+ $res=array('result' => 'OK');
+ } else {
+ $res=array('result' => 'FAILED');
+ }
+ break;
+ case 'save_media_props':
+ if ( save_media_props($path) ) {
+ $res=array('result' => 'OK');
+ } else {
+ $res=array('result' => 'FAILED');
+ }
+ break;
+ default:
+ $res = array('result' => 'ERROR', 'error'=>'invalid action');
+ break;
+ }
+ echo json_encode($res);
+?>