Exemplo n.º 1
0
 /**
  * Method to get bookmarks
  * 
  * @return void
  */
 protected function getBookmarks()
 {
     $bookmarks = WpHerissonBookmarksTable::getAll(true);
     $this->assertTrue(is_array($bookmarks->toArray()));
     $this->assertCount(20, $bookmarks);
     return $bookmarks;
 }
Exemplo n.º 2
0
 /**
  * Add a new backup
  *
  * Start a backup of all bookmarks to a remote friend
  *
  * @return void
  */
 function addAction()
 {
     $friend = WpHerissonFriendsTable::get(post('friend_id'));
     if (!$friend->id) {
         Message::i()->addError(__("Friend could not be found", HERISSON_TD));
         $this->indexAction();
         $this->setView('index');
         return;
     }
     $acceptsBackups = $friend->acceptsBackups();
     switch ($acceptsBackups) {
         case 0:
             Message::i()->addError(__("Friend doesn't accept backups", HERISSON_TD));
             $this->indexAction();
             $this->setView('index');
             return;
         case 1:
             Message::i()->addSucces(__("Friend accepts backups", HERISSON_TD));
             break;
         case 2:
             Message::i()->addError(__("Friend backup directory is full", HERISSON_TD));
             $this->indexAction();
             $this->setView('index');
             return;
     }
     $bookmarks = WpHerissonBookmarksTable::getAll();
     include_once HERISSON_BASE_DIR . "/Herisson/Format/Herisson.php";
     $format = new \Herisson\Format\Herisson();
     $herissonBookmarks = $format->exportData($bookmarks);
     //print_r($herissonBookmarks);
     $res = $friend->sendBackup($herissonBookmarks);
     //echo $res;
     if ($res) {
         // TODO : Delete backups from that friend before adding a new one
         $backup = new WpHerissonBackups();
         $backup->friend_id = $friend->id;
         $backup->size = strlen($herissonBookmarks);
         $backup->nb = sizeof($bookmarks);
         $backup->creation = date('Y-m-d H:i:s');
         $backup->save();
     }
     // Redirects to Backups list
     $this->indexAction();
     $this->setView('index');
 }
Exemplo n.º 3
0
 /**
  * Display import and maintenance options page
  *
  * This is the default Action
  *
  * @return void
  */
 function indexAction()
 {
     if (post('maintenance')) {
         $condition = "\n                LENGTH(favicon_url)=?   or favicon_url is null or\n                LENGTH(favicon_image)=? or favicon_image is null or\n                LENGTH(content)=?       or content is null or\n                LENGTH(content_image)=? or content_image is null";
         $bookmarks_errors = WpHerissonBookmarksTable::getWhere($condition, array(0, 0, 0, 0));
         foreach ($bookmarks_errors as $b) {
             $b->maintenance(false);
             //$b->captureFromUrl();
             $b->save();
         }
     }
     // TODO Check for correct backups
     $bookmarks = WpHerissonBookmarksTable::getAll();
     $this->view->total = sizeof($bookmarks);
     $favicon = WpHerissonBookmarksTable::getWhere("LENGTH(favicon_image)=?   or favicon_image is null", array(0));
     $html_content = WpHerissonBookmarksTable::getWhere("LENGTH(content)=?         or content is null", array(0));
     $full_content = WpHerissonBookmarksTable::getWhere("LENGTH(content)=?         or content is null", array(0));
     $screenshot = WpHerissonBookmarksTable::getWhere("LENGTH(content_image)=?   or content_image is null", array(0));
     $this->view->stats = array('favicon' => sizeof($favicon), 'html_content' => sizeof($html_content), 'full_content' => sizeof($full_content), 'screenshot' => sizeof($screenshot));
 }
Exemplo n.º 4
0
 /**
  * Action to display homepage of Herisson site
  *
  * This is the default action
  *
  * @return void
  */
 function indexAction()
 {
     $tag = get('tag');
     $search = get('search');
     if ($tag) {
         $bookmarks = WpHerissonBookmarksTable::getTag(array($tag), true);
     } else {
         if ($search) {
             $bookmarks = WpHerissonBookmarksTable::getSearch($search, true);
         } else {
             $bookmarks = WpHerissonBookmarksTable::getAll(true);
         }
     }
     $this->view->bookmarks = $bookmarks;
     $this->view->title = $this->options['sitename'];
     $this->view->friends = WpHerissonFriendsTable::getWhere("is_active=1");
     foreach ($this->view->friends as $friendId => $friend) {
         $this->view->friendBookmarks[$friend->id] = $friend->retrieveBookmarks($_GET);
     }
 }
 /**
  * Test countAll and getAll are equals
  *
  * @return void
  */
 public function testCountAllEqualsWhereAll()
 {
     $nb = WpHerissonBookmarksTable::countAll();
     $list = WpHerissonBookmarksTable::getAll();
     $this->assertEquals(sizeof($list), $nb);
 }
Exemplo n.º 6
0
 /**
  * Action to list bookmarks
  *
  * This is the default action
  *
  * @return void
  */
 function indexAction()
 {
     $tag = get('tag');
     if ($tag) {
         $this->view->subtitle = __("Results for tag « " . esc_html($tag) . " »");
         $this->view->countAll = sizeof(WpHerissonBookmarksTable::getTag($tag));
         $this->view->bookmarks = WpHerissonBookmarksTable::getTag($tag, true);
     } else {
         $this->view->bookmarks = WpHerissonBookmarksTable::getAll(true);
         $this->view->countAll = sizeof(WpHerissonBookmarksTable::getAll());
     }
     $this->view->pagination = Pagination::i()->getVars();
 }