本文整理汇总了PHP中Widgets::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Widgets::instance方法的具体用法?PHP Widgets::instance怎么用?PHP Widgets::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widgets
的用法示例。
在下文中一共展示了Widgets::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manager
function manager()
{
if (!$this->manager instanceof Widgets) {
$this->manager = Widgets::instance();
}
return $this->manager;
}
示例2: me
public static function me()
{
if (is_null(self::$instance)) {
self::$instance = new Widgets();
}
return self::$instance;
}
示例3: __construct
/**
* Constructor, globally sets region and format
*
* @param $region
* @param $format
*/
public function __construct($region, $format)
{
// Store the region locally
$this->_region = $region;
// Store the format locally
$this->_format = $format;
// Load the widgets from database
$this->load();
// Store the widgets instance
Widgets::$instance = $this;
}
示例4: paginate
function paginate($arguments = null, $items_per_page = 10, $current_page = 1) {
if (isset ( $this ) && instance_of ( $this, 'Widgets' )) {
return parent::paginate ( $arguments, $items_per_page, $current_page );
} else {
return Widgets::instance ()->paginate ( $arguments, $items_per_page, $current_page );
}
}
示例5:
</div>
</header>
<!-- ########## Navbar end ########## -->
<!-- ########## template / container start ########## -->
<main id="content" class="welcome-main" role="main">
<?php
include Kohana::find_file('views', 'welcome');
?>
</main>
<!-- ########## template / container end ########## -->
<!-- ########## Footer start ########## -->
<footer class="footer" role="contentinfo">
<?php
$footer = Widgets::instance()->render('footer', 'footer');
?>
<?php
if ($footer) {
?>
<div class="extra">
<div class="container">
<div class="row">
<?php
echo $footer;
?>
</div>
</div>
</div>
<?php
}
示例6:
" class="<?php
echo $post->type;
?>
blog<?php
if ($post->sticky) {
echo ' sticky';
}
?>
<?php
echo ' blog-' . $post->status;
?>
">
<?php
$widget_p_top = Widgets::instance()->render('post_top');
$widget_p_bot = Widgets::instance()->render('post_bottom');
?>
<?php
if ($post->taxonomy or $config->use_submitted) {
?>
<div class="row meta">
<?php
if ($config->use_submitted) {
?>
<div class="col-md-7">
<span class="author">
<?php
echo HTML::anchor($post->user->url, User::getAvatar($post->user));
?>
<?php
示例7:
<?php
$top = Widgets::instance()->render('top');
$bottom = Widgets::instance()->render('bottom');
$content_top = Widgets::instance()->render('content_top', 'html');
$content_bottom = Widgets::instance()->render('content_top', 'html');
?>
<div class="container">
<?php
if ($messages) {
?>
<!-- ########## Messages start ########## -->
<div class="row">
<div id="messages" class="messages col-md-8 col-md-offset-2">
<?php
echo $messages;
?>
</div>
</div>
<!-- ########## Messages end ########## -->
<?php
}
?>
<?php
if ($top and !empty($top)) {
?>
<!-- ########## Top start ########## -->
<div class="row">
<div class="col-md-12">
<?php
示例8: before
/**
* Loads the template View object, if it is direct request
*
* @return void
* @throws Http_Exception_415 If none of the accept-types are supported
*/
public function before()
{
// Execute parent::before first
parent::before();
if ($this->bare == FALSE) {
// Load the config
$this->_config = Config::load('site');
if (Kohana::$profiling) {
// Start a new benchmark token
$this->_benchmark = Profiler::start('Gleez', ucfirst($this->request->controller()) . ' Controller');
}
// Test whether the current request is command line request
if (Kohana::$is_cli) {
$this->_ajax = FALSE;
$this->auto_render = FALSE;
}
// Test whether the current request is the first request
if (!$this->request->is_initial()) {
$this->_internal = TRUE;
$this->auto_render = FALSE;
}
// Test whether the current request is ajax request
if ($this->request->is_ajax()) {
$this->_ajax = TRUE;
$this->auto_render = FALSE;
}
// Test whether the current request is jquery mobile request. ugly hack
if (Request::is_mobile() and $this->_config->get('mobile_theme', FALSE)) {
$this->_ajax = FALSE;
$this->auto_render = TRUE;
}
// Test whether the current request is datatables request
if (Request::is_datatables()) {
$this->_ajax = TRUE;
$this->auto_render = FALSE;
}
$this->response->headers('X-Powered-By', Gleez::getVersion(TRUE, TRUE) . ' (' . Gleez::CODENAME . ')');
$this->_auth = Auth::instance();
// Get desired response formats
$accept_types = Request::accept_type();
$accept_types = Arr::extract($accept_types, array_keys($this->_accept_formats));
// Set response format to first matched element
$this->_response_format = $this->request->headers()->preferred_accept(array_keys($this->_accept_formats));
$site_name = Template::getSiteName();
$url = URL::site(NULL, TRUE);
View::bind_global('site_name', $site_name);
View::bind_global('site_url', $url);
}
if ($this->auto_render && $this->bare == FALSE) {
// Throw exception if none of the accept-types are supported
if (!($accept_types = array_filter($accept_types))) {
throw new Http_Exception_415('Unsupported accept-type', 415);
}
// Initiate a Format instance
$this->_format = Format::instance();
// Load the template
$this->template = View::factory($this->template);
$this->title_separator = $this->_config->get('title_separator', ' | ');
$this->_widgets = Widgets::instance();
$this->template->_admin = Theme::$is_admin;
// Set the destination & redirect url
$this->_desti = array('destination' => $this->request->uri());
$this->redirect = $this->request->query('destination') !== NULL ? $this->request->query('destination') : array();
// Bind the generic page variables
$this->template->set('site_name', Template::getSiteName())->set('site_slogan', $this->_config->get('site_slogan', __('Innovate IT')))->set('site_url', URL::site(NULL, TRUE))->set('site_logo', $this->_config->get('site_logo', FALSE))->set('sidebar_left', array())->set('sidebar_right', array())->set('column_class', '')->set('main_column', 12)->set('head_title', $this->title)->set('title', $this->title)->set('subtitle', $this->subtitle)->set('icon', $this->icon)->set('schemaType', $this->schemaType)->set('front', FALSE)->set('mission', FALSE)->set('tabs', FALSE)->set('subtabs', FALSE)->set('actions', FALSE)->set('_user', $this->_auth->get_user())->bind('datatables', $this->_datatables);
// Page Title
$this->title = ucwords($this->request->controller());
// Assign the default css files
$this->_set_default_css();
// Assign the default js files
$this->_set_default_js();
// Set default server headers
$this->_set_default_server_headers();
// Set default meta data and media
$this->_set_default_meta_links();
$this->_set_default_meta_tags();
/**
* Make your view template available to all your other views
* so easily you could access template variables
*/
View::bind_global('template', $this->template);
}
if (Kohana::$environment === Kohana::DEVELOPMENT) {
Log::debug('Executing Controller [:controller] action [:action]', array(':controller' => $this->request->controller(), ':action' => $this->request->action()));
}
}
示例9: configure_widgets_default_submit
function configure_widgets_default_submit()
{
ajx_current("empty");
$widgets_data = array_var($_POST, 'widgets');
try {
DB::beginWork();
foreach ($widgets_data as $name => $data) {
$widget = Widgets::instance()->findOne(array('conditions' => array('name = ?', $name)));
if (!$widget instanceof Widget) {
continue;
}
$widget->setDefaultOrder($data['order']);
$widget->setDefaultSection($data['section']);
$widget->save();
if (isset($data['options']) && is_array($data['options'])) {
foreach ($data['options'] as $opt_name => $opt_val) {
$contact_widget_option = ContactWidgetOptions::instance()->findOne(array('conditions' => array('contact_id=0 AND widget_name=? AND `option`=?', $name, $opt_name)));
if (!$contact_widget_option instanceof ContactWidgetOption) {
continue;
}
$contact_widget_option->setValue($opt_val);
$contact_widget_option->save();
}
}
}
DB::commit();
evt_add('reload tab panel', 'overview-panel');
ajx_current("back");
} catch (Exception $e) {
flash_error($e->getMessage());
DB::rollback();
}
}
示例10: widgets
/**
* Display widgets inline of post body
*
* @param string $content The post content
* @param string $region The widget's region name
* @return string The replaced content with widgets
* @uses Widgets::render
*/
public static function widgets($content, $region = 'post_inline')
{
// Save some cpu cycles, when the content is empty
if ($content == NULL or empty($content)) {
return $content;
}
// We found special tag, so don't set widgets!
// Just return the content
if (strpos($content, self::NO_WIDGETS_TAG) !== FALSE) {
return $content;
}
$poses = array();
$lastpos = -1;
$repchar = "<p";
// if we didn't find a p tag, try br tag
if (strpos($content, "<p") === FALSE) {
$repchar = "<br";
}
while (strpos($content, $repchar, $lastpos + 1) !== FALSE) {
$lastpos = strpos($content, $repchar, $lastpos + 1);
$poses[] = $lastpos;
}
// Cut the doc in half, so the widgets don't go past the end of the article.
$pickme = $poses[ceil(sizeof($poses) / 2) - 1];
$widgets = Widgets::instance()->render($region);
$replacewith = $widgets ? '<div id="' . $region . '" class="clear-block">' . $widgets . '</div>' : NULL;
$content = substr_replace($content, $replacewith . $repchar, $pickme, 2);
// save some memory
unset($poses, $lastpos, $repchar, $half, $pickme, $widgets, $replacewith);
return $content;
}
示例11: action_index
public function action_index()
{
$this->title = __('Administer');
$view = View::factory('admin/dashboard')->set('widgets', Widgets::instance()->render('dashboard'));
$this->response->body($view);
}
示例12: renderSection
static function renderSection($name)
{
$widgetsToRender = array();
self::$widgets = Widgets::instance()->findAll(array("conditions" => " plugin_id = 0 OR plugin_id IS NULL OR plugin_id IN ( SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_activated > 0 AND is_installed > 0 )", "order" => "default_order", "order_dir" => "DESC"));
// If exists an instance of cw for this section, render the widgets with the options overriden
foreach (self::$widgets as $w) {
/* @var $w Widget */
if ($cw = ContactWidgets::instance()->findById(array('contact_id' => logged_user()->getId(), 'widget_name' => $w->getName()))) {
if ($cw->getSection() == $name) {
$w->setOptions($cw->getOptions());
$w->setDefaultOrder($cw->getOrder());
$widgetsToRender[] = $w;
}
} elseif ($w->getDefaultSection() == $name) {
$widgetsToRender[] = $w;
}
}
usort($widgetsToRender, "widget_sort");
foreach ($widgetsToRender as $k => $w) {
$w->execute();
}
}
示例13: configure_widgets
function configure_widgets()
{
$widgets = Widgets::instance()->findAll(array("conditions" => " plugin_id = 0 OR plugin_id IS NULL OR plugin_id IN ( SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_activated > 0 AND is_installed > 0 )", "order" => "default_order", "order_dir" => "ASC"));
$widgets_info = array();
foreach ($widgets as $widget) {
$widgets_info[] = $widget->getContactWidgetSettings(logged_user());
}
$ordered = array();
foreach ($widgets_info as $info) {
$ord = isset($info['order']) ? $info['order'] : $info['default_order'];
$key = str_pad($ord, 4, '0', STR_PAD_LEFT) . '_' . $info['name'];
$ordered[$key] = $info;
}
ksort($ordered);
tpl_assign('widgets_info', array_values($ordered));
}
示例14: manager
function manager() {
if (! ($this->manager instanceof Widgets))
$this->manager = Widgets::instance ();
return $this->manager;
}
示例15: count
<?php
$ws_dim = Dimensions::findByCode('workspaces');
$row_cls = "";
$add_button_text = count($data_ws) > 0 ? lang('add new workspace') : lang('add your first workspace');
$no_objects_text = count($data_ws) > 0 ? '' : lang('you have no workspaces yet');
$ws_widget = Widgets::instance()->findById('workspaces');
$section = $ws_widget instanceof Widget && in_array($ws_widget->getDefaultSection(), array('left', 'right')) ? $ws_widget->getDefaultSection() : 'right';
?>
<div class="ws-widget widget">
<div class="widget-header" onclick="og.dashExpand('<?php
echo $genid;
?>
');">
<div class="widget-title"><?php
echo $ws_dim->getName();
?>
</div>
<div class="dash-expander ico-dash-expanded" id="<?php
echo $genid;
?>
expander"></div>
</div>
<div class="widget-body" id="<?php
echo $genid;
?>
_widget_body" >