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


PHP Notice::maxContent方法代码示例

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


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

示例1: onEndShowScripts

 function onEndShowScripts($action)
 {
     $action->inlineScript('var Notice_maxContent = ' . Notice::maxContent());
     if (common_logged_in()) {
         $action->script($this->path('shorten.js'));
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:7,代码来源:ClientSideShortenPlugin.php

示例2: onEndShowScripts

 function onEndShowScripts($action)
 {
     $action->inlineScript('var Notice_maxContent = ' . Notice::maxContent());
     if (common_logged_in()) {
         $action->script('plugins/ClientSideShorten/shorten.js');
     }
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:7,代码来源:ClientSideShortenPlugin.php

示例3: handle_message

 function handle_message($rawmessage)
 {
     list($from, $to, $msg, $attachments) = $this->parse_message($rawmessage);
     if (!$from || !$to || !$msg) {
         // TRANS: Error message in incoming mail handler used when an incoming e-mail cannot be processed.
         $this->error(null, _('Could not parse message.'));
     }
     common_log(LOG_INFO, "Mail from {$from} to {$to} with " . count($attachments) . ' attachment(s): ' . substr($msg, 0, 20));
     $user = $this->user_from_header($from);
     if (!$user) {
         // TRANS: Error message in incoming mail handler used when an incoming e-mail is not from a registered user.
         $this->error($from, _('Not a registered user.'));
         return false;
     }
     if (!$this->user_match_to($user, $to)) {
         // TRANS: Error message in incoming mail handler used when an incoming e-mail is not from a user's incoming e-mail address.
         $this->error($from, _('Sorry, that is not your incoming email address.'));
         return false;
     }
     if (!$user->emailpost) {
         // TRANS: Error message in incoming mail handler used when no incoming e-mail is allowed.
         $this->error($from, _('Sorry, no incoming email allowed.'));
         return false;
     }
     $response = $this->handle_command($user, $from, $msg);
     if ($response) {
         return true;
     }
     $msg = $this->cleanup_msg($msg);
     $msg = $user->shortenLinks($msg);
     if (Notice::contentTooLong($msg)) {
         // TRANS: Error message in incoming mail handler used when an incoming e-mail contains too many characters.
         $this->error($from, 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()));
     }
     $mediafiles = array();
     foreach ($attachments as $attachment) {
         $mf = null;
         try {
             $mf = MediaFile::fromFileHandle($attachment, $user);
         } catch (ClientException $ce) {
             $this->error($from, $ce->getMessage());
         }
         $msg .= ' ' . $mf->shortUrl();
         array_push($mediafiles, $mf);
         fclose($attachment);
     }
     $err = $this->add_notice($user, $msg, $mediafiles);
     if (is_string($err)) {
         $this->error($from, $err);
         return false;
     } else {
         return true;
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:54,代码来源:mailhandler.php

示例4: maxNoticeLength

 static function maxNoticeLength($user)
 {
     $def = common_config('url', 'maxnoticelength');
     if ($def == -1) {
         $def = Notice::maxContent();
     }
     $prefs = self::getPrefs($user);
     if (empty($prefs)) {
         return $def;
     } else {
         return $prefs->maxnoticelength;
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:13,代码来源:User_urlshortener_prefs.php

示例5: maxNoticeLength

 static function maxNoticeLength($user)
 {
     $def = common_config('url', 'maxnoticelength');
     if ($def == -1) {
         /*
          * maxContent==0 means infinite length,
          * but maxNoticeLength==0 means "always shorten"
          * so if maxContent==0 we must set this to -1
          */
         $def = Notice::maxContent() ?: -1;
     }
     $prefs = self::getPrefs($user);
     if (empty($prefs)) {
         return $def;
     } else {
         return $prefs->maxnoticelength;
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:18,代码来源:User_urlshortener_prefs.php

示例6: 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();
     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;
     }
     $content_shortened = $user->shortenLinks($content);
     if (Notice::contentTooLong($content_shortened)) {
         // TRANS: Client error displayed when the parameter "status" is missing.
         // TRANS: %d is the maximum number of character for a notice.
         $this->clientError(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()));
     }
     $replyto = $this->int('inreplyto');
     if ($replyto) {
         $options['reply_to'] = $replyto;
     }
     $upload = null;
     try {
         // throws exception on failure
         $upload = MediaFile::fromUpload('attach', $this->scoped);
         if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options))) {
             $content_shortened .= ' ' . $upload->shortUrl();
         }
         Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options));
         if (Notice::contentTooLong($content_shortened)) {
             $upload->delete();
             // TRANS: Client error displayed exceeding the maximum notice length.
             // TRANS: %d is the maximum length for a notice.
             $this->clientError(sprintf(_m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent()), Notice::maxContent()));
         }
     } catch (NoUploadedMediaException $e) {
         // simply no attached media to the new notice
     }
     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);
         }
         $options = array_merge($options, $locOptions);
     }
     $author_id = $this->scoped->id;
     $text = $content_shortened;
     // Does the heavy-lifting for getting "To:" information
     ToSelector::fillOptions($this, $options);
     if (Event::handle('StartNoticeSaveWeb', array($this, &$author_id, &$text, &$options))) {
         $this->stored = Notice::saveNew($this->scoped->id, $content_shortened, 'web', $options);
         if ($upload instanceof MediaFile) {
             $upload->attachToNotice($this->stored);
         }
         Event::handle('EndNoticeSaveWeb', array($this, $this->stored));
     }
     Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
     if (!GNUsocial::isAjax()) {
         $url = common_local_url('shownotice', array('notice' => $this->stored->id));
         common_redirect($url, 303);
     }
     return _('Saved the notice!');
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:87,代码来源:newnotice.php

