本文整理汇总了PHP中Theme::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::fetch方法的具体用法?PHP Theme::fetch怎么用?PHP Theme::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Theme
的用法示例。
在下文中一共展示了Theme::fetch方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: theme_linkoid
/**
* Respond to call to $theme->linkoid() in template
*
* @param string $return The return value to the template function (passed through other potential plugin calls)
* @param Theme $theme The theme object
* @param string $tag An optional tag to use instead of the one defined in the plugin options.
* @return string The return value to the template function
*/
public function theme_linkoid($theme, $tag = null)
{
if (!isset($tag)) {
$tag = Options::get('linkoid__show');
}
$linkoids = Posts::get(array('tag_slug' => $tag, 'limit' => Options::get('linkoid__count')));
$theme->linkoids = $linkoids;
return $theme->fetch('linkoid');
}
示例2: filter_plugin_loader
public function filter_plugin_loader($existing_loader, Theme $theme)
{
$infos = array();
foreach ($this->get_repos() as $repo) {
$infos = array_merge($infos, $this->scrape_repo($repo));
}
//Utils::debug($theme->inactive_plugins);
$plugins = array();
$id = 0;
foreach ($infos as $key => $info) {
$xinfo = reset($info);
$id = sprintf('%x', crc32($key));
$plugins[$id] = array('plugind_id' => $id, 'file' => '', 'debug' => false, 'info' => new SimpleXMLElement($xinfo), 'active' => false, 'verb' => 'Download');
foreach ($info as $version => $xinfo) {
$plugins[$id]['actions'][$version] = array('url' => URL::get('admin', 'page=plugin_download&plugin_id=' . $id . '&version=' . $version), 'caption' => _t('Get %s', array($version)), 'action' => 'download-');
}
}
$theme->loadable = $plugins;
$loader = $theme->fetch('plugins.loader');
return $existing_loader . $loader;
}
示例3:
/**
* Assigns output code to the template variables
* @param Theme $theme The theme that will display the template
*/
function theme_colophon($theme)
{
$theme->colophon_text = Format::autop(Options::get('colophon__text'));
$theme->colophon_title = Options::get('colophon__title');
return $theme->fetch('colophon');
}
示例4: theme_twitter
/**
* Add last Twitter status, time, and image to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_twitter($theme)
{
$notices = array();
if (Options::get('twitter__show') && Options::get('twitter__username') != '') {
$twitter_url = 'http://twitter.com/statuses/user_timeline/' . urlencode(Options::get('twitter__username')) . '.xml';
// We only need to get a single tweet if we're hiding replies (otherwise we can rely on the maximum returned and hope there's a non-reply)
if (!Options::get('twitter__hide_replies') && Options::get('twitter__limit')) {
$twitter_url .= '?count=' . Options::get('twitter__limit');
}
if (Cache::has('twitter_notices')) {
$notices = Cache::get('twitter_notices');
} else {
try {
$r = new RemoteRequest($twitter_url);
$r->set_timeout(10);
$r->execute();
$response = $r->get_response_body();
$xml = @new SimpleXMLElement($response);
// Check we've got a load of statuses returned
if ($xml->getName() === 'statuses') {
foreach ($xml->status as $status) {
if (!Options::get('twitter__hide_replies') || strpos($status->text, '@') === false) {
$notice = (object) array('text' => (string) $status->text, 'time' => (string) $status->created_at, 'image_url' => (string) $status->user->profile_image_url);
$notices[] = $notice;
if (Options::get('twitter__hide_replies') && count($notices) >= Options::get('twitter__limit')) {
break;
}
} else {
// it's a @. Keep going.
}
}
if (!$notices) {
$notice = (object) array('text' => 'No non-replies replies available from Twitter.', 'time' => '', 'image_url' => '');
}
} else {
if ($xml->getName() === 'error') {
$notice = (object) array('text' => (string) $xml, 'time' => '', 'image_url' => '');
} else {
$notice = (object) array('text' => 'Received unexpected XML from Twitter.', 'time' => '', 'image_url' => '');
}
}
} catch (Exception $e) {
$notice = (object) array('text' => 'Unable to contact Twitter.', 'time' => '', 'image_url' => '');
}
if (!$notices) {
$notices[] = $notice;
}
// Cache (even errors) to avoid hitting rate limit.
Cache::set('twitter_notices', $notices, Options::get('twitter__cache'), true);
}
} else {
$notice = (object) array('text' => _t('Please set your username in the <a href="%s">Twitter plugin config</a>', array(URL::get('admin', 'page=plugins&configure=' . $this->plugin_id . '&configaction=Configure') . '#plugin_' . $this->plugin_id), 'twitter'), 'time' => '', 'image_url' => '');
$notices[] = $notice;
}
if (Options::get('twitter__linkify_urls') != FALSE) {
foreach ($notices as $notice) {
/* link to all http: */
$notice->text = preg_replace('%https?://\\S+?(?=(?:[.:?"!$&\'()*+,=]|)(?:\\s|$))%i', "<a href=\"\$0\">\$0</a>", $notice->text);
/* link to usernames */
$notice->text = preg_replace("/(?<!\\w)@([\\w-_.]{1,64})/", "@<a href=\"http://twitter.com/\$1\">\$1</a>", $notice->text);
/* link to hashtags */
$notice->text = preg_replace('/(?<!\\w)#((?>\\d{1,64}|)[\\w-.]{1,64})/', "<a href=\"" . Options::get('twitter__hashtags_query') . "\$1\">#\$1</a>", $notice->text);
}
}
$theme->tweets = $notices;
return $theme->fetch('tweets');
}
示例5: theme_tag_links
/**
* Add simplified tag array to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_tag_links($theme, $sortorder = 'term_display asc')
{
$theme->tag_links = Tags::vocabulary()->get_tree($sortorder);
return $theme->fetch('simpletaglist');
}
示例6: theme_flickrfeed
/**
* Add Flickr images to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_flickrfeed($theme, $params = array())
{
$params = array_merge($this->config, $params);
if ($this->plugin_configured($params)) {
$theme->flickrfeed = $this->load_feeds($params);
} else {
$theme->flickrfeed = _t('FlickrFeed Plugin is not configured properly.', $this->class_name);
}
return $theme->fetch('flickrfeed');
}
示例7: theme_similar_posts
/**
* Theme function for displaying similar posts to the post passed in. By default
* will display a list of post titles that are considered similar to the post in
* question. Note that the post needs to be found in the search index, so this
* will only work on published items. The easiest way with unpublished would be to
* index then delete the post.
*
* Called from a theme like <code><?php $theme->similar_posts($post); ?></code>
* Uses search_similar template.
*
* @param Theme $theme
* @param Post $post
* @param int $max_recommended
*/
public function theme_similar_posts($theme, $post, $max_recommended = 5)
{
if (!$this->_enabled) {
return;
}
if ($this->_enabled && $post instanceof Post && intval($post->id) > 0) {
$ids = $this->_backend->get_similar_posts($post, $max_recommended);
$theme->similar = count($ids) > 0 ? Posts::get(array('id' => $ids)) : array();
$theme->base_post = $post;
return $theme->fetch('searchsimilar');
}
}
示例8: filter_dash_module_status
/**
* Provide the content for the System Status dashboard module
*
* @param array $module the module data
* @param string $id the id of the module
* @param Theme $theme an associated theme for outputting a template
* @return array An array of module data
*/
public static function filter_dash_module_status($module, $id, $theme)
{
$theme->status_data = self::$status_data;
$module['content'] = $theme->fetch('dash_status');
return $module;
}
示例9: theme_show_tweetbacks
/**
* $theme->show_tweetbacks();
* @param Theme $theme The theme that will display the template
**/
public function theme_show_tweetbacks($theme, $params = array())
{
return $theme->fetch('tweetbacks');
}
示例10: theme_jaiku
/**
* Add last Jaiku status, time, and image to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_jaiku($theme, $params = array())
{
$params = array_merge($this->config, $params);
$cache_name = $this->class_name . '__' . md5(serialize($params));
if ($params['username'] != '') {
if (Cache::has($cache_name)) {
$theme->presences = Cache::get($cache_name);
} else {
if ($params['limit'] == 1) {
$url = 'http://' . $params['username'] . '.jaiku.com/presence/last/json';
} else {
$url = 'http://' . $params['username'] . '.jaiku.com/feed/json';
}
try {
// Get JSON content via Jaiku API
$call = new RemoteRequest($url);
$call->set_timeout(5);
$result = $call->execute();
if (Error::is_error($result)) {
throw Error::raise(_t('Unable to contact Jaiku.', $this->class_name));
}
$response = $call->get_response_body();
// Decode JSON
$obj = json_decode($response);
if (!$obj instanceof stdClass) {
// Response is not JSON
throw Error::raise(_t('Response is not correct, maybe Jaiku server is down or API is changed.', $this->class_name));
}
$serial = property_exists($obj, 'stream') ? serialize($obj->stream) : serialize($obj);
// Convert stdClass to JaikuPresence and JaikuUser
$serial = str_replace('s:4:"user";O:8:"stdClass":', 's:4:"user";O:9:"JaikuUser":', $serial);
$serial = str_replace('O:8:"stdClass":', 'O:13:"JaikuPresence":', $serial);
$presences = unserialize($serial);
// Pass $presences to $theme
if (is_array($presences)) {
$theme->presences = array_slice($presences, 0, $params['limit']);
} else {
$theme->presences = array($presences);
}
// Do cache
Cache::set($cache_name, $theme->presences, $params['cache']);
} catch (Exception $e) {
$theme->presences = $e->getMessage();
}
}
} else {
$theme->presences = _t('Please set your username in the Jaiku plugin config.', $this->class_name);
}
return $theme->fetch('jaiku');
}
示例11: theme_twitter
/**
* Add last Twitter status, time, and image to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_twitter($theme)
{
$twitter = Options::get_group('twitter');
$theme->tweets = $this->tweets($twitter['username'], $twitter['hide_replies'], $twitter['limit'], $twitter['cache'], $twitter['linkify_urls'], $twitter['hashtags_query']);
return $theme->fetch('tweets');
}
示例12: theme_audioscrobbler
/**
* Add last Audioscrobbler status, time, and image to the available template vars
* @param Theme $theme The theme that will display the template
**/
public function theme_audioscrobbler($theme, $params = array())
{
$params = array_merge($this->config, $params);
$cache_name = $this->class_name . '__' . md5(serialize($params));
if ($params['username'] != '') {
$track_url = 'http://ws.audioscrobbler.com/1.0/user/' . urlencode($params['username']) . '/recenttracks.xml';
if (Cache::has($cache_name)) {
$xml = new SimpleXMLElement(Cache::get($cache_name));
$theme->track = $xml->track;
} else {
try {
// Get XML content via Audioscrobbler API
$call = new RemoteRequest($track_url);
$call->set_timeout(5);
$result = $call->execute();
if (Error::is_error($result)) {
throw Error::raise(_t('Unable to contact Last.fm.', $this->class_name));
}
$response = $call->get_response_body();
// Parse XML content
$xml = new SimpleXMLElement($response);
$theme->track = $xml->track;
Cache::set($cache_name, $response, $params['cache']);
} catch (Exception $e) {
$theme->track = $e->getMessage();
}
}
} else {
$theme->track = _t('Please set your username in the Audioscrobbler plugin config.', $this->class_name);
}
return $theme->fetch('audioscrobbler');
}