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


PHP common_render_content函数代码示例

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


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

示例1: fixupNoticeRendered

function fixupNoticeRendered()
{
    printfnq("Ensuring all notices have rendered HTML...");
    $notice = new Notice();
    $notice->whereAdd('rendered IS NULL');
    $notice->find();
    while ($notice->fetch()) {
        $original = clone $notice;
        $notice->rendered = common_render_content($notice->content, $notice);
        $notice->update($original);
    }
    printfnq("DONE.\n");
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:13,代码来源:upgrade.php

示例2: showContent

 /**
  * show the content of the notice
  *
  * Trims out the rel=nofollow for external links
  * if nofollow|external = 'sometimes'
  *
  * @return void
  */
 function showContent()
 {
     // FIXME: URL, image, video, audio
     $this->out->elementStart('p', array('class' => 'entry-content'));
     if (!empty($this->notice->rendered)) {
         $html = $this->notice->rendered;
     } else {
         $html = common_render_content($this->notice->content, $this->notice);
     }
     if (common_config('nofollow', 'external') == 'sometimes') {
         // remove the nofollow part
         // XXX: cache the results here
         $html = preg_replace('/rel="(.*)nofollow ?/', 'rel="\\1', $html);
     }
     $this->out->raw($html);
     $this->out->elementEnd('p');
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:25,代码来源:dofollowlistitem.php

示例3: define

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
// Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    print "This script must be run from the command line\n";
    exit;
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('GNUSOCIAL', true);
define('STATUSNET', true);
// compatibility
require_once INSTALLDIR . '/lib/common.php';
common_log(LOG_INFO, 'Starting to do old notices.');
$notice = new Notice();
$cnt = $notice->find();
while ($notice->fetch()) {
    common_log(LOG_INFO, 'Getting tags for notice #' . $notice->id);
    $notice->saveTags();
    $original = clone $notice;
    $notice->rendered = common_render_content($notice->content, $notice->getProfile(), $notice->hasParent() ? $notice->getParent() : null);
    $result = $notice->update($original);
    if (!$result) {
        common_log_db_error($notice, 'UPDATE', __FILE__);
    }
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:31,代码来源:fixup_hashtags.php

示例4: saveNew


//.........这里部分代码省略.........
         // unknown remote user - within a known conversation.
         if (empty($notice->conversation) and !empty($options['conversation'])) {
             $conv = Conversation::getKV('uri', $options['conversation']);
             if ($conv instanceof Conversation) {
                 common_debug('Conversation stitched together from (probably) a reply to unknown remote user. Activity creation time (' . $notice->created . ') should maybe be compared to conversation creation time (' . $conv->created . ').');
             } else {
                 // Conversation entry with specified URI was not found, so we must create it.
                 common_debug('Conversation URI not found, so we will create it with the URI given in the options to Notice::saveNew: ' . $options['conversation']);
                 // The insert in Conversation::create throws exception on failure
                 $conv = Conversation::create($options['conversation'], $notice->created);
             }
             $notice->conversation = $conv->getID();
             unset($conv);
         }
     }
     // If it's not part of a conversation, it's the beginning of a new conversation.
     if (empty($notice->conversation)) {
         $conv = Conversation::create();
         $notice->conversation = $conv->getID();
         unset($conv);
     }
     $notloc = new Notice_location();
     if (!empty($lat) && !empty($lon)) {
         $notloc->lat = $lat;
         $notloc->lon = $lon;
     }
     if (!empty($location_ns) && !empty($location_id)) {
         $notloc->location_id = $location_id;
         $notloc->location_ns = $location_ns;
     }
     if (!empty($rendered)) {
         $notice->rendered = $rendered;
     } else {
         $notice->rendered = common_render_content($final, $notice->getProfile(), $notice->hasParent() ? $notice->getParent() : null);
     }
     if (empty($verb)) {
         if ($notice->isRepeat()) {
             $notice->verb = ActivityVerb::SHARE;
             $notice->object_type = ActivityObject::ACTIVITY;
         } else {
             $notice->verb = ActivityVerb::POST;
         }
     } else {
         $notice->verb = $verb;
     }
     if (empty($object_type)) {
         $notice->object_type = empty($notice->reply_to) ? ActivityObject::NOTE : ActivityObject::COMMENT;
     } else {
         $notice->object_type = $object_type;
     }
     if (is_null($scope) && $reply instanceof Notice) {
         $notice->scope = $reply->scope;
     } else {
         $notice->scope = $scope;
     }
     $notice->scope = self::figureOutScope($profile, $groups, $notice->scope);
     if (Event::handle('StartNoticeSave', array(&$notice))) {
         // XXX: some of these functions write to the DB
         try {
             $notice->insert();
             // throws exception on failure, if successful we have an ->id
             if ($notloc->lat && $notloc->lon || $notloc->location_id && $notloc->location_ns) {
                 $notloc->notice_id = $notice->getID();
                 $notloc->insert();
                 // store the notice location if it had any information
             }
开发者ID:a780201,项目名称:gnu-social,代码行数:67,代码来源:Notice.php

示例5: format_entry

 /**
  * extra information for XMPP messages, as defined by Twitter
  *
  * @param Profile $profile Profile of the sending user
  * @param Notice  $notice  Notice being sent
  *
  * @return string Extra information (Atom, HTML, addresses) in string format
  */
 protected function format_entry(Notice $notice)
 {
     $profile = $notice->getProfile();
     $entry = $notice->asAtomEntry(true, true);
     $xs = new XMLStringer();
     $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
     $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
     $xs->element('a', array('href' => $profile->profileurl), $profile->nickname);
     try {
         $parent = $notice->getParent();
         $orig_profile = $parent->getProfile();
         $orig_profurl = $orig_profile->getUrl();
         $xs->text(" => ");
         $xs->element('a', array('href' => $orig_profurl), $orig_profile->nickname);
         $xs->text(": ");
     } catch (InvalidUrlException $e) {
         $xs->text(sprintf(' => %s', $orig_profile->nickname));
     } catch (NoParentNoticeException $e) {
         $xs->text(": ");
     }
     if (!empty($notice->rendered)) {
         $notice->rendered = str_replace("\t", "", $notice->rendered);
         $xs->raw($notice->rendered);
     } else {
         $xs->raw(common_render_content($notice->content, $notice));
     }
     $xs->text(" ");
     $xs->element('a', array('href' => common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id), sprintf(_m('[%u]'), $notice->id));
     $xs->elementEnd('body');
     $xs->elementEnd('html');
     $html = $xs->getString();
     return $html . ' ' . $entry;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:41,代码来源:XmppPlugin.php

示例6: showContent

 /**
  * show the content of the notice
  *
  * Shows the content of the notice. This is pre-rendered for efficiency
  * at save time. Some very old notices might not be pre-rendered, so
  * they're rendered on the spot.
  *
  * @return void
  */
 function showContent()
 {
     $this->out->elementStart('p', array('class' => 'entry-content answer-content'));
     if ($this->notice->rendered) {
         $this->out->raw($this->notice->rendered);
     } else {
         // XXX: may be some uncooked notices in the DB,
         // we cook them right now. This should probably disappear in future
         // versions (>> 0.4.x)
         $this->out->raw(common_render_content($this->notice->content, $this->notice));
     }
     if (!empty($this->answer)) {
         $form = new QnashowanswerForm($this->out, $this->answer);
         $form->show();
     } else {
         // TRANS: Error message displayed when an answer has no content.
         $out->text(_m('Answer data is missing.'));
     }
     $this->out->elementEnd('p');
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:29,代码来源:qnanewanswer.php

示例7: saveNew


//.........这里部分代码省略.........
     $notice->profile_id = $profile_id;
     $autosource = common_config('public', 'autosource');
     # Sandboxed are non-false, but not 1, either
     if (!$profile->hasRight(Right::PUBLICNOTICE) || $source && $autosource && in_array($source, $autosource)) {
         $notice->is_local = Notice::LOCAL_NONPUBLIC;
     } else {
         $notice->is_local = $is_local;
     }
     if (!empty($created)) {
         $notice->created = $created;
     } else {
         $notice->created = common_sql_now();
     }
     $notice->content = $final;
     $notice->source = $source;
     $notice->uri = $uri;
     $notice->url = $url;
     // Handle repeat case
     if (isset($repeat_of)) {
         $notice->repeat_of = $repeat_of;
     } else {
         $notice->reply_to = self::getReplyTo($reply_to, $profile_id, $source, $final);
     }
     if (!empty($notice->reply_to)) {
         $reply = Notice::staticGet('id', $notice->reply_to);
         $notice->conversation = $reply->conversation;
     }
     if (!empty($lat) && !empty($lon)) {
         $notice->lat = $lat;
         $notice->lon = $lon;
     }
     if (!empty($location_ns) && !empty($location_id)) {
         $notice->location_id = $location_id;
         $notice->location_ns = $location_ns;
     }
     if (!empty($rendered)) {
         $notice->rendered = $rendered;
     } else {
         $notice->rendered = common_render_content($final, $notice);
     }
     if (Event::handle('StartNoticeSave', array(&$notice))) {
         // XXX: some of these functions write to the DB
         $id = $notice->insert();
         if (!$id) {
             common_log_db_error($notice, 'INSERT', __FILE__);
             // TRANS: Server exception thrown when a notice cannot be saved.
             throw new ServerException(_('Problem saving notice.'));
         }
         // Update ID-dependent columns: URI, conversation
         $orig = clone $notice;
         $changed = false;
         if (empty($uri)) {
             $notice->uri = common_notice_uri($notice);
             $changed = true;
         }
         // If it's not part of a conversation, it's
         // the beginning of a new conversation.
         if (empty($notice->conversation)) {
             $conv = Conversation::create();
             $notice->conversation = $conv->id;
             $changed = true;
         }
         if ($changed) {
             if (!$notice->update($orig)) {
                 common_log_db_error($notice, 'UPDATE', __FILE__);
                 // TRANS: Server exception thrown when a notice cannot be updated.
                 throw new ServerException(_('Problem saving notice.'));
             }
         }
     }
     # Clear the cache for subscribed users, so they'll update at next request
     # XXX: someone clever could prepend instead of clearing the cache
     $notice->blowOnInsert();
     // Save per-notice metadata...
     if (isset($replies)) {
         $notice->saveKnownReplies($replies);
     } else {
         $notice->saveReplies();
     }
     if (isset($tags)) {
         $notice->saveKnownTags($tags);
     } else {
         $notice->saveTags();
     }
     // Note: groups may save tags, so must be run after tags are saved
     // to avoid errors on duplicates.
     if (isset($groups)) {
         $notice->saveKnownGroups($groups);
     } else {
         $notice->saveGroups();
     }
     if (isset($urls)) {
         $notice->saveKnownUrls($urls);
     } else {
         $notice->saveUrls();
     }
     // Prepare inbox delivery, may be queued to background.
     $notice->distribute();
     return $notice;
 }
开发者ID:Br3nda,项目名称:statusnet-debian,代码行数:101,代码来源:Notice.php

示例8: doPost

 /**
  * This doPost saves a new notice, based on arguments
  *
  * If successful, will show the notice, or return an Ajax-y result.
  * If not, it will show an error message -- possibly Ajax-y.
  *
  * Also, if the notice input looks like a command, it will run the
  * command and show the results -- again, possibly ajaxy.
  *
  * @return void
  */
 protected function doPost()
 {
     assert($this->scoped instanceof Profile);
     // XXX: maybe an error instead...
     $user = $this->scoped->getUser();
     $content = $this->trimmed('status_textarea');
     $options = array('source' => 'web');
     Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options));
     if (empty($content)) {
         // TRANS: Client error displayed trying to send a notice without content.
         $this->clientError(_('No content!'));
     }
     $inter = new CommandInterpreter();
     $cmd = $inter->handle_command($user, $content);
     if ($cmd) {
         if (GNUsocial::isAjax()) {
             $cmd->execute(new AjaxWebChannel($this));
         } else {
             $cmd->execute(new WebChannel($this));
         }
         return;
     }
     if ($this->int('inreplyto')) {
         // Throws exception if the inreplyto Notice is given but not found.
         $parent = Notice::getByID($this->int('inreplyto'));
     } else {
         $parent = null;
     }
     $act = new Activity();
     $act->verb = ActivityVerb::POST;
     $act->time = time();
     $act->actor = $this->scoped->asActivityObject();
     $upload = null;
     try {
         // throws exception on failure
         $upload = MediaFile::fromUpload('attach', $this->scoped);
         if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options))) {
             $content .= ' ' . $upload->shortUrl();
         }
         Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
         // We could check content length here if the URL was added, but I'll just let it slide for now...
         $act->enclosures[] = $upload->getEnclosure();
     } catch (NoUploadedMediaException $e) {
         // simply no attached media to the new notice
     }
     // Reject notice if it is too long (without the HTML)
     // This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
     if (Notice::contentTooLong($content)) {
         // TRANS: Client error displayed when the parameter "status" is missing.
         // TRANS: %d is the maximum number of character for a notice.
         throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.', 'That\'s too long. Maximum notice size is %d characters.', Notice::maxContent()), Notice::maxContent()));
     }
     $act->context = new ActivityContext();
     if ($parent instanceof Notice) {
         $act->context->replyToID = $parent->getUri();
         $act->context->replyToUrl = $parent->getUrl(true);
         // maybe we don't have to send true here to force a URL?
     }
     if ($this->scoped->shareLocation()) {
         // use browser data if checked; otherwise profile data
         if ($this->arg('notice_data-geo')) {
             $locOptions = Notice::locationOptions($this->trimmed('lat'), $this->trimmed('lon'), $this->trimmed('location_id'), $this->trimmed('location_ns'), $this->scoped);
         } else {
             $locOptions = Notice::locationOptions(null, null, null, null, $this->scoped);
         }
         $act->context->location = Location::fromOptions($locOptions);
     }
     $content = $this->scoped->shortenLinks($content);
     // FIXME: Make sure NoticeTitle plugin gets a change to add the title to our activityobject!
     if (Event::handle('StartNoticeSaveWeb', array($this, $this->scoped, &$content, &$options))) {
         // FIXME: We should be able to get the attentions from common_render_content!
         // and maybe even directly save whether they're local or not!
         $act->context->attention = common_get_attentions($content, $this->scoped, $parent);
         $actobj = new ActivityObject();
         $actobj->type = ActivityObject::NOTE;
         $actobj->content = common_render_content($content, $this->scoped, $parent);
         // Finally add the activity object to our activity
         $act->objects[] = $actobj;
         $this->stored = Notice::saveActivity($act, $this->scoped, $options);
         if ($upload instanceof MediaFile) {
             $upload->attachToNotice($this->stored);
         }
         Event::handle('EndNoticeSaveWeb', array($this, $this->stored));
     }
     Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content, &$options));
     if (!GNUsocial::isAjax()) {
         $url = common_local_url('shownotice', array('notice' => $this->stored->id));
         common_redirect($url, 303);
     }
