本文整理匯總了PHP中Theme::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Theme::instance方法的具體用法?PHP Theme::instance怎麽用?PHP Theme::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Theme
的用法示例。
在下文中一共展示了Theme::instance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pre_set_site_transient
/**
* Add language translations to update_plugins or update_themes transients.
*
* @param $transient
*
* @return mixed
*/
public function pre_set_site_transient($transient)
{
$locales = get_available_languages();
$locales = !empty($locales) ? $locales : array(get_locale());
$repos = array();
if (!isset($transient->translations)) {
return $transient;
}
if ('pre_set_site_transient_update_plugins' === current_filter()) {
$repos = Plugin::instance()->get_plugin_configs();
$translations = wp_get_installed_translations('plugins');
}
if ('pre_set_site_transient_update_themes' === current_filter()) {
$repos = Theme::instance()->get_theme_configs();
$translations = wp_get_installed_translations('themes');
}
$repos = array_filter($repos, function ($e) {
return isset($e->language_packs);
});
foreach ($repos as $repo) {
foreach ($locales as $locale) {
$lang_pack_mod = isset($repo->language_packs->{$locale}) ? strtotime($repo->language_packs->{$locale}->updated) : 0;
$translation_mod = isset($translations[$repo->repo][$locale]) ? strtotime($translations[$repo->repo][$locale]['PO-Revision-Date']) : 0;
if ($lang_pack_mod > $translation_mod) {
$transient->translations[] = (array) $repo->language_packs->{$locale};
}
}
}
$transient->translations = array_unique($transient->translations, SORT_REGULAR);
return $transient;
}
示例2: after
public function after($response)
{
if (empty($response) or !$response instanceof Response) {
$response = \Response::forge(\Theme::instance()->render());
}
return parent::after($response);
}
示例3: action_index
public function action_index()
{
if (\Input::method() == 'POST') {
if (!\Extension\NoCsrf::check()) {
// validate token failed
$output['form_status'] = 'error';
$output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
} else {
// update to 1.5 first time
$result = \Fs\update0001::run();
// update to 1.5.4
$result = \Fs\update0002::run();
if ($result === true) {
$output['hide_form'] = true;
$output['form_status'] = 'success';
$output['form_status_message'] = \Lang::get('fs_update_completed');
} else {
$output['form_status'] = 'error';
$output['form_status_message'] = \Lang::get('fs_failed_to_update');
}
}
}
// <head> output ----------------------------------------------------------------------------------------------
$output['page_title'] = \Lang::get('fs_updater');
// <head> output ----------------------------------------------------------------------------------------------
$theme = \Theme::instance();
return $theme->view('update_v', $output, false);
}
示例4: show
protected function show($slug = false)
{
if (isset($sorting)) {
Model_Category::$sorting = $sorting;
}
if ($category = Model_Category::get_by_slug($slug)) {
// TODO delete this
srand($category->id);
$items = null;
$parent_category = null;
if ($category->parent_id == 0) {
$view_file = 'category';
// Categories
$items = Model_Category::find(array('where' => array('parent_id' => $category->id, 'status' => 1), 'order_by' => array('sort' => 'asc')));
} else {
$view_file = 'subcategory';
// Products
$items = $category->products;
$parent_category = Model_Category::find_one_by_id($category->parent_id);
}
\Helper::sorting($items);
// Reset to empty array if there are no result found by query
if (is_null($items)) {
$items = array();
}
// Initiate pagination
$pagination = \Hybrid\Pagination::make(array('total_items' => count($items), 'per_page' => \Input::get('per_page', 15), 'uri_segment' => null));
// Remove unwanted items, and show only required ones
$items = array_slice($items, $pagination->offset, $pagination->per_page);
\Theme::instance()->set_partial('content', $this->view_dir . $view_file)->set('category', $category, false)->set('parent_category', $parent_category, false)->set('items', $items, false)->set('pagination', $pagination, false);
} else {
throw new \HttpNotFoundException();
}
}
示例5: build
public function build($action = null)
{
$data = array();
$attributes = $this->get_config('form_attributes');
if ($action and ($this->fieldset_tag == 'form' or empty($this->fieldset_tag))) {
$attributes['action'] = $action;
}
$data['form_open'] = ($this->fieldset_tag == 'form' or empty($this->fieldset_tag)) ? $this->form()->open($attributes) . PHP_EOL : $this->form()->{$this->fieldset_tag . '_open'}($attributes);
$data['fields'] = '';
foreach ($this->field() as $f) {
$data['fields'] .= $f->build() . PHP_EOL;
}
$data['form_close'] = ($this->fieldset_tag == 'form' or empty($this->fieldset_tag)) ? $this->form()->close($attributes) . PHP_EOL : $this->form()->{$this->fieldset_tag . '_close'}($attributes);
try {
return \Theme::instance()->view('form/fieldset', $data)->render();
} catch (\Exception $e) {
return \View::forge('form/fieldset', $data)->render();
}
/*$template = $this->form()->get_config((empty($this->fieldset_tag) ? 'form' : $this->fieldset_tag).'_template',
"\n\t\t{open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{close}\n");
$template = str_replace(array('{form_open}', '{open}', '{fields}', '{form_close}', '{close}'),
array($open, $open, $fields_output, $close, $close),
$template);
return $template;*/
}
示例6: getAdminAvatar
/**
* get admin's avatar picture.
*
* @param integer $account_id
* @return string return element ready for display avatar.
*/
function getAdminAvatar($account_id)
{
// set default avatar
$theme = \Theme::instance();
$doc_root = str_replace('\\', '/', DOCROOT);
$default_avatar_getfile = $theme->asset->get_file('default-avatar.jpg', 'img');
$default_no_avatar = str_replace([$doc_root, \Uri::base()], '', $default_avatar_getfile);
unset($doc_root, $default_avatar_getfile, $theme);
if (!is_numeric($account_id) || intval($account_id) === intval(0)) {
return $default_no_avatar;
}
$cache_name = 'public.themes.sys2.getAdminAvatar-' . \Model_Sites::getSiteId(false) . '-' . $account_id;
$cache_data = \Extension\Cache::getSilence($cache_name);
if (false === $cache_data) {
// if never cached or cache expired.
$result = \DB::select()->as_object()->from('accounts')->where('account_id', $account_id)->execute();
if (count($result) > 0) {
$row = $result->current();
if ($row->account_avatar != null) {
$return_val = $row->account_avatar;
\Cache::set($cache_name, $return_val, 86400);
unset($cache_name);
return $return_val;
}
}
if (!isset($return_val) || isset($return_val) && $return_val == null) {
// not found account or not found avatar.
\Cache::set($cache_name, $default_no_avatar, 86400);
unset($cache_name);
return $default_no_avatar;
}
}
unset($cache_name);
return $cache_data;
}
示例7: send_email_to_group
/**
* Send email to group of admin users
*
* @param type $group_name
* @param type $subject
* @param type $view
* @param type $email_data
* @param type $attachment = Attache a file
* @param type $theme = theme to load views from
* @return boolean
* @throws \Exception
*/
public static function send_email_to_group($group_name, $subject, $view, $email_data, $attachment = false)
{
\Config::load('auto_response_emails', 'auto_response_emails', true);
$emails = \Config::get('auto_response_emails.' . $group_name . '_emails', false);
if ($emails == false) {
$emails = \Config::get('auto_response_emails.default_emails', false);
}
$bcc = \Config::get('auto_response_emails.bcc');
$email = \Email::forge();
$email->cc($emails);
if ($bcc) {
$email->bcc($bcc);
}
$email->subject($subject);
$email->from(\Config::get('auto_response_emails.autoresponder_from_email'), \Config::get('site_title'));
if ($attachment) {
$email->attach($attachment);
}
$emailView = \Theme::instance()->view('views/' . $view)->set('email_data', $email_data, false);
$email->html_body($emailView);
try {
$email->send();
} catch (\Exception $e) {
if (\Fuel::$env == 'development') {
throw new \Exception($e->getMessage());
} else {
return false;
}
}
return true;
}
示例8: action_index
/**
* The index action
*
* @access public
* @return void
*/
public function action_index()
{
$settings = \Config::load('autoresponder.db');
// $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
if (\Input::post()) {
$input = \Input::post();
if (!\Input::is_ajax()) {
$val = Model_Setting::validate('create');
if (!$val->run()) {
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
} else {
try {
\Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
// $setting->save();
\Messages::success('Settings successfully created.');
\Response::redirect('admin/settings');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings.</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
}
}
}
\View::set_global('title', 'Settings');
\Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
}
示例9: show
protected function show($slug = false)
{
if (isset($sorting)) {
Model_Category::$sorting = $sorting;
}
if ($category = Model_Category::get_by_slug($slug)) {
// TODO delete this
srand($category->id);
$items = null;
$parent_category = null;
if ($category->parent_id == 0) {
$view_file = 'category';
// Categories
$items = Model_Category::find(array('where' => array('parent_id' => $category->id, 'status' => 1), 'order_by' => array('sort' => 'asc')));
if (!$items) {
$view_file = 'subcategory';
$items = $category->products;
}
} else {
$view_file = 'subcategory';
// Products
$items = $category->products;
// echo '<pre>';
// print_r($items);
// echo '</pre>';
$parent_category = Model_Category::find_one_by_id($category->parent_id);
}
\Helper::sorting($items);
// Reset to empty array if there are no result found by query
if (is_null($items)) {
$items = array();
}
// Initiate pagination
$pagination = \Hybrid\Pagination::make(array('total_items' => count($items), 'per_page' => \Input::get('per_page', 15), 'uri_segment' => null));
// Remove unwanted items, and show only required ones
$items = array_slice($items, $pagination->offset, $pagination->per_page);
$category_parents = false;
if ($parent_category) {
$parents = array();
if ($category_parents_id = Model_Category::find_parents($category->parent_id, $parents, true)) {
$category_parents = Model_Category::find(array('where' => array(array('id', 'in', $category_parents_id))));
}
}
$stock_options = \Config::load('stock-option.db');
\Theme::instance()->set_partial('content', $this->view_dir . $view_file)->set('category', $category, false)->set('parent_category', $parent_category, false)->set('items', $items, false)->set('category_parents', $category_parents, false)->set('pagination', $pagination, false)->set('manage_stock', $stock_options['manage_stock'], false)->set('hide_out_of_stock', $stock_options['hide_out_of_stock'], false);
\View::set_global('title', $category->seo->meta_title ?: $category->title);
\View::set_global('meta_description', $category->seo->meta_description ?: '');
\View::set_global('meta_keywords', $category->seo->meta_keywords ?: '');
$robots = array('meta_robots_index' => $category->seo->meta_robots_index == 1 ? 'index' : 'noindex', 'meta_robots_follow' => $category->seo->meta_robots_follow == 1 ? 'follow' : 'nofollow');
\View::set_global('robots', $robots);
\View::set_global('canonical', $category->seo->canonical_links);
\View::set_global('h1_tag', $category->seo->h1_tag);
if ($category->seo->redirect_301) {
\Response::redirect($category->seo->redirect_301);
}
} else {
throw new \HttpNotFoundException();
}
}
示例10: index
public function index()
{
$this->theme = Theme::instance();
parent::index();
$feeds = ORM::factory('external_feed')->find_all();
$this->feeds = $feeds;
$content = $this->_render_boxes();
$this->__set_options(array('content' => $content, 'feeds' => $this->feeds, 'theme' => $this->theme, 'profile_links' => $this->_render_profiles()));
}
示例11: action_404
public function action_404()
{
Lang::load('error', 'error');
$output['error_head'] = Lang::get('error.404_error_head');
$output['error_content'] = Lang::get('error.404_error_content', array('home_link' => Uri::base()));
// <head> output ----------------------------------------------------------------------------------------------
$output['page_title'] = Lang::get('error.404_page_title');
// <head> output ----------------------------------------------------------------------------------------------
return Response::forge(Theme::instance()->view('error/404_v', $output)->auto_filter(false), 404);
}
示例12: before
public function before()
{
parent::before();
\Theme::instance()->active('admin');
\Theme::instance()->set_template($this->template);
// Assign current_user to the instance so controllers can use it
$this->current_user = \Sentry::check() ? \Sentry::user() : null;
// Set a global variable so views can use it
\View::set_global('current_user', $this->current_user);
}
示例13: template
protected function template($build_field)
{
$form = $this->fieldset()->form();
// init data array
$data = array('field_classes' => '');
$data['required_mark'] = $this->get_attribute('required', null) ? $form->get_config('required_mark', null) : null;
$data['label'] = $this->label ? $form->label($this->label, $this->get_attribute('id', null)) : '';
//$error_template = $form->get_config('error_template', "");
$error_msg = $form->get_config('inline_errors') && $this->error() ? str_replace('{error_msg}', $this->error(), $error_template) : '';
$error_class = $this->error() ? $form->get_config('error_class') : '';
// additional content
$data['prepended'] = $this->prepended;
$data['appended'] = $this->appended;
if (is_array($build_field)) {
/*$label = $this->label ? $form->label($this->label) : '';
$template = $this->template ?: $form->get_config('multi_field_template', "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n");
if ($template && preg_match('#\{fields\}(.*)\{fields\}#Dus', $template, $match) > 0)
{
$build_fields = '';
foreach ($build_field as $lbl => $bf)
{
$bf_temp = str_replace('{label}', $lbl, $match[1]);
$bf_temp = str_replace('{required}', $required_mark, $bf_temp);
$bf_temp = str_replace('{field}', $bf, $bf_temp);
$build_fields .= $bf_temp;
}
$template = str_replace($match[0], '{fields}', $template);
$template = str_replace(array('{group_label}', '{required}', '{fields}', '{error_msg}', '{error_class}'), array($label, $required_mark, $build_fields, $error_msg, $error_class), $template);
return $template;
}
// still here? wasn't a multi field template available, try the normal one with imploded $build_field
$build_field = implode(' ', $build_field);*/
}
$data['field'] = $build_field;
// TODO: add field error class and message
if (\Config::get('sform.field_classes')) {
$field_classes = array($this->type);
$data['field_classes'] = ' class="' . implode(' ', $field_classes) . '"';
}
try {
return \Theme::instance()->view('form/field', $data)->render();
} catch (\Exception $e) {
return \View::forge('form/field', $data)->render();
}
/*
$template = $this->template ?: $form->get_config('field_template', "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} {error_msg}</td>\n\t\t</tr>\n");
$template = str_replace(array('{label}', '{required}', '{field}', '{error_msg}', '{error_class}'),
array($label, $required_mark, $build_field, $error_msg, $error_class),
$template);
return $template;
*/
}
示例14: __construct
public function __construct()
{
$this->theme = Theme::instance();
$this->zest = new Zest_admin();
parent::__construct();
$this->config = Kohana::config_load('zest');
$this->__setup();
if (request::is_ajax()) {
$this->auto_render = FALSE;
Event::add('system.post_controller', array($this, '_json_render'));
}
}
示例15: after
/**
* After controller method has run, render the theme template
*
* @param Response $response
*/
public function after($response)
{
if (!\Input::is_ajax()) {
// If nothing was returned set the theme instance as the response
if (empty($response)) {
$response = \Response::forge(\Theme::instance());
}
if (!$response instanceof Response) {
$response = \Response::forge($response);
}
return $response;
}
return parent::after($response);
}