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


PHP Bookmark::saveNew方法代码示例

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


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

示例1: 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

示例2: 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

示例3: saveNoticeFromActivity

 /**
  * Save a bookmark from an activity
  *
  * @param Activity $activity Activity to save
  * @param Profile  $actor    Profile to use as author
  * @param array    $options  Options to pass to bookmark-saving code
  *
  * @return Notice resulting notice
  */
 function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options = array())
 {
     $bookmark = $activity->objects[0];
     $relLinkEls = ActivityUtils::getLinks($bookmark->element, 'related');
     if (count($relLinkEls) < 1) {
         // TRANS: Client exception thrown when a bookmark is formatted incorrectly.
         throw new ClientException(_m('Expected exactly 1 link ' . 'rel=related in a Bookmark.'));
     }
     if (count($relLinkEls) > 1) {
         common_log(LOG_WARNING, "Got too many link rel=related in a Bookmark.");
     }
     $linkEl = $relLinkEls[0];
     $url = $linkEl->getAttribute('href');
     $tags = array();
     foreach ($activity->categories as $category) {
         $tags[] = common_canonical_tag($category->term);
     }
     if (!empty($activity->time)) {
         $options['created'] = common_sql_date($activity->time);
     }
     // Fill in location if available
     $location = $activity->context->location;
     if ($location) {
         $options['lat'] = $location->lat;
         $options['lon'] = $location->lon;
         if ($location->location_id) {
             $options['location_ns'] = $location->location_ns;
             $options['location_id'] = $location->location_id;
         }
     }
     $options['groups'] = array();
     $options['replies'] = array();
     // TODO: context->attention
     foreach ($activity->context->attention as $attnUrl => $type) {
         try {
             $other = Profile::fromUri($attnUrl);
             if ($other->isGroup()) {
                 $options['groups'][] = $other->id;
             } else {
                 $options['replies'][] = $attnUrl;
             }
         } catch (UnknownUriException $e) {
             // We simply don't know this URI, despite lookup attempts.
         }
     }
     // Maintain direct reply associations
     // @fixme what about conversation ID?
     if (!empty($activity->context->replyToID)) {
         $orig = Notice::getKV('uri', $activity->context->replyToID);
         if (!empty($orig)) {
             $options['reply_to'] = $orig->id;
         }
     }
     return Bookmark::saveNew($actor, $bookmark->title, $url, $tags, $bookmark->summary, $options);
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:64,代码来源:BookmarkPlugin.php

示例4: saveNoticeFromActivity

 /**
  * Save a bookmark from an activity
  *
  * @param Activity $activity Activity to save
  * @param Profile  $profile  Profile to use as author
  * @param array    $options  Options to pass to bookmark-saving code
  *
  * @return Notice resulting notice
  */
 function saveNoticeFromActivity($activity, $profile, $options = array())
 {
     $bookmark = $activity->objects[0];
     $relLinkEls = ActivityUtils::getLinks($bookmark->element, 'related');
     if (count($relLinkEls) < 1) {
         // TRANS: Client exception thrown when a bookmark is formatted incorrectly.
         throw new ClientException(_m('Expected exactly 1 link ' . 'rel=related in a Bookmark.'));
     }
     if (count($relLinkEls) > 1) {
         common_log(LOG_WARNING, "Got too many link rel=related in a Bookmark.");
     }
     $linkEl = $relLinkEls[0];
     $url = $linkEl->getAttribute('href');
     $tags = array();
     foreach ($activity->categories as $category) {
         $tags[] = common_canonical_tag($category->term);
     }
     if (!empty($activity->time)) {
         $options['created'] = common_sql_date($activity->time);
     }
     // Fill in location if available
     $location = $activity->context->location;
     if ($location) {
         $options['lat'] = $location->lat;
         $options['lon'] = $location->lon;
         if ($location->location_id) {
             $options['location_ns'] = $location->location_ns;
             $options['location_id'] = $location->location_id;
         }
     }
     $replies = $activity->context->attention;
     $options['groups'] = array();
     $options['replies'] = array();
     foreach ($replies as $replyURI) {
         $other = Profile::fromURI($replyURI);
         if (!empty($other)) {
             $options['replies'][] = $replyURI;
         } else {
             $group = User_group::staticGet('uri', $replyURI);
             if (!empty($group)) {
                 $options['groups'][] = $replyURI;
             }
         }
     }
     // Maintain direct reply associations
     // @fixme what about conversation ID?
     if (!empty($activity->context->replyToID)) {
         $orig = Notice::staticGet('uri', $activity->context->replyToID);
         if (!empty($orig)) {
             $options['reply_to'] = $orig->id;
         }
     }
     return Bookmark::saveNew($profile, $bookmark->title, $url, $tags, $bookmark->summary, $options);
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:63,代码来源:BookmarkPlugin.php

示例5: newBookmark

 /**
  * Add a new bookmark
  *
  * @return void
  */
 function newBookmark()
 {
     try {
         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::saveNew($this->user->getProfile(), $this->title, $this->url, $this->tags, $this->description, $options);
     } catch (ClientException $ce) {
         if ($this->boolean('ajax')) {
             throw $ce;
         } else {
             $this->error = $ce->getMessage();
             $this->showPage();
             return;
         }
     }
     if ($this->boolean('ajax')) {
         header('Content-Type: text/xml;charset=utf-8');
         $this->xw->startDocument('1.0', 'UTF-8');
         $this->elementStart('html');
         $this->elementStart('head');
         // TRANS: Page title after posting a bookmark.
         $this->element('title', null, _m('Bookmark posted'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $this->showNotice($saved);
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect($saved->bestUrl(), 303);
     }
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:44,代码来源:newbookmark.php

示例6: newBookmark

 /**
  * Add a new bookmark
  *
  * @return void
  */
 function newBookmark()
 {
     try {
         if (empty($this->title)) {
             throw new ClientException(_('Bookmark must have a title.'));
         }
         if (empty($this->url)) {
             throw new ClientException(_('Bookmark must have an URL.'));
         }
         $saved = Bookmark::saveNew($this->user->getProfile(), $this->title, $this->url, $this->tags, $this->description);
     } catch (ClientException $ce) {
         $this->error = $ce->getMessage();
         $this->showPage();
         return;
     }
     common_redirect($saved->bestUrl(), 303);
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:22,代码来源:newbookmark.php


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