[pLog-svn] r2154 - in plugins/trunk: . mobile mobile/class mobile/class/action mobile/class/controller mobile/class/net mobile/class/view mobile/config mobile/templates mobile/templates/html-nokia

oscar at devel.plogworld.net oscar at devel.plogworld.net
Wed Jun 1 21:42:01 GMT 2005


Author: oscar
Date: 2005-06-01 21:42:00 +0000 (Wed, 01 Jun 2005)
New Revision: 2154

Added:
   plugins/trunk/mobile.php
   plugins/trunk/mobile/
   plugins/trunk/mobile/class/
   plugins/trunk/mobile/class/action/
   plugins/trunk/mobile/class/action/mobileaction.class.php
   plugins/trunk/mobile/class/action/mobiledefaultaction.class.php
   plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php
   plugins/trunk/mobile/class/controller/
   plugins/trunk/mobile/class/controller/mobilecontroller.class.php
   plugins/trunk/mobile/class/controller/mobilecontrollermap.properties.php
   plugins/trunk/mobile/class/net/
   plugins/trunk/mobile/class/net/mobilerequestgenerator.class.php
   plugins/trunk/mobile/class/net/terminalidentifier.class.php
   plugins/trunk/mobile/class/net/terminalinfo.class.php
   plugins/trunk/mobile/class/view/
   plugins/trunk/mobile/class/view/mobiledefaultview.class.php
   plugins/trunk/mobile/class/view/mobileerrorview.class.php
   plugins/trunk/mobile/class/view/mobileview.class.php
   plugins/trunk/mobile/class/view/mobileviewarticleview.class.php
   plugins/trunk/mobile/config/
   plugins/trunk/mobile/config/terminal.properties.php
   plugins/trunk/mobile/pluginmobile.class.php
   plugins/trunk/mobile/templates/
   plugins/trunk/mobile/templates/html-nokia/
   plugins/trunk/mobile/templates/html-nokia/error.template
   plugins/trunk/mobile/templates/html-nokia/footer.template
   plugins/trunk/mobile/templates/html-nokia/header.template
   plugins/trunk/mobile/templates/html-nokia/main.template
   plugins/trunk/mobile/templates/html-nokia/pager.template
   plugins/trunk/mobile/templates/html-nokia/post.template
   plugins/trunk/mobile/templates/html-nokia/postandcomments.template
Log:
plog goes 100% mobile! I know I should be working on the replacmenet for adodb or any of the other open issues we've got
at the moment but I always wanted to work on this :)

This plugin creates a mobile version of any given blog, and providing support for terminal-specific
templates. By adding new regular expressions to match against the User-Agent header to plugins/mobile/config/terminal.properties.php, we can add support for unlimited devices. At the moment only Nokia Series60 phones are supported, but that's because I haven't got anything else to test with (I will
add support for the 9500 later on) Even when browsing the pages with a browser we will get the version for Nokia phones. 

The current template is shamelessly ripped off from the mobile version of osnews.com but as soon as everything's working I will design a nicer template.

The plugin is not ready yet but I am committing it now so that there is already a copy stored somewhere... Please do *not*
include this plugin when generating the _all_plugins.zip package.
The plugin currently allows to browse the front page of a blog and browse the comments of a post. It uses a pager to 
distribute the posts and comments in different smaller pages.

The plugin itself is only a bogus file, since mobile.php implements its own controller, views, etc.