//.........这里部分代码省略.........
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:101,代码来源:newnotice.php

示例9: jabber_format_entry

/**
 * extra information for XMPP messages, as defined by Twitter
 *
 * @param Profile $profile Profile of the sending user
 * @param Notice  $notice  Notice being sent
 *
 * @return string Extra information (Atom, HTML, addresses) in string format
 */
function jabber_format_entry($profile, $notice)
{
    // FIXME: notice url might be remote
    $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
    $msg = jabber_format_notice($profile, $notice);
    $self_url = common_local_url('userrss', array('nickname' => $profile->nickname));
    $entry = "\n<entry xmlns='http://www.w3.org/2005/Atom'>\n";
    $entry .= "<source>\n";
    $entry .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
    $entry .= "<link href='" . htmlspecialchars($profile->profileurl) . "'/>\n";
    $entry .= "<link rel='self' type='application/rss+xml' href='" . $self_url . "'/>\n";
    $entry .= "<author><name>" . $profile->nickname . "</name></author>\n";
    $entry .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
    $entry .= "</source>\n";
    $entry .= "<title>" . htmlspecialchars($msg) . "</title>\n";
    $entry .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
    $entry .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
    $entry .= "<id>" . $notice->uri . "</id>\n";
    $entry .= "<published>" . common_date_w3dtf($notice->created) . "</published>\n";
    $entry .= "<updated>" . common_date_w3dtf($notice->modified) . "</updated>\n";
    if ($notice->reply_to) {
        $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
        $entry .= "<link rel='related' href='" . $replyurl . "'/>\n";
    }
    $entry .= "</entry>\n";
    $html = "\n<html xmlns='http://jabber.org/protocol/xhtml-im'>\n";
    $html .= "<body xmlns='http://www.w3.org/1999/xhtml'>\n";
    $html .= "<a href='" . htmlspecialchars($profile->profileurl) . "'>" . $profile->nickname . "</a>: ";
    $html .= $notice->rendered ? $notice->rendered : common_render_content($notice->content, $notice);
    $html .= "\n</body>\n";
    $html .= "\n</html>\n";
    $address = "<addresses xmlns='http://jabber.org/protocol/address'>\n";
    $address .= "<address type='replyto' jid='" . jabber_daemon_address() . "' />\n";
    $address .= "</addresses>\n";
    // FIXME: include a pubsub event, too.
    return $html . $entry . $address;
}
开发者ID:Br3nda,项目名称:laconica,代码行数:45,代码来源:jabber.php

