[Solar-svn] Revision 3279

pmjones at solarphp.com pmjones at solarphp.com
Wed Jul 30 09:51:20 CDT 2008


Solar_View_Helper_Href: [NEW] Helper to work with 'href' and 'src' values directly, instead of via Solar_View_Helper_Anchor.  Thanks, Jeff Moore, for the report that led to this.


Added: trunk/Solar/View/Helper/Href.php
===================================================================
--- trunk/Solar/View/Helper/Href.php	                        (rev 0)
+++ trunk/Solar/View/Helper/Href.php	2008-07-30 14:51:20 UTC (rev 3279)
@@ -0,0 +1,24 @@
+<?php
+class Solar_View_Helper_Href extends Solar_View_Helper
+{
+    /**
+     * 
+     * Returns an escaped href or src attribute value for a generic URI.
+     * 
+     * @param Solar_Uri|string $spec The href or src specification.
+     * 
+     * @return string
+     * 
+     */
+    public function href($spec)
+    {
+        if ($spec instanceof Solar_Uri) {
+            // fetch the full href, not just the path/query/fragment
+            $href = $spec->get(true);
+        } else {
+            $href = $spec;
+        }
+        
+        return $this->_view->escape($href);
+    }
+}
\ No newline at end of file




More information about the Solar-svn mailing list