Skip to content

Commit

Permalink
13.10.0 Release to GitHub
Browse files Browse the repository at this point in the history
Internal SVN Revision 577
Initial Commit
  • Loading branch information
Jake committed Oct 20, 2013
1 parent 33e1fb7 commit 414027b
Show file tree
Hide file tree
Showing 315 changed files with 24,667 additions and 1 deletion.
23 changes: 23 additions & 0 deletions OpenNote/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenNote</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.aptana.editor.php.aptanaPhpBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.aptana.editor.php.phpNature</nature>
<nature>com.aptana.projects.webnature</nature>
</natures>
</projectDescription>
240 changes: 240 additions & 0 deletions OpenNote/NoteBook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
<?php
/**
* Project name: InFood
* File-name: recipes.php
* Author: Jacob Liscom
* Version: 13.2.0
**/

//include_once dirname(__FILE__)."/modules/core/Common.php";
//OO code
class NoteBook{
/**
* Constructor
* @param mode - the mode for the reviewer
* @param id - the id of and existing class if a subFolder. Default value is null
*/
public function NoteBook($id = NULL){
if($id!=NULL)
$this->subFolder($id);//TODO
else
$this->root();
}

/**
* Displays the root folder contents
*/
private function root(){
echo " <script type=\"text/javascript\">
setButton0(\"\");
setButton1(\"New Folder\");
setButton2(\"Find\");
setURL(\"./\",\"OpenNote\");
</script>";

//echo the label for the page
self::folderTitle("Home",false);

$result = Core::query("SELECT id, parrentFolderID, name FROM folder WHERE parrentFolderID IS NULL AND userID=? ORDER BY name",array(Authenticater::getUserID()));
foreach($result as $row)
echo self::boxFactory($row["id"], "folder green", $row["name"], null,"Folder");
}

/**
* Display sub folder
* @param id - the id of the sub folder
*/
public function subFolder($id){

$query = Core::query("SELECT id, parrentFolderID, name FROM folder WHERE id = ? AND userID=? ORDER BY name",array($id, Authenticater::getUserID()));

if(!count($query))
return;

echo sprintf(" <script type=\"text/javascript\">
setButton0(\"New Note\");
setButton1(\"New Folder\");
setButton2(\"Find\");
setURL(\"index.php?folderID=%d\",\"%s\");
</script>", $query[0]["id"], $query[0]["name"]);

//echo this foldersID for future reference
echo sprintf("<folder id=\"folder\" folderID=\"%d\"></list>",$query[0]["id"]);


//echo the label for the page
self::folderTitle($query[0]["name"],true);

//get all the folders
$folders = Core::query("SELECT id, parrentFolderID, name FROM folder WHERE parrentFolderID = ? and userID=? ORDER BY name", array($id,Authenticater::getUserID()));
foreach($folders as $row)
echo self::boxFactory($row["id"], "folder green", $row["name"], null,"Folder");

//get all the notes
$folders = Core::query("SELECT n.id, n.title
FROM note n
WHERE n.folderID = ?
AND (n.originNoteID IS NULL OR n.id IN (SELECT MAX(id) FROM note WHERE originNoteID=n.originNoteID))
AND (SELECT COUNT(*) FROM note WHERE originNoteID = n.id)=0
AND userID=?
ORDER BY n.title",
array($id,Authenticater::getUserID()));//bascally get notes that id is null and have not been overwriten or are the latest
foreach($folders as $row)
echo self::boxFactory($row["id"], "note", $row["title"], null,null,"Note");
}

/**
* echos the folder list
* @param folderList - a array of all the folders
*/
public static function getFolderList(){
$root = Core::query("SELECT id, parrentFolderID, name FROM folder WHERE parrentFolderID IS NULL AND userID=? ORDER BY name",array(Authenticater::getUserID()));
if(count($root)==0)
return;

self::startSubTree();
foreach ($root as $rootFolder)
self::getChildren($rootFolder["id"],$rootFolder["name"]);
self::endSubTree();
}

/**
* This method prints the folder passed in and finds all children and prints them
* @param folderID - the folder to find children for
* @param name - the name of the folder to find children for
*/
private static function getChildren($folderID, $name){
self::startTreeEntry();
self::treeEntryFactory($folderID, $name); //print self

$result = Core::query("SELECT id, parrentFolderID, name FROM folder WHERE parrentFolderID=? AND userID=? ORDER BY name",array($folderID,Authenticater::getUserID()));
if(count($result)>0){//do I have any children
self::startSubTree();//great line them up

foreach($result as $child)
self::getChildren($child["id"],$child["name"]);

self::endSubTree();
}

self::endTreeEntry();
}

/**
* creates a new folder
* @param parrentID - the id of the parent folder.
* @param name - the title of folder
*/
public static function newFolder($parentID =null,$name){
Core::query("INSERT INTO folder(parrentFolderID,name, userID) VALUES(?,?,?)",array($parentID,$name,Authenticater::getUserID()));

//update the view
echo " <script type=\"text/javascript\">
getFolderList();
</script>";
new NoteBook($parentID);
}

/**
* delete a new folder
* @param $id - the id of the folder to delete.
*/
public static function removeFolder($id){
$parrent = Core::query("SELECT parrentFolderID, name, userID FROM folder WHERE id=? AND userID=?;",array($id,Authenticater::getUserID()));
Core::query("DELETE FROM folder WHERE id=? AND userID=?;",array($id,Authenticater::getUserID()));

//update the view
echo " <script type=\"text/javascript\">
getFolderList();
</script>";
new NoteBook($parrent[0]["parrentFolderID"]);
}

/**
* change a folders parrent
* @param folderID - the folder id to change the parrent of
* @param newParrentID - the new parrent of the folder
*/
public static function moveFolder($folderID, $newParrentID){
$parrent = Core::query("UPDATE folder SET parrentFolderID = ? WHERE id=? AND userID=?;",array($newParrentID,$folderID,Authenticater::getUserID()));
}

/**
* @param id - the id of the box
* @param color/class - the color/class code to format the box
* @param title - the title string
* @param desc - the description
* @return - return a box html to go into the box container
*/
private static function boxFactory($id=null, $color=null, $title=null,$desc=null,$left=null,$right=null){
return "
<div class=\"box $color startHidden\" boxID=\"$id\">
<h2>
$title
</h2>
<p class=\"box_description\">$desc</p>
<p class=\"options\">
$left
<span class=\"right\">$right</span>
</p>
</div>
<script type=\"text/javascript\">
$(\"[boxID=$id]\").fadeIn(fadeSpeedLong*Math.random()+200);
</script>";
}

/**
* @param folderID - the folder id to print the entry for
* @param title - the title of the folder to print
*/
private static function treeEntryFactory($folderID, $title){
echo "<a class=\"customButton folder\" folderID=\"$folderID\">$title</a>";
}

/**
* start a tree entry
*/
private static function startTreeEntry(){
echo "<li>";
}

/**
* close a entry tag
*/
private static function endTreeEntry(){
echo "</li>";
}

/**
* start a sub tree
*/
private static function startSubTree(){
echo "<ul>";
}

/**
* close a sub tree
*/
private static function endSubTree(){
echo "</ul>";
}

/**
* @param title - the title for the folder
* @param remove - weather to show the remove button
* echos the title block
*/
private static function folderTitle($title, $remove){
$button="";
if($remove)
$button="<button id=\"removeFolder\" class=\"customButton\">X</button>";

echo sprintf(
"<div id=\"folderTitleBar\">
<div id=\"folderTitle\">%s</div>
%s
</div>",$title,$button);
}
}
?>
Loading

0 comments on commit 414027b

Please sign in to comment.