Move initial twitter client layout to a Horde_View
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 7 Dec 2010 16:48:25 +0000 (11:48 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 8 Dec 2010 02:56:28 +0000 (21:56 -0500)
horde/lib/Block/twitter_timeline.php
horde/templates/block/twitter-layout.html.php [new file with mode: 0644]

index 63ab2b9..175ca69 100644 (file)
@@ -161,17 +161,16 @@ EOT;
         $latestStatus = htmlspecialchars($this->_profile->status->text);
 
         /* Build the UI */
-        $html = '<div style="padding: 0 8px 8px">'
-           . '<div class="fbgreybox"><textarea rows="2" style="width:98%;margin-top:4px;margin-bottom:4px;" type="text" id="' . $instance . '_newStatus" name="' . $instance . '_newStatus">' . $defaultText . '</textarea>'
-           . '<a class="button" onclick="Horde[\'twitter' . $instance . '\'].updateStatus($F(\'' . $instance . '_newStatus\'));" href="#">' . _("Tweet") . '</a><span id="' . $instance . '_counter" style="color: rgb(204, 204, 204);margin-left:6px;">140</span>  <span id="' . $instance . '_inReplyTo"></span>'
-           . Horde::img('loading.gif', '', array('id' => $instance . '_loading', 'style' => 'display:none;'));
-        $html .= '<div id="currentStatus" class="" style="margin: 10px;"><strong>' . _("Latest") . '</strong> ' . $latestStatus . ' - <span class="fbstreaminfo">' . Horde_Date_Utils::relativeDateTime(strtotime($this->_profile->status->created_at), $GLOBALS['prefs']->getValue('date_format'), ($GLOBALS['prefs']->getValue('twentyFour') ? "%H:%M" : "%I:%M %P")) . '</span></div></div>';
-        $html .= '<div style="height:' . (empty($this->_params['height']) ? 350 : $this->_params['height']) . 'px;overflow-y:auto;" id="' . $instance . '_twitter_body">';
-        $html .= '</div>';
-        $html .= '<div class="hordeSmGetmore"><input type="button" class="button" id="' . $instance . '_getmore" value="' . _("Get More") . '"></div>';
-        $html .= '</div>';
-
-        return $html;
+        $view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/block'));
+        $view->addHelper('Tag');
+        $view->instance = $instance;
+        $view->defaultText = $defaultText;
+        $view->loadingImg = Horde::img('loading.gif', '', array('id' => $instance . '_loading', 'style' => 'display:none;'));
+        $view->latestStatus = $latestStatus;
+        $view->latestDate = Horde_Date_Utils::relativeDateTime(strtotime($this->_profile->status->created_at), $GLOBALS['prefs']->getValue('date_format'), ($GLOBALS['prefs']->getValue('twentyFour') ? "%H:%M" : "%I:%M %P"));
+        $view->bodyHeight = empty($this->_params['height']) ? 350 : $this->_params['height'];
+
+        return $view->render('twitter-layout');
     }
 
     private function _getTwitterObject()
diff --git a/horde/templates/block/twitter-layout.html.php b/horde/templates/block/twitter-layout.html.php
new file mode 100644 (file)
index 0000000..5891226
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Twitter client initial layout
+ * Uses:
+ *   ->instance
+ *   ->defaultText
+ *   ->loadingImg
+ *   ->latestStatus
+ *   ->latestDate
+ *   ->bodyHeight
+ */
+?>
+<div style="padding: 0 8px 8px">
+ <div class="fbgreybox">
+   <textarea rows="2" style="width:98%;margin-top:4px;margin-bottom:4px;" type="text" id="<?php echo $this->instance ?>_newStatus" name="<?php echo $this->instance ?>_newStatus"><?php echo $this->defaultText ?></textarea> <a class="button" onclick="Horde['twitter<?php echo $this->instance ?>'].updateStatus($F('<?php echo $this->instance ?>_newStatus'));" href="#"><?php echo _("Tweet") ?></a>
+   <span id="<?php echo $this->instance ?>_counter" style="color:rgb(204, 204, 204); margin-left:6px;">140</span>
+   <span id="<?php echo $this->instance ?>_inReplyTo"></span>
+   <?php echo $this->loadingImg ?>
+   <div id="currentStatus" class="" style="margin:10px;"><strong>'<?php echo _("Latest") ?></strong><?php echo $this->latestStatus ?> - <span class="fbstreaminfo"><?php echo $this->latestDate ?></span></div>
+ </div>
+ <div style="height:<?php echo $this->bodyHeight ?>px; overflow-y:auto;" id="<?php echo $this->instance ?>_twitter_body"></div>
+ <div class="hordeSmGetmore"><input type="button" class="button" id="<?php echo $this->instance ?>_getmore" value="<?php echo _("Get More") ?>"></div>
+</div>
\ No newline at end of file