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


PHP URL::get_matched_rule方法代码示例

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


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

示例1: add_template_vars

 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('tags')) {
         $this->assign('tags', Tags::get());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('atom_entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag')));
                 break;
             case 'display_home':
             default:
                 $feed_alternate = URL::get('atom_feed', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     // Specify pages you want in your navigation here
     $this->assign('nav_pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:phoenixblue,代码行数:52,代码来源:theme.php

示例2: out_title

 /**
  * Output the page title.
  */
 public function out_title()
 {
     switch (URL::get_matched_rule()->name) {
         case 'display_entry':
         case 'display_page':
             $title = $this->post->title;
             break;
         case 'display_entries_by_tag':
             $title = $this->tag;
             break;
         case 'display_entries_by_date':
             $args = URL::get_matched_rule()->named_arg_values;
             if (isset($args['day'])) {
                 $title = date('d : F : Y', mktime(0, 0, 0, $args['month'], $args['day'], $args['year']));
             } elseif (isset($args['month'])) {
                 $title = date('F : Y', mktime(0, 0, 0, $args['month'], 1, $args['year']));
             } else {
                 $title = date('Y', mktime(0, 0, 0, 1, 1, $args['year']));
             }
             break;
         default:
             $title = NULL;
     }
     if (!empty($title)) {
         $title .= ' :';
     }
     echo $title;
 }
开发者ID:ahutchings,项目名称:habari-manifest,代码行数:31,代码来源:theme.php

示例3: act

 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $this->theme->assign('matched_rule', URL::get_matched_rule());
     $request = new StdClass();
     foreach (URL::get_active_rules() as $rule) {
         $request->{$rule->name} = false;
     }
     $request->{$this->theme->matched_rule->name} = true;
     $this->theme->assign('request', $request);
     $action_hook = 'plugin_act_' . $action;
     $before_action_hook = 'before_' . $action_hook;
     $theme_hook = 'route_' . $action;
     $after_action_hook = 'after_' . $action_hook;
     Plugins::act($before_action_hook, $this);
     Plugins::act($action_hook, $this);
     if (Plugins::implemented($theme_hook, 'theme')) {
         $theme = Themes::create();
         $rule = URL::get_matched_rule();
         Plugins::theme($theme_hook, $theme, $rule->named_arg_values, $this);
     }
     Plugins::act($after_action_hook);
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:34,代码来源:pluginhandler.php

示例4: filter_template_where_filters

 public function filter_template_where_filters($where_filters)
 {
     if (Options::get('customquery__' . URL::get_matched_rule()->name)) {
         $where_filters['limit'] = Options::get('customquery__' . URL::get_matched_rule()->name);
     }
     return $where_filters;
 }
开发者ID:habari-extras,项目名称:customquery,代码行数:7,代码来源:customquery.plugin.php

示例5: embed_gists

 public function embed_gists($content)
 {
     $gists_regex = '/<script[^>]+src="(http:\\/\\/gist.github.com\\/[^"]+)"[^>]*><\\/script>/i';
     // remove gists from multiple-post templates
     if (Options::get('gistextras__removefrommultiple')) {
         if (!in_array(URL::get_matched_rule()->name, array('display_entry', 'display_page'))) {
             return preg_replace($gists_regex, '', $content);
         }
     }
     preg_match_all($gists_regex, $content, $gists);
     for ($i = 0, $n = count($gists[0]); $i < $n; $i++) {
         if (Options::get('gistextras__cachegists')) {
             if (Cache::has($gists[1][$i])) {
                 $gist = Cache::get($gists[1][$i]);
             } else {
                 if ($gist = RemoteRequest::get_contents($gists[1][$i])) {
                     $gist = $this->process_gist($gist);
                     Cache::set($gists[1][$i], $gist, 86400);
                     // cache for 1 day
                 }
             }
         } else {
             $gist = RemoteRequest::get_contents($gists[1][$i]);
             $gist = $this->process_gist($gist);
         }
         // replace the script tag
         $content = str_replace($gists[0][$i], $gist, $content);
     }
     return $content;
 }
开发者ID:ahutchings,项目名称:habari-gistextras,代码行数:30,代码来源:gistextras.plugin.php

示例6: theme_footer

    function theme_footer()
    {
        if (URL::get_matched_rule()->entire_match == 'user/login') {
            // Login page; don't dipslay
            return;
        }
        if (User::identify()->loggedin) {
            // Only track the logged in user if we were told to
            if (Options::get('getclicky__loggedin')) {
                return;
            }
        }
        $siteid = Options::get('getclicky__siteid');
        $sitedb = Options::get('getclicky__sitedb');
        echo <<<ENDAD
<a title="Clicky Web Analytics" href="http://getclicky.com/{$siteid}">
  <img alt="Clicky Web Analytics" src="http://static.getclicky.com/media/links/badge.gif" border="0" />
</a>
<script src="http://static.getclicky.com/{$siteid}.js" type="text/javascript"></script>
<noscript>
  <p>
    <img alt="Clicky" src="http://static.getclicky.com/{$siteid}-{$sitedb}.gif" />
  </p>
</noscript>
ENDAD;
    }
开发者ID:habari-extras,项目名称:getclicky,代码行数:26,代码来源:getclicky.plugin.php

示例7: theme_footer

    public function theme_footer()
    {
        if (URL::get_matched_rule()->entire_match == 'user/login') {
            // Login page; don't display
            return;
        }
        $clientcode = Options::get('googleanalytics__clientcode');
        // get the url for the main Google Analytics code
        if (Options::get('googleanalytics__cache')) {
            $ga_url = Site::get_url('habari') . '/ga.js';
        } else {
            $ga_url = self::detect_ssl() ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js';
        }
        // only actually track the page if we're not logged in, or we're told to always track
        $do_tracking = !User::identify()->loggedin || Options::get('googleanalytics__loggedintoo');
        $ga_extra_url = $do_tracking ? '<script src="' . Site::get_url('habari') . '/gaextra.js' . '" type="text/javascript"></script>' : '';
        $track_page = $do_tracking ? 'pageTracker._trackPageview();' : '';
        echo <<<ANALYTICS
{$ga_extra_url}
<script src="{$ga_url}" type="text/javascript"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
try {var pageTracker = _gat._getTracker("{$clientcode}");{$track_page}} catch(e) {}
//--><!]]>
</script>
ANALYTICS;
    }
开发者ID:anupom,项目名称:my-blog,代码行数:27,代码来源:googleanalytics.plugin.php

示例8: add_template_vars

 /**
  * Add additional template variables to the template output.
  * 	 
  *  You can assign additional output values in the template here, instead of 
  *  having the PHP execute directly in the template.  The advantage is that 
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *  
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.	  	 	 
  *  
  *  Note that the variables added here should possibly *always* be added, 
  *  especially 'user'.
  * 	 
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing 
  *  values.	 	 	 
  */
 public function add_template_vars()
 {
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     if (!$this->template_engine->assigned('feed_alternate')) {
         $matched_rule = URL::get_matched_rule();
         switch ($matched_rule->name) {
             case 'display_entry':
             case 'display_page':
                 $feed_alternate = URL::get('entry', array('slug' => Controller::get_var('slug')));
                 break;
             case 'display_entries_by_tag':
                 $feed_alternate = URL::get('tag_collection', array('tag' => Controller::get_var('tag')));
                 break;
             case 'index_page':
             default:
                 $feed_alternate = URL::get('collection', array('index' => '1'));
         }
         $this->assign('feed_alternate', $feed_alternate);
     }
     parent::add_template_vars();
 }
开发者ID:habari-extras,项目名称:redarry,代码行数:49,代码来源:theme.php

示例9: body_class

 public function body_class()
 {
     $classes = array();
     foreach (get_object_vars($this->request) as $key => $value) {
         if ($value) {
             $classes[$key] = $key;
         }
     }
     $classes[] = URL::get_matched_rule()->entire_match;
     $classes = array_unique(array_merge($classes, Stack::get_named_stack('body_class')));
     $classes = Plugins::filter('body_class', $classes, $this);
     echo implode(' ', $classes);
 }
开发者ID:ahutchings,项目名称:habari-sparse,代码行数:13,代码来源:theme.php

示例10: __construct

	/**
	 * Verifies user credentials before creating the theme and displaying the request.
	 */
	public function __construct()
	{
		$user = User::identify();
		if ( !$user->loggedin ) {
			Session::add_to_set( 'login', $_SERVER['REQUEST_URI'], 'original' );
			if ( URL::get_matched_rule()->action == 'admin_ajax' && isset( $_SERVER['HTTP_REFERER'] ) ) {
				 $ar = new AjaxResponse(408, _t('Your session has ended, please log in and try again.') );
				 $ar->out();
			}
			else {
				$post_raw = $_POST->get_array_copy_raw();
				if ( !empty( $post_raw ) ) {
					Session::add_to_set( 'last_form_data', $post_raw, 'post' );
					Session::error( _t( 'We saved the last form you posted. Log back in to continue its submission.' ), 'expired_form_submission' );
				}
				$get_raw = $_GET->get_array_copy_raw();
				if ( !empty( $get_raw ) ) {
					Session::add_to_set( 'last_form_data', $get_raw, 'get' );
					Session::error( _t( 'We saved the last form you posted. Log back in to continue its submission.' ), 'expired_form_submission' );
				}
				Utils::redirect( URL::get( 'auth', array( 'page' => 'login' ) ) );
			}
			exit;
		}

		$last_form_data = Session::get_set( 'last_form_data' ); // This was saved in the "if ( !$user )" above, UserHandler transferred it properly.
		/* At this point, Controller has not created handler_vars, so we have to modify $_POST/$_GET. */
		if ( isset( $last_form_data['post'] ) ) {
			$_POST = $_POST->merge( $last_form_data['post'] );
			$_SERVER['REQUEST_METHOD'] = 'POST'; // This will trigger the proper act_admin switches.
			Session::remove_error( 'expired_form_submission' );
		}
		if ( isset( $last_form_data['get'] ) ) {
			$_GET = $_GET->merge( $last_form_data['get'] );
			Session::remove_error( 'expired_form_submission' );
			// No need to change REQUEST_METHOD since GET is the default.
		}
		$user->remember();

		// Create an instance of the active public theme so that its plugin functions are implemented
		$this->active_theme = Themes::create();

		// setup the stacks for javascript in the admin - it's a method so a plugin can call it externally
		self::setup_stacks();
		
		// on every page load check the plugins currently loaded against the list we last checked for updates and trigger a cron if we need to
		Update::check_plugins();
	}
开发者ID:rynodivino,项目名称:system,代码行数:51,代码来源:adminhandler.php

示例11: action_init_atom

 /**
  * When the AtomHandler is created, check what action called it
  * If the action is set in our URL list, intercept and redirect to Feedburner
  */
 public function action_init_atom()
 {
     $action = Controller::get_action();
     $feed_uri = Options::get('feedburner__' . $action);
     $exclude_ips = Options::get('feedburner__exlude_ips');
     $exclude_agents = Options::get('feedburner__exclude_agents');
     if ($feed_uri != '' && (!isset(URL::get_matched_rule()->named_arg_values['index']) || URL::get_matched_rule()->named_arg_values['index'] == 1)) {
         if (!in_array($_SERVER['REMOTE_ADDR'], (array) $exclude_ips)) {
             if (isset($_SERVER['HTTP_USER_AGENT']) && !in_array($_SERVER['HTTP_USER_AGENT'], (array) $exclude_agents)) {
                 ob_clean();
                 header('Location: http://feedproxy.google.com/' . $feed_uri, TRUE, 302);
                 die;
             }
         }
     }
 }
开发者ID:habari-extras,项目名称:feedburner,代码行数:20,代码来源:feedburner.plugin.php

示例12: __construct

 /**
  * Verifies user credentials before creating the theme and displaying the request.
  */
 public function __construct()
 {
     $user = User::identify();
     if (!$user->loggedin) {
         Session::add_to_set('login', $_SERVER['REQUEST_URI'], 'original');
         if (URL::get_matched_rule()->name == 'admin_ajax' && isset($_SERVER['HTTP_REFERER'])) {
             header('Content-Type: text/javascript;charset=utf-8');
             echo '{callback: function(){location.href="' . $_SERVER['HTTP_REFERER'] . '"} }';
         } else {
             $post_raw = $_POST->get_array_copy_raw();
             if (!empty($post_raw)) {
                 Session::add_to_set('last_form_data', $post_raw, 'post');
                 Session::error(_t('We saved the last form you posted. Log back in to continue its submission.'), 'expired_form_submission');
             }
             $get_raw = $_GET->get_array_copy_raw();
             if (!empty($get_raw)) {
                 Session::add_to_set('last_form_data', $get_raw, 'get');
                 Session::error(_t('We saved the last form you posted. Log back in to continue its submission.'), 'expired_form_submission');
             }
             Utils::redirect(URL::get('auth', array('page' => 'login')));
         }
         exit;
     }
     $last_form_data = Session::get_set('last_form_data');
     // This was saved in the "if ( !$user )" above, UserHandler transferred it properly.
     /* At this point, Controller has not created handler_vars, so we have to modify $_POST/$_GET. */
     if (isset($last_form_data['post'])) {
         $_POST = $_POST->merge($last_form_data['post']);
         $_SERVER['REQUEST_METHOD'] = 'POST';
         // This will trigger the proper act_admin switches.
         Session::remove_error('expired_form_submission');
     }
     if (isset($last_form_data['get'])) {
         $_GET = $_GET->merge($last_form_data['get']);
         Session::remove_error('expired_form_submission');
         // No need to change REQUEST_METHOD since GET is the default.
     }
     $user->remember();
     // Create an instance of the active public theme so that its plugin functions are implemented
     $this->active_theme = Themes::create();
     // setup the stacks for javascript in the admin - it's a method so a plugin can call it externally
     self::setup_stacks();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:46,代码来源:adminhandler.php

示例13: act

 /**
  * All handlers must implement act() to conform to handler API.
  * This is the default implementation of act(), which attempts
  * to call a class member method of $this->act_$action().  Any
  * subclass is welcome to override this default implementation.
  *
  * @param string $action the action that was in the URL rule
  */
 public function act($action)
 {
     if (null === $this->handler_vars) {
         $this->handler_vars = new SuperGlobal(array());
     }
     $this->action = $action;
     $this->theme->assign('matched_rule', URL::get_matched_rule());
     $request = new StdClass();
     foreach (RewriteRules::get_active() as $rule) {
         $request->{$rule->name} = false;
     }
     $request->{$this->theme->matched_rule->name} = true;
     $this->theme->assign('request', $request);
     $action_hook = 'plugin_act_' . $action;
     $before_action_hook = 'before_' . $action_hook;
     $after_action_hook = 'after_' . $action_hook;
     Plugins::act($before_action_hook, $this);
     Plugins::act($action_hook, $this);
     Plugins::act($after_action_hook);
 }
开发者ID:anupom,项目名称:my-blog,代码行数:28,代码来源:pluginhandler.php

示例14: tracking_code

    private function tracking_code()
    {
        if (URL::get_matched_rule()->entire_match == 'user/login') {
            // Login page; don't display
            return;
        }
        $clientcode = Options::get('googleanalytics__clientcode');
        if (empty($clientcode)) {
            return;
        }
        // only actually track the page if we're not logged in, or we're told to always track
        $do_tracking = !User::identify()->loggedin || Options::get('googleanalytics__loggedintoo');
        $track_pageview = $do_tracking ? "_gaq.push(['_trackPageview']);" : '';
        $habari_url = Site::get_url('habari');
        if (Options::get('googleanalytics__skip_gaextra')) {
            $extra = '';
        } else {
            $extra = <<<EXTRA

  var ex = document.createElement('script'); ex.type = 'text/javascript'; ex.async = true;
  ex.src = '{$habari_url}/gaextra.js';
  s.parentNode.insertBefore(ex, s);

EXTRA;
        }
        return <<<ANALYTICS

var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{$clientcode}']);
{$track_pageview}

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
{$extra}})();

ANALYTICS;
    }
开发者ID:habari-extras,项目名称:googleanalytics,代码行数:39,代码来源:googleanalytics.plugin.php

示例15: theme_footer

    /**
     * Outputs the Javascript tracking code in the theme's footer.
     *
     * @param Theme $theme The current Theme to add the tracking JS to.
     */
    public function theme_footer(Theme $theme)
    {
        // trailing slash url
        $siteurl = Options::get('piwik__siteurl');
        if ($siteurl[strlen($siteurl) - 1] != '/') {
            $siteurl .= '/';
        }
        $ssl_siteurl = str_replace("http://", "https://", $siteurl);
        $sitenum = Options::get('piwik__sitenum');
        if (URL::get_matched_rule()->entire_match == 'auth/login') {
            // Login page; don't dipslay
            return;
        }
        // don't track loggedin user
        if (User::identify()->loggedin && !Options::get('piwik__trackloggedin')) {
            return;
        }
        // set title and track 404's'
        $title = 'piwikTracker.setDocumentTitle(document.title);';
        if ($theme->request->display_404 == true) {
            $title = <<<KITTENS
piwikTracker.setDocumentTitle('404/URL = '+String(document.location.pathname+document.location.search).replace(/\\//g,"%2f") + '/From = ' + String(document.referrer).replace(/\\//g,"%2f"));
KITTENS;
        }
        // track tags for individual posts
        $tags = '';
        if (count($theme->posts) == 1 && $theme->posts instanceof Post) {
            foreach ($theme->posts->tags as $i => $tag) {
                $n = $i + 1;
                $tags .= "piwikTracker.setCustomVariable ({$n}, 'Tag', '{$tag->term_display}', 'page');";
            }
        }
        // output the javascript
        echo $this->get_piwik_script($ssl_siteurl, $siteurl, $sitenum, $title, $tags);
        if (Options::get('piwik__use_clickheat', false)) {
            // Click Heat integration
            // @todo use groups of entry, page, home, archive, etc. instead of title
            // @todo implement select option to let user choose group, page title, or URL for click tracking
            // @todo implement click quota option
            // $group = $this->get_click_heat_group(); this will check rewrite rule a determine group
            echo $this->get_clickheat_script($sitenum, "(document.title == '' ? '-none-' : encodeURIComponent(document.title))");
        }
    }
开发者ID:habari-extras,项目名称:piwik,代码行数:48,代码来源:piwik.plugin.php


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