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/account/login.php | 10 +++ tpl/general/bottom.php | 4 ++ tpl/general/choice.php | 6 ++ tpl/general/empty.php | 3 + tpl/general/form.php | 6 ++ tpl/general/inc_form.php | 26 ++++++++ tpl/general/inc_tree.php | 18 ++++++ tpl/general/sqlerror.php | 13 ++++ tpl/general/top.php | 43 +++++++++++++ tpl/image/index.php | 34 ++++++++++ tpl/image/upload-ok.php | 12 ++++ tpl/image/upload.php | 15 +++++ 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 ++++++ 19 files changed, 436 insertions(+) create mode 100644 tpl/account/login.php create mode 100644 tpl/general/bottom.php create mode 100644 tpl/general/choice.php create mode 100644 tpl/general/empty.php create mode 100644 tpl/general/form.php create mode 100644 tpl/general/inc_form.php create mode 100644 tpl/general/inc_tree.php create mode 100644 tpl/general/sqlerror.php create mode 100644 tpl/general/top.php create mode 100644 tpl/image/index.php create mode 100644 tpl/image/upload-ok.php create mode 100644 tpl/image/upload.php 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') diff --git a/tpl/account/login.php b/tpl/account/login.php new file mode 100644 index 0000000..7853186 --- /dev/null +++ b/tpl/account/login.php @@ -0,0 +1,10 @@ + "Username : ", "name" => "login", "value" => (isset($login) ? $login : '')), + array ("label" => "Password : ", "name" => "pw", "type" => "password")); +$validate = "Log in"; + +require("tpl/general/form.php"); diff --git a/tpl/general/bottom.php b/tpl/general/bottom.php new file mode 100644 index 0000000..b506bf0 --- /dev/null +++ b/tpl/general/bottom.php @@ -0,0 +1,4 @@ + + + + diff --git a/tpl/general/choice.php b/tpl/general/choice.php new file mode 100644 index 0000000..3d54dce --- /dev/null +++ b/tpl/general/choice.php @@ -0,0 +1,6 @@ + $u) { + echo ''; +} +require("bottom.php"); diff --git a/tpl/general/empty.php b/tpl/general/empty.php new file mode 100644 index 0000000..48b662b --- /dev/null +++ b/tpl/general/empty.php @@ -0,0 +1,3 @@ +'; +if (isset($form_message)) echo '' . $form_message . "

\n"; + +foreach($fields as $f) { + if (isset($f['type']) && $f['type'] == 'textarea') { + echo '
'; + echo '
'; + } else { +?> + + id="ff_"/>
 '; diff --git a/tpl/general/inc_tree.php b/tpl/general/inc_tree.php new file mode 100644 index 0000000..9b13d5a --- /dev/null +++ b/tpl/general/inc_tree.php @@ -0,0 +1,18 @@ +'.$func($branch).'

'; + if (isset($tree[$branch['id']])) { + echo '
'; + tree_branch($tree, $branch['id'], $func); + echo '
'; + } + } +} + +function tree($tree, $func) { + echo '
'; + tree_branch($tree, 0, $func); + echo '
'; +} diff --git a/tpl/general/sqlerror.php b/tpl/general/sqlerror.php new file mode 100644 index 0000000..59f0806 --- /dev/null +++ b/tpl/general/sqlerror.php @@ -0,0 +1,13 @@ += $sql_min_priv_for_debug) { + echo '
An error happenned with the following SQL query :
'; + echo '' . $request . '
'; + echo 'Mysql answered : ' . $sql_error . '
'; +} else { + echo '
An internal error occurred, sorry.
'; +} + +require("bottom.php"); diff --git a/tpl/general/top.php b/tpl/general/top.php new file mode 100644 index 0000000..e87e466 --- /dev/null +++ b/tpl/general/top.php @@ -0,0 +1,43 @@ + + + + + + <?php echo $title; ?> + + + + + + +
+ +

+ +' . $message . "
\n"; +if (isset($error)) echo '
' . $error . "
\n"; + diff --git a/tpl/image/index.php b/tpl/image/index.php new file mode 100644 index 0000000..0f76abe --- /dev/null +++ b/tpl/image/index.php @@ -0,0 +1,34 @@ +Images you have uploaded'; + +if (count($images) == 0) { + echo '
You have uploaded no images yet.
'; +} else { +echo ''; + foreach ($images as $img) { + $min = $baseurl . $img['id'] . "-min." . $img['extension']; + $imgf = $baseurl . $img['id'] . "." . $img['extension']; + echo ''; + echo ''; + } + echo '
PreviewFiles
Miniature: ' . $min . '
'; + echo 'Image: ' . $imgf . ''; + if ($can_delete) echo '
Delete this image'; + echo '
'; +} + +if ($can_upload) { +?> + +
+

Upload an image

+
+A px preview will be created.

+
+
+ + Preview :
+ Image :
+ "Image file : ", "type" => "file", "name" => "image") + ); +$validate = "Upload"; + +require("tpl/general/form.php"); + + 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