summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/Web/Services/TPageService.php15
-rw-r--r--tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.page3
-rw-r--r--tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.php14
-rw-r--r--tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.page3
-rw-r--r--tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.php6
-rw-r--r--tests/FunctionalTests/features/tests/NamespacesTestCase.php17
6 files changed, 53 insertions, 5 deletions
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index be865d89..a52efd13 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -102,6 +102,10 @@ class TPageService extends \Prado\TService
*/
const PAGE_FILE_EXT='.page';
/**
+ * Prefix of Pages used for instantiating new pages
+ */
+ const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\';
+ /**
* @var string root path of pages
*/
private $_basePath=null;
@@ -490,21 +494,22 @@ class TPageService extends \Prado\TService
if($hasClassFile)
{
$className=basename($path);
- if(!class_exists($className,false))
+ $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath);
+ if(!class_exists($className,false) && !class_exists($namespacedClassName, false))
include_once($path.Prado::CLASS_FILE_EXT);
+
+ if(!class_exists($className,false))
+ $className = $namespacedClassName;
}
else
{
$className=$this->getBasePageClass();
- Prado::using($className);
- if(($pos=strrpos($className,'.'))!==false)
- $className=substr($className,$pos+1);
}
if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage')))
throw new THttpException(404,'pageservice_page_unknown',$pagePath);
- $page=new $className;
+ $page=Prado::createComponent($className);
$page->setPagePath($pagePath);
if($hasTemplateFile)
diff --git a/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.page b/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.page
new file mode 100644
index 00000000..842868ba
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.page
@@ -0,0 +1,3 @@
+<com:TContent ID="Content">
+ With Namespaces loaded
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.php b/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.php
new file mode 100644
index 00000000..5a49f6f6
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/Namespaces/WithNamespace.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Application\Pages\Namespaces;
+
+use Prado\Web\UI\TPage;
+
+class WithNamespace extends TPage
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ }
+} \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.page b/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.page
new file mode 100644
index 00000000..28d38cec
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.page
@@ -0,0 +1,3 @@
+<com:TContent ID="Content">
+ Without Namespaces loaded
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.php b/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.php
new file mode 100644
index 00000000..ad671e7f
--- /dev/null
+++ b/tests/FunctionalTests/features/protected/pages/Namespaces/WithoutNamespace.php
@@ -0,0 +1,6 @@
+<?php
+
+class WithoutNamespace extends TPage
+{
+
+} \ No newline at end of file
diff --git a/tests/FunctionalTests/features/tests/NamespacesTestCase.php b/tests/FunctionalTests/features/tests/NamespacesTestCase.php
new file mode 100644
index 00000000..f712d526
--- /dev/null
+++ b/tests/FunctionalTests/features/tests/NamespacesTestCase.php
@@ -0,0 +1,17 @@
+<?php
+
+
+class NamespacesTestCase extends \PradoGenericSelenium2Test
+{
+ public function test()
+ {
+ $this->url("features/index.php?page=Namespaces.WithoutNamespace");
+ $this->pause(50);
+ $this->assertContains('Without Namespaces loaded', $this->source());
+
+ $this->url("features/index.php?page=Namespaces.WithNamespace");
+ $this->pause(50);
+ $this->assertContains('With Namespaces loaded', $this->source());
+ }
+
+} \ No newline at end of file