本文整理汇总了PHP中Widget::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::widget方法的具体用法?PHP Widget::widget怎么用?PHP Widget::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::widget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public static function dispatch()
{
$pathInfo = self::getPathInfo();
foreach (self::$_routingTable as $key => $route) {
if (preg_match($route['regx'], $pathInfo, $matches)) {
self::$current = $key;
try {
$params = NULL;
if (!empty($route['param'])) {
unset($matches[0]);
$params = array_combine($route['param'], $matches);
}
$widget = Widget::widget($route['widget'], NULL, $params);
if (isset($route['action'])) {
$method = $route['action'];
$widget->{$method}();
}
return;
} catch (Exception $e) {
if (404 == $e->getCode()) {
Widget::destory($route['widget']);
continue;
}
throw $e;
}
}
}
/** 载入路由异常支持 */
throw new HandleException("Path '{$pathInfo}' not found", 404);
}
示例2: widget
/**
* Renders the frontend widget
*
* @param array $args Options provided at registration
* @param array $data Database values provided in backend
*/
public function widget($args, $data)
{
$defaults = array('title' => 'Instagram', 'columns' => 2, 'username' => null, 'limit' => 4, 'before_content' => '', 'after_content' => '');
$data = array_merge($defaults, $data);
// fetch feed
$data['results'] = $this->getFeed($data['username'], $data['limit']);
parent::widget($args, $data);
}
示例3: widget
/**
* Renders the frontend social widget
*
* This widget uses a combination of theme options and widget settings.
*
* @param array $args Options provided at registration
* @param array $data Database values provided in backend
*/
public function widget($args, $data)
{
$defaults = array('title' => null, 'twitter_limit' => null);
$data = array_merge($defaults, $data);
$twitteruser = $this->theme->options('twitter_user');
$twitterterm = $this->theme->options('twitter_search');
$facebookUser = $this->theme->options('facebook_user');
$tweets = $this->getTweets($twitterterm, $data['twitter_limit']);
if (!empty($facebookUser)) {
$facebookResults = $this->getFacebook($facebookUser);
} else {
$facebookResults = array();
}
$this->theme->set(compact('tweets', 'facebookResults', 'facebookUser'));
parent::widget($args, $data);
}
示例4: widget
/**
* Renders the frontend core widget
*
* This widget uses the widget settings to pull CORE events. If those settings
* are not defined, it falls back to the CORE meta for the page. If that isn't
* defined, nothing is rendered.
*
* @param array $args Options provided at registration
* @param array $data Database values provided in backend
*/
public function widget($args, $data)
{
global $post;
$events = array();
$defaults = array('core_campus_id' => null, 'core_id' => null, 'core_involvement_id' => null, 'limit' => 0);
$data = array_merge($defaults, $data);
if (empty($data['core_id']) && empty($data['core_involvement_id'])) {
$metadata = $this->theme->metaToData($post->ID);
// If $metadata['limit'] not 0 or a positive integer ignore it
if (!($metadata['limit'] === 0 || $metadata['limit'] > 0)) {
$metadata['limit'] = $data['limit'];
}
$data = array_merge($data, $metadata);
}
if (empty($data['core_campus_id']) && empty($data['core_id']) && empty($data['core_involvement_id'])) {
return;
}
// build url
$endpoint = $this->getCoreCalendarEndpoint();
if (!empty($data['core_campus_id'])) {
$endpoint .= '/Campus:' . $data['core_campus_id'];
}
if (!empty($data['core_id'])) {
$endpoint .= '/Ministry:' . $data['core_id'];
}
if (!empty($data['core_involvement_id'])) {
$endpoint .= '/Involvement:' . $data['core_involvement_id'];
}
$start = strtotime('now');
if (!empty($data['start_date'])) {
$start = strtotime($data['start_date']);
}
$end = strtotime('+60 days', $start);
if (!empty($data['end_date'])) {
$end = strtotime($data['end_date']);
}
$endpoint .= '/full.json?start=' . $start . '&end=' . $end;
$this->theme->set('url', $endpoint);
$this->theme->set('limit', $data['limit']);
parent::widget($args, $data);
}
示例5: shortcode
/**
* Handle the shortcode
*
* @param array $attr Array of the attributes to the short code, none is expected
* @param string $content The content enclosed in the shortcode, none is expected
*
* @return string An HTML of the "widget" based on its settings, actual or customized
*
*/
function shortcode($attr, $content = null)
{
if (is_singular()) {
$instance = shortcode_settings();
if (is_array($instance)) {
$widget = new Widget();
$widget->number = 'shortcode-' . get_the_ID();
// needed to make a unique id for the widget html element
ob_start();
$widget->widget(array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''), $instance);
$ret = ob_get_clean();
$ret = '<div id="' . WIDGET_BASE_ID . '-' . $widget->number . '" class="' . WIDGET_BASE_ID . '-shortcode">' . $ret . '</div>';
return $ret;
}
}
return '';
}
示例6: widget
/**
* Renders the frontend widget
*
* This widget uses the widget settings to create a grid of images.
*
* @param array $args Options provided at registration
* @param array $data Database values provided in backend
*/
public function widget($args, $data)
{
$defaults = array('columns' => 2, 'images' => array(), 'image_links' => array(), 'before_content' => '', 'after_content' => '');
$data = array_merge($defaults, $data);
parent::widget($args, $data);
}
示例7:
<?php
include_once "config.php";
Widget::widget('Init');
Router::dispatch();
示例8: widget
public function widget($widget_name, $params = null, $return = false)
{
ob_start();
$widget = new Widget();
$widget->widget($widget_name, $params);
$my_widget = ob_get_contents();
ob_clean();
if (!$return) {
cout($my_widget);
} else {
return $my_widget;
}
}