本文整理汇总了PHP中common_canonical_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP common_canonical_tag函数的具体用法?PHP common_canonical_tag怎么用?PHP common_canonical_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_canonical_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onStartShowSections
function onStartShowSections($action)
{
$name = $action->trimmed('action');
if ($name == 'tag') {
$taginput = $action->trimmed('tag');
$tag = common_canonical_tag($taginput);
if (!empty($tag)) {
$url = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=render', urlencode($tag));
$editurl = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=edit', urlencode($tag));
$context = stream_context_create(array('http' => array('method' => "GET", 'header' => "User-Agent: " . $this->userAgent())));
$html = @file_get_contents($url, false, $context);
$action->elementStart('div', array('id' => 'wikihashtags', 'class' => 'section'));
if (!empty($html)) {
$action->element('style', null, "span.editsection { display: none }\n" . "table.toc { display: none }");
$action->raw($html);
$action->elementStart('p');
$action->element('a', array('href' => $editurl, 'title' => sprintf(_('Edit the article for #%s on WikiHashtags'), $tag)), _('Edit'));
$action->element('a', array('href' => 'http://www.gnu.org/copyleft/fdl.html', 'title' => _('Shared under the terms of the GNU Free Documentation License'), 'rel' => 'license'), 'GNU FDL');
$action->elementEnd('p');
} else {
$action->element('a', array('href' => $editurl), sprintf(_('Start the article for #%s on WikiHashtags'), $tag));
}
$action->elementEnd('div');
}
}
return true;
}
示例2: onStartShowSections
function onStartShowSections($action)
{
$name = $action->trimmed('action');
if ($name == 'tag') {
$taginput = $action->trimmed('tag');
$tag = common_canonical_tag($taginput);
if (!empty($tag)) {
$url = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=render', urlencode($tag));
$editurl = sprintf('http://hashtags.wikia.com/index.php?title=%s&action=edit', urlencode($tag));
$request = HTTPClient::start();
$response = $request->get($url);
$html = $response->getBody();
$action->elementStart('div', array('id' => 'wikihashtags', 'class' => 'section'));
if ($response->isOk() && !empty($html)) {
$action->element('style', null, "span.editsection { display: none }\n" . "table.toc { display: none }");
$action->raw($html);
$action->elementStart('p');
$action->element('a', array('href' => $editurl, 'title' => sprintf(_m('Edit the article for #%s on WikiHashtags'), $tag)), _m('Edit'));
$action->element('a', array('href' => 'http://www.gnu.org/copyleft/fdl.html', 'title' => _m('Shared under the terms of the GNU Free Documentation License'), 'rel' => 'license'), _m('GNU FDL'));
$action->elementEnd('p');
} else {
$action->element('a', array('href' => $editurl), sprintf(_m('Start the article for #%s on WikiHashtags'), $tag));
}
$action->elementEnd('div');
}
}
return true;
}
示例3: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$taginput = $this->trimmed('tag');
$this->tag = common_canonical_tag($taginput);
$this->notices = $this->getNotices();
return true;
}
示例4: doStreamPreparation
protected function doStreamPreparation()
{
$tag = common_canonical_tag($this->trimmed('tag'));
$this->tag = Notice_tag::getKV('tag', $tag);
if (!$this->tag instanceof Notice_tag) {
// TRANS: Client error when requesting a tag feed for a non-existing tag.
$this->clientError(_('No such tag.'));
}
}
示例5: prepare
function prepare($args)
{
parent::prepare($args);
$tag = common_canonical_tag($this->trimmed('tag'));
$this->tag = Notice_tag::staticGet('tag', $tag);
if (!$this->tag) {
$this->clientError(_('No such tag.'));
return false;
} else {
return true;
}
}
示例6: prepare
function prepare($args)
{
parent::prepare($args);
$tag = common_canonical_tag($this->trimmed('tag'));
$this->tag = Notice_tag::getKV('tag', $tag);
if (!$this->tag) {
// TRANS: Client error when requesting a tag feed for a non-existing tag.
$this->clientError(_('No such tag.'));
} else {
$this->notices = $this->getNotices($this->limit);
return true;
}
}
示例7: prepare
function prepare($args)
{
parent::prepare($args);
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg);
$tag = common_canonical_tag($tag_arg);
// Permanent redirect on non-canonical nickname
if ($tagger_arg != $tagger || $tag_arg != $tag) {
$args = array('tagger' => $nickname, 'tag' => $tag);
if ($this->page != 1) {
$args['page'] = $this->page;
}
common_redirect(common_local_url('showprofiletag', $args), 301);
return false;
}
if (!$tagger) {
// TRANS: Client error displayed when a tagger is expected but not provided.
$this->clientError(_('No tagger.'), 404);
return false;
}
$user = User::staticGet('nickname', $tagger);
if (!$user) {
// TRANS: Client error displayed trying to perform an action related to a non-existing user.
$this->clientError(_('No such user.'), 404);
return false;
}
$this->tagger = $user->getProfile();
$this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
$current = common_current_user();
$can_see = !empty($this->peopletag) && (!$this->peopletag->private || $this->peopletag->private && $this->peopletag->tagger === $current->id);
if (!$can_see) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'), 404);
return false;
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
$this->userProfile = Profile::current();
$stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
$this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if ($this->page > 1 && $this->notice->N == 0) {
// TRANS: Server error when page not found (404).
$this->serverError(_('No such page.'), $code = 404);
}
return true;
}
示例8: doStreamPreparation
protected function doStreamPreparation()
{
$tag = common_canonical_tag($this->arg('tag'));
try {
$this->peopletag = Profile_list::getByPK(array('tagger' => $this->target->getID(), 'tag' => $tag));
} catch (NoResultException $e) {
// TRANS: Client error displayed trying to reference a non-existing list.
throw new ClientException('No such list.');
}
if ($this->peopletag->private && !$this->peopletag->getTagger()->sameAs($this->scoped)) {
// TRANS: Client error displayed trying to reference a non-existing list.
throw new AuthorizationException('You do not have permission to see this list.');
}
}
示例9: prepare
function prepare($args)
{
parent::prepare($args);
$taginput = $this->trimmed('tag');
$this->tag = common_canonical_tag($taginput);
if (!$this->tag) {
common_redirect(common_local_url('publictagcloud'), 301);
return false;
}
if ($this->tag != $taginput) {
common_redirect(common_local_url('tag', array('tag' => $this->tag)));
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
return true;
}
示例10: prepare
function prepare($args)
{
parent::prepare($args);
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
$tag_arg = $this->arg('tag');
$tag = common_canonical_tag($tag_arg);
// Permanent redirect on non-canonical nickname
if ($tag_arg != $tag) {
$args = array('tag' => $nickname);
if ($this->page && $this->page != 1) {
$args['page'] = $this->page;
}
common_redirect(common_local_url('peopletag', $args), 301);
}
$this->tag = $tag;
return true;
}
示例11: prepare
function prepare($args)
{
parent::prepare($args);
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
if (common_config('singleuser', 'enabled')) {
$tagger_arg = User::singleUserNickname();
} else {
$tagger_arg = $this->arg('tagger');
}
$tag_arg = $this->arg('tag');
$tagger = common_canonical_nickname($tagger_arg);
$tag = common_canonical_tag($tag_arg);
// Permanent redirect on non-canonical nickname
if ($tagger_arg != $tagger || $tag_arg != $tag) {
$args = array('tagger' => $nickname, 'tag' => $tag);
if ($this->page != 1) {
$args['page'] = $this->page;
}
common_redirect(common_local_url('peopletagged', $args), 301);
return false;
}
if (!$tagger) {
// TRANS: Client error displayed when a tagger is expected but not provided.
$this->clientError(_('No tagger.'), 404);
return false;
}
$user = User::staticGet('nickname', $tagger);
if (!$user) {
// TRANS: Client error displayed trying to perform an action related to a non-existing user.
$this->clientError(_('No such user.'), 404);
return false;
}
$this->tagger = $user->getProfile();
$this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
if (!$this->peopletag) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'), 404);
return false;
}
return true;
}
示例12: prepare
protected function prepare(array $args = array())
{
parent::prepare($args);
$taginput = $this->trimmed('tag');
$this->tag = common_canonical_tag($taginput);
if (empty($this->tag)) {
common_redirect(common_local_url('publictagcloud'), 301);
}
// after common_canonical_tag we have a lowercase, no-specials tag string
if ($this->tag !== $taginput) {
common_redirect(common_local_url('tag', array('tag' => $this->tag)), 301);
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
$this->notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if ($this->page > 1 && $this->notice->N == 0) {
// TRANS: Client error when page not found (404).
$this->clientError(_('No such page.'), 404);
}
return true;
}
示例13: prepare
function prepare($args)
{
parent::prepare($args);
$taginput = $this->trimmed('tag');
$this->tag = common_canonical_tag($taginput);
if (!$this->tag) {
common_redirect(common_local_url('publictagcloud'), 301);
return false;
}
if ($this->tag != $taginput) {
common_redirect(common_local_url('tag', array('tag' => $this->tag)), 301);
return false;
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
$this->notice = Notice_tag::getStream($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if ($this->page > 1 && $this->notice->N == 0) {
// TRANS: Server error when page not found (404)
$this->serverError(_('您访问的网页不存在'), $code = 404);
}
return true;
}
示例14: prepare
function prepare($args)
{
parent::prepare($args);
$this->q = $this->trimmed('q');
// FIXME: very dependent on tag format
if (preg_match('/^#([\\pL\\pN_\\-\\.]{1,64})/ue', $this->q)) {
common_redirect(common_local_url('tag', array('tag' => common_canonical_tag(substr($this->q, 1)))), 303);
}
if (!empty($this->q)) {
$profile = Profile::current();
$stream = new SearchNoticeStream($this->q, $profile);
$page = $this->trimmed('page');
if (empty($page)) {
$page = 1;
} else {
$page = (int) $page;
}
$this->notice = $stream->getNotices(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
}
common_set_returnto($this->selfUrl());
return true;
}
示例15: postNote
function postNote($activity)
{
$note = $activity->objects[0];
// Use summary as fallback for content
if (!empty($note->content)) {
$sourceContent = $note->content;
} else {
if (!empty($note->summary)) {
$sourceContent = $note->summary;
} else {
if (!empty($note->title)) {
$sourceContent = $note->title;
} else {
// @fixme fetch from $sourceUrl?
// TRANS: Client error displayed when posting a notice without content through the API.
// TRANS: %d is the notice ID (number).
$this->clientError(sprintf(_('No content for notice %d.'), $note->id));
}
}
}
// Get (safe!) HTML and text versions of the content
$rendered = common_purify($sourceContent);
$content = common_strip_html($rendered);
$shortened = $this->auth_user->shortenLinks($content);
$options = array('is_local' => Notice::LOCAL_PUBLIC, 'rendered' => $rendered, 'replies' => array(), 'groups' => array(), 'tags' => array(), 'urls' => array());
// accept remote URI (not necessarily a good idea)
common_debug("Note ID is {$note->id}");
if (!empty($note->id)) {
$notice = Notice::getKV('uri', trim($note->id));
if (!empty($notice)) {
// TRANS: Client error displayed when using another format than AtomPub.
// TRANS: %s is the notice URI.
$this->clientError(sprintf(_('Notice with URI "%s" already exists.'), $note->id));
}
common_log(LOG_NOTICE, "Saving client-supplied notice URI '{$note->id}'");
$options['uri'] = $note->id;
}
// accept remote create time (also maybe not such a good idea)
if (!empty($activity->time)) {
common_log(LOG_NOTICE, "Saving client-supplied create time {$activity->time}");
$options['created'] = common_sql_date($activity->time);
}
// Check for optional attributes...
if ($activity->context instanceof ActivityContext) {
foreach ($activity->context->attention as $uri => $type) {
try {
$profile = Profile::fromUri($uri);
if ($profile->isGroup()) {
$options['groups'][] = $profile->id;
} else {
$options['replies'][] = $uri;
}
} catch (UnknownUriException $e) {
common_log(LOG_WARNING, sprintf('AtomPub post with unknown attention URI %s', $uri));
}
}
// 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;
}
}
$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;
}
}
}
// Atom categories <-> hashtags
foreach ($activity->categories as $cat) {
if ($cat->term) {
$term = common_canonical_tag($cat->term);
if ($term) {
$options['tags'][] = $term;
}
}
}
// Atom enclosures -> attachment URLs
foreach ($activity->enclosures as $href) {
// @fixme save these locally or....?
$options['urls'][] = $href;
}
$saved = Notice::saveNew($this->target->id, $content, 'atompub', $options);
return $saved;
}