Skip to content

Commit

Permalink
New attribute 'category' for note entity
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Jan 8, 2017
1 parent f0e940b commit e649c67
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
8 changes: 7 additions & 1 deletion db/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace OCA\Notes\Db;

use OCP\Files\File;
use OCP\Files\Folder;
use OCP\AppFramework\Db\Entity;

/**
Expand All @@ -22,6 +23,8 @@
* @method void setModified(integer $value)
* @method string getTitle()
* @method void setTitle(string $value)
* @method string getCategory()
* @method void setCategory(string $value)
* @method string getContent()
* @method void setContent(string $value)
* @method boolean getFavorite()
Expand All @@ -32,6 +35,7 @@ class Note extends Entity {

public $modified;
public $title;
public $category;
public $content;
public $favorite = false;

Expand All @@ -44,12 +48,14 @@ public function __construct() {
* @param File $file
* @return static
*/
public static function fromFile(File $file, $tags=[]){
public static function fromFile(File $file, Folder $notesFolder, $tags=[]){
$note = new static();
$note->setId($file->getId());
$note->setContent($file->getContent());
$note->setModified($file->getMTime());
$note->setTitle(pathinfo($file->getName(),PATHINFO_FILENAME)); // remove extension
$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1);
$note->setCategory($subdir ? $subdir : null);
if(is_array($tags) && in_array(\OC\Tags::TAG_FAVORITE, $tags)) {
$note->setFavorite(true);
//unset($tags[array_search(\OC\Tags::TAG_FAVORITE, $tags)]);
Expand Down
2 changes: 1 addition & 1 deletion js/public/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e649c67

Please sign in to comment.