当前位置: 首页>>代码示例>>PHP>>正文


PHP Widget::add方法代码示例

本文整理汇总了PHP中Widget::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::add方法的具体用法?PHP Widget::add怎么用?PHP Widget::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Widget的用法示例。


在下文中一共展示了Widget::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index

 /**
  * Controller default action
  */
 public function action_index()
 {
     $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name')));
     // Display news feed
     $newsfeed = new NewsFeed(self::$user);
     $newsfeed->max_items = 25;
     Widget::add('main', View_Module::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array())));
     // Shout
     $shouts = Jelly::select('shout')->limit(10)->execute();
     Widget::add('side', View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE), 'errors' => array(), 'values' => array())));
 }
开发者ID:netbiel,项目名称:core,代码行数:14,代码来源:index.php

示例2: action_edit

 /**
  * Action: edit
  */
 public function action_edit()
 {
     $this->history = false;
     // Load role
     $role_id = (int) $this->request->param('id', 0);
     if ($role_id) {
         $role = Jelly::select('role', $role_id);
         if (!$role->loaded()) {
             throw new Model_Exception($role, $role_id);
         }
         Permission::required($role, Model_Role::PERMISSION_UPDATE, self::$user);
     } else {
         $role = Jelly::factory('role');
         Permission::required($role, Model_Role::PERMISSION_CREATE, self::$user);
     }
     // Handle post
     $errors = array();
     if ($_POST) {
         $role->set($_POST);
         try {
             $role->save();
             $this->request->redirect(Route::get('roles')->uri());
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     // Set title
     $this->page_title = __('Role') . ($role->name ? ': ' . HTML::chars($role->name) : '');
     // Set actions
     if ($role->loaded() && Permission::has($role, Model_Role::PERMISSION_DELETE, self::$user)) {
         $this->page_actions[] = array('link' => Route::model($role, 'delete', false), 'text' => __('Delete role'), 'class' => 'role-delete');
     }
     // Build form
     $form = array('values' => $role, 'errors' => $errors, 'cancel' => Request::back(Route::get('roles')->uri(), true), 'groups' => array(array('fields' => array('name' => array(), 'description' => array()))));
     //Widget::add('main', View_Module::factory('roles/edit', array('role' => $role, 'errors' => $errors)));
     Widget::add('main', View_Module::factory('form/anqh', array('form' => $form)));
 }
开发者ID:netbiel,项目名称:core,代码行数:40,代码来源:roles.php

示例3: action_shout

 /**
  * Action: shout
  */
 public function action_shout()
 {
     $shout = Jelly::factory('shout');
     $errors = array();
     if (Permission::has($shout, Permission_Interface::PERMISSION_CREATE) && Security::csrf_valid()) {
         $shout->author = self::$user;
         $shout->shout = $_POST['shout'];
         try {
             $shout->save();
             if (!$this->ajax) {
                 $this->request->redirect(Route::get('shouts')->uri());
             }
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     $shouts = Jelly::select('shout')->limit(10)->execute();
     $view = View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has($shout, Model_Shout::PERMISSION_CREATE), 'errors' => $errors));
     if ($this->ajax) {
         echo $view;
     } else {
         Widget::add('side', $view);
     }
 }
开发者ID:netbiel,项目名称:core,代码行数:27,代码来源:shouts.php

示例4: filters

Widget::add('footer', html::script_source('
function filters(all) {
	if (all) {

		// Open all
		$("form.filters input").each(function() {
			$("." + this.id + ":hidden").slideDown("normal");
		});

	} else {

		// Filter individually
		$("form.filters input").each(function() {
			if ($(this).is(":checked")) {
				$("." + this.id + ":hidden").slideDown("normal");
			} else {
				$("." + this.id + ":visible").slideUp("normal");
			}
		});

	}
}

head.ready("jquery-ui", function() {

	// Hook clicks
	$("form.filters :checkbox").click(function() {

		var checked = $(this).is(":checked");

		if ($(this).val() != "all") {

			// Individual filters
			if (checked) {

				// Uncheck "all"
				$("form.filters input[value=all]").attr("checked", false);

			}

			// Check "all" if no other filters
			if ($("form.filters input[value!=all]").is(":checked") == false) {
				$("form.filters input[value=all]").attr("checked", "checked");
				filters(true);
			} else {
				filters();
			}

		} else {

			// All filters
			if (!checked) {
				return false;
			}

			$("form.filters input[value!=all]").attr("checked", false);
			filters(checked);

		}

	});
});
'));
开发者ID:anqh,项目名称:core,代码行数:63,代码来源:filters.php

示例5: error

 /**
  * Print an error message
  *
  * @param  string  $message
  */
 public function error($message = null)
 {
     !$message && ($message = __('Error occured.'));
     Widget::add('error', View_Module::factory('generic/error', array('message' => $message)));
 }
开发者ID:anqh,项目名称:core,代码行数:10,代码来源:template.php

示例6: array

				<?php 
    echo Form::checkbox('filter[]', 'all', true, array('id' => 'all-' . $type));
    ?>
				<?php 
    echo Form::label('all-' . $type, __('All'));
    ?>
			</li>
			<?php 
    foreach ($filter['filters'] as $key => $name) {
        ?>
			<li>
				<?php 
        echo Form::checkbox('filter[]', $type . '-' . $key, false, array('id' => $type . '-' . $key));
        ?>
				<?php 
        echo Form::label($type . '-' . $key, $name);
        ?>
			</li>
			<?php 
    }
    ?>
		</ul>
	</fieldset>
	<?php 
}
?>

<?php 
echo form::close();
Widget::add('footer', html::script_source("\nfunction filters(all) {\n\tif (all) {\n\n\t\t// Open all\n\t\t\$('form.filters input').each(function() {\n\t\t\t\$('.' + this.id + ':hidden').slideDown('normal');\n\t\t});\n\n\t} else {\n\n\t\t// Filter individually\n\t\t\$('form.filters input').each(function() {\n\t\t\tif (\$(this).is(':checked')) {\n\t\t\t\t\$('.' + this.id + ':hidden').slideDown('normal');\n\t\t\t} else {\n\t\t\t\t\$('.' + this.id + ':visible').slideUp('normal');\n\t\t\t}\n\t\t});\n\n\t}\n}\n\n\$(function() {\n\n\t// Hook clicks\n\t\$('form.filters :checkbox').click(function() {\n\n\t\tvar checked = \$(this).is(':checked');\n\n\t\tif (\$(this).val() != 'all') {\n\n\t\t\t// Individual filters\n\t\t\tif (checked) {\n\n\t\t\t\t// Uncheck 'all'\n\t\t\t\t\$('form.filters input[value=\"all\"]').attr('checked', false);\n\n\t\t\t}\n\n\t\t\t// Check 'all' if no other filters\n\t\t\tif (\$('form.filters input[value!=\"all\"]').is(':checked') == false) {\n\t\t\t\t\$('form.filters input[value=\"all\"]').attr('checked', 'checked');\n\t\t\t\tfilters(true);\n\t\t\t} else {\n\t\t\t\tfilters();\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// All filters\n\t\t\tif (!checked) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t\$('form.filters input[value!=\"all\"]').attr('checked', false);\n\t\t\tfilters(checked);\n\n\t\t}\n\n\t});\n});\n"));
开发者ID:netbiel,项目名称:core,代码行数:30,代码来源:filters.php

示例7: function

/**
 * Custom Function(s)
 * ------------------
 *
 * Add your own custom function(s) here. You can do something like
 * making custom widget(s), custom route(s), custom filter(s),
 * custom weapon(s), loading custom asset(s), etc. So that you can
 * manipulate the site output without having to touch the CMS core.
 *
 */
// Link generator for the current article tag(s)
Widget::add('tagLinks', function ($connect = ', ') use($speak) {
    $config = Config::get();
    $links = array();
    $source = $config->article->tags;
    if (!isset($source) || !is_object($source)) {
        return "";
    }
    foreach ($source as $tag) {
        if ($tag && $tag->id !== 0) {
            $links[] = '<a href="' . $config->url . '/' . $config->tag->slug . '/' . $tag->slug . '" rel="tag">' . $tag->name . '</a>';
        }
    }
    $text = count($links) > 1 ? $speak->tags : $speak->tag;
    return !empty($links) ? $text . ': ' . implode($connect, $links) : "";
});
// Add an arrow to the older and newer link text
$speak->older = $speak->older . ' <i class="fa fa-angle-right"></i>';
$speak->newer = '<i class="fa fa-angle-left"></i> ' . $speak->newer;
Config::set(array('speak.older' => $speak->older, 'speak.newer' => $speak->newer));
开发者ID:razordaze,项目名称:mecha-cms,代码行数:30,代码来源:functions.php

示例8: _edit_tag

 /**
  * Edit tag
  *
  * @param  integer  $group_id
  * @param  integer  $tag_id
  */
 protected function _edit_tag($group_id = null, $tag_id = null)
 {
     $this->history = false;
     if ($group_id) {
         // Add new tag
         $group = Jelly::select('tag_group')->load($group_id);
         if (!$group->loaded()) {
             throw new Model_Exception($group, $group_id);
         }
         $this->page_title = HTML::chars($group->name);
         $this->page_subtitle = HTML::chars($group->description);
         $tag = Jelly::factory('tag')->set(array('group' => $group));
         $cancel = Route::model($group);
     } else {
         if ($tag_id) {
             // Edit old tag
             $tag = Jelly::select('tag')->load($tag_id);
             if (!$tag->loaded()) {
                 throw new Model_Exception($tag, $tag_id);
             }
             $this->page_title = HTML::chars($tag->name);
             $this->page_subtitle = HTML::chars($tag->description);
             $cancel = Route::model($tag);
         } else {
             Request::back(Route::get('tags')->uri());
         }
     }
     $errors = array();
     if ($_POST) {
         $tag->set($_POST);
         try {
             $tag->save();
             $this->request->redirect(Route::model($tag));
         } catch (Validate_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     // Build form
     $form = array('values' => $tag, 'errors' => $errors, 'cancel' => $cancel, 'groups' => array(array('fields' => array('name' => array(), 'description' => array()))));
     Widget::add('main', View_Module::factory('form/anqh', array('form' => $form)));
 }
开发者ID:netbiel,项目名称:core,代码行数:47,代码来源:tags.php

示例9: _event_subtitle

    /**
     * Add event subtitle.
     *
     * @param   Model_Event  $event
     * @return  string
     */
    protected function _event_subtitle(Model_Event $event)
    {
        $subtitle = array();
        // Date
        $subtitle[] = '<i class="icon-calendar icon-white"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', ' . Date::format(Date::DMY_LONG, $event->stamp_begin), $event->stamp_begin, true);
        // Time
        if ($event->stamp_begin != $event->stamp_end) {
            $subtitle[] = $event->stamp_end ? '<i class="icon-time icon-white"></i> ' . __(':from until :to', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin), ':to' => HTML::time(Date::format('HHMM', $event->stamp_end), $event->stamp_end))) : '<i class="icon-time icon-white"></i> ' . __('From :from onwards', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin)));
        }
        // Venue
        if ($_venue = $event->venue()) {
            // Venue found from db
            $venue = HTML::anchor(Route::model($_venue), HTML::chars($_venue->name));
            $address = HTML::chars($_venue->city_name);
            if ($_venue->latitude) {
                $map = array('marker' => HTML::chars($_venue->name), 'infowindow' => HTML::chars($_venue->address) . '<br />' . HTML::chars($_venue->city_name), 'lat' => $_venue->latitude, 'long' => $_venue->longitude);
                Widget::add('foot', HTML::script_source('
head.ready("anqh", function() {
	$("a[href=#map]").on("click", function toggleMap(event) {
		$("#map").toggle("fast", function openMap() {
			$("#map").googleMap(' . json_encode($map) . ');
		});

		return false;
	});
});
'));
            }
        } else {
            if ($event->venue_name) {
                // No venue in db
                $venue = $event->venue_url ? HTML::anchor($event->venue_url, HTML::chars($event->venue_name)) : HTML::chars($event->venue_name);
                $address = HTML::chars($event->city_name);
            } else {
                // Venue not set
                $venue = $event->venue_hidden ? __('Underground') : __('(Unknown)');
                $address = HTML::chars($event->city_name);
            }
        }
        $subtitle[] = '<i class="icon-map-marker icon-white"></i> ' . $venue . ($address ? ', ' . $address : '');
        if (isset($map)) {
            $subtitle[] = HTML::anchor('#map', __('Show map'));
            return implode(' &nbsp; ', $subtitle) . '<div id="map" style="display: none">' . __('Map loading') . '</div>';
        }
        return implode(' &nbsp; ', $subtitle);
    }
开发者ID:anqh,项目名称:events,代码行数:52,代码来源:events.php

示例10: action_settings

    /**
     * Action: settings
     */
    public function action_settings()
    {
        $this->history = false;
        $user = $this->_get_user();
        Permission::required($user, Model_User::PERMISSION_UPDATE, self::$user);
        // Set generic page parameters
        $this->_set_page($user);
        // Handle post
        $errors = array();
        if ($_POST && Security::csrf_valid()) {
            $user->set(Arr::extract($_POST, Model_User::$editable_fields));
            // GeoNames
            if ($_POST['city_id'] && ($city = Geo::find_city((int) $_POST['city_id']))) {
                $user->city = $city;
            }
            $user->modified = time();
            try {
                $user->save();
                $this->request->redirect(URL::user($user));
            } catch (Validate_Exception $e) {
                $errors = $e->array->errors('validation');
            }
        }
        // Build form
        $form = array('values' => $user, 'errors' => $errors, 'cancel' => URL::user($user), 'hidden' => array('city_id' => $user->city ? $user->city->id : 0, 'latitude' => $user->latitude, 'longitude' => $user->longitude), 'groups' => array('basic' => array('header' => __('Basic information'), 'fields' => array('name' => array(), 'gender' => array('input' => 'radio'), 'dob' => array('pretty_format' => 'j.n.Y'), 'title' => array(), 'description' => array('attributes' => array('rows' => 5)))), 'contact' => array('header' => __('Contact information'), 'fields' => array('email' => array(), 'homepage' => array(), 'address_street' => array(), 'address_zip' => array(), 'address_city' => array())), 'forum' => array('header' => __('Forum settings'), 'fields' => array('signature' => array('attributes' => array('rows' => 5))))));
        Widget::add('main', View_Module::factory('form/anqh', array('form' => $form)));
        // Autocomplete
        $this->autocomplete_city('address_city', 'city_id');
        // Date picker
        $options = array('changeMonth' => true, 'changeYear' => true, 'dateFormat' => 'd.m.yy', 'defaultDate' => date('j.n.Y', $user->dob), 'dayNames' => array(__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday')), 'dayNamesMin' => array(__('Su'), __('Mo'), __('Tu'), __('We'), __('Th'), __('Fr'), __('Sa')), 'firstDay' => 1, 'monthNames' => array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')), 'monthNamesShort' => array(__('Jan'), __('Feb'), __('Mar'), __('Apr'), __('May'), __('Jun'), __('Jul'), __('Aug'), __('Sep'), __('Oct'), __('Nov'), __('Dec')), 'nextText' => __('&raquo;'), 'prevText' => __('&laquo;'), 'showWeek' => true, 'showOtherMonths' => true, 'weekHeader' => __('Wk'), 'yearRange' => '1900:+0');
        Widget::add('foot', HTML::script_source('$("#field-dob").datepicker(' . json_encode($options) . ');'));
        // Maps
        Widget::add('foot', HTML::script_source('
$(function() {
	$("#fields-contact ul").append("<li><div id=\\"map\\">' . __('Loading map..') . '</div></li>");

	$("#map").googleMap(' . ($user->latitude ? json_encode(array('marker' => true, 'lat' => $user->latitude, 'long' => $user->longitude)) : '') . ');

	$("input[name=address_street], input[name=address_city]").blur(function(event) {
		var address = $("input[name=address_street]").val();
		var city = $("input[name=address_city]").val();
		if (address != "" && city != "") {
			var geocode = address + ", " + city;
			geocoder.geocode({ address: geocode }, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK && results.length) {
				  map.setCenter(results[0].geometry.location);
				  $("input[name=latitude]").val(results[0].geometry.location.lat());
				  $("input[name=longitude]").val(results[0].geometry.location.lng());
				  var marker = new google.maps.Marker({
				    position: results[0].geometry.location,
				    map: map
				  });
				}
			});
		}
	});

});
'));
    }
开发者ID:netbiel,项目名称:core,代码行数:63,代码来源:user.php

示例11: after

 /**
  * Destroy controller.
  */
 public function after()
 {
     if ($this->_request_type !== Controller::REQUEST_INITIAL) {
         // AJAX and HMVC requests
         $this->response->body((string) $this->response->body());
     } else {
         if ($this->auto_render) {
             // Normal requests
             // Footer
             $section = new View_Events_List();
             $section->class .= ' col-sm-4';
             $section->title = __('New events');
             $section->events = Model_Event::factory()->find_new(10);
             $this->view->add(View_Page::COLUMN_FOOTER, $section);
             $section = new View_Topics_List();
             $section->class .= ' col-sm-4';
             $section->topics = Model_Forum_Topic::factory()->find_by_latest_post(10);
             $this->view->add(View_Page::COLUMN_FOOTER, $section);
             $section = new View_Blogs_List();
             $section->class .= ' col-sm-4';
             $section->title = __('New blogs');
             $section->blog_entries = Model_Blog_Entry::factory()->find_new(10);
             $this->view->add(View_Page::COLUMN_FOOTER, $section);
             // Ads
             /*			$ads = Kohana::$config->load('site.ads');
             			if ($ads && $ads['enabled']) {
             				foreach ($ads['slots'] as $ad => $slot) {
             					if ($slot == 'side') {
             						$this->view->add(View_Page::COLUMN_SIDE, View::factory('ads/' . $ad));
             					} else {
             						Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE);
             					}
             				}
             			}*/
             // Theme
             $theme = $this->session->get('theme');
             //Arr::get($_COOKIE, 'theme');
             if (!in_array($theme, array_keys(Kohana::$config->load('site.themes')))) {
                 if (Visitor::$user) {
                     $theme = Visitor::$user->setting('ui.theme');
                 }
                 if (!$theme) {
                     $theme = Kohana::$config->load('site.theme');
                 }
                 $this->session->set('theme', $theme);
             }
             // Do some CSS magic to page class
             $page_class = array_merge(array('theme-' . $theme, Visitor::$user ? 'authenticated' : 'unauthenticated'), explode(' ', $this->page_class));
             $page_class = implode(' ', array_unique($page_class));
             // Set the generic page variables
             $this->view->language = $this->language;
             $this->view->id = $this->page_id;
             $this->view->class = $page_class;
             if ($this->page_actions) {
                 $this->view->tabs = $this->page_actions;
             }
             if ($this->page_breadcrumbs) {
                 $this->view->breadcrumbs = $this->page_breadcrumbs;
             }
             // Set meta data
             if (!Anqh::page_meta('title')) {
                 Anqh::page_meta('title', $this->view->title ? $this->view->title : Kohana::$config->load('site.site_name'));
             }
             // And finally the profiler stats
             if (Visitor::$user && Visitor::$user->has_role('admin')) {
                 Widget::add('foot', new View_Generic_Debug());
                 Widget::add('foot', View::factory('profiler/stats'));
             }
         }
     }
     parent::after();
 }
开发者ID:anqh,项目名称:anqh,代码行数:75,代码来源:page.php

示例12: function

 *
 * Add your own custom function(s) here. You can do something like
 * making custom widget(s), custom route(s), custom filter(s),
 * custom weapon(s), loading custom asset(s), etc. So that you can
 * manipulate the site output without having to touch the CMS core.
 *
 */
// Link generator for the current article tag(s)
Widget::add('tagLinks', function ($connect = ', ') use($config, $speak) {
    $links = array();
    $article = Shield::lot('article');
    if (!$article || !isset($article->tags)) {
        return "";
    }
    foreach ($article->tags as $tag) {
        if ($tag && $tag->id !== 0) {
            $url = Filter::colon('tag:url', $config->url . '/' . $config->tag->slug . '/' . $tag->slug);
            $links[] = '<a href="' . $url . '" rel="tag">' . $tag->name . '</a>';
        }
    }
    $text = count($links) > 1 ? $speak->tags : $speak->tag;
    return !empty($links) ? $text . ': ' . implode($connect, $links) : "";
});
// HTML output manipulation
Filter::add('chunk:output', function ($content, $path) use($config, $speak) {
    $name = File::N($path);
    // Add an icon to the older and newer link text
    if ($name === 'pager') {
        $content = str_replace('>' . $speak->newer . '</a>', '><i class="fa fa-angle-left"></i> ' . trim(strip_tags($speak->newer)) . '</a>', $content);
        $content = str_replace('>' . $speak->older . '</a>', '>' . trim(strip_tags($speak->older)) . ' <i class="fa fa-angle-right"></i></a>', $content);
    }
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:functions.php

示例13: after

 /**
  * Destroy controller.
  */
 public function after()
 {
     if ($this->_request_type !== Controller::REQUEST_INITIAL) {
         // AJAX and HMVC requests
         $this->response->body((string) $this->response->body());
     } else {
         if ($this->auto_render) {
             // Normal requests
             // Stylesheets
             $styles = array('ui/jquery-ui.css', 'http://fonts.googleapis.com/css?family=Terminal+Dosis');
             // Skins
             $selected_skin = $this->session->get('skin', 'blue');
             // Less files needed to build a skin
             $less_imports = array('ui/mixin.less', 'ui/anqh.less');
             $skins = array(HTML::style('static/css/bootstrap.css'), HTML::style('static/css/bootstrap-responsive.css'));
             foreach (array('blue') as $skin) {
                 $skinsi[] = Less::style('ui/' . $skin . '.less', array('title' => $skin, 'rel' => $skin == $selected_skin ? 'stylesheet' : 'alternate stylesheet'), false, $less_imports);
             }
             // Footer
             $section = new View_Events_List();
             $section->class .= ' span4';
             $section->title = __('New events');
             $section->events = Model_Event::factory()->find_new(10);
             Widget::add('footer', $section);
             $section = new View_Topics_List();
             $section->class .= ' span4';
             $section->title = __('New posts');
             $section->topics = Model_Forum_Topic::factory()->find_by_latest_post(10);
             Widget::add('footer', $section);
             $section = new View_Blogs_List();
             $section->class .= ' span4';
             $section->title = __('New blogs');
             $section->blog_entries = Model_Blog_Entry::factory()->find_new(10);
             Widget::add('footer', $section);
             // Open Graph
             $og = array();
             foreach ((array) Anqh::open_graph() as $key => $value) {
                 $og[] = '<meta property="' . $key . '" content="' . HTML::chars($value) . '" />';
             }
             if (!empty($og)) {
                 Widget::add('head', implode("\n", $og));
             }
             // Analytics
             if ($google_analytics = Kohana::$config->load('site.google_analytics')) {
                 Widget::add('head', HTML::script_source("\nvar tracker;\nhead.js(\n\t{ 'google-analytics': 'http://www.google-analytics.com/ga.js' },\n\tfunction() {\n\t\ttracker = _gat._getTracker('" . $google_analytics . "');\n\t\ttracker._trackPageview();\n\t}\n);\n"));
             }
             // Ads
             /*			$ads = Kohana::$config->load('site.ads');
             			if ($ads && $ads['enabled']) {
             				foreach ($ads['slots'] as $ad => $slot) {
             					if ($slot == 'side') {
             						$this->view->add(View_Page::COLUMN_SIDE, View::factory('ads/' . $ad));
             					} else {
             						Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE);
             					}
             				}
             			}*/
             // Do some CSS magic to page class
             $page_class = array_merge(array($this->language, $this->request->action(), self::$user ? 'authenticated' : 'unauthenticated'), explode(' ', $this->page_class));
             $page_class = implode(' ', array_unique($page_class));
             // Set the generic page variables
             $this->view->styles = $styles;
             $this->view->skins = $skins;
             $this->view->language = $this->language;
             $this->view->id = $this->page_id;
             $this->view->class = $page_class;
             if ($this->page_actions) {
                 $this->view->tabs = $this->page_actions;
             }
             if ($this->page_breadcrumbs) {
                 $this->view->breadcrumbs = $this->page_breadcrumbs;
             }
             // And finally the profiler stats
             if (self::$user && self::$user->has_role('admin')) {
                 //in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))) {
                 Widget::add('foot', View::factory('generic/debug'));
                 Widget::add('foot', View::factory('profiler/stats'));
             }
         }
     }
     parent::after();
 }
开发者ID:anqh,项目名称:core,代码行数:85,代码来源:page.php

示例14: _event_subtitle

    /**
     * Add event subtitle.
     *
     * @param   Model_Event  $event
     * @return  string
     */
    public static function _event_subtitle(Model_Event $event)
    {
        $subtitle = array();
        // Date
        if ($event->stamp_end - $event->stamp_begin > Date::DAY) {
            // Multi day event
            $subtitle[] = '<i class="fa fa-calendar"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', <strong>' . Date::format(Date::DM_LONG, $event->stamp_begin) . ' &ndash; ' . Date::format(Date::DMY_LONG, $event->stamp_end) . '</strong>', $event->stamp_begin, true);
        } else {
            // Single day event
            $subtitle[] = '<i class="fa fa-calendar"></i> ' . HTML::time(Date('l', $event->stamp_begin) . ', <strong>' . Date::format(Date::DMY_LONG, $event->stamp_begin) . '</strong>', $event->stamp_begin, true);
        }
        // Time
        if ($event->stamp_begin != $event->stamp_end) {
            $subtitle[] = $event->stamp_end ? '<i class="fa fa-clock-o"></i> ' . __('From :from until :to', array(':from' => '<strong>' . HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin) . '</strong>', ':to' => '<strong>' . HTML::time(Date::format('HHMM', $event->stamp_end), $event->stamp_end) . '</strong>')) : '<i class="fa fa-clock-o"></i> ' . __('From :from onwards', array(':from' => HTML::time(Date::format('HHMM', $event->stamp_begin), $event->stamp_begin)));
        }
        // Tickets
        $tickets = '';
        if ($event->price === 0 || $event->price > 0 || $event->ticket_url) {
            $tickets = '<i class="fa fa-ticket"></i> ';
        }
        if ($event->price === 0) {
            $tickets .= '<strong>' . __('Free entry') . '</strong> ';
        } else {
            if ($event->price > 0) {
                $tickets .= __('Tickets :price', array(':price' => '<strong>' . Num::currency($event->price, $event->stamp_begin) . '</strong>')) . ' ';
            }
        }
        if ($event->ticket_url) {
            $tickets .= HTML::anchor($event->ticket_url, __('Buy tickets'), array('target' => '_blank'));
        }
        if ($tickets) {
            $subtitle[] = $tickets;
        }
        // Age limit
        if ($event->age > 0) {
            $subtitle[] = '<i class="fa fa-user"></i> ' . __('Age limit') . ': <strong>' . $event->age . '</strong>';
        }
        // Homepage
        if (!empty($event->url)) {
            $subtitle[] = '<i class="fa fa-link"></i> ' . HTML::anchor($event->url, Text::limit_url($event->url, 25));
        }
        // Venue
        if ($_venue = $event->venue()) {
            // Venue found from db
            $venue = HTML::anchor(Route::model($_venue), HTML::chars($_venue->name));
            $address = HTML::chars($_venue->city_name);
            if ($_venue->latitude) {
                $map = array('marker' => HTML::chars($_venue->name), 'infowindow' => HTML::chars($_venue->address) . '<br />' . HTML::chars($_venue->city_name), 'lat' => $_venue->latitude, 'long' => $_venue->longitude);
                Widget::add('foot', HTML::script_source('
head.ready("anqh", function() {
	$("a[href=#map]").on("click", function toggleMap(event) {
		$("#map").toggle("fast", function openMap() {
			$("#map").googleMap(' . json_encode($map) . ');
		});

		return false;
	});
});
'));
            }
        } else {
            if ($event->venue_name) {
                // No venue in db
                $venue = $event->venue_url ? HTML::anchor($event->venue_url, HTML::chars($event->venue_name)) : HTML::chars($event->venue_name);
                $address = HTML::chars($event->city_name);
            } else {
                // Venue not set
                $venue = $event->venue_hidden ? __('Underground') : __('(Unknown)');
                $address = HTML::chars($event->city_name);
            }
        }
        $subtitle[] = '<br /><i class="fa fa-map-marker"></i> <strong>' . $venue . '</strong>' . ($address ? ', ' . $address : '');
        if (isset($map)) {
            $subtitle[] = HTML::anchor('#map', __('Show map'));
        }
        // Tags
        if ($tags = $event->tags()) {
            $subtitle[] = '<br /><i class="fa fa-music"></i> <em>' . implode(', ', $tags) . '</em>';
        } else {
            if (!empty($event->music)) {
                $subtitle[] = '<br /><i class="fa fa-music"></i> <em>' . $event->music . '</em>';
            }
        }
        return implode(' &nbsp; ', $subtitle) . (isset($map) ? '<div id="map" style="display: none">' . __('Map loading') . '</div>' : '');
    }
开发者ID:anqh,项目名称:anqh,代码行数:91,代码来源:events.php

示例15: action_venue

 /**
  * Action: venue
  */
 public function action_venue()
 {
     $venue_id = (int) $this->request->param('id');
     // Load venue
     /** @var  Model_Venue  $venue */
     $venue = Model_Venue::factory($venue_id);
     if (!$venue->loaded()) {
         throw new Model_Exception($venue, $venue_id);
     }
     // Build page
     $this->view = new View_Page($venue->name);
     $this->view->tab = 'venue';
     $this->view->tabs[] = array('link' => Route::url('venues'), 'text' => '&laquo; ' . __('Back to Venues'));
     $this->view->tabs['venue'] = array('link' => Route::model($venue), 'text' => __('Venue'));
     // Set actions
     if (Permission::has($venue, Model_Venue::PERMISSION_UPDATE, self::$user)) {
         $this->view->actions[] = array('link' => Route::model($venue, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit venue'));
     }
     if (Permission::has($venue, Model_Venue::PERMISSION_COMBINE, self::$user)) {
         $this->view->actions[] = array('link' => Route::model($venue, 'combine'), 'text' => '<i class="icon-filter icon-white"></i> ' . __('Combine duplicate'));
     }
     // Events
     $has_events = false;
     $events = $venue->find_events_upcoming(25);
     if (count($events)) {
         $has_events = true;
         $section = $this->section_events_list($events);
         $section->title = __('Upcoming events');
         $this->view->add(View_Page::COLUMN_MAIN, $section);
     }
     $events = $venue->find_events_past(10);
     if (count($events)) {
         $has_events = true;
         $section = $this->section_events_list($events);
         $section->title = __('Past events');
         $this->view->add(View_Page::COLUMN_MAIN, $section);
     }
     if (!$has_events) {
         $this->view->add(View_Page::COLUMN_MAIN, new View_Alert(__('Nothing has happened here yet.'), null, View_Alert::INFO));
     }
     // Similar venues
     if (Permission::has($venue, Model_Venue::PERMISSION_COMBINE, self::$user)) {
         $similar = $venue->find_similar(65);
         if ($similar) {
             $this->view->add(View_Page::COLUMN_MAIN, $this->section_venue_similar($venue, $similar));
         }
     }
     // Slideshow
     if (count($venue->images) > 1) {
         $images = array();
         foreach ($venue->images as $image) {
             $images[] = $image;
         }
         Widget::add('side', View_Module::factory('generic/image_slideshow', array('images' => array_reverse($images), 'default_id' => $venue->default_image->id)));
     }
     // Default image
     $this->view->add(View_Page::COLUMN_SIDE, $this->section_venue_image($venue));
     // Venue info
     $this->view->add(View_Page::COLUMN_SIDE, $this->section_venue_info($venue));
     /* @todo Needs a decent OAuth2 module
     		$this->view->add(View_Page::COLUMN_SIDE, $this->section_venue_foursquare($venue));
     		 */
 }
开发者ID:anqh,项目名称:venues,代码行数:66,代码来源:venues.php


注:本文中的Widget::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。