示例7: common_shorten_links

function common_shorten_links($text)
{
    $maxLength = Notice::maxContent();
    if ($maxLength == 0 || mb_strlen($text) <= $maxLength) {
        return $text;
    }
    return common_replace_urls_callback($text, array('File_redirection', 'makeShort'));
}
开发者ID:himmelex,项目名称:NTW,代码行数:8,代码来源:util.php

示例8: handle

 /**
  * Handle the request
  *
  * Make a new notice for the update, save it, and show it
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
         // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
         $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
     }
     if (empty($this->status)) {
         // TRANS: Client error displayed when the parameter "status" is missing.
         $this->clientError(_('Client must provide a \'status\' parameter with a value.'));
     }
     if (is_null($this->scoped)) {
         // TRANS: Client error displayed when updating a status for a non-existing user.
         $this->clientError(_('No such user.'), 404);
     }
     /* Do not call shortenLinks until the whole notice has been build */
     // Check for commands
     $inter = new CommandInterpreter();
     $cmd = $inter->handle_command($this->auth_user, $this->status);
     if ($cmd) {
         if ($this->supported($cmd)) {
             $cmd->execute(new Channel());
         }
         // Cmd not supported?  Twitter just returns your latest status.
         // And, it returns your last status whether the cmd was successful
         // or not!
         $this->notice = $this->auth_user->getCurrentNotice();
     } else {
         $reply_to = null;
         if (!empty($this->in_reply_to_status_id)) {
             // Check whether notice actually exists
             $reply = Notice::getKV($this->in_reply_to_status_id);
             if ($reply) {
                 $reply_to = $this->in_reply_to_status_id;
             } else {
                 // TRANS: Client error displayed when replying to a non-existing notice.
                 $this->clientError(_('Parent notice not found.'), 404);
             }
         }
         $upload = null;
         try {
             $upload = MediaFile::fromUpload('media', $this->scoped);
             $this->status .= ' ' . $upload->shortUrl();
             /* Do not call shortenLinks until the whole notice has been build */
         } catch (NoUploadedMediaException $e) {
             // There was no uploaded media for us today.
         }
         /* Do call shortenlinks here & check notice length since notice is about to be saved & sent */
         $status_shortened = $this->auth_user->shortenLinks($this->status);
         if (Notice::contentTooLong($status_shortened)) {
             if ($upload instanceof MediaFile) {
                 $upload->delete();
             }
             // TRANS: Client error displayed exceeding the maximum notice length.
             // TRANS: %d is the maximum lenth for a notice.
             $msg = _m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent());
             /* Use HTTP 413 error code (Request Entity Too Large)
              * instead of basic 400 for better understanding
              */
             $this->clientError(sprintf($msg, Notice::maxContent()), 413);
         }
         $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
         $options = array('reply_to' => $reply_to);
         if ($this->scoped->shareLocation()) {
             $locOptions = Notice::locationOptions($this->lat, $this->lon, null, null, $this->scoped);
             $options = array_merge($options, $locOptions);
         }
         try {
             $this->notice = Notice::saveNew($this->scoped->id, $content, $this->source, $options);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode());
         }
         if (isset($upload)) {
             $upload->attachToNotice($this->notice);
         }
     }
     $this->showNotice();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:89,代码来源:apistatusesupdate.php

