[puntoengine] r92 committed - * New object Url to parse urls and get posibles controllers...

5 views
Skip to first unread message

punto...@googlecode.com

unread,
Nov 1, 2011, 10:38:23 AM11/1/11
to punto...@googlegroups.com
Revision: 92
Author: jba...@gmail.com
Date: Tue Nov 1 07:37:31 2011
Log: * New object Url to parse urls and get posibles controllers
* New magic method to Object class
http://code.google.com/p/puntoengine/source/detail?r=92

Added:
/trunk/puntoengine/core/http/Url.php
Modified:
/trunk/puntoengine/core/Object.php

=======================================
--- /dev/null
+++ /trunk/puntoengine/core/http/Url.php Tue Nov 1 07:37:31 2011
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Source code of Url class
+ * @category puntoengine
+ * @package core
+ * @subpackage http
+ * @author Juan Benavides Romero <juan.benav...@gmail.com>
+ * @since 0.4.0
+ */
+
+
+/**
+ * Url class is a class to content and parse urls for puntoengine
+ * @category puntoengine
+ * @package core
+ * @subpackage http
+ * @author Juan Benavides Romero <juan.benav...@gmail.com>
+ * @since 0.4.0
+ */
+class Url {
+ /**
+ * Url path
+ * @var string
+ */
+ protected $url;
+
+
+ /**
+ * Diferentes url parth separated in directories
+ * @var array
+ */
+ protected $urlParts;
+
+
+
+ /**
+ * Construct to specified the url to parse
+ * @param string $url Url to parse
+ * @since 0.4.0
+ */
+ public function __construct($url) {
+ $this->url = $url;
+
+ $this->urlParts = explode('/', ((substr($url, 0, 1) == '/') ?
substr($url, 1) : $url));
+
+ unset($url);
+ }//__construct
+
+
+ /**
+ * Return the posibles controllers are content in the url
+ * @return array
+ * @since 0.4.0
+ */
+ public function getControllers() {
+ $controllers = array();
+
+ for($i = count($this->urlParts) - 1; $i >= 0; $i--) {
+ if($i == count($this->urlParts) - 1) {
+ if(isset($this->urlParts[$i - 1]) && strpos($this->urlParts[$i], '.')
=== false && strpos($this->urlParts[$i - 1], '.') === false) {
+ $controllers[] = $this->urlParts[$i - 1].'.'.$this->urlParts[$i];
+ }
+ } else if($i != count($this->urlParts) - 2) {
+ if(isset($this->urlParts[$i + 1]) && strpos($this->urlParts[$i], '.')
=== false && strpos($this->urlParts[$i + 1], '.') === false) {
+ $controllers[] = $this->urlParts[$i].'.'.$this->urlParts[$i + 1];
+ }
+ }
+
+ $controllers[] = $this->urlParts[$i];
+ }
+
+ unset($i);
+
+ return $controllers;
+ }//getControllers
+}//Url
+?>
=======================================
--- /trunk/puntoengine/core/Object.php Sun Oct 30 14:45:40 2011
+++ /trunk/puntoengine/core/Object.php Tue Nov 1 07:37:31 2011
@@ -16,6 +16,57 @@
* @since 0.4.0
*/
class Object {
+ /**
+ * This method is called when unset the object
+ * @since 0.4.0
+ * @todo Implements
+ */
+ public function __destruct() {
+ }//__destruct
+
+
+
+ /**
+ * Default method call
+ * @since 0.4.0
+ * @todo Implements
+ */
+ public function __invoke() {
+ }//__invoke
+
+
+
+ /**
+ * Call when serialize a object to string
+ * @since 0.4.0
+ * @todo Implements
+ */
+ public function __sleep() {
+ }//__sleep
+
+
+
+ /**
+ * Call when unserialize a object from string
+ * @since 0.4.0
+ * @todo Implements
+ */
+ public function __wakeup() {
+ }//__wakeup
+
+
+
+ /**
+ * Clone this class
+ * @return __CLASS__
+ * @since 0.4.0
+ */
+ public function __clone() {
+ return clone($this);
+ }//__clone
+
+
+
/**
* Override undefined call to a method
* @param string $name Name of undefined method
@@ -27,6 +78,16 @@

+ /**
+ * Override undefined call a static method
+ * @param string $name Name of static undefined method
+ * @param array $arguments Params of the method
+ */
+ public function __callStatic($name, $arguments) {
+ }//__callStatic
+
+
+
/**
* Override undefined set property
* @param string $name Property name
@@ -36,6 +97,7 @@
public function __set($name, $value) {
}//__set

+

/**
* Override the get property
@@ -65,6 +127,7 @@
* Override the unset function are called againt property of the class
* @param string $name Property name
* @since 0.4.0
+ * @todo Implement this method
*/
public function __unset($name) {
}//__unset
@@ -81,9 +144,10 @@
}//toJson


+
/**
* Render the class to a string encoding
- * @return type
+ * @return string
* @since 0.4.0
*/
public function toString() {
@@ -92,10 +156,22 @@

+ /**
+ * Render the class to a string encoding
+ * @return string
+ * @since 0.4.0
+ */
+ public function __toString() {
+ return serialize($this);
+ }//__toString
+
+
+
/**
* Render the class to a xml encoding
* @throws NotImplementedException
* @since 0.4.0
+ * @todo Implement this method
*/
public function toXml() {
throw new NotImplementedException(__CLASS__ . '::' . __METHOD__);

Reply all
Reply to author
Forward
0 new messages