Add missing standard fields (Tomboy legacy):
[grauphel.git] / lib / notestorage.php
index 275374c4ed7f36348cb11c7328cad93fdb1994eb..5dc503b2a286ccee3f55665c8d0a1ac9f8a6800f 100644 (file)
@@ -95,6 +95,9 @@ class NoteStorage
             'pinned',
             'tags',
             'title',
+            'x', 'y', 'width', 'height',
+            'selection-bound-position',
+            'cursor-position',
         );
 
         $changed = array();
@@ -237,19 +240,27 @@ class NoteStorage
                 return null;
             }
             return (object) array(
-                'guid' => $guid,
+                'guid'                      => $guid,
 
                 'create-date'               => null,
                 'last-change-date'          => null,
                 'last-metadata-change-date' => null,
 
-                'title'                => null,
-                'note-content'         => null,
-                'note-content-version' => 0.3,
+                'title'                     => null,
+                'note-content'              => null,
+                'note-content-version'      => 0.3,
 
-                'open-on-startup' => false,
-                'pinned'          => false,
-                'tags'            => array(),
+                'open-on-startup'           => false,
+                'pinned'                    => false,
+                'tags'                      => array(),
+
+                'x'                         => 20,
+                'y'                         => 20,
+                'width'                     => -1,
+                'height'                    => -1,
+
+                'cursor-position'           => 0,
+                'selection-bound-position'  => 0,
             );
         }
 
@@ -298,8 +309,8 @@ class NoteStorage
             $keywordGroups['NOT'] = array();
         }
 
-        $sqlTplAnd = ' AND (note_title ILIKE ? OR note_tags ILIKE ? OR note_content ILIKE ?)';
-        $sqlTplNot = ' AND NOT (note_title ILIKE ? OR note_tags ILIKE ? OR note_content ILIKE ?)';
+        $sqlTplAnd = ' AND (`note_title` ILIKE ? OR `note_tags` ILIKE ? OR `note_content` ILIKE ?)';
+        $sqlTplNot = ' AND NOT (`note_title` ILIKE ? OR `note_tags` ILIKE ? OR `note_content` ILIKE ?)';
         $arData = array(
             $this->username
         );
@@ -513,37 +524,53 @@ class NoteStorage
             'last-change-date'          => $this->fixDate($row['note_last_change_date']),
             'last-metadata-change-date' => $this->fixDate($row['note_last_metadata_change_date']),
 
-            'title'                => $row['note_title'],
-            'note-content'         => $row['note_content'],
-            'note-content-version' => $row['note_content_version'],
+            'title'                     => $row['note_title'],
+            'note-content'              => $row['note_content'],
+            'note-content-version'      => $row['note_content_version'],
+
+            'open-on-startup'           => (bool) $row['note_open_on_startup'],
+            'pinned'                    => (bool) $row['note_pinned'],
+            'tags'                      => json_decode($row['note_tags']),
 
-            'open-on-startup' => (bool) $row['note_open_on_startup'],
-            'pinned'          => (bool) $row['note_pinned'],
-            'tags'            => json_decode($row['note_tags']),
+            'x'                         => (int) $row['note_x'],
+            'y'                         => (int) $row['note_y'],
+            'height'                    => (int) $row['note_height'],
+            'width'                     => (int) $row['note_width'],
 
-            'last-sync-revision' => (int) $row['note_last_sync_revision'],
+            'selection-bound-position'  => (int) $row['note_selection_bound_position'],
+            'cursor-position'           => (int) $row['note_cursor_position'],
+
+            'last-sync-revision'        => (int) $row['note_last_sync_revision'],
         );
     }
 
     protected function rowFromNote($note)
     {
         return array(
-            'note_guid'  => $note->guid,
-            'note_title' => (string) $note->title,
+            'note_guid'                      => $note->guid,
+            'note_title'                     => (string) $note->title,
 
-            'note_content'         => (string) $note->{'note-content'},
-            'note_content_version' => (string) $note->{'note-content-version'},
+            'note_content'                   => (string) $note->{'note-content'},
+            'note_content_version'           => (string) $note->{'note-content-version'},
 
             'note_create_date'               => $note->{'create-date'},
             'note_last_change_date'          => $note->{'last-change-date'},
             'note_last_metadata_change_date' => $note->{'last-metadata-change-date'},
 
-            'note_open_on_startup' => (int) $note->{'open-on-startup'},
-            'note_pinned'          => (int) $note->pinned,
-            'note_tags'            => json_encode($note->tags),
+            'note_open_on_startup'           => (int) $note->{'open-on-startup'},
+            'note_pinned'                    => (int) $note->pinned,
+            'note_tags'                      => json_encode($note->tags),
+
+            'note_x'                         => (int) $note->{'x'},
+            'note_y'                         => (int) $note->{'y'},
+            'note_height'                    => (int) $note->{'height'},
+            'note_width'                     => (int) $note->{'width'},
+
+            'note_selection_bound_position'  => (int) $note->{'selection-bound-position'},
+            'note_cursor_position'           => (int) $note->{'cursor-position'},
 
-            'note_last_sync_revision' => $note->{'last-sync-revision'},
+            'note_last_sync_revision'        => $note->{'last-sync-revision'},
         );
     }
 }
-?>
\ No newline at end of file
+?>