示例9: onStartShowNoticeFormData

 function onStartShowNoticeFormData($form)
 {
     if (!$this->serveMobile) {
         return true;
     }
     $form->out->element('textarea', array('id' => 'notice_data-text', 'cols' => 15, 'rows' => 4, 'name' => 'status_textarea'), $form->content ? $form->content : '');
     $contentLimit = Notice::maxContent();
     if ($contentLimit > 0) {
         $form->out->element('div', array('id' => 'notice_text-count'), $contentLimit);
     }
     if (common_config('attachments', 'uploads')) {
         if ($this->mobileFeatures['inputfiletype']) {
             $form->out->element('label', array('for' => 'notice_data-attach'), _('Attach'));
             $form->out->element('input', array('id' => 'notice_data-attach', 'type' => 'file', 'name' => 'attach', 'title' => _('Attach a file')));
             $form->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
         }
     }
     if ($form->action) {
         $form->out->hidden('notice_return-to', $form->action, 'returnto');
     }
     $form->out->hidden('notice_in-reply-to', $form->inreplyto, 'inreplyto');
     return false;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:23,代码来源:MobileProfilePlugin.php

示例10: common_shorten_links

/**
 * Find and shorten links in a given chunk of text if it's longer than the
 * configured notice content limit (or unconditionally).
 *
 * Side effects: may save file and file_redirection records for referenced URLs.
 *
 * Pass the $user option or call $user->shortenLinks($text) to ensure the proper
 * user's options are used; otherwise the current web session user's setitngs
 * will be used or ur1.ca if there is no active web login.
 *
 * @param string $text
 * @param boolean $always (optional)
 * @param User $user (optional)
 *
 * @return string
 */
function common_shorten_links($text, $always = false, User $user = null)
{
    $maxLength = Notice::maxContent();
    if (!$always && ($maxLength == 0 || mb_strlen($text) <= $maxLength)) {
        return $text;
    }
    return common_replace_urls_callback($text, array('File_redirection', 'makeShort'), $user);
}
开发者ID:microcosmx,项目名称:experiments,代码行数:24,代码来源:util.php

示例11: saveNew

 static function saveNew($profile, $title, $content, $options = null)
 {
     if (is_null($options)) {
         $options = array();
     }
     $be = new Blog_entry();
     $be->id = (string) new UUID();
     $be->profile_id = $profile->id;
     $be->title = $title;
     // Note: not HTML-protected
     $be->content = self::purify($content);
     if (array_key_exists('summary', $options)) {
         $be->summary = self::purify($options['summary']);
     } else {
         // Already purified
         $be->summary = self::summarize($be->content);
     }
     // Don't save an identical summary
     if ($be->summary == $be->content) {
         $be->summary = null;
     }
     $url = common_local_url('showblogentry', array('id' => $be->id));
     if (!array_key_exists('uri', $options)) {
         $options['uri'] = $url;
     }
     $be->uri = $options['uri'];
     if (!array_key_exists('url', $options)) {
         $options['url'] = $url;
     }
     $be->url = $options['url'];
     if (!array_key_exists('created', $options)) {
         $be->created = common_sql_now();
     }
     $be->created = $options['created'];
     $be->modified = common_sql_now();
     $be->insert();
     // Use user's preferences for short URLs, if possible
     try {
         $user = $profile->getUser();
         $shortUrl = File_redirection::makeShort($url, empty($user) ? null : $user);
     } catch (Exception $e) {
         // Don't let this stop us.
         $shortUrl = $url;
     }
     // XXX: this might be too long.
     if (!empty($be->summary)) {
         $options['rendered'] = $be->summary . ' ' . XMLStringer::estring('a', array('href' => $url, 'class' => 'blog-entry'), _('More...'));
         $text = html_entity_decode(strip_tags($be->summary), ENT_QUOTES, 'UTF-8');
     } else {
         $options['rendered'] = $be->content;
         $text = html_entity_decode(strip_tags($be->content), ENT_QUOTES, 'UTF-8');
     }
     if (Notice::contentTooLong($text)) {
         $text = substr($text, 0, Notice::maxContent() - mb_strlen($shortUrl) - 2) . '… ' . $shortUrl;
     }
     // Override this no matter what.
     $options['object_type'] = self::TYPE;
     $source = array_key_exists('source', $options) ? $options['source'] : 'web';
     $saved = Notice::saveNew($profile->id, $text, $source, $options);
     return $saved;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:61,代码来源:Blog_entry.php

示例12: formData

 /**
  * Data elements
  *
  * @return void
  */
 function formData()
 {
     if (Event::handle('StartShowNoticeFormData', array($this))) {
         $this->out->element('label', array('for' => 'notice_data-text', 'id' => 'notice_data-text-label'), sprintf(_('What\'s up, %s?'), $this->user->nickname));
         // XXX: vary by defined max size
         $this->out->element('textarea', array('class' => 'notice_data-text', 'required' => 'required', 'placeholder' => $this->placeholderText(), 'cols' => 35, 'rows' => 4, 'name' => 'status_textarea'), $this->content ? $this->content : '');
         $contentLimit = Notice::maxContent();
         if ($contentLimit > 0) {
             $this->out->element('span', array('class' => 'count'), $contentLimit);
         }
         if (common_config('attachments', 'uploads')) {
             $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
             $this->out->element('label', array('class' => 'notice_data-attach', 'for' => $this->id() . '-notice_data-attach'), _('Attach'));
             // The actual input element tends to be hidden with CSS.
             $this->out->element('input', array('class' => 'notice_data-attach', 'type' => 'file', 'name' => 'attach', 'id' => $this->id() . '-notice_data-attach', 'title' => _('Attach a file.')));
         }
         if (!empty($this->actionName)) {
             $this->out->hidden('notice_return-to', $this->actionName, 'returnto');
         }
         $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
         $this->out->elementStart('div', 'to-selector');
         $toWidget = new ToSelector($this->out, $this->user, !empty($this->to_group) ? $this->to_group : $this->to_profile);
         $toWidget->show();
         $this->out->elementEnd('div');
         if ($this->profile->shareLocation()) {
             $this->out->hidden('notice_data-lat', empty($this->lat) ? empty($this->profile->lat) ? null : $this->profile->lat : $this->lat, 'lat');
             $this->out->hidden('notice_data-lon', empty($this->lon) ? empty($this->profile->lon) ? null : $this->profile->lon : $this->lon, 'lon');
             $this->out->hidden('notice_data-location_id', empty($this->location_id) ? empty($this->profile->location_id) ? null : $this->profile->location_id : $this->location_id, 'location_id');
             $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? empty($this->profile->location_ns) ? null : $this->profile->location_ns : $this->location_ns, 'location_ns');
             $this->out->elementStart('div', array('class' => 'notice_data-geo_wrap', 'data-api' => common_local_url('geocode')));
             // @fixme checkbox method allows no way to change the id without changing the name
             //$this->out->checkbox('notice_data-geo', _('Share my location'), true);
             $this->out->element('input', array('name' => 'notice_data-geo', 'type' => 'checkbox', 'class' => 'checkbox', 'id' => $this->id() . '-notice_data-geo', 'checked' => true));
             $this->out->element('label', array('class' => 'notice_data-geo', 'for' => $this->id() . '-notice_data-geo'), _('Share my location'));
             $this->out->elementEnd('div');
             // TRANS: Text to not share location for a notice in notice form.
             $share_disable_text = _('Do not share my location');
             // TRANS: Timeout error text for location retrieval in notice form.
             $error_timeout_text = _('Sorry, retrieving your geo location is taking longer than expected, please try again later');
             $this->out->inlineScript(' var NoticeDataGeo_text = {' . 'ShareDisable: ' . json_encode($share_disable_text) . ',' . 'ErrorTimeout: ' . json_encode($error_timeout_text) . '}');
         }
         Event::handle('EndShowNoticeFormData', array($this));
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:49,代码来源:noticeform.php

示例13: saveNew

 /**
  * Save a new question notice
  *
  * @param Profile $profile
  * @param string  $question
  * @param string  $title
  * @param string  $description
  * @param array   $option // and whatnot
  *
  * @return Notice saved notice
  */
 static function saveNew($profile, $title, $description, $options = array())
 {
     $q = new QnA_Question();
     $q->id = UUID::gen();
     $q->profile_id = $profile->id;
     $q->title = $title;
     $q->description = $description;
     if (array_key_exists('created', $options)) {
         $q->created = $options['created'];
     } else {
         $q->created = common_sql_now();
     }
     if (array_key_exists('uri', $options)) {
         $q->uri = $options['uri'];
     } else {
         $q->uri = common_local_url('qnashowquestion', array('id' => $q->id));
     }
     common_log(LOG_DEBUG, "Saving question: {$q->id} {$q->uri}");
     $q->insert();
     if (Notice::contentTooLong($q->title . ' ' . $q->uri)) {
         $max = Notice::maxContent();
         $uriLen = mb_strlen($q->uri);
         $targetLen = $max - ($uriLen + 15);
         $title = mb_substr($q->title, 0, $targetLen) . '…';
     }
     $content = $title . ' ' . $q->uri;
     $link = '<a href="' . htmlspecialchars($q->uri) . '">' . htmlspecialchars($q->title) . '</a>';
     // TRANS: Rendered version of the notice content creating a question.
     // TRANS: %s a link to the question as link description.
     $rendered = sprintf(_m('Question: %s'), $link);
     $tags = array('question');
     $replies = array();
     $options = array_merge(array('urls' => array(), 'rendered' => $rendered, 'tags' => $tags, 'replies' => $replies, 'object_type' => self::OBJECT_TYPE), $options);
     if (!array_key_exists('uri', $options)) {
         $options['uri'] = $q->uri;
     }
     $saved = Notice::saveNew($profile->id, $content, array_key_exists('source', $options) ? $options['source'] : 'web', $options);
     return $saved;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:50,代码来源:QnA_Question.php

示例14: shorten

 static function shorten($content, $notice)
 {
     $short = null;
     if (Notice::contentTooLong($content)) {
         common_debug("content too long");
         $max = Notice::maxContent();
         // TRANS: Link description for link to full notice text if it is longer than
         // TRANS: what will be dispplayed.
         $ellipsis = _m('…');
         $short = mb_substr($content, 0, $max - 1);
         $short .= sprintf('<a href="%1$s" rel="more" title="%2$s">%3$s</a>', $notice->getUrl(), _m('more...'), $ellipsis);
     } else {
         $short = $content;
     }
     return $short;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:16,代码来源:QnAPlugin.php

示例15: handle

 /**
  * Handle the request
  *
  * Make a new notice for the update, save it, and show it
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
         // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
         $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
         return;
     }
     if (empty($this->status)) {
         $this->clientError(_('Client must provide a \'status\' parameter with a value.'), 400, $this->format);
         return;
     }
     if (empty($this->auth_user)) {
         // TRANS: Client error displayed when updating a status for a non-existing user.
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     $status_shortened = $this->auth_user->shortenlinks($this->status);
     if (Notice::contentTooLong($status_shortened)) {
         // Note: Twitter truncates anything over 140, flags the status
         // as "truncated."
         $this->clientError(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()), 406, $this->format);
         return;
     }
     // Check for commands
     $inter = new CommandInterpreter();
     $cmd = $inter->handle_command($this->auth_user, $status_shortened);
     if ($cmd) {
         if ($this->supported($cmd)) {
             $cmd->execute(new Channel());
         }
         // Cmd not supported?  Twitter just returns your latest status.
         // And, it returns your last status whether the cmd was successful
         // or not!
         $this->notice = $this->auth_user->getCurrentNotice();
     } else {
         $reply_to = null;
         if (!empty($this->in_reply_to_status_id)) {
             // Check whether notice actually exists
             $reply = Notice::staticGet($this->in_reply_to_status_id);
             if ($reply) {
                 $reply_to = $this->in_reply_to_status_id;
             } else {
                 $this->clientError(_('Parent notice not found.'), $code = 404, $this->format);
                 return;
             }
         }
         if (!empty($this->link)) {
             try {
                 $post_url_file = MediaFile::fromLink($this->link, $this->auth_user);
             } catch (Exception $e) {
                 $this->clientError($e->getMessage(), $e->getCode(), $this->format);
                 return;
             }
         }
         $upload2 = null;
         try {
             $upload2 = MediaFile::fromUpload('media2', $this->auth_user);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode(), $this->format);
             return;
         }
         $upload = null;
         try {
             $upload = MediaFile::fromUpload('media', $this->auth_user);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode(), $this->format);
             return;
         }
         if (isset($upload)) {
             if (Notice::contentTooLong($status_shortened)) {
                 $upload->delete();
                 // TRANS: Client error displayed exceeding the maximum notice length.
                 // TRANS: %d is the maximum lenth for a notice.
                 $msg = _m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent());
                 $this->clientError(sprintf($msg, Notice::maxContent()), 400, $this->format);
             }
         }
         $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
         $options = array('reply_to' => $reply_to);
         if ($this->auth_user->shareLocation()) {
             $locOptions = Notice::locationOptions($this->lat, $this->lon, null, null, $this->auth_user->getProfile());
             $options = array_merge($options, $locOptions);
//.........这里部分代码省略.........
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:101,代码来源:apistatusesupdate.php


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