Skip to content

Commit

Permalink
Merge pull request #130 from betaman/master
Browse files Browse the repository at this point in the history
New navigation interface, fixes #88
  • Loading branch information
jbroadway committed Nov 20, 2012
2 parents 18b8159 + c5f4809 commit 24fc37b
Show file tree
Hide file tree
Showing 13 changed files with 517 additions and 4,740 deletions.
13 changes: 10 additions & 3 deletions apps/navigation/handlers/admin.php
Expand Up @@ -11,18 +11,25 @@

$page->title = i18n_get ('Navigation');
$page->layout = 'admin';
$page->add_script ('<script src="/apps/navigation/js/jquery.jstree.js"></script>');

$page->add_script ('<script src="/apps/navigation/js/tree-drag-drop/jquery-ui-1.9.1.custom.min.js"></script>', 'tail');
$page->add_script ('<script src="/apps/navigation/js/tree-drag-drop/tree-drag-drop.js"></script>', 'tail');

if (detect ('msie 7')) {
$page->add_style ('/apps/admin/css/font-awesome/css/font-awesome-ie7.css');
}
$page->add_style ('/apps/admin/css/font-awesome/css/font-awesome.css');

// get ids already in tree to skip
$nav = new Navigation;
$ids = $nav->get_all_ids ();

// build other page list
require_once ('apps/navigation/lib/Functions.php');
$pages = navigation_get_other_pages ($ids);
$other_pages = navigation_get_other_pages ($ids);

echo $tpl->render ('navigation/admin', array (
'pages' => $pages
'other_pages' => $other_pages
));

?>
14 changes: 14 additions & 0 deletions apps/navigation/handlers/admin_tree.php
@@ -0,0 +1,14 @@
<?php

/**
* Displays a multi-level bulleted list for the app/navigation/admin.
*/

$n = new Navigation;

require_once ('apps/navigation/lib/Functions.php');
navigation_print_admin_tree ($n->tree);

//$this->cache = true;

?>
49 changes: 9 additions & 40 deletions apps/navigation/handlers/api.php
Expand Up @@ -22,52 +22,21 @@
$out = null;
$nav = new Navigation;

switch ($this->params[0]) {
case 'add':
$id = $_POST['page'];
$parent = $_POST['parent'];
if ($parent === 'false') {
$parent = false;
switch ($this->params[0]) {
case 'update':
$tree = $_POST['tree'];
if(empty($tree)){
$tree = array();
}
if ($nav->add ($id, $parent) && $nav->save ()) {
require_once ('apps/navigation/lib/Functions.php');
if ($nav->update ($tree) && $nav->save ()) {
$out = array (
'msg' => sprintf ('Page %s added to tree under %s.', $id, $parent),
'page' => $id,
'parent' => $parent
'msg' => sprintf ('Nav json has been updated'),
);
} else {
$error = $nav->error;
}
break;
case 'move':
$id = $_POST['page'];
$ref = $_POST['ref'];
$pos = $_POST['pos'];
if ($nav->move ($id, $ref, $pos) && $nav->save ()) {
$out = array (
'msg' => sprintf ('Page %s moved to %s %s.', $id, $pos, $ref),
'page' => $id,
'ref' => $ref,
'pos' => $pos
);
} else {
$error = $nav->error;
}
break;
case 'remove':
$id = $_POST['page'];
if ($nav->remove ($id) && $nav->save ()) {
require_once ('apps/navigation/lib/Functions.php');
$ids = $nav->get_all_ids ();
$out = array (
'msg' => sprintf ('Page %s removed.', $id),
'page' => $id,
'other' => navigation_get_other_pages ($ids)
);
} else {
$error = $nav->error;
}
break;
break;
default:
$error = 'Unknown method';
break;
Expand Down

0 comments on commit 24fc37b

Please sign in to comment.