Clean up mobile controller script, move html to templates
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 16 Nov 2010 06:07:37 +0000 (01:07 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 16 Nov 2010 06:07:37 +0000 (01:07 -0500)
kronolith/mobile.php
kronolith/templates/mobile/day.html.php [new file with mode: 0644]
kronolith/templates/mobile/event.html.php [new file with mode: 0644]
kronolith/templates/mobile/head.html.php [new file with mode: 0644]
kronolith/templates/mobile/month.html.php [new file with mode: 0644]
kronolith/templates/mobile/summary.html.php [new file with mode: 0644]

index 328db70..97390e9 100644 (file)
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @pacakge Kronolith
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Kronolith
  */
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
-//@TODO: Will eventually need a separate Horde::includeScriptFiles for mobile
-//       apps to avoid outputing all the prototype dependent stuff.
-//
-//Horde::addScriptFile('http://code.jquery.com/jquery-1.4.3.min.js', 'horde', array('external' => true));
-//Horde::addScriptFile('http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js', 'horde', array('external' => true));
-
-// Probably want to use a customized Kronolith::header() method as well instead
-// of including a common-header-mobile file.
-
 $title = _("My Calendar");
-require $registry->get('templates', 'horde') . '/common-header-mobile.inc';
-$today = new Horde_Date($_SERVER['REQUEST_TIME']);
-?>
-  <?php Horde::addInlineScript(Kronolith::includeJSVars());?>
-  <script type="text/javascript" src="<?php echo $registry->get('jsuri', 'horde') ?>/date/en-US.js"></script>
-  <script type="text/javascript" src="<?php echo $registry->get('jsuri', 'horde') ?>/date/date.js"></script>
-  <script type="text/javascript" src="<?php echo $registry->get('jsuri', 'kronolith') ?>/kronolithmobile.js"></script>
-  <link href="<?php echo $registry->get('themesuri');?>/mobile.css" rel="stylesheet" type="text/css" />
-</head>
-<body>
-
-<!-- Initial, Day view -->
-<div data-role="page" id="dayview">
-  <div data-role="header">
-   <h1>My Calendar:Day</h1>
-   <a class="ui-btn-left" href="<?php echo Horde::getServiceLink('portal', 'horde')?>"><?php echo _("Home")?></a>
-   <a rel="external" class="ui-btn-right" href="<?php echo Horde::getServiceLink('logout', 'horde')?>"><?php echo _("Logout")?></a>
-   <div class="ui-bar-b kronolithDayHeader"><a href="#" class="kronolithPrevDay" data-icon="arrow-l" data-iconpos="notext"><?php echo _("Previous")?></a><span class="kronolithDayDate"></span><a href="#" data-icon="arrow-r" data-iconpos="notext" class="kronolithNextDay"><?php echo _("Next")?></a></div>
-  </div>
-  <div data-role="content"></div>
-  <div data-role="footer" data-position="fixed">
-   <div data-role="navbar">
-    <ul>
-     <li><a href="#" class="ui-btn-active">Day</a></li>
-     <li><a href="#monthview">Month</a></li>
-     <li><a href="#overview">Summary</a></li>
-    </ul>
-   </div>
-  </div>
-</div>
-
-<!-- Single Event -->
-<div data-role="page" id="eventview">
-  <div data-role="header" data-theme="b"><h1>Event</h1></div>
-  <div data-role="content" class="ui-body"></div>
-  <div data-role="footer"></div>
-</div>
 
-<!-- Overview Page -->
-<div data-role="page" id="overview">
-  <div data-role="header"><h1>My Calendar: Overview</h1></div>
-  <div data-role="content" class="ui-body"></div>
-  <div data-role="footer" data-position="fixed">
-   <div data-role="navbar">
-    <ul>
-     <li><a href="#dayview">Day</a></li>
-     <li><a href="#monthview">Month</a></li>
-     <li><a href="#" class="ui-btn-active">Summary</a></li>
-    </ul>
-   </div>
-  </div>
-</div>
+$view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/mobile'));
+$view->today = new Horde_Date($_SERVER['REQUEST_TIME']);
+$view->registry = $registry;
+$view->portal = Horde::getServiceLink('portal', 'horde')->setRaw(false);
+$view->logout = Horde::getServiceLink('logout')->setRaw(false);
 
-<!-- Month View -->
-<div data-role="page" id="monthview" class="monthview">
- <div data-role="header">
-   <h1>Month</h1>
-   <a class="ui-btn-left" href="<?php echo Horde::getServiceLink('portal', 'horde')?>"><?php echo _("Home")?></a>
-   <a rel="external" class="ui-btn-right" href="<?php echo Horde::getServiceLink('logout', 'horde')?>"><?php echo _("Logout")?></a>
- </div>
- <div data-role="content" class="ui-body" id="monthcontent">
-  <div id="kronolithMinical" class="kronolithMinical">
-    <table>
-    <caption>
-      <a href="#" id="kronolithMinicalPrev" title="<?php echo _("Previous month") ?>">&lt;</a>
-      <a href="#" id="kronolithMinicalNext" title="<?php echo _("Next month") ?>">&gt;</a>
-      <span id="kronolithMinicalDate"><?php echo $today->format('F Y') ?></span>
-    </caption>
-
-    <thead>
-      <tr>
-        <?php for ($i = $prefs->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++): ?>
-        <th title="<?php echo Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1))) ?>"><?php echo substr(Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1))), 0, 1) ?></th>
-        <?php endfor; ?>
-      </tr>
-    </thead>
-
-    <tbody><tr><td>test</td></tr></tbody>
-    </table>
-  </div>
-
- </div>
-  <div data-role="footer" data-position="fixed">
-   <div data-role="navbar">
-    <ul>
-     <li><a href="#dayview">Day</a></li>
-     <li><a href="#" class="ui-btn-active">Month</a></li>
-     <li><a href="#overview">Summary</a></li>
-    </ul>
-   </div>
-  </div>
-</div>
-
-<?php $registry->get('templates', 'horde') . '/common-footer-mobile.inc';
+require $registry->get('templates', 'horde') . '/common-header-mobile.inc';
+echo $view->render('head');
+echo $view->render('day');
+echo $view->render('event');
+echo $view->render('month');
+echo $view->render('summary');
+$registry->get('templates', 'horde') . '/common-footer-mobile.inc';
diff --git a/kronolith/templates/mobile/day.html.php b/kronolith/templates/mobile/day.html.php
new file mode 100644 (file)
index 0000000..f8f2800
--- /dev/null
@@ -0,0 +1,21 @@
+<div data-role="page" id="dayview">
+  <div data-role="header">
+   <h1><?php echo _("Day")?></h1>
+   <a class="ui-btn-left" href="<?php echo $this->portal ?>"><?php echo _("Portal")?></a>
+   <a rel="external" class="ui-btn-right" href="<?php echo $this->logout?>"><?php echo _("Logout")?></a>
+   <div class="ui-bar-b kronolithDayHeader">
+    <a href="#" class="kronolithPrevDay" data-icon="arrow-l" data-iconpos="notext"><?php echo _("Previous")?></a>
+    <span class="kronolithDayDate"></span>
+    <a href="#" data-icon="arrow-r" data-iconpos="notext" class="kronolithNextDay"><?php echo _("Next")?></a></div>
+  </div>
+  <div data-role="content"></div>
+  <div data-role="footer" data-position="fixed">
+   <div data-role="navbar">
+    <ul>
+     <li><a href="#" class="ui-btn-active">Day</a></li>
+     <li><a href="#monthview">Month</a></li>
+     <li><a href="#overview">Summary</a></li>
+    </ul>
+   </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/kronolith/templates/mobile/event.html.php b/kronolith/templates/mobile/event.html.php
new file mode 100644 (file)
index 0000000..8983673
--- /dev/null
@@ -0,0 +1,5 @@
+<div data-role="page" id="eventview">
+  <div data-role="header" data-theme="b"><h1><?php echo ("Event")?></h1></div>
+  <div data-role="content" class="ui-body"></div>
+  <div data-role="footer"></div>
+</div>
\ No newline at end of file
diff --git a/kronolith/templates/mobile/head.html.php b/kronolith/templates/mobile/head.html.php
new file mode 100644 (file)
index 0000000..6671e12
--- /dev/null
@@ -0,0 +1,7 @@
+  <?php Horde::addInlineScript(Kronolith::includeJSVars());?>
+  <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'horde') ?>/date/en-US.js"></script>
+  <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'horde') ?>/date/date.js"></script>
+  <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'kronolith') ?>/kronolithmobile.js"></script>
+  <link href="<?php echo $this->registry->get('themesuri');?>/mobile.css" rel="stylesheet" type="text/css" />
+</head>
+<body>
\ No newline at end of file
diff --git a/kronolith/templates/mobile/month.html.php b/kronolith/templates/mobile/month.html.php
new file mode 100644 (file)
index 0000000..41fd5d0
--- /dev/null
@@ -0,0 +1,36 @@
+<!-- Month View -->
+<div data-role="page" id="monthview" class="monthview">
+ <div data-role="header">
+   <h1>Month</h1>
+   <a class="ui-btn-left" href="<?php echo $this->portal?>"><?php echo _("Home")?></a>
+   <a rel="external" class="ui-btn-right" href="<?php echo $this->logout?>"><?php echo _("Logout")?></a>
+ </div>
+ <div data-role="content" class="ui-body" id="monthcontent">
+  <div id="kronolithMinical" class="kronolithMinical">
+    <table>
+    <caption>
+      <a href="#" id="kronolithMinicalPrev" title="<?php echo _("Previous month") ?>">&lt;</a>
+      <a href="#" id="kronolithMinicalNext" title="<?php echo _("Next month") ?>">&gt;</a>
+      <span id="kronolithMinicalDate"><?php echo $this->today->format('F Y') ?></span>
+    </caption>
+    <thead>
+      <tr>
+        <?php for ($i = $GLOBALS['prefs']->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++): ?>
+        <th title="<?php echo Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1))) ?>"><?php echo substr(Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1))), 0, 1) ?></th>
+        <?php endfor; ?>
+      </tr>
+    </thead>
+    <tbody><tr><td></td></tr></tbody>
+    </table>
+  </div>
+ </div>
+  <div data-role="footer" data-position="fixed">
+   <div data-role="navbar">
+    <ul>
+     <li><a href="#dayview"><?php echo _("Day")?></a></li>
+     <li><a href="#" class="ui-btn-active"><?php echo _("Month")?></a></li>
+     <li><a href="#overview"><?php echo _("Summary")?></a></li>
+    </ul>
+   </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/kronolith/templates/mobile/summary.html.php b/kronolith/templates/mobile/summary.html.php
new file mode 100644 (file)
index 0000000..f754248
--- /dev/null
@@ -0,0 +1,13 @@
+<div data-role="page" id="overview">
+  <div data-role="header"><h1><?php echo _("Summary")?></h1></div>
+  <div data-role="content" class="ui-body"></div>
+  <div data-role="footer" data-position="fixed">
+   <div data-role="navbar">
+    <ul>
+     <li><a href="#dayview"><?php echo _("Day")?></a></li>
+     <li><a href="#monthview"><?php echo _("Month")?></a></li>
+     <li><a href="#" class="ui-btn-active"><?php echo _("Summary")?></a></li>
+    </ul>
+   </div>
+  </div>
+</div>
\ No newline at end of file