From d0060968b77c39bdf8abffb071c971c166b59edb Mon Sep 17 00:00:00 2001 From: Nicolas BERNSTEIN Date: Sat, 17 Sep 2011 16:48:29 +0200 Subject: First commit. --- tpl/notes/edit.php | 17 +++++ tpl/notes/inc_relativestree.php | 139 ++++++++++++++++++++++++++++++++++++++++ tpl/notes/index.php | 11 ++++ tpl/notes/move.php | 16 +++++ tpl/notes/new.php | 18 ++++++ tpl/notes/user.php | 27 ++++++++ tpl/notes/view.php | 18 ++++++ 7 files changed, 246 insertions(+) create mode 100644 tpl/notes/edit.php create mode 100644 tpl/notes/inc_relativestree.php create mode 100644 tpl/notes/index.php create mode 100644 tpl/notes/move.php create mode 100644 tpl/notes/new.php create mode 100644 tpl/notes/user.php create mode 100644 tpl/notes/view.php (limited to 'tpl/notes') diff --git a/tpl/notes/edit.php b/tpl/notes/edit.php new file mode 100644 index 0000000..7e4d88f --- /dev/null +++ b/tpl/notes/edit.php @@ -0,0 +1,17 @@ +return to note'; + +require("tpl/general/inc_form.php"); + +if (isset($preview)) { + echo '

Preview

'; + echo'
Warning : this is only a preview. Click the "Edit note" button above to save changes.
'; + echo $preview; +} + +$can_new = false; +require("tpl/notes/inc_relativestree.php"); +require("tpl/general/bottom.php"); diff --git a/tpl/notes/inc_relativestree.php b/tpl/notes/inc_relativestree.php new file mode 100644 index 0000000..be0e224 --- /dev/null +++ b/tpl/notes/inc_relativestree.php @@ -0,0 +1,139 @@ +
'; +echo '

' . $note['ownername'] . '


'; +echo ''; + +function list_brothers_and_children() { + global $brothers, $children, $note, $user, $can_new; + echo '
'; + foreach($brothers as $b) { + if ($b['id'] == $note['id']) { + echo '

' . $b['title'] . '

'; + foreach($children as $nn) { + echo '

' . $nn['title'] . '

'; + } + if ($can_new) { + echo '

+ new note

'; + } + echo '
'; + } else { + echo '

' . $b['title'] . '

'; + } + } + if ($can_new) { + echo '

+ new note

'; + } + echo '
'; +} + +echo '
'; +$did_show_up = false; +foreach($user_root_notes as $n) { + if ($n['id'] == $note['id']) { + $did_show_up = true; + echo '

' . $n['title'] . '

'; + foreach($children as $nn) { + echo '

' . $nn['title'] . '

'; + } + if ($can_new) { + echo '

+ new note

'; + } + echo '
'; + } else { + echo '

' . $n['title'] . '

'; + if ($n['id'] == $note['parent_id']) { + $did_show_up = true; + list_brothers_and_children(); + } + } +} +if ($can_new) { + echo '

+ new note

'; +} +echo '
'; + +if (!$did_show_up) { + echo '

'; + echo '' . $note['parent_title'] . ''; + list_brothers_and_children(); +} + +*/ + +// *** NEW WAY + +$notes_tree = array(); +$notes_parents = array(); +$n = sql("SELECT id, parent, title FROM notes ". + "WHERE owner = " . $note['owner'] . + ($note['owner'] == $user['id'] ? " " : " AND public != 0 ") . + "ORDER BY title ASC"); +while ($nn = mysql_fetch_assoc($n)) { + $notes_parents[$nn['id']] = $nn['parent']; + if (isset($notes_tree[$nn['parent']])) { + $notes_tree[$nn['parent']][] = $nn; + } else { + $notes_tree[$nn['parent']] = array($nn); + } +} + +$notest = array(0 => @$notes_tree[0]); +for($id = $note['id']; $id != 0; $id = $notes_parents[$id]) { + $notest[$id] = @$notes_tree[$id]; +} + +echo '
'; +echo '

' . $note['ownername'] . '


'; +echo ''; + +function n_tree_branch($id) { + global $notest, $note, $can_new; + if (!isset($notest[$id])) return; + foreach($notest[$id] as $branch) { + if ($branch['id'] == $note['id']) + echo '

' . $branch['title'] . '

'; + else + echo '

' . $branch['title'] . '

'; + if (isset($notest[$branch['id']])) { + echo '
'; + n_tree_branch($branch['id']); + echo '
'; + } else if ($can_new && $branch['id'] == $note['id']) { + echo '
'; + if ($can_new) echo '

+ new note

'; + echo '
'; + } + } + if ($can_new) echo '

+ new note

'; +} + +echo '
'; +n_tree_branch(0); +echo '
'; + diff --git a/tpl/notes/index.php b/tpl/notes/index.php new file mode 100644 index 0000000..1be4cd5 --- /dev/null +++ b/tpl/notes/index.php @@ -0,0 +1,11 @@ +"; +foreach($users as $u) { + echo '
  • ' . $u['name'] . ' (' . $u['nbNotes'] . ' notes)
  • '; +} +echo ""; + +require("tpl/general/bottom.php"); diff --git a/tpl/notes/move.php b/tpl/notes/move.php new file mode 100644 index 0000000..d94e745 --- /dev/null +++ b/tpl/notes/move.php @@ -0,0 +1,16 @@ +move here'; +} + +require("tpl/general/inc_tree.php"); +tree($notes_tree, @f); +echo 'move to root'; + +$can_new = false; +require("tpl/notes/inc_relativestree.php"); +require("tpl/general/bottom.php"); diff --git a/tpl/notes/new.php b/tpl/notes/new.php new file mode 100644 index 0000000..ca17f21 --- /dev/null +++ b/tpl/notes/new.php @@ -0,0 +1,18 @@ +back to ' . + $parent['title'] . '
    '; +} + +require("tpl/general/inc_form.php"); + +if (isset($parent)) { + $note = $parent; + $can_new = false; + require("tpl/notes/inc_relativestree.php"); +} + +require("tpl/general/bottom.php"); diff --git a/tpl/notes/user.php b/tpl/notes/user.php new file mode 100644 index 0000000..4da34e9 --- /dev/null +++ b/tpl/notes/user.php @@ -0,0 +1,27 @@ +' . $n['title'] . ''; +} + +require("tpl/general/inc_tree.php"); +tree($notes_tree, @f); +if ($note_owner['id'] == $user['id']) { + echo 'create new note'; +} + +echo '
    '; +echo '

    Other users

    '; +echo ""; + +require("tpl/general/bottom.php"); diff --git a/tpl/notes/view.php b/tpl/notes/view.php new file mode 100644 index 0000000..c33e836 --- /dev/null +++ b/tpl/notes/view.php @@ -0,0 +1,18 @@ +' . $note['parent_title'] . ''; +} +if ($can_edit) $t[] = 'edit'; +$t[] = 'view source'; +if ($can_move) $t[] = 'move'; +if ($can_delete) $t[] = 'delete'; +echo '
    ' . implode(' | ', $t) . '
    '; +echo $note['html']; + +require("tpl/notes/inc_relativestree.php"); + +require("tpl/general/bottom.php"); -- cgit v1.2.3