示例10: saveNew


//.........这里部分代码省略.........
         if (!empty($reply)) {
             if (!$reply->inScope($profile)) {
                 // TRANS: Client error displayed when trying to reply to a notice a the target has no access to.
                 // TRANS: %1$s is a user nickname, %2$d is a notice ID (number).
                 throw new ClientException(sprintf(_('%1$s has no access to notice %2$d.'), $profile->nickname, $reply->id), 403);
             }
             $notice->reply_to = $reply->id;
             $notice->conversation = $reply->conversation;
             // If the original is private to a group, and notice has no group specified,
             // make it to the same group(s)
             if (empty($groups) && $reply->scope | Notice::GROUP_SCOPE) {
                 $groups = array();
                 $replyGroups = $reply->getGroups();
                 foreach ($replyGroups as $group) {
                     if ($profile->isMember($group)) {
                         $groups[] = $group->id;
                     }
                 }
             }
             // Scope set below
         }
     }
     if (!empty($lat) && !empty($lon)) {
         $notice->lat = $lat;
         $notice->lon = $lon;
     }
     if (!empty($location_ns) && !empty($location_id)) {
         $notice->location_id = $location_id;
         $notice->location_ns = $location_ns;
     }
     if (!empty($rendered)) {
         $notice->rendered = $rendered;
     } else {
         $notice->rendered = common_render_content($final, $notice);
     }
     if (empty($verb)) {
         if (!empty($notice->repeat_of)) {
             $notice->verb = ActivityVerb::SHARE;
             $notice->object_type = ActivityObject::ACTIVITY;
         } else {
             $notice->verb = ActivityVerb::POST;
         }
     } else {
         $notice->verb = $verb;
     }
     if (empty($object_type)) {
         $notice->object_type = empty($notice->reply_to) ? ActivityObject::NOTE : ActivityObject::COMMENT;
     } else {
         $notice->object_type = $object_type;
     }
     if (is_null($scope)) {
         // 0 is a valid value
         if (!empty($reply)) {
             $notice->scope = $reply->scope;
         } else {
             $notice->scope = self::defaultScope();
         }
     } else {
         $notice->scope = $scope;
     }
     // For private streams
     $user = $profile->getUser();
     if (!empty($user)) {
         if ($user->private_stream && ($notice->scope == Notice::PUBLIC_SCOPE || $notice->scope == Notice::SITE_SCOPE)) {
             $notice->scope |= Notice::FOLLOWER_SCOPE;
         }
开发者ID:Grasia,项目名称:bolotweet,代码行数:67,代码来源:Notice.php

示例11: showContent

 /**
  * show the content of the notice
  *
  * Shows the content of the notice. This is pre-rendered for efficiency
  * at save time. Some very old notices might not be pre-rendered, so
  * they're rendered on the spot.
  *
  * @return void
  */
 function showContent()
 {
     // FIXME: URL, image, video, audio
     $this->out->elementStart('article', array('class' => 'e-content'));
     if (Event::handle('StartShowNoticeContent', array($this->notice, $this->out, $this->out->getScoped()))) {
         if ($this->maxchars > 0 && mb_strlen($this->notice->content) > $this->maxchars) {
             $this->out->text(mb_substr($this->notice->content, 0, $this->maxchars) . '[…]');
         } elseif ($this->notice->rendered) {
             $this->out->raw($this->notice->rendered);
         } else {
             // XXX: may be some uncooked notices in the DB,
             // we cook them right now. This should probably disappear in future
             // versions (>> 0.4.x)
             $this->out->raw(common_render_content($this->notice->content, $this->notice));
         }
         Event::handle('EndShowNoticeContent', array($this->notice, $this->out, $this->out->getScoped()));
     }
     $this->out->elementEnd('article');
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:28,代码来源:noticelistitem.php

示例12: saveStatus

 function saveStatus($status, $flink)
 {
     $profile = $this->ensureProfile($status->user);
     if (empty($profile)) {
         common_log(LOG_ERR, $this->name() . ' - Problem saving notice. No associated Profile.');
         return;
     }
     $statusUri = 'http://twitter.com/' . $status->user->screen_name . '/status/' . $status->id;
     // check to see if we've already imported the status
     $dupe = $this->checkDupe($profile, $statusUri);
     if (!empty($dupe)) {
         common_log(LOG_INFO, $this->name() . " - Ignoring duplicate import: {$statusUri}");
         return;
     }
     $notice = new Notice();
     $notice->profile_id = $profile->id;
     $notice->uri = $statusUri;
     $notice->url = $statusUri;
     $notice->created = strftime('%Y-%m-%d %H:%M:%S', strtotime($status->created_at));
     $notice->source = 'twitter';
     $notice->reply_to = null;
     $notice->is_local = Notice::GATEWAY;
     $notice->content = common_shorten_links($status->text);
     $notice->rendered = common_render_content($notice->content, $notice);
     if (Event::handle('StartNoticeSave', array(&$notice))) {
         $id = $notice->insert();
         if (!$id) {
             common_log_db_error($notice, 'INSERT', __FILE__);
             common_log(LOG_ERR, $this->name() . ' - Problem saving notice.');
         }
         Event::handle('EndNoticeSave', array($notice));
     }
     $orig = clone $notice;
     $conv = Conversation::create();
     $notice->conversation = $conv->id;
     if (!$notice->update($orig)) {
         common_log_db_error($notice, 'UPDATE', __FILE__);
         common_log(LOG_ERR, $this->name() . ' - Problem saving notice.');
     }
     Inbox::insertNotice($flink->user_id, $notice->id);
     $notice->blowOnInsert();
     return $notice;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:43,代码来源:twitterstatusfetcher.php

示例13: saveStatus

 function saveStatus($status, $flink)
 {
     $id = $this->ensureProfile($status->user);
     $profile = Profile::staticGet($id);
     if (!$profile) {
         common_log(LOG_ERR, 'Problem saving notice. No associated Profile.');
         return null;
     }
     // XXX: change of screen name?
     $uri = 'http://twitter.com/' . $status->user->screen_name . '/status/' . $status->id;
     $notice = Notice::staticGet('uri', $uri);
     // check to see if we've already imported the status
     if (!$notice) {
         $notice = new Notice();
         $notice->profile_id = $id;
         $notice->uri = $uri;
         $notice->created = strftime('%Y-%m-%d %H:%M:%S', strtotime($status->created_at));
         $notice->content = common_shorten_links($status->text);
         // XXX
         $notice->rendered = common_render_content($notice->content, $notice);
         $notice->source = 'twitter';
         $notice->reply_to = null;
         // XXX lookup reply
         $notice->is_local = Notice::GATEWAY;
         if (Event::handle('StartNoticeSave', array(&$notice))) {
             $id = $notice->insert();
             Event::handle('EndNoticeSave', array($notice));
         }
     }
     if (!Notice_inbox::pkeyGet(array('notice_id' => $notice->id, 'user_id' => $flink->user_id))) {
         // Add to inbox
         $inbox = new Notice_inbox();
         $inbox->user_id = $flink->user_id;
         $inbox->notice_id = $notice->id;
         $inbox->created = $notice->created;
         $inbox->source = NOTICE_INBOX_SOURCE_GATEWAY;
         // From a private source
         $inbox->insert();
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:40,代码来源:twitterstatusfetcher.php

示例14: define

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
# Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    print "This script must be run from the command line\n";
    exit;
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('NEWTYPE', true);
define('DWORKS', true);
// compatibility
require_once INSTALLDIR . '/lib/common.php';
common_log(LOG_INFO, 'Starting to do old notices.');
$notice = new Notice();
$cnt = $notice->find();
while ($notice->fetch()) {
    common_log(LOG_INFO, 'Getting tags for notice #' . $notice->id);
    $notice->saveTags();
    $original = clone $notice;
    $notice->rendered = common_render_content($notice->content, $notice);
    $result = $notice->update($original);
    if (!$result) {
        common_log_db_error($notice, 'UPDATE', __FILE__);
    }
}
开发者ID:himmelex,项目名称:NTW,代码行数:31,代码来源:fixup_hashtags.php

示例15: jabber_format_entry

/**
 * extra information for XMPP messages, as defined by Twitter
 *
 * @param Profile $profile Profile of the sending user
 * @param Notice  $notice  Notice being sent
 *
 * @return string Extra information (Atom, HTML, addresses) in string format
 */
function jabber_format_entry($profile, $notice)
{
    $entry = $notice->asAtomEntry(true, true);
    $xs = new XMLStringer();
    $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
    $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
    $xs->element('a', array('href' => $profile->profileurl), $profile->nickname);
    $xs->text(": ");
    if (!empty($notice->rendered)) {
        $xs->raw($notice->rendered);
    } else {
        $xs->raw(common_render_content($notice->content, $notice));
    }
    $xs->text(" ");
    $xs->element('a', array('href' => common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id), sprintf(_('[%s]'), $notice->id));
    $xs->elementEnd('body');
    $xs->elementEnd('html');
    $html = $xs->getString();
    return $html . ' ' . $entry;
}
开发者ID:microcosmx,项目名称:experiments,代码行数:28,代码来源:jabber.php


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