本文整理汇总了PHP中Action::element方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::element方法的具体用法?PHP Action::element怎么用?PHP Action::element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::element方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onStartShowSections
function onStartShowSections(Action $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;
}
示例2: onEndShowHeadElements
public function onEndShowHeadElements(Action $action)
{
switch ($action->getActionName()) {
case 'attachment':
$action->element('link', array('rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'json', 'url' => common_local_url('attachment', array('attachment' => $action->attachment->id)))), 'title' => 'oEmbed'), null);
$action->element('link', array('rel' => 'alternate', 'type' => 'text/xml+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'xml', 'url' => common_local_url('attachment', array('attachment' => $action->attachment->id)))), 'title' => 'oEmbed'), null);
break;
case 'shownotice':
try {
$action->element('link', array('rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'json', 'url' => $action->notice->getUrl())), 'title' => 'oEmbed'), null);
$action->element('link', array('rel' => 'alternate', 'type' => 'text/xml+oembed', 'href' => common_local_url('oembed', array(), array('format' => 'xml', 'url' => $action->notice->getUrl())), 'title' => 'oEmbed'), null);
} catch (InvalidUrlException $e) {
// The notice is probably a share or similar, which don't
// have a representational URL of their own.
}
break;
}
return true;
}
示例3: onEndShowHeadElements
/**
* Add extra <meta> headers for certain pages that geourl.org understands
*
* @param Action $action page being shown
*
* @return boolean event handler flag
*/
function onEndShowHeadElements($action)
{
$name = $action->trimmed('action');
$location = null;
if ($name == 'showstream') {
$profile = $action->profile;
if (!empty($profile) && !empty($profile->lat) && !empty($profile->lon)) {
$location = $profile->lat . ', ' . $profile->lon;
}
} else {
if ($name == 'shownotice') {
$notice = $action->profile;
if (!empty($notice) && !empty($notice->lat) && !empty($notice->lon)) {
$location = $notice->lat . ', ' . $notice->lon;
}
}
}
if (!empty($location)) {
$action->element('meta', array('name' => 'ICBM', 'content' => $location));
$action->element('meta', array('name' => 'DC.title', 'content' => $action->title()));
}
return true;
}
示例4: onEndShowHeadElements
/**
* Add extra <meta> headers for certain pages that geourl.org understands
*
* @param Action $action page being shown
*
* @return boolean event handler flag
*/
function onEndShowHeadElements(Action $action)
{
$name = $action->trimmed('action');
$location = null;
if ($action instanceof ShowstreamAction) {
$profile = $action->getTarget();
if (!empty($profile->lat) && !empty($profile->lon)) {
$location = $profile->lat . ', ' . $profile->lon;
}
} elseif ($action instanceof ShownoticeAction) {
// FIXME: getNotice in ShownoticeAction will do a new lookup, we should fix those classes
// so they can reliably just get a pre-stored notice object which was fetched in Shownotice prepare()...
$notice = $action->notice;
if ($notice instanceof Notice && !empty($notice->lat) && !empty($notice->lon)) {
$location = $notice->lat . ', ' . $notice->lon;
}
}
if (!is_null($location)) {
$action->element('meta', array('name' => 'ICBM', 'content' => $location));
$action->element('meta', array('name' => 'DC.title', 'content' => $action->title()));
}
return true;
}
示例5: showLeaderboard
/**
* Show a leaderboard ad
*
* @param Action $action Action being shown
*
* @return void
*/
protected function showLeaderboard($action)
{
$action->element('img', array('width' => 728, 'height' => 90, 'src' => common_path('plugins/BlankAd/redpixel.png')), '');
}
示例6: onEndShowHeadElements
/**
* We include a <meta> element linking to the webfinger resource page,
* for OpenID client-side authentication.
*
* @param Action $action Action being shown
*
* @return void
*/
function onEndShowHeadElements(Action $action)
{
if ($action instanceof ShowstreamAction) {
$action->element('link', array('rel' => 'openid2.provider', 'href' => common_local_url('openidserver')));
$action->element('link', array('rel' => 'openid2.local_id', 'href' => $action->getTarget()->getUrl()));
$action->element('link', array('rel' => 'openid.server', 'href' => common_local_url('openidserver')));
$action->element('link', array('rel' => 'openid.delegate', 'href' => $action->getTarget()->getUrl()));
}
if ($action instanceof SitestreamAction) {
$action->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('publicxrds')));
}
return true;
}
示例7: onStartShowHeadTitle
/**
* If a notice has a title, show it in the <title> element
*
* @param Action $action Action being executed
*
* @return boolean hook value
*/
function onStartShowHeadTitle($action)
{
$actionName = $action->trimmed('action');
if ($actionName == 'shownotice') {
$title = Notice_title::fromNotice($action->notice);
if (!empty($title)) {
$action->element('title', null, sprintf(_m("%1\$s - %2\$s"), $title, common_config('site', 'name')));
}
}
return true;
}
示例8: onEndShowStatusNetStyles
/**
* SN plugin API, here we will add css needed for modifiyed rendered
*
* @param Action $xml
*/
public function onEndShowStatusNetStyles($xml)
{
$xml->element('style', array('type' => 'text/css'), 'span.rtl {display:block;direction:rtl;text-align:right;float:right;} .notice .author {float:left}');
}
示例9: onEndShowSections
function onEndShowSections(Action $action)
{
$actionName = $action->trimmed('action');
// These are the ones that have maps on 'em
if (!in_array($actionName, array('showstream', 'all'))) {
return true;
}
$action->elementStart('div', array('id' => 'entity_map', 'class' => 'section'));
// TRANS: Header for Map widget that displays a map with geodata for notices.
$action->element('h2', null, _m('Map'));
$action->element('div', array('id' => 'map_canvas', 'class' => 'gray smallmap', 'style' => "width: 100%; height: 240px"));
$mapAct = $actionName == 'showstream' ? 'usermap' : 'allmap';
$mapUrl = common_local_url($mapAct, array('nickname' => $action->trimmed('nickname')));
$action->element('a', array('href' => $mapUrl), _m('Full size'));
$action->elementEnd('div');
}
示例10: onStartShowHeadElements
/**
* Meta tags for "claiming" a site
*
* We add extra meta tags that search engines like Yahoo!, Google, and Bing
* require to let you claim your site.
*
* @param Action $action Action being executed
*
* @return boolean hook value.
*/
function onStartShowHeadElements($action)
{
$actionName = $action->trimmed('action');
$singleUser = common_config('singleuser', 'enabled');
// Different "top" pages if it's single user or not
if ($singleUser && $actionName == 'showstream' || !$singleUser && $actionName == 'public') {
$keys = array('googlekey' => 'google-site-verification', 'yahookey' => 'y_key', 'bingkey' => 'msvalidate.01');
// XXX: is this the same for all sites?
foreach ($keys as $config => $metaname) {
$content = common_config('sitemap', $config);
if (!empty($content)) {
$action->element('meta', array('name' => $metaname, 'content' => $content));
}
}
}
return true;
}
示例11: onEndGroupProfileElements
/**
* Show an indicator that the group is (essentially) private on the group page
*
* @param Action $action The action being shown
* @param User_group $group The group being shown
*
* @return boolean hook value
*/
function onEndGroupProfileElements($action, $group)
{
$gps = Group_privacy_settings::forGroup($group);
if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) {
$action->element('p', 'privategroupindicator', _('Private'));
}
return true;
}
示例12: onEndShowSections
function onEndShowSections(Action $action)
{
if (!$action instanceof ShowstreamAction) {
// early return for actions we're not interested in
return true;
}
$scoped = $action->getScoped();
if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) {
// only continue if we are allowed to VIEWMODLOG
return true;
}
$profile = $action->getTarget();
$ml = new ModLog();
$ml->profile_id = $profile->getID();
$ml->orderBy("created");
$cnt = $ml->find();
if ($cnt > 0) {
$action->elementStart('div', array('id' => 'entity_mod_log', 'class' => 'section'));
$action->element('h2', null, _('Moderation'));
$action->elementStart('table');
while ($ml->fetch()) {
$action->elementStart('tr');
$action->element('td', null, strftime('%y-%m-%d', strtotime($ml->created)));
$action->element('td', null, sprintf($ml->is_grant ? _('+%s') : _('-%s'), $ml->role));
$action->elementStart('td');
if ($ml->moderator_id) {
$mod = Profile::getByID($ml->moderator_id);
if (empty($mod)) {
$action->text(_('[unknown]'));
} else {
$action->element('a', array('href' => $mod->getUrl(), 'title' => $mod->getFullname()), $mod->getNickname());
}
} else {
$action->text(_('[unknown]'));
}
$action->elementEnd('td');
$action->elementEnd('tr');
}
$action->elementEnd('table');
$action->elementEnd('div');
}
}
示例13: onEndGroupProfileElements
/**
* Show an indicator that the group is (essentially) private on the group page
*
* @param Action $action The action being shown
* @param User_group $group The group being shown
*
* @return boolean hook value
*/
function onEndGroupProfileElements($action, $group)
{
$gps = Group_privacy_settings::forGroup($group);
if ($gps->allow_privacy == Group_privacy_settings::ALWAYS) {
// TRANS: Indicator on the group page that the group is (essentially) private.
$action->element('p', 'privategroupindicator', _m('Private'));
}
return true;
}
示例14: onEndShowHeadElements
public function onEndShowHeadElements(Action $action)
{
if ($action instanceof ShowNoticeAction) {
// Showing a notice
$notice = Notice::getKV('id', $action->arg('notice'));
try {
$flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
$fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
} catch (NoResultException $e) {
return true;
}
$statusId = twitter_status_id($notice);
if ($notice instanceof Notice && $notice->isLocal() && $statusId) {
$tweetUrl = 'https://twitter.com/' . $fuser->nickname . '/status/' . $statusId;
$action->element('link', array('rel' => 'syndication', 'href' => $tweetUrl));
}
}
if (!$action instanceof AttachmentAction) {
return true;
}
/* Twitter card support. See https://dev.twitter.com/docs/cards */
/* @fixme: should we display twitter cards only for attachments posted
* by local users ? Seems mandatory to display twitter:creator
*
* Author: jbfavre
*/
switch ($action->attachment->mimetype) {
case 'image/pjpeg':
case 'image/jpeg':
case 'image/jpg':
case 'image/png':
case 'image/gif':
$action->element('meta', array('name' => 'twitter:card', 'content' => 'photo'), null);
$action->element('meta', array('name' => 'twitter:url', 'content' => common_local_url('attachment', array('attachment' => $action->attachment->id))), null);
$action->element('meta', array('name' => 'twitter:image', 'content' => $action->attachment->url));
$action->element('meta', array('name' => 'twitter:title', 'content' => $action->attachment->title));
$ns = new AttachmentNoticeSection($action);
$notices = $ns->getNotices();
$noticeArray = $notices->fetchAll();
// Should not have more than 1 notice for this attachment.
if (count($noticeArray) != 1) {
break;
}
$post = $noticeArray[0];
try {
$flink = Foreign_link::getByUserID($post->profile_id, TWITTER_SERVICE);
$fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
$action->element('meta', array('name' => 'twitter:creator', 'content' => '@' . $fuser->nickname));
} catch (NoResultException $e) {
// no foreign link and/or user for Twitter on this profile ID
}
break;
default:
break;
}
return true;
}
示例15: onEndShowInsideFooter
public function onEndShowInsideFooter(Action $action)
{
if ($this->serveMobile) {
// TRANS: Link to switch site layout from mobile to desktop mode. Appears at very bottom of page.
$linkText = _m('Switch to desktop site layout.');
$key = 'mobile-toggle-disable';
} else {
// TRANS: Link to switch site layout from desktop to mobile mode. Appears at very bottom of page.
$linkText = _m('Switch to mobile site layout.');
$key = 'mobile-toggle-enable';
}
$action->elementStart('p');
$action->element('a', array('href' => '#', 'id' => $key), $linkText);
$action->elementEnd('p');
return true;
}