This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "quickfw".
The branch, master has been updated
via 132b644d399bc4915e0b208795f7ab02b7423b8c (commit)
from 83ad45eda87333cfdf171a858cb7aae331126392 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 132b644d399bc4915e0b208795f7ab02b7423b8c
Author: Ivan1986 <iva...@li...>
Date: Tue Jul 13 14:48:15 2010 +0400
В качестве реврайта можно указать указатель на функцию
diff --git a/QFW/QuickFW/Router.php b/QFW/QuickFW/Router.php
index bf0e1e6..acecdb0 100644
--- a/QFW/QuickFW/Router.php
+++ b/QFW/QuickFW/Router.php
@@ -309,15 +309,7 @@ class QuickFW_Router
*/
public function backrewrite($uri)
{
- if (!QFW::$config['redirection']['useRewrite'])
- return $uri;
- if ($this->backrewrite == false)
- {
- $backrewrite = array();
- require APPPATH . '/rewrite.php';
- $this->backrewrite = $backrewrite;
- }
- return preg_replace(array_keys($this->backrewrite), array_values($this->backrewrite), $uri);
+ return $this->rewr($uri, 'backrewrite');
}
/**
@@ -329,15 +321,37 @@ class QuickFW_Router
*/
protected function rewrite($uri)
{
+ return $this->rewr($uri, 'rewrite');
+ }
+
+ /**
+ * Реализация преобразования адресов
+ *
+ * @internal
+ * @param string $url Uri для реврайта
+ * @param string $type тип преобразования
+ * @return string преобразованный Uri
+ */
+ private function rewr($uri, $type)
+ {
if (!QFW::$config['redirection']['useRewrite'])
return $uri;
- if ($this->rewrite == false)
+ if ($this->$type == false)
{
$rewrite = array();
- require APPPATH . '/rewrite.php';
+ $backrewrite = array();
+ require_once APPPATH . '/rewrite.php';
$this->rewrite = $rewrite;
+ $this->backrewrite = $backrewrite;
+ }
+ if (is_array($this->$type))
+ return preg_replace(array_keys($this->$type), array_values($this->$type), $uri);
+ elseif (is_callable($this->$type))
+ {
+ $f = $this->$type;
+ return $f($uri);
}
- return preg_replace(array_keys($this->rewrite), array_values($this->rewrite), $uri);
+ return $uri;
}
/**
-----------------------------------------------------------------------
Summary of changes:
QFW/QuickFW/Router.php | 38 ++++++++++++++++++++++++++------------
1 files changed, 26 insertions(+), 12 deletions(-)
hooks/post-receive
--
quickfw
|