[pLog-svn] r2169 - in plugins/trunk/mobile: class/action class/net
class/view config
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sun Jun 5 13:19:09 GMT 2005
Author: oscar
Date: 2005-06-05 13:19:08 +0000 (Sun, 05 Jun 2005)
New Revision: 2169
Modified:
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/net/terminalidentifier.class.php
plugins/trunk/mobile/class/net/terminalinfo.class.php
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/terminal.properties.php
Log:
few changes:
- adde a new "itemsPerPage" property to each terminal so that different terminals can
display a different amount of items per page (probably WAP terminals, if ever implemented,
should display fewer than 5 items per page)
- added some documentation to the platform config file.
- some other changes...
Modified: plugins/trunk/mobile/class/action/mobileaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobileaction.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/action/mobileaction.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -10,6 +10,7 @@
var $_blogInfo;
var $_locale;
+ var $_tInfo;
function MobileAction( $actionInfo, $httpRequest )
{
@@ -17,6 +18,16 @@
$this->_blogInfo = $this->_getBlogInfo();
$this->_locale =& $this->_blogInfo->getLocale();
+
+ // detect the terminal that made the request...
+ $ti = new TerminalIdentifier();
+ $this->_tInfo = $ti->identify( $_SERVER );
+
+ // ...and quit the whole thing if there is no 'default' terminal
+ if( !$this->_tInfo ) {
+ die( "No terminal matched the request! Make sure that at least there is
+ one matching terminal definition." );
+ }
}
/**
Modified: plugins/trunk/mobile/class/action/mobiledefaultaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobiledefaultaction.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/action/mobiledefaultaction.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -13,7 +13,7 @@
function perform()
{
- $this->_view = new MobileDefaultView( $this->_blogInfo );
+ $this->_view = new MobileDefaultView( $this->_blogInfo, $this->_tInfo );
$this->setCommonData();
return( true );
Modified: plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php
===================================================================
--- plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/action/mobileviewarticleaction.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -14,7 +14,7 @@
$this->MobileAction( $actionInfo, $request );
$this->registerFieldValidator( "articleId", new IntegerValidator());
- $view = new MobileErrorView( $this->_blogInfo );
+ $view = new MobileErrorView( $this->_blogInfo, $this->_tInfo );
$view->setErrorMessage( $this->_locale->tr("error_invalid_blog_id" ));
$this->setValidationErrorView( $view );
}
@@ -28,14 +28,14 @@
// was it correct?
if( !$article ) {
- $this->_view = new MobileErrorView( $this->_blogInfo );
+ $this->_view = new MobileErrorView( $this->_blogInfo, $this->_tInfo );
$this->_view->setErrorMessage( $this->_locale->tr( "incorrect_blog_id" ));
$this->setCommonData();
return( false );
}
// if so, continue
- $this->_view = new MobileViewArticleView( $this->_blogInfo );
+ $this->_view = new MobileViewArticleView( $this->_blogInfo, $this->_tInfo );
$this->_view->setValue( "post", $article );
$this->setCommonData();
Modified: plugins/trunk/mobile/class/net/terminalidentifier.class.php
===================================================================
--- plugins/trunk/mobile/class/net/terminalidentifier.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/net/terminalidentifier.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -47,7 +47,6 @@
//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++;
Modified: plugins/trunk/mobile/class/net/terminalinfo.class.php
===================================================================
--- plugins/trunk/mobile/class/net/terminalinfo.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/net/terminalinfo.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -54,5 +54,10 @@
{
return( $this->_headers["HTTP_ACCEPT"] );
}
+
+ function getNumItemsPerPage()
+ {
+ return( $this->_def["itemsPerPage"] );
+ }
}
?>
\ No newline at end of file
Modified: plugins/trunk/mobile/class/view/mobiledefaultview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobiledefaultview.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/view/mobiledefaultview.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -8,9 +8,9 @@
var $_page;
- function MobileDefaultView( $blogInfo )
+ function MobileDefaultView( $blogInfo, $tInfo )
{
- $this->MobileView( $blogInfo, "main" );
+ $this->MobileView( $blogInfo, $tInfo, "main" );
}
function render()
@@ -22,7 +22,7 @@
$articles = new Articles();
$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(),
-1,
- MOBILE_PLOG_NUM_POSTS_PER_PAGE,
+ $this->_tInfo->getNumItemsPerPage(),
0,
POST_STATUS_PUBLISHED,
0,
@@ -32,7 +32,7 @@
// number of articles
$numPosts = $articles->getNumBlogArticles( $this->_blogInfo->getId(),
-1,
- MOBILE_PLOG_NUM_POSTS_PER_PAGE,
+ $this->_tInfo->getNumItemsPerPage(),
-1,
POST_STATUS_PUBLISHED,
0,
@@ -49,7 +49,7 @@
$this->_blogInfo->getId()."&page=",
$this->_page,
$numPosts,
- MOBILE_PLOG_NUM_POSTS_PER_PAGE );
+ $this->_tInfo->getNumItemsPerPage());
$this->setValue( "pager", $pager );
parent::render();
Modified: plugins/trunk/mobile/class/view/mobileerrorview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileerrorview.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/view/mobileerrorview.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -5,9 +5,9 @@
class MobileErrorView extends MobileView
{
- function MobileErrorView( $blogInfo )
+ function MobileErrorView( $blogInfo, $tInfo )
{
- $this->MobileView( $blogInfo, "error" );
+ $this->MobileView( $blogInfo, $tInfo, "error" );
}
}
?>
\ No newline at end of file
Modified: plugins/trunk/mobile/class/view/mobileview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileview.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/view/mobileview.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -5,27 +5,23 @@
class MobileView extends PluginTemplatedView
{
- function MobileView( $blogInfo, $templateName )
+ // used to store the terminal info
+ var $_tInfo;
+
+ function MobileView( $blogInfo, $tInfo, $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->_tInfo = $tInfo;
+ $terminalTemplate = $this->_tInfo->getContent()."/".$templateName;
+
$this->PluginTemplatedView( $blogInfo,
"mobile",
$terminalTemplate,
SMARTY_VIEW_CACHED_DISABLED );
// set the response type
- $this->setContentType( $info->getContentType());
+ $this->setContentType( $this->_tInfo->getContentType());
+ $this->setValue( "terminal", $this->_tInfo );
}
}
?>
\ No newline at end of file
Modified: plugins/trunk/mobile/class/view/mobileviewarticleview.class.php
===================================================================
--- plugins/trunk/mobile/class/view/mobileviewarticleview.class.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/class/view/mobileviewarticleview.class.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -9,9 +9,9 @@
var $_page;
- function MobileViewArticleView( $blogInfo )
+ function MobileViewArticleView( $blogInfo, $tInfo )
{
- $this->MobileView( $blogInfo, "postandcomments" );
+ $this->MobileView( $blogInfo, $tInfo, "postandcomments" );
$this->_page = $this->getCurrentPageFromRequest();
}
@@ -25,7 +25,7 @@
COMMENT_ORDER_OLDEST_FIRST,
COMMENT_STATUS_NONSPAM,
$this->_page,
- MOBILE_PLOG_NUM_COMMENTS_PER_PAGE );
+ $this->_tInfo->getNumItemsPerPage());
// get the number of comments
$numComments = $comments->getNumPostComments( $article->getId(),
COMMENT_STATUS_NONSPAM );
@@ -36,7 +36,7 @@
$this->_blogInfo->getId()."&articleId=".$article->getId()."&page=",
$this->_page,
$numComments,
- MOBILE_PLOG_NUM_COMMENTS_PER_PAGE );
+ $this->_tInfo->getNumItemsPerPage());
// pass everything to the templates
$this->setValue( "comments", $articleComments );
Modified: plugins/trunk/mobile/config/terminal.properties.php
===================================================================
--- plugins/trunk/mobile/config/terminal.properties.php 2005-06-05 12:29:54 UTC (rev 2168)
+++ plugins/trunk/mobile/config/terminal.properties.php 2005-06-05 13:19:08 UTC (rev 2169)
@@ -6,6 +6,22 @@
* Opera 6.20 / Nokia7610
* Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 7610;451) Opera 6.20 [en]
*
+ *
+ * How to add new terminal definitions: create an array with the following values:
+ *
+ * - regexp: The regular expression that will be applied agains the User-Agent
+ * string of the device. Make sure that it does not collide with any of the
+ * other regexps already defined.
+ * - content: The name of the template folder where terminal-specific templates can be found.
+ * The folder must exist and be readable in the plugins/mobile/templates/ folder.
+ * - content-type: The "Content-Type" header that will be sent to the device when sending a
+ * response
+ * - id: The unique identifier assigned to this definition.
+ * - itemsPerPage: The number of items per page that will be displayed (number of posts, number
+ * of comments, etc) This can be configured on a per-platform basis so that
+ * we can reduce the amount of items for WAP platforms, which usually have less
+ * memory available for pages.
+ * - desc: A generic string describing this platform.
*/
$config["terminals"] = Array (
@@ -14,30 +30,14 @@
"content" => "html-light",
"content-type" => "text/html",
"id" => "nokia",
- "desc" => "Nokia Symbian Browser" ),
+ "itemsPerPage" => 5,
+ "desc" => "Nokia Series60 Browser/Opera" ),
- Array( "regexp" => "/.*Safari.*/",
+ Array( "regexp" => "/.*/", // please keep this rule always as the last one
"content" => "html-light",
"content-type" => "text/html",
- "id" => "safari",
- "desc" => "Apple Safari/WebKit" ),
-
- Array( "regexp" => "/.*Opera.*/",
- "content" => "html-light",
- "content-type" => "text/html",
- "id" => "safari",
- "desc" => "Apple Safari/WebKit" ),
-
- Array( "regexp" => "/.*Mozilla.*/",
- "content" => "html-light",
- "content-type" => "text/html",
- "id" => "mozilla",
- "desc" => "Mozilla/Gecko" ),
-
- Array( "regexp" => "/.*/",
- "content" => "default",
- "content-type" => "text/html",
"id" => "default",
+ "itemsPerPage" => 5,
"desc" => "Any other browser" )
);
?>
\ No newline at end of file
More information about the pLog-svn
mailing list