[Solar-svn] Revision 3282

pmjones at solarphp.com pmjones at solarphp.com
Wed Jul 30 09:57:27 CDT 2008


Solar_View_Helper_(Anchor|AnchorImage): [REF] Refactor to use the href() helper for href values.




Modified: trunk/Solar/View/Helper/Anchor.php
===================================================================
--- trunk/Solar/View/Helper/Anchor.php	2008-07-30 14:57:00 UTC (rev 3281)
+++ trunk/Solar/View/Helper/Anchor.php	2008-07-30 14:57:27 UTC (rev 3282)
@@ -18,7 +18,7 @@
 {
     /**
      * 
-     * Returns a anchor href tag.
+     * Returns an anchor tag or anchor href.
      * 
      * If the $text link text is empty, will return only the href
      * value (no attributes) instead of an <a href="">...</a> tag.
@@ -34,19 +34,14 @@
      */
     public function anchor($spec, $text = null, $attribs = array())
     {
-        if ($spec instanceof Solar_Uri) {
-            // fetch the full href, not just the path/query/fragment
-            $href = $spec->get(true);
-        } else {
-            $href = $spec;
-        }
+        // get an escaped href value
+        $href = $this->_view->href($spec);
         
         if (empty($text)) {
-            return $this->_view->escape($href);
+            return $href;
         } else {
             settype($attribs, 'array');
             unset($attribs['href']);
-            $href = $this->_view->escape($href);
             $text = $this->_view->getText($text);
             $attr = $this->_view->attribs($attribs);
             return "<a href=\"$href\"$attr>$text</a>";

Modified: trunk/Solar/View/Helper/AnchorImage.php
===================================================================
--- trunk/Solar/View/Helper/AnchorImage.php	2008-07-30 14:57:00 UTC (rev 3281)
+++ trunk/Solar/View/Helper/AnchorImage.php	2008-07-30 14:57:27 UTC (rev 3282)
@@ -36,16 +36,9 @@
     public function anchorImage($spec, $src, $a_attribs = array(),
         $img_attribs = array())
     {
-        if ($spec instanceof Solar_Uri) {
-            // fetch the full href, not just the path/query/fragment
-            $href = $spec->get(true);
-        } else {
-            $href = $spec;
-        }
+        // get an escaped href value
+        $href = $this->_view->href($spec);
         
-        // escape the anchor href itself
-        $href = $this->_view->escape($href);
-        
         // get the <img /> tag
         $img = $this->_view->image($src, $img_attribs);
         




More information about the Solar-svn mailing list