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 0f1eafc3627eb8dd6702fa77e91cbc08e48e207a (commit)
from 19cf094318c883921a8a3f0f7fe9f3c499e66630 (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 0f1eafc3627eb8dd6702fa77e91cbc08e48e207a
Author: Ivan1986 <iva...@li...>
Date: Mon Apr 26 16:08:21 2010 +0400
Хелпер для урлов
diff --git a/QFW/Init.php b/QFW/Init.php
index 78924e2..8caad4d 100644
--- a/QFW/Init.php
+++ b/QFW/Init.php
@@ -59,6 +59,10 @@ class QFW
require QFWPATH.'/QuickFW/Cache.php';
require QFWPATH.'/QuickFW/Plugs.php';
+ //хелпер для урлов
+ require QFWPATH.'/QuickFW/Url.php';
+ Url::Init();
+
//выставляем заголовок с нужной кодировкой
if (!empty(self::$config['host']['encoding']))
header("Content-Type: text/html; charset=".self::$config['host']['encoding']);
diff --git a/QFW/QuickFW/Url.php b/QFW/QuickFW/Url.php
new file mode 100644
index 0000000..6981730
--- /dev/null
+++ b/QFW/QuickFW/Url.php
@@ -0,0 +1,144 @@
+<?php
+
+/**
+ * Хелпер для адресов
+ *
+ * @author ivan1986
+ */
+class Url
+{
+ /**
+ * Возвращает базовый урл
+ *
+ * @return self базовый url
+ */
+ public static function base()
+ {
+ return new self('');
+ }
+
+ /**
+ * Урл, относительно корня сайта
+ *
+ * @param string|self $url url
+ * @param string|array $get параметры
+ * @param string $ancor якорь
+ * @return self адрес на сайте
+ */
+ public static function site($url, $get='', $ancor='')
+ {
+ return new self($url, $get);
+ }
+
+ /**
+ * Урл, относительно модуля
+ *
+ * @param string|self $url url
+ * @param string|array $get параметры
+ * @param string $ancor якорь
+ * @return self адрес на сайте
+ */
+ public static function M($CA, $get='', $ancor='')
+ {
+ return new self($CA, $get, $ancor, QFW::$router->cModule.
+ QuickFW_Router::PATH_SEPARATOR);
+ }
+
+ /**
+ * Урл, относительно контроллера
+ *
+ * @param string|self $url url
+ * @param string|array $get параметры
+ * @param string $ancor якорь
+ * @return self адрес на сайте
+ */
+ public static function C($action, $get='', $ancor='')
+ {
+ return new self($action, $get, $ancor, QFW::$router->cModule.
+ QuickFW_Router::PATH_SEPARATOR.
+ QFW::$router->cController.
+ QuickFW_Router::PATH_SEPARATOR);
+ }
+
+ /**
+ * Урл, относительно экшена
+ *
+ * @param string|self $url url
+ * @param string|array $get параметры
+ * @param string $ancor якорь
+ * @return self адрес на сайте
+ */
+ public static function A($get='', $ancor='')
+ {
+ return new self('', $get, $ancor, QFW::$router->cModule.
+ QuickFW_Router::PATH_SEPARATOR.
+ QFW::$router->cController.
+ QuickFW_Router::PATH_SEPARATOR.
+ QFW::$router->cAction);
+ }
+
+ /**
+ * Инициализация класса из конфига
+ */
+ public static function Init()
+ {
+ self::$config = QFW::$config['redirection'];
+ self::$config['base'] = self::$config['baseUrl'].
+ (self::$config['useIndex'] ? 'index.php/' : '');
+ self::$config['ext'] = self::$config['defExt'] ?
+ self::$config['defExt'] : '/';
+ }
+
+ /** @var array QFW::$config['redirection'] */
+ private static $config;
+
+ /**
+ * Конструктор класса запроса
+ *
+ * @param string $url внутреннее представление адреса
+ * @param string|array $get параметры get
+ * @param string $ancor якорь
+ * @param string $begin базовый урл от текущего
+ */
+ private function __construct($url, $get='', $ancor='', $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->ancor = $ancor ? ltrim($ancor, '#') : $url->ancor;
+ return;
+ }
+ $this->u = $begin.trim($url, QuickFW_Router::PATH_SEPARATOR);
+ $this->get = $get;
+ $this->ancor = ltrim($ancor, '#');
+ }
+
+ /** @var string внутреннее представление адреса */
+ private $u;
+
+ /** @var string внутреннее представление адреса */
+ private $get;
+
+ /** @var string якорь */
+ private $ancor;
+
+ /**
+ * урл для вывода, с подстановками
+ *
+ * @return string урл
+ */
+ public function __toString()
+ {
+ return self::$config['base'].$this->u.
+ ($this->u!==''?self::$config['ext']:'').
+ ($this->get ? '?' . $this->get : '').
+ ($this->ancor ? '#' . $this->ancor : '');
+
+ }
+
+}
+
+?>
-----------------------------------------------------------------------
Summary of changes:
QFW/Init.php | 4 ++
QFW/QuickFW/Url.php | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 148 insertions(+), 0 deletions(-)
create mode 100644 QFW/QuickFW/Url.php
hooks/post-receive
--
quickfw
|