Added: plugins/trunk/mobile/class/action/mobileaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobileaction.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/action/mobileaction.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,54 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
+    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+    include_once( MOBILE_PLOG_CLASS_PATH."class/net/mobilerequestgenerator.class.php" );
+
+    class MobileAction extends Action
+    {
+    
+        var $_blogInfo;
+        var $_locale;
+    
+        function MobileAction( $actionInfo, $httpRequest )
+        {
+            $this->Action( $actionInfo, $httpRequest );
+            
+            $this->_blogInfo = $this->_getBlogInfo();
+            $this->_locale =& $this->_blogInfo->getLocale();
+        }
+        
+        /**
+         * @private
+         */
+        function _getBlogInfo()
+        {
+            $blogId = $this->_request->getValue( "blogId" );
+            $val = new IntegerValidator();
+            if( !$val->validate( $blogId )) {
+                $config =& Config::getConfig();
+                $blogId = $config->getValue( "default_blog_id" );
+            }
+            
+            // try to load the blog
+            $blogs = new Blogs();
+            $blogInfo = $blogs->getBlogInfo( $blogId );
+            
+            if( !$blogInfo ) {
+                die( "ERROR: The blog does not exist" );
+            }
+            
+            if( $blogInfo->getStatus() != BLOG_STATUS_ACTIVE ) {
+                die( "ERROR: The blog does not exist" );            
+            }
+            
+            return( $blogInfo );
+        }
+        
+        function setCommonData()
+        {            
+            $this->_view->setValue( "blog", $this->_blogInfo );
+            $this->_view->setValue( "murl", new MobileRequestGenerator( $this->_blogInfo ));
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/action/mobiledefaultaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobiledefaultaction.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/action/mobiledefaultaction.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,22 @@
+<?php
+
+    include_once( MOBILE_PLOG_CLASS_PATH."class/action/mobileaction.class.php" );
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobiledefaultview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+    
+    class MobileDefaultAction extends MobileAction
+    {
+        function MobileDefaultAction( $actionInfo, $request )
+        {
+            $this->MobileAction( $actionInfo, $request );
+        }
+        
+        function perform()
+        {
+            $this->_view = new MobileDefaultView( $this->_blogInfo );            
+            $this->setCommonData();
+            
+            return( true );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,45 @@
+<?php
+    
+    include_once( MOBILE_PLOG_CLASS_PATH."class/action/mobileaction.class.php" );
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileerrorview.class.php" );
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileviewarticleview.class.php" );    
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+    
+    class MobileViewArticleAction extends MobileAction
+    {
+    
+        function MobileViewArticleAction( $actionInfo, $request )
+        {
+            $this->MobileAction( $actionInfo, $request );
+            
+            $this->registerFieldValidator( "articleId", new IntegerValidator());
+            $view = new MobileErrorView( $this->_blogInfo );
+            $view->setErrorMessage( $this->_locale->tr("error_invalid_blog_id" ));
+            $this->setValidationErrorView( $view );
+        }
+    
+        function perform()
+        {
+            // load the article
+            $this->_articleId = $this->_request->getValue( "articleId" );
+            $articles = new Articles();
+            $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId());
+            
+            // was it correct?
+            if( !$article ) {
+                $this->_view = new MobileErrorView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr( "incorrect_blog_id" ));
+                $this->setCommonData();
+                return( false );
+            }
+            
+            // if so, continue
+            $this->_view = new MobileViewArticleView( $this->_blogInfo );
+            $this->_view->setValue( "post", $article );
+            $this->setCommonData();
+            
+            return( true );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/controller/mobilecontroller.class.php
===================================================================
--- plugins/trunk/mobile/class/controller/mobilecontroller.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/controller/mobilecontroller.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,32 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/controller/controller.class.php" );
+
+     class MobileController extends Controller 
+     {
+
+    	/**
+         * Constructor. Automatically loads the maps
+         */
+		function MobileController()
+        {
+			$actionMap = $this->_loadActionMaps();        
+        
+            $this->Controller( $actionMap, "op" );
+			
+			$this->setActionFolderPath( PLOG_CLASS_PATH.'plugins/mobile/class/action/' );
+        }
+        
+        /**
+         * Loads the maps
+         *
+         * @private
+         */
+        function _loadActionMaps()
+        {
+			include( PLOG_CLASS_PATH."plugins/mobile/class/controller/mobilecontrollermap.properties.php" );
+
+            return $actions;
+        }
+    }
+?>

Added: plugins/trunk/mobile/class/controller/mobilecontrollermap.properties.php
===================================================================
--- plugins/trunk/mobile/class/controller/mobilecontrollermap.properties.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/controller/mobilecontrollermap.properties.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,7 @@
+<?php
+
+    // default action that is used if no other
+    $actions["Default"] = "MobileDefaultAction";
+    // load a post
+    $actions["ViewArticle"] = "MobileViewArticleAction";
+?>

Added: plugins/trunk/mobile/class/net/mobilerequestgenerator.class.php
===================================================================
--- plugins/trunk/mobile/class/net/mobilerequestgenerator.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/net/mobilerequestgenerator.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,30 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/net/baserequestgenerator.class.php" );
+    
+    class MobileRequestGenerator extends BaseRequestGenerator
+    {
+    
+        function MobileRequestGenerator( $blogInfo )
+        {
+            $this->BaseRequestGenerator( $blogInfo );
+        }
+        
+        function getMobileUrl()
+        {
+            return( $this->getBaseUrl()."/mobile.php" );
+        }
+        
+        function blogLink()
+        {
+            return( $this->getMobileUrl()."?blogId=".$this->_blogInfo->getId());
+        }
+        
+        function postPermalink( $post )
+        {
+            $url = $this->getMobileUrl()."?op=ViewArticle&amp;blogId=".$this->_blogInfo->getId()."&amp;articleId=".$post->getId();
+            
+            return( $url );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/net/terminalidentifier.class.php
===================================================================
--- plugins/trunk/mobile/class/net/terminalidentifier.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/net/terminalidentifier.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,72 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/mobile/class/net/terminalinfo.class.php" );
+    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+    
+    class TerminalIdentifier extends Object
+    {
+    
+        var $_headers;
+        var $_terminals;
+    
+        function TerminalIdentifier()
+        {
+            $this->Object();
+            
+            $this->_loadTerminalDefinition();
+        }
+        
+        /**
+         * @private
+         */
+        function _loadTerminalDefinition()
+        {
+            $config =& Config::getConfig( "file", Array( "file" => PLOG_CLASS_PATH."plugins/mobile/config/terminal.properties.php" ));
+            
+            // load the "terminals" key, which is an array of arrays with the definition of
+            // each terminal
+            $this->_terminals = $config->getValue( "terminals" );
+        }
+        
+        /** 
+         * @return TerminalInfo
+         */
+        function identify( $headers )
+        {
+            $this->_headers = $headers;
+            
+            $userAgent = $headers[ "HTTP_USER_AGENT" ];
+            
+            // loop through the definition of each one of the terminals
+            //foreach( $this->_terminals as $terminalDef ) {
+            $matches = false;
+            $i = 0;
+            while( $i < count($this->_terminals ) && !$matches ) {
+                $terminalDef = $this->_terminals[$i];
+                //print("terminal = ".$terminalDef["id"]."<br/>" );
+                // check if the terminal regexp matches with the user-agent string
+                if( preg_match( $terminalDef["regexp"], $userAgent, $matches )) {
+                    //print("Terminal = ".$terminalDef["id"]." - matches = ".$terminalDef["regexp"]."<br/>");
+                    $matches = true;
+                }
+                $i++;
+            }
+            
+            //
+            // if nothing matched, then there's nothing for us to do here
+            //
+            if( !$matches ) {
+                print("No matches found!");
+                return( null );
+            }
+            
+            //
+            // if something matched, build the correct TerminalInfo object
+            //
+            $info = new TerminalInfo( $terminalDef, $headers );
+            
+            return( $info );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/net/terminalinfo.class.php
===================================================================
--- plugins/trunk/mobile/class/net/terminalinfo.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/net/terminalinfo.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,58 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+    
+    class TerminalInfo extends Object
+    {
+        var $_headers;
+        var $_def;
+    
+        function TerminalInfo( $terminalDef, $headers )
+        {
+            $this->Object();
+            
+            $this->_def = $terminalDef;
+            $this->_headers = $headers;
+        }
+        
+        function getRegexp()
+        {
+            return( $this->_def["regexp"] );
+        }
+        
+        function getContent()
+        {
+            return( $this->_def["content"] );
+        }
+        
+        function getContentType()
+        {
+            return( $this->_def["content-type"] );
+        }
+        
+        function getId()
+        {
+            return( $this->_def["id"] );
+        }
+        
+        function getDesc()
+        {
+            return( $this->_def["desc"] );
+        }
+        
+        function getDescription()
+        {
+            return( $this->getDesc());
+        }
+        
+        function getUserAgent()
+        {
+            return( $this->_headers["HTTP_USER_AGENT"] );
+        }
+        
+        function getAcceptTypes()
+        {
+            return( $this->_headers["HTTP_ACCEPT"] );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/view/mobiledefaultview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobiledefaultview.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/view/mobiledefaultview.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,56 @@
+<?php
+
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+    
+    class MobileDefaultView extends MobileView
+    {
+    
+        var $_page;
+    
+        function MobileDefaultView( $blogInfo )
+        {
+            $this->MobileView( $blogInfo, "main" );
+        }
+        
+        function render()
+        {
+            // load the current page
+            $this->_page = $this->getCurrentPageFromRequest();
+        
+            // load some posts
+            $articles = new Articles();
+            $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(),
+                                                        -1,
+                                                        MOBILE_PLOG_NUM_POSTS_PER_PAGE,
+                                                        0,
+                                                        POST_STATUS_PUBLISHED,
+                                                        0,
+                                                        0,
+                                                        "",
+                                                        $this->_page );
+            // number of articles
+            $numPosts = $articles->getNumBlogArticles( $this->_blogInfo->getId(),
+                                                        -1,
+                                                        MOBILE_PLOG_NUM_POSTS_PER_PAGE,
+                                                        -1,
+                                                        POST_STATUS_PUBLISHED,
+                                                        0,
+                                                        0,
+                                                        "",
+                                                        $this->_page );       
+            
+            // pass them to the template
+            $this->setValue( "posts", $blogArticles );
+            
+            // create the pager and pass it to the template too
+            $pager = new Pager( "?op=Default&amp;blogId=".$this->_blogInfo->getId()."&amp;page=",
+                                $this->_page,
+                                $numPosts,
+                                MOBILE_PLOG_NUM_POSTS_PER_PAGE );
+            $this->setValue( "pager", $pager );                                
+            
+            parent::render();        
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/view/mobileerrorview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileerrorview.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/view/mobileerrorview.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,13 @@
+<?php
+
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileview.class.php" );
+    
+    class MobileErrorView extends MobileView
+    {
+    
+        function MobileErrorView( $blogInfo )
+        {
+            $this->MobileView( $blogInfo, "error" );
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/view/mobileview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileview.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/view/mobileview.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,31 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );
+    include_once( MOBILE_PLOG_CLASS_PATH."class/net/terminalidentifier.class.php" );
+    
+    class MobileView extends PluginTemplatedView
+    {
+        function MobileView( $blogInfo, $templateName )
+        {
+
+            // detect the terminal that made the request
+            $ti = new TerminalIdentifier();
+            $info = $ti->identify( $_SERVER );
+            
+            if( !$info ) {
+                die( "No terminal matched the request! Make sure that at least there is
+                      one matching terminal definition." );
+            }
+            
+            $terminalTemplate = $info->getContent()."/".$templateName;
+        
+            $this->PluginTemplatedView( $blogInfo, 
+                                        "mobile",
+                                        $terminalTemplate, 
+                                        SMARTY_VIEW_CACHED_DISABLED );
+                                        
+            // set the response type
+            $this->setContentType( $info->getContentType());
+        }                
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/class/view/mobileviewarticleview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileviewarticleview.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/class/view/mobileviewarticleview.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,46 @@
+<?php
+
+    include_once( MOBILE_PLOG_CLASS_PATH."class/view/mobileview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+    
+    class MobileViewArticleView extends MobileView
+    {
+    
+        var $_page;
+    
+        function MobileViewArticleView( $blogInfo )
+        {
+            $this->MobileView( $blogInfo, "postandcomments" );
+            
+            $this->_page = $this->getCurrentPageFromRequest();
+        }
+        
+        function render()
+        {
+            // load a paginated view of the article comments
+            $comments = new ArticleComments();
+            $article = $this->getValue( "post" );
+            $articleComments = $comments->getPostComments( $article->getId(),
+                                                           COMMENT_ORDER_OLDEST_FIRST,
+                                                           COMMENT_STATUS_NONSPAM,
+                                                           $this->_page,
+                                                           MOBILE_PLOG_NUM_COMMENTS_PER_PAGE );
+            // get the number of comments
+            $numComments = $comments->getNumPostComments( $article->getId(),
+                                                          COMMENT_STATUS_NONSPAM );
+                                                          
+            // and finally, generate the pager
+            $pager = new Pager( "?op=ViewArticle&amp;blogId=".$this->_blogInfo->getId()."&amp;articleId=".$article->getId()."&amp;page=",
+                                $this->_page,
+                                $numComments,
+                                MOBILE_PLOG_NUM_COMMENTS_PER_PAGE );
+                                
+            // pass everything to the templates
+            $this->setValue( "comments", $articleComments );
+            $this->setValue( "pager", $pager );
+            
+            parent::render();
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/config/terminal.properties.php
===================================================================
--- plugins/trunk/mobile/config/terminal.properties.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/config/terminal.properties.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * known headers so far
+ *
+ * Opera 6.20 / Nokia7610
+ *      Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 7610;451) Opera 6.20  [en]
+ *
+ */
+
+$config["terminals"] = Array (
+
+    Array( "regexp" => "/.*Nokia.*/",
+           "content" => "html-nokia",
+           "content-type" => "text/html",
+           "id" => "nokia",
+           "desc" => "Nokia Symbian Browser" ),
+           
+    Array( "regexp" => "/.*Safari.*/",
+           "content" => "html-nokia",
+           "content-type" => "text/html",
+           "id" => "safari",
+           "desc" => "Apple Safari/WebKit" ),
+           
+    Array( "regexp" => "/.*Mozilla.*/",
+           "content" => "html-nokia",
+           "content-type" => "text/html",
+           "id" => "mozilla",
+           "desc" => "Mozilla/Gecko" ),
+           
+    Array( "regexp" => "/.*/",
+           "content" => "default",
+           "content-type" => "text/html",
+           "id" => "default",
+           "desc" => "Any other browser" )
+);
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/pluginmobile.class.php
===================================================================
--- plugins/trunk/mobile/pluginmobile.class.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/pluginmobile.class.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,17 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+    
+    class PluginMobile extends PluginBase
+    {
+    
+        function PluginMobile()
+        {
+            $this->PluginBase();
+            
+            $this->id = "mobile";
+            $this->desc = "Allows pLog blogs to be accessed via mobile terminals";
+            $this->author = "The pLog Project";
+        }
+    }
+?>
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/error.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/error.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/error.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,4 @@
+{include file="html-nokia/header.template"}
+<B>Error</B><BR>
+{$viewErrorMessage}
+{include file="html-nokia/footer.template"}
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/footer.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/footer.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/footer.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,2 @@
+</BODY>
+</HTML>
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/header.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/header.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/header.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,5 @@
+<HTML>
+<HEAD>
+ <TITLE>{$blog->getBlog()}</TITLE>
+</HEAD> 
+<BODY BGCOLOR="#C8CFC8" TEXT="#000000" LINK="#669900" VLINK="#669900" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" RIGHTMARGIN="0">
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/main.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/main.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/main.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,6 @@
+{include file="html-nokia/header.template"}
+{foreach from=$posts item=post}
+{include file="html-nokia/post.template"}
+{/foreach}
+{include file="html-nokia/pager.template"}
+{include file="html-nokia/footer.template"}
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/pager.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/pager.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/pager.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,21 @@
+<CENTER><TABLE CELLPADDING=1 CELLSPACING=0 BORDER=1 BORDERCOLOR="#C0C0C0" WIDTH="100%">
+<TR>
+<TD bgcolor="#DDDDDD"><center><B><FONT SIZE=2 FACE="Arial">
+
+	{if !$pager->isFirstPage() && !$pager->isEmpty()}
+	   <A HREF="{$pager->getPrevPageLink()}">&laquo;</a>&nbsp;</A>
+	{/if}	
+	{foreach from=$pager->getPageLinks() item=pageLink key=pageId}
+	  {if $pageId == $pager->getCurrentPage()}
+	    {$pageId}
+	  {else}
+	    <A HREF="{$pageLink}">&nbsp;{$pageId}&nbsp;</A>&nbsp;
+	  {/if}  
+	{/foreach}
+	{if !$pager->isLastPage() && !$pager->isEmpty()}
+	    <A HREF="{$pager->getNextPageLink()}">&raquo;</A>&nbsp;
+	{/if}
+	
+</FONT></B></center></TD></TR>
+</TABLE></center>
+

Added: plugins/trunk/mobile/templates/html-nokia/post.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/post.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/post.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,5 @@
+<TABLE WIDTH="100%" CELLPADDING="1" CELLSPACING="0" BORDER=1 BGCOLOR="#FFFFFF" BORDERCOLOR="#C0C0C0">
+ <tr><td width="100%" BGCOLOR="#CCCCCC"><FONT FACE="Arial" SIZE=2  color="#990000"><B><A HREF="{$murl->postPermalink($post)}">{$post->getTopic()}</a></b></font></td></tr>
+ <TR><TD WIDTH="100%" BGCOLOR="#FFFFFF" VALIGN="TOP"><FONT FACE="Arial" SIZE=2 color="#000000">{$post->getIntroText()}</td></tr>
+ <TR><TD WIDTH="100%" HEIGHT=18 ALIGN="CENTER" BGCOLOR="#EFEDED"><A HREF="{$murl->postPermalink($post)}" class="non"><FONT FACE="Arial" SIZE=1><A HREF="{$murl->postPermalink($post)}">{$post->getTotalComments()}</FONT> <IMG SRC="{$url->getUrl("/imgs/face.gif")}" ALT="Comments" WIDTH=8 HEIGHT=10></A></TD></TR>
+</TABLE>
\ No newline at end of file

Added: plugins/trunk/mobile/templates/html-nokia/postandcomments.template
===================================================================
--- plugins/trunk/mobile/templates/html-nokia/postandcomments.template	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile/templates/html-nokia/postandcomments.template	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,13 @@
+{include file="html-nokia/header.template"}
+{include file="html-nokia/post.template"}
+{foreach from=$comments item=comment}
+<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=1 BORDERCOLOR="#C0C0C0" WIDTH="100%">
+<TR>
+<TD BGCOLOR="#D3D3D3" WIDTH="100%"><FONT FACE="Arial" SIZE=2 color="#334433"><B>{$comment->getTopic()}</B></FONT></TD>
+</TR>
+{assign var=commentDate value=$comment->getDateObject()}
+<TR><TD BGCOLOR="#DEDEDE" WIDTH="100%"> <FONT FACE="Verdana, Arial" SIZE=1><B>{$comment->getUsername()}</B> @ {$locale->formatDate($commentDate,"%d-%m-%Y %H:%M")}</FONT></TD></TR>
+<TR><TD VALIGN="TOP" WIDTH="100%" bgcolor="#EEEEEE"><FONT FACE="Arial, Sans-serif, Trebuchet MS" SIZE=2 color="#000000">{$post->getText()}</FONT></TD></TR></TABLE>
+{/foreach}
+{include file="html-nokia/pager.template"}
+{include file="html-nokia/footer.template"}
\ No newline at end of file

Added: plugins/trunk/mobile.php
===================================================================
--- plugins/trunk/mobile.php	2005-06-01 02:15:23 UTC (rev 2153)
+++ plugins/trunk/mobile.php	2005-06-01 21:42:00 UTC (rev 2154)
@@ -0,0 +1,28 @@
+<?php
+    // please enable the line below if you are having memory issues
+    //ini_set('memory_limit', "16M");
+
+    if (!defined( "PLOG_CLASS_PATH" )) {
+        define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+    }
+    if( !defined( "MOBILE_PLOG_CLASS_PATH" )) {
+        define( "MOBILE_PLOG_CLASS_PATH", PLOG_CLASS_PATH."plugins/mobile/" );
+    }
+
+    include_once( MOBILE_PLOG_CLASS_PATH."class/controller/mobilecontroller.class.php" );
+    include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
+
+    ini_set("arg_seperator.output", "&amp;");
+    ini_set("magic_quotes_runtime", 0 );
+    
+    //
+    // a few more constants, please change them if needed
+    // 
+    define( "MOBILE_PLOG_NUM_COMMENTS_PER_PAGE", 5 );
+    define( "MOBILE_PLOG_NUM_POSTS_PER_PAGE", 5 );    
+
+    $controller = new MobileController();
+
+    // give control to the, ehem, controller :)
+    $controller->process( HttpVars::getRequest());
+?>




More information about the pLog-svn mailing list