summaryrefslogtreecommitdiff
path: root/demos/blog
diff options
context:
space:
mode:
authorcarlgmathisen <>2008-12-07 13:05:05 +0000
committercarlgmathisen <>2008-12-07 13:05:05 +0000
commit736e92efbc75908a2bf26fe333a03990e3bb8100 (patch)
tree21dfe413b2f3f52704ca28e17f22269f9cfdb5ea /demos/blog
parent6228873cf9d6471463d2413e7dfd7447f759baf2 (diff)
work on php style configuration
Diffstat (limited to 'demos/blog')
-rw-r--r--demos/blog/index_php.php20
-rw-r--r--demos/blog/protected/Data/Settings.php13
-rw-r--r--demos/blog/protected/Pages/Admin/config.php13
-rw-r--r--demos/blog/protected/Pages/Posts/config.php20
-rw-r--r--demos/blog/protected/application.php86
-rw-r--r--demos/blog/protected/application.xml10
6 files changed, 157 insertions, 5 deletions
diff --git a/demos/blog/index_php.php b/demos/blog/index_php.php
new file mode 100644
index 00000000..a5434860
--- /dev/null
+++ b/demos/blog/index_php.php
@@ -0,0 +1,20 @@
+<?php
+
+$basePath=dirname(__FILE__);
+$frameworkPath=$basePath.'/../../framework/prado.php';
+$assetsPath=$basePath.'/assets';
+$runtimePath=$basePath.'/protected/runtime';
+$dataPath=$basePath.'/protected/Data';
+
+if(!is_writable($assetsPath))
+ die("Please make sure that the directory $assetsPath is writable by Web server process.");
+if(!is_writable($runtimePath))
+ die("Please make sure that the directory $runtimePath is writable by Web server process.");
+if(!is_writable($dataPath))
+ die("Please make sure that the directory $dataPath is writable by Web server process.");
+if(!extension_loaded("sqlite"))
+ die("SQLite PHP extension is required.");
+
+require_once($frameworkPath);
+$application=new TApplication('protected',false,TApplication::CONFIG_TYPE_PHP);
+$application->run(); \ No newline at end of file
diff --git a/demos/blog/protected/Data/Settings.php b/demos/blog/protected/Data/Settings.php
new file mode 100644
index 00000000..a4adcd9f
--- /dev/null
+++ b/demos/blog/protected/Data/Settings.php
@@ -0,0 +1,13 @@
+<?php
+return array(
+ 'SiteTitle' => 'MyBlog',
+ 'SiteSubtitle' => 'A Prado-driven weblog',
+ 'SiteOwner' => 'Prado User',
+ 'AdminEmail' => 'admin@example.com',
+ 'MultipleUser' => false,
+ 'AccountApproval' => false,
+ 'PostPerPage' => 6,
+ 'RecentComments' => 6,
+ 'PostApproval' => false,
+ 'ThemeName' => 'Winter'
+); \ No newline at end of file
diff --git a/demos/blog/protected/Pages/Admin/config.php b/demos/blog/protected/Pages/Admin/config.php
new file mode 100644
index 00000000..d392da4e
--- /dev/null
+++ b/demos/blog/protected/Pages/Admin/config.php
@@ -0,0 +1,13 @@
+<?php
+return array(
+ 'authorization' => array(
+ array(
+ 'action' => 'allow',
+ 'roles' => 'admin',
+ ),
+ array(
+ 'action' => 'deny',
+ 'users' => '*',
+ ),
+ ),
+); \ No newline at end of file
diff --git a/demos/blog/protected/Pages/Posts/config.php b/demos/blog/protected/Pages/Posts/config.php
new file mode 100644
index 00000000..8af0dd56
--- /dev/null
+++ b/demos/blog/protected/Pages/Posts/config.php
@@ -0,0 +1,20 @@
+<?php
+return array(
+ 'authorization' => array(
+ array(
+ 'action' => 'deny',
+ 'pages' => 'EditPost,NewPost,MyPost',
+ 'users' => '?',
+ ),
+ array(
+ 'action' => 'allow',
+ 'pages' => 'NewCategory,EditCategory',
+ 'users' => 'admin',
+ ),
+ array(
+ 'action' => 'deny',
+ 'pages' => 'NewCategory,EditCategory',
+ 'users' => '*',
+ ),
+ )
+); \ No newline at end of file
diff --git a/demos/blog/protected/application.php b/demos/blog/protected/application.php
new file mode 100644
index 00000000..c6f26c7e
--- /dev/null
+++ b/demos/blog/protected/application.php
@@ -0,0 +1,86 @@
+<?php
+return array(
+ 'application' => array(
+ 'id' => 'blog',
+ 'mode' => 'Debug'
+ ),
+ 'paths' => array(
+ 'using' => array(
+ 'Application.Common.*',
+ ),
+ ),
+ // Modules configured and loaded for all services
+ 'modules' => array(
+ 'request' => array(
+ 'class' => 'THttpRequest',
+ 'properties' => array(
+ 'UrlFormat' => 'Path',
+ 'UrlManager' => 'friendly-url',
+ ),
+ ),
+
+ 'cache' => array(
+ 'class' => 'System.Caching.TSqliteCache',
+ ),
+
+ 'error' => array(
+ 'class' => 'Application.Common.BlogErrorHandler',
+ ),
+ array(
+ 'class' => 'System.Util.TLogRouter',
+ 'routes' => array(
+ array(
+ 'class' => 'TFileLogRoute',
+ 'properties' => array(
+ 'Categories' => 'BlogApplication',
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'class' => 'System.Util.TParameterModule',
+ 'properties' => array(
+ 'ParameterFile' => 'Application.Data.Settings',
+ ),
+ ),
+ 'friendly-url' => array(
+ 'class' => 'System.Web.TUrlMapping',
+ 'properties' => array(
+ 'EnableCustomUrl' => true,
+ ),
+ 'urls' => array(
+ array('properties' => array('ServiceParameter'=>'Posts.ViewPost','pattern'=>'post/{id}/?','parameters.id'=>'\d+')),
+ ),
+ ),
+ ),
+ 'services' => array(
+ 'page' => array(
+ 'class' => 'TPageService',
+ 'properties' => array(
+ 'BasePath' => 'Application.Pages',
+ 'DefaultPage' => 'Posts.ListPost',
+ ),
+ 'modules' => array(
+ 'users' => array(
+ 'class' => 'Application.Common.BlogUserManager',
+ ),
+ 'auth' => array(
+ 'class' => 'System.Security.TAuthManager',
+ 'properties' => array(
+ 'UserManager' => 'users',
+ 'LoginPage' => 'Posts.ListPost',
+ ),
+ ),
+ 'data' => array(
+ 'class' => 'Application.Common.BlogDataModule',
+ ),
+ ),
+ ),
+ ),
+ 'pages' => array(
+ 'properties' => array(
+ 'MasterClass' => 'Application.Layouts.MainLayout',
+ 'Theme' => 'Basic',
+ ),
+ ),
+); \ No newline at end of file
diff --git a/demos/blog/protected/application.xml b/demos/blog/protected/application.xml
index d28b2dd7..1ab6a9c0 100644
--- a/demos/blog/protected/application.xml
+++ b/demos/blog/protected/application.xml
@@ -6,10 +6,10 @@
</paths>
<!-- modules configured and loaded for all services -->
<modules>
- <!-- Remove this comment mark to enable PATH url format
- <module id="request" class="THttpRequest" UrlFormat="Path" />
- -->
- <module id="cache" class="System.Caching.TSqliteCache" />
+
+ <module id="request" class="THttpRequest" UrlFormat="Path" UrlManager="friendly-url" />
+
+ <!--<module id="cache" class="System.Caching.TSqliteCache" />-->
<module class="Application.Common.BlogErrorHandler" />
<module id="log" class="System.Util.TLogRouter">
<route class="TFileLogRoute" Categories="BlogApplication" />
@@ -17,7 +17,7 @@
<module class="System.Util.TParameterModule" ParameterFile="Application.Data.Settings" />
<!-- use TUrlMapping to map URL patterns to particular requests -->
- <module id="friendly-url" class="System.Web.TUrlMapping">
+ <module id="friendly-url" class="System.Web.TUrlMapping" EnableCustomUrl="true">
<url ServiceParameter="Posts.ViewPost" pattern="post/{id}/?" parameters.id="\d+" />
<url ServiceParameter="Posts.ListPost" pattern="archive/{time}/?" parameters.time="\d{6}" />
<url ServiceParameter="Posts.ListPost" pattern="category/{cat}/?" parameters.cat="\d+" />