当前位置: 首页>>代码示例>>PHP>>正文


PHP Bookmark类代码示例

本文整理汇总了PHP中Bookmark的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark类的具体用法?PHP Bookmark怎么用?PHP Bookmark使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Bookmark类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMisformatedJSON

 /**
  * @expectedException \Exception
  */
 public function testMisformatedJSON()
 {
     $request = $this->getMockBuilder('\\Kanedo\\Request')->disableOriginalConstructor()->getMock();
     $testee = new Bookmark($request);
     $json = "{this is wroooong: lols'}";
     $testee->setUp($json);
 }
开发者ID:Type-of-Read,项目名称:Readability-API-1,代码行数:10,代码来源:BookmarkTest.php

示例2: testGetsUrl

 public function testGetsUrl()
 {
     $url = $this->getUrlMock();
     $comment = $this->getBookmarkCommentMock();
     $date = new DateTimeImmutable();
     $bookmark = new Bookmark($url, $comment, $date);
     $this->assertEquals($url, $bookmark->getWebsite());
 }
开发者ID:noichl,项目名称:pw-bookmarks,代码行数:8,代码来源:BookmarkTest.php

示例3: create

 /**
  * Creates a new bookmark
  * @param $type
  * @param $object_id   the object who owns the bookmark
  * @param $owner       if not set, owner will be current user
  * @return bookmark id
  */
 public static function create($type, $object_id, $owner = 0)
 {
     $session = SessionHandler::getInstance();
     $o = new Bookmark();
     $o->type = $type;
     $o->value = $object_id;
     $o->owner = $owner ? $owner : $session->id;
     return $o->store();
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:16,代码来源:Bookmark.php

示例4: addDel

 /**
  * Add or Delete Bookmark.
  */
 public function addDel($postId)
 {
     $row = Bookmark::model()->find('postId=:postId and userId=:userId', array(':postId' => $postId, ':userId' => Yii::app()->user->id));
     if (empty($row)) {
         $row = new Bookmark();
         $row->postId = $postId;
         $row->userId = Yii::app()->user->id;
         $row->save();
         return true;
     } else {
         $row->delete();
         return false;
     }
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:17,代码来源:Bookmark.php

示例5: showSelector

 /**
  * Show a date selector
  * @param  datetime $date1    date of start
  * @param  datetime $date2    date of ending
  * @param  string $randname random string (to prevent conflict in js selection)
  * @return nothing
  */
 static function showSelector($date1, $date2, $randname)
 {
     $request_string = self::getRequestString($_GET);
     echo "<div class='center'><form method='POST' action='?{$request_string}' name='form'" . " id='mreporting_date_selector'>\n";
     echo "<table class='tab_cadre'><tr class='tab_bg_1'>";
     echo '<td><table><tr class="tab_bg_1">';
     echo "<td>";
     Html::showDateFormItem("date1" . $randname, $date1, false);
     echo "</td>\n";
     echo "<td>";
     Html::showDateFormItem("date2" . $randname, $date2, false);
     echo "</td>\n";
     self::getReportSelectors();
     echo "</tr></table></td>";
     echo "<td rowspan='2' class='center'>";
     echo "<input type='submit' class='button' name='submit' Value=\"" . _sx('button', 'Post') . "\">";
     echo "</td>\n";
     echo "<td class='center'>";
     $_SERVER['REQUEST_URI'] .= "&date1" . $randname . "=" . $date1;
     $_SERVER['REQUEST_URI'] .= "&date2" . $randname . "=" . $date2;
     Bookmark::showSaveButton(Bookmark::URI);
     echo "</td>\n";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:34,代码来源:misc.class.php

示例6: showContent

 function showContent()
 {
     $notice = $this->nli->notice;
     $out = $this->nli->out;
     $nb = Bookmark::getByNotice($notice);
     if (empty($nb)) {
         common_log(LOG_ERR, "No bookmark for notice {$notice->id}");
         parent::showContent();
         return;
     } else {
         if (empty($nb->url)) {
             common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$notice->id}");
             parent::showContent();
             return;
         }
     }
     $profile = $notice->getProfile();
     $out->elementStart('p', array('class' => 'entry-content'));
     // Whether to nofollow
     $attrs = array('href' => $nb->url, 'class' => 'bookmark-title');
     $nf = common_config('nofollow', 'external');
     if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
         $attrs['rel'] = 'external';
     } else {
         $attrs['rel'] = 'nofollow external';
     }
     $out->elementStart('h3');
     $out->element('a', $attrs, $nb->title);
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $notice->getReplies();
     $tags = $notice->getTags();
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::staticGet('id', $reply);
             if (!empty($other)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     $out->elementEnd('p');
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:59,代码来源:bookmarklistitem.php

示例7: beforeSave

 protected function beforeSave()
 {
     $folderModel = Folder::model()->findByPk($this->folder_id);
     $existingBookmarkModel = Bookmark::model()->findSingleByAttributes(array('user_id' => \GO::user()->id, 'folder_id' => $folderModel->id));
     if (!empty($existingBookmarkModel)) {
         throw new \Exception(str_replace('%fn', $folderModel->name, \GO::t('bookmarkAlreadyExists', 'files')));
     }
     return parent::beforeSave();
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:9,代码来源:Bookmark.php

示例8: handle

 /**
  * Handle the data
  *
  * @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
  *
  * @return boolean success value
  */
 function handle($data)
 {
     $profile = Profile::staticGet('id', $data['profile_id']);
     try {
         $saved = Bookmark::saveNew($profile, $data['title'], $data['url'], $data['tags'], $data['description'], array('created' => $data['created'], 'distribute' => false));
     } catch (ClientException $e) {
         // Most likely a duplicate -- continue on with the rest!
         common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $e->getMessage());
         return true;
     }
     return true;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:19,代码来源:deliciousbookmarkimporter.php

示例9: actionSet

 public function actionSet()
 {
     $book_id = (int) $_POST["book_id"];
     $orig_id = (int) $_POST["orig_id"];
     $pk = array("user_id" => Yii::app()->user->id, "book_id" => $book_id);
     if ($orig_id) {
         $pk["orig_id"] = $orig_id;
     }
     $bm = Bookmark::model()->findByAttributes($pk);
     if (!$bm) {
         $bm = new Bookmark();
         $bm->user_id = Yii::app()->user->id;
         $bm->book_id = $book_id;
         if ($orig_id) {
             $bm->orig_id = $orig_id;
         }
     }
     if (isset($_POST["note"])) {
         $post = $_POST;
         unset($post["book_id"]);
         unset($post["orig_id"]);
         $bm->setAttributes($post);
         $bm->watch = (int) $_POST["watch"];
         $new_ord = Yii::app()->db->createCommand("SELECT MAX(ord) FROM bookmarks WHERE user_id = :user_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id)) + 1;
         if ($orig_id) {
             // А есть ли закладка на перевод?
             if (!Yii::app()->db->createCommand("SELECT 1 FROM bookmarks WHERE user_id = :user_id AND book_id = :book_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id))) {
                 Yii::app()->db->createCommand("INSERT INTO bookmarks (user_id, book_id, ord) VALUES (:user_id, :book_id, :ord)")->execute(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id, ":ord" => $new_ord));
             }
         } else {
             $bm->ord = $new_ord;
         }
         if (!$bm->save()) {
             throw new CHttpException(500, $bm->getErrorsString());
         }
         echo json_encode(array("book_id" => (int) $bm->book_id, "orig_id" => (int) $bm->orig_id, "note" => $bm->note, "status" => "set"));
     } else {
         $this->renderPartial("set", array("bm" => $bm));
     }
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:40,代码来源:BookmarksController.php

示例10: testIdentityMapAndRecordStatus

 /**
  * This test case demonstrates an issue with the identity case in the
  * Doctrine_Table class.  The brief summary is that if you create a
  * record, then delete it, then create another record with the same
  * primary keys, the record can get into a state where it is in the
  * database but may appear to be marked as TCLEAN under certain
  * circumstances (such as when it comes back as part of a collection).
  * This makes the $record->exists() method return false, which prevents
  * the record from being deleted among other things.
  */
 public function testIdentityMapAndRecordStatus()
 {
     // load our user and our collection of pages
     $user = Doctrine_Query::create()->query('SELECT * FROM BookmarkUser u WHERE u.name=?', array('Anonymous'))->getFirst();
     $pages = Doctrine_Query::create()->query('SELECT * FROM Page');
     // bookmark the pages (manually)
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
     // now delete them all.
     $user['Bookmarks']->delete();
     // verify count when accessed directly from database
     $bookmarks = Doctrine_Query::create()->query('SELECT * FROM Bookmark');
     $this->assertEqual(count($bookmarks), 0);
     // now recreate bookmarks and verify they exist:
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks for the user
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:49,代码来源:587TestCase.php

示例11: handlePost

 /**
  * Add a new bookmark
  *
  * @return void
  */
 function handlePost()
 {
     if (empty($this->title)) {
         // TRANS: Client exception thrown when trying to create a new bookmark without a title.
         throw new ClientException(_m('Bookmark must have a title.'));
     }
     if (empty($this->url)) {
         // TRANS: Client exception thrown when trying to create a new bookmark without a URL.
         throw new ClientException(_m('Bookmark must have an URL.'));
     }
     $options = array();
     ToSelector::fillOptions($this, $options);
     $saved = Bookmark::addNew($this->scoped, $this->title, $this->url, $this->tags, $this->description, $options);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:19,代码来源:newbookmark.php

示例12: showContent

 function showContent()
 {
     $notice = $this->nli->notice;
     $out = $this->nli->out;
     $out->elementStart('p', array('class' => 'entry-content'));
     $nb = Bookmark::getByNotice($notice);
     $profile = $notice->getProfile();
     $atts = $notice->attachments();
     if (count($atts) < 1) {
         // Something wrong; let default code deal with it.
         // TRANS: Exception thrown when a bookmark has no attachments.
         // TRANS: %1$s is a bookmark ID, %2$s is a notice ID (number).
         throw new Exception(sprintf(_m('Bookmark %1$s (notice %2$d) has no attachments.'), $nb->id, $notice->id));
     }
     $att = $atts[0];
     $out->elementStart('h3');
     $out->element('a', array('href' => $att->url, 'class' => 'bookmark-title'), $nb->title);
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $notice->getReplies();
     $tags = $notice->getTags();
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::staticGet('id', $reply);
             if (!empty($other)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     $out->elementEnd('p');
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:48,代码来源:bookmarklistitem.php

示例13: getNotice

 function getNotice()
 {
     $this->id = $this->trimmed('id');
     $this->bookmark = Bookmark::staticGet('id', $this->id);
     if (empty($this->bookmark)) {
         // TRANS: Client exception thrown when referring to a non-existing bookmark.
         throw new ClientException(_m('No such bookmark.'), 404);
     }
     $notice = Notice::staticGet('uri', $this->bookmark->uri);
     if (empty($notice)) {
         // Did we used to have it, and it got deleted?
         // TRANS: Client exception thrown when referring to a non-existing bookmark.
         throw new ClientException(_m('No such bookmark.'), 404);
     }
     return $notice;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:16,代码来源:showbookmark.php

示例14: showMassiveActionsSubForm

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case 'move_bookmark':
             $values = array('after' => __('After'), 'before' => __('Before'));
             Dropdown::showFromArray('move_type', $values, array('width' => '20%'));
             $param = array('name' => "bookmarks_id_ref", 'width' => '50%');
             $param['condition'] = "(`is_private`='1' AND `users_id`='" . Session::getLoginUserID() . "') ";
             $param['entity'] = -1;
             Bookmark::dropdown($param);
             echo "<br><br>\n";
             echo Html::submit(_x('button', 'Move'), array('name' => 'massiveaction')) . "</span>";
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:22,代码来源:bookmark.class.php

示例15: handle

 /**
  * Handle the data
  *
  * @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
  *
  * @return boolean success value
  */
 function handle($data)
 {
     $profile = Profile::getKV('id', $data['profile_id']);
     try {
         $saved = Bookmark::saveNew($profile, $data['title'], $data['url'], $data['tags'], $data['description'], array('created' => $data['created'], 'distribute' => false));
     } catch (ClientException $ce) {
         // Most likely a duplicate -- continue on with the rest!
         common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
         return true;
     } catch (Exception $ex) {
         if (preg_match("/DB Error: already exists/", $ex->getMessage())) {
             common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
             return true;
         } else {
             throw $ex;
         }
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:26,代码来源:deliciousbookmarkimporter.php


注:本文中的Bookmark类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。