Changeset 165 for trunk/trax/vendor/trax/action_view
- Timestamp:
- 03/09/06 12:50:58 (6 years ago)
- Files:
-
- 1 modified
-
trunk/trax/vendor/trax/action_view/helpers.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_view/helpers.php
r160 r165 30 30 31 31 /** 32 * 33 * @package PHPonTrax 32 * Basic helper functions 34 33 */ 35 34 class Helpers { … … 40 39 function __construct($object_name = null, $attribute_name = null) { 41 40 if(substr($object_name, -2) == "[]") { 42 $auto_index = true; 43 } 41 $auto_index = true; 42 } else { 43 $auto_index = false; 44 } 44 45 $this->auto_index = false; 45 46 $this->object_name = str_replace("[]", "", $object_name); … … 82 83 83 84 /** 84 * 85 * Convert array of tag attribute names and values to string 86 * 87 * @param string[] $options 88 * @return string 85 89 */ 86 90 protected function tag_options($options) { … … 92 96 sort($html); 93 97 $html = implode(" ", $html); 94 } 95 return $html; 96 } 97 98 /** 99 * 98 return $html; 99 } else { 100 return ''; 101 } 102 } 103 104 /** 105 * Convert selected attributes to proper XML boolean form 106 * 107 * @uses boolean_attribute() 108 * @param string[] $options 109 * @return string[] Input argument with selected attributes converted 110 * to proper XML boolean form 100 111 */ 101 112 protected function convert_options($options = array()) { 102 113 foreach(array('disabled', 'readonly', 'multiple') as $a) { 103 $this->boolean_attribute( &$options, $a);114 $this->boolean_attribute($options, $a); 104 115 } 105 116 return $options; … … 107 118 108 119 /** 109 * 120 * Convert an attribute to proper XML boolean form 121 * 122 * @param string[] $options 123 * @param string $attribute 124 * @return void Contents of $options have been converted 110 125 */ 111 126 protected function boolean_attribute(&$options, $attribute) { … … 118 133 119 134 /** 120 * 121 * Returns a CDATA section for the given +content+. CDATA sections 122 * are used to escape blocks of text containing characters which would 123 * otherwise be recognized as markup. CDATA sections begin with the string 124 * <tt><![CDATA[</tt> and end with (and may not contain) the string 125 * <tt>]]></tt>. 135 * Wrap CDATA begin and end tags around argument 136 * 137 * Returns a CDATA section for the given +content+. CDATA sections 138 * are used to escape blocks of text containing characters which would 139 * otherwise be recognized as markup. CDATA sections begin with the string 140 * <tt><![CDATA[</tt> and end with (and may not contain) the string 141 * <tt>]]></tt>. 142 * @param string $content Content to wrap 143 * @return string Wrapped argument 126 144 */ 127 145 function cdata_section($content) { … … 136 154 * Example: tag("input", array("type" => "text")); 137 155 * <input type="text" /> 156 * @uses tag_options() 157 * @param string $name Tag name 158 * @param string[] $options Tag attributes to apply 159 * @param boolean $open 160 * <ul> 161 * <li>true => make opening tag (end with '>')</li> 162 * <li>false => make self-terminating tag (end with ' \>')</li> 163 * </ul> 164 * @return string The tag, followed by "\n" 138 165 */ 139 166 function tag($name, $options = array(), $open = false) { … … 149 176 * Example: content_tag("p", "Hello world!"); 150 177 * Result: <p>Hello world!</p> 151 * Example: content_tag("div", content_tag("p", "Hello world!"), array("class" => "strong")) => 178 * Example: content_tag("div", content_tag("p", "Hello world!"), 179 * array("class" => "strong")) => 152 180 * Result:<div class="strong"><p>Hello world!</p></div> 181 * @uses tag_options() 182 * @param string $name Tag to wrap around $content 183 * @param string $content Text to put between tags 184 * @param string[] $options Tag attributes to apply 185 * @return string Text wrapped with tag and attributes, 186 * followed by "\n" 153 187 */ 154 188 function content_tag($name, $content, $options = array()) { 155 $html .= "<$name ";189 $html = "<$name "; 156 190 $html .= $this->tag_options($options); 157 191 $html .= ">$content</$name>"; … … 169 203 170 204 /** 171 * Avialble functions for use in views 205 * Create a Helpers object and call its content_tag() method 206 * 207 * @see Helpers::content_tag() 208 * @param string $name Tag to wrap around $content 209 * @param string $content Text to put between tags 210 * @param string[] $options Tag attributes to apply 211 * @return string Text wrapped with tag and attributes, 212 * followed by "\n" 172 213 */ 173 214 function content_tag() { … … 177 218 } 178 219 220 /** 221 * Create a Helpers object and call its tag() method 222 * 223 * @see Helpers::tag() 224 * @param string $name Tag name 225 * @param string[] $options Tag attributes to apply 226 * @param boolean $open 227 * <ul> 228 * <li>true => make opening tag (end with '>')</li> 229 * <li>false => make self-terminating tag (end with ' \>')</li> 230 * </ul> 231 * @return string The tag, followed by "\n" 232 */ 179 233 function tag() { 180 234 $helper = new Helpers(); … … 183 237 } 184 238 239 /** 240 * Create a Helpers object and call its cdata_section() method 241 */ 185 242 function cdata_section() { 186 243 $helper = new Helpers(); … … 189 246 } 190 247 248 // -- set Emacs parameters -- 249 // Local variables: 250 // tab-width: 4 251 // c-basic-offset: 4 252 // c-hanging-comment-ender-p: nil 253 // indent-tabs-mode: nil 254 // End: 191 255 ?>
