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 d57fc49c5b8d21fbcf1ee274191915ffafae5c92 (commit)
via 0c395a446c92c2945c6d0444cf456ac2683e5f87 (commit)
via f2a5c6ea0d6b780d49c26f2f48fbcbeb71aafa8b (commit)
via 5113e76d94b8fc5baf37135df41a83afd59366b8 (commit)
from 6707c473238aaca477c0ac9c661a5e4a0a4e66b5 (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 d57fc49c5b8d21fbcf1ee274191915ffafae5c92
Merge: 6707c47 0c395a4
Author: Ivan Borzenkov <iva...@li...>
Date: Tue May 31 18:03:12 2011 +0400
Merge branch 'newUrl'
commit 0c395a446c92c2945c6d0444cf456ac2683e5f87
Author: Ivan Borzenkov <iva...@li...>
Date: Tue May 31 18:02:28 2011 +0400
Документация по новому урлу
diff --git a/doc/asciidoc/helpers.txt b/doc/asciidoc/helpers.txt
index b21ef5b..93c79b8 100644
--- a/doc/asciidoc/helpers.txt
+++ b/doc/asciidoc/helpers.txt
@@ -5,7 +5,7 @@
~~~~~~~~~~~~~
Для генерации URL существует отдельный класс +Url+ в котором есть статические методы.
-Каждая функция-генератор кромя base принимает три параметра: относительный адрес, get параметы и якорь.
+Каждая функция-генератор кромя base принимает произвольное количество параметров - компонентов Url и соединяет их разделителем компонентов (+/+ по умолчанию).
+Url::base+::
отдает базовый Url
@@ -20,6 +20,8 @@
Настройки хранятся в +QFW::$config[\'redirection']+, перечитать можно с помощью функции +Url::Init()+.
+Функция возвращает объект, у которого есть функции добавляния якоря (+anchor+) и GET параметров (+get+).
+
Функции get/out Head
~~~~~~~~~~~~~~~~~~~~
commit f2a5c6ea0d6b780d49c26f2f48fbcbeb71aafa8b
Author: Ivan Borzenkov <iva...@li...>
Date: Wed May 11 16:25:26 2011 +0400
Несколько параметров в урле
diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php
index eef339e..a82e25f 100644
--- a/QFW/QuickFW/Url.php
+++ b/QFW/QuickFW/Url.php
@@ -28,7 +28,7 @@ class Url
*/
public static function site($url='')
{
- return new static($url);
+ return new static(func_get_args());
}
/**
@@ -41,7 +41,7 @@ class Url
*/
public static function M($CA='')
{
- return new static($CA, static::$config['router']->cModule.
+ return new static(func_get_args(), static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR);
}
@@ -55,7 +55,7 @@ class Url
*/
public static function C($action='')
{
- return new static($action, static::$config['router']->cModule.
+ return new static(func_get_args(), static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR.
static::$config['router']->cController.
QuickFW_Router::PATH_SEPARATOR);
@@ -71,7 +71,7 @@ class Url
*/
public static function A($params='')
{
- return new static($params, static::$config['router']->cModule.
+ return new static(func_get_args(), static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR.
static::$config['router']->cController.
QuickFW_Router::PATH_SEPARATOR.
@@ -112,6 +112,8 @@ class Url
$this->anchor = $url->anchor;
return;
}
+ if (is_array($url))
+ $url = join(QuickFW_Router::PATH_SEPARATOR, $url);
//Заменяем / на QuickFW_Router::PATH_SEPARATOR
if (QuickFW_Router::PATH_SEPARATOR != '/')
$url = strtr($url, '/', QuickFW_Router::PATH_SEPARATOR);
commit 5113e76d94b8fc5baf37135df41a83afd59366b8
Author: Ivan Borzenkov <iva...@li...>
Date: Wed May 11 14:29:15 2011 +0400
Переделано добавление get параметров и якоря
diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php
index 5bc2d79..eef339e 100644
--- a/QFW/QuickFW/Url.php
+++ b/QFW/QuickFW/Url.php
@@ -11,7 +11,7 @@ class Url
* Добавляет в начале базовый урл
*
* @param string|self $url url
- * @return self базовый url
+ * @return Url базовый url
*/
public static function base($url='')
{
@@ -24,11 +24,11 @@ class Url
* @param string|self $url url
* @param string|array $get параметры
* @param string $anchor якорь
- * @return self адрес на сайте
+ * @return Url адрес на сайте
*/
- public static function site($url='', $get='', $anchor='')
+ public static function site($url='')
{
- return new static($url, $get, $anchor);
+ return new static($url);
}
/**
@@ -37,11 +37,11 @@ class Url
* @param string|self $CA url
* @param string|array $get параметры
* @param string $anchor якорь
- * @return self адрес на сайте
+ * @return Url адрес на сайте
*/
- public static function M($CA='', $get='', $anchor='')
+ public static function M($CA='')
{
- return new static($CA, $get, $anchor, static::$config['router']->cModule.
+ return new static($CA, static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR);
}
@@ -51,11 +51,11 @@ class Url
* @param string|self $action url
* @param string|array $get параметры
* @param string $anchor якорь
- * @return self адрес на сайте
+ * @return Url адрес на сайте
*/
- public static function C($action='', $get='', $anchor='')
+ public static function C($action='')
{
- return new static($action, $get, $anchor, static::$config['router']->cModule.
+ return new static($action, static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR.
static::$config['router']->cController.
QuickFW_Router::PATH_SEPARATOR);
@@ -67,11 +67,11 @@ class Url
* @param string|self $params url
* @param string|array $get параметры
* @param string $anchor якорь
- * @return self адрес на сайте
+ * @return Url адрес на сайте
*/
- public static function A($params='', $get='', $anchor='')
+ public static function A($params='')
{
- return new static($params, $get, $anchor, static::$config['router']->cModule.
+ return new static($params, static::$config['router']->cModule.
QuickFW_Router::PATH_SEPARATOR.
static::$config['router']->cController.
QuickFW_Router::PATH_SEPARATOR.
@@ -103,23 +103,21 @@ class Url
* @param string $anchor якорь
* @param string $begin базовый урл от текущего
*/
- protected function __construct($url, $get='', $anchor='', $begin='')
+ protected function __construct($url, $begin='')
{
- if (is_array($get) && count($get))
- $get = http_build_query($get);
if ($url instanceof self)
{
$this->u = $begin.$url->u;
- $this->get = $url->get.($get?('&'.$get):'');
- $this->anchor = $anchor ? ltrim($anchor, '#') : $url->anchor;
+ $this->get = $url->get;
+ $this->anchor = $url->anchor;
return;
}
//Заменяем / на QuickFW_Router::PATH_SEPARATOR
if (QuickFW_Router::PATH_SEPARATOR != '/')
$url = strtr($url, '/', QuickFW_Router::PATH_SEPARATOR);
$this->u = trim($begin.$url, QuickFW_Router::PATH_SEPARATOR);
- $this->get = $get;
- $this->anchor = ltrim($anchor, '#');
+ $this->get = array();
+ $this->anchor = '';
if (static::$config['delDef'])
$this->u = static::$config['router']->delDef($this->u);
}
@@ -140,24 +138,53 @@ class Url
*/
public function __toString()
{
- return $this->get();
+ return $this->asString();
}
/**
* урл для вывода, с подстановками
+ * (не всегда работает __toString)
*
* @return string урл
*/
- public function get()
+ public function asString()
{
return static::$config['router']->backrewriteUrl(
static::$config['base'].static::$config['router']->backrewrite($this->u).
($this->u!=='' ? static::$config['ext'] : '').
- ($this->get ? '?' . $this->get : '').
+ ($this->get ? ('?' . http_build_query($this->get)) : '').
($this->anchor ? '#' . $this->anchor : ''));
}
/**
+ * Добавляет get параметр
+ *
+ * @param string|array $k ключ
+ * @param string|false $v значение
+ * @return Url
+ */
+ public function get($k, $v=false)
+ {
+ if (is_array($k))
+ $this->get = array_merge_recursive($this->get, $k);
+ else
+ $this->get[$k] = $v;
+ return $this;
+ }
+
+ /**
+ * Добавляет якорь
+ *
+ * @param string $a якорь
+ * @return Url
+ */
+ public function anchor($a)
+ {
+ $this->anchor = $a;
+ return $this;
+ }
+
+ /**
* Внутренний адрес - для блока
*
* @internal
-----------------------------------------------------------------------
Summary of changes:
QFW/QuickFW/Url.php | 75 ++++++++++++++++++++++++++++++++--------------
doc/asciidoc/helpers.txt | 4 ++-
2 files changed, 55 insertions(+), 24 deletions(-)
hooks/post-receive
--
quickfw
|