9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/grauphel.htm
14 namespace OCA\Grauphel\Controller;
16 use \OCP\AppFramework\Controller;
17 use \OCP\AppFramework\Http\TemplateResponse;
18 use \OCA\Grauphel\Lib\Client;
19 use \OCA\Grauphel\Lib\TokenStorage;
20 use \OCA\Grauphel\Lib\Response\ErrorResponse;
23 * Owncloud frontend: Notes
27 * @author Christian Weiske <cweiske@cweiske.de>
28 * @copyright 2014 Christian Weiske
29 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
30 * @version Release: @package_version@
31 * @link http://cweiske.de/grauphel.htm
33 class NotesController extends Controller
36 * constructor of the controller
38 * @param string $appName Name of the app
39 * @param IRequest $request Instance of the request
41 public function __construct($appName, \OCP\IRequest $request, $user)
43 parent::__construct($appName, $request);
46 //default http header: we assume something is broken
47 header('HTTP/1.0 500 Internal Server Error');
51 * Output a note in tomboy XML format
53 * @link https://wiki.gnome.org/Apps/Tomboy/NoteXmlFormat
58 public function xml($guid)
60 $note = $this->getNotes()->load($guid, false);
62 $xw = new \XMLWriter();
64 $xw->startDocument('1.0', 'utf-8');
66 $xw->startElementNS(null, 'note', 'http://beatniksoftware.com/tomboy');
67 $xw->writeAttribute('version', '0.3');
68 $xw->writeAttribute('xmlns:link', 'http://beatniksoftware.com/tomboy/link');
69 $xw->writeAttribute('xmlns:size', 'http://beatniksoftware.com/tomboy/size');
71 $xw->writeElement('title', $note->title);
72 $xw->startElement('text');
73 $xw->writeAttribute('xml:space', 'preserve');
75 $xw->startElement('note-content');
76 $xw->writeAttribute('version', $note->{'note-content-version'});
77 $xw->writeRaw($note->{'note-content'});
78 $xw->endElement();//note-content
79 $xw->endElement();//text
81 $xw->writeElement('last-change-date', $note->{'last-change-date'});
82 $xw->writeElement('last-metadata-change-date', $note->{'last-metadata-change-date'});
83 $xw->writeElement('create-date', $note->{'create-date'});
84 $xw->writeElement('cursor-position', 0);
85 $xw->writeElement('width', 450);
86 $xw->writeElement('height', 360);
87 $xw->writeElement('x', 0);
88 $xw->writeElement('y', 0);
89 $xw->writeElement('open-on-startup', $note->{'open-on-startup'});
91 $xw->endElement();//note
93 return new \OCA\Grauphel\Response\XmlResponse($xw->outputMemory());
96 protected function getNotes()
98 $username = $this->user->getUid();
99 $notes = new \OCA\Grauphel\Lib\NoteStorage($this->urlGen);
100 $notes->setUsername($username);