| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4 // +----------------------------------------------------------------------+ 5 // | Akelos Framework - http://www.akelos.org | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez | 8 // | Released under the GNU Lesser General Public License, see LICENSE.txt| 9 // +----------------------------------------------------------------------+ 10 11 /** 12 * @package ActionView 13 * @subpackage Helpers 14 * @author Jose Salavert <salavert a.t akelos c.om> 15 * @author Bermi Ferrer <bermi a.t akelos c.om> 16 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org 17 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html> 18 */ 19 20 require_once(AK_VENDOR_DIR.DS.'phputf8'.DS.'utf8.php'); 21 22 defined('AK_VALID_URL_CHARS_REGEX') ? null : define('AK_VALID_URL_CHARS_REGEX','A-Z-a-z0-9:=?&\/\.\-\\%~#_;,+'); 23 define('AK_AUTO_LINK_REGEX','/ 24 ( # leading text 25 <\w+.*?>| # leading HTML tag, or 26 [^=!:\'"\/]| # leading punctuation, or 27 ^ # beginning of line 28 ) 29 ( 30 (?:https?:\/\/)| # protocol spec, or 31 (?:www\.) # www.* 32 ) 33 ( 34 [-\w]+ # subdomain or domain 35 (?:\.[-\w]+)* # remaining subdomains or domain 36 (?::\d+)? # port 37 (?:\/(?:(?:[~\w\+%-]|(?:[,.;:][^\s$]))+)?)* # path 38 (?:\?[\w\+%&=.;-]+)? # query string 39 (?:\#[\w\-]*)? # trailing anchor 40 ) 41 ([[:punct:]]|\s|<|$) # trailing text 42 /x'); 43 44 /** 45 * Provides a set of methods for working with text strings that can help unburden 46 * the level of inline AkelosFramework code in the templates. In the example 47 * below we iterate over a collection of posts provided to the template and print 48 * each title after making sure it doesn't run longer than 20 characters: 49 * {loop posts} 50 * Title: <?= $text_helper->truncate($post->title, 20) ?> 51 * {end} 52 */ 53 class TextHelper extends AkObject 54 { 55 56 function setController(&$controller) 57 { 58 $this->_controller =& $controller; 59 } 60 61 function TextHelper() 62 { 63 TextHelper::cycle(array('reset'=>'all')); 64 } 65 66 67 /** 68 * Truncates "$text" to the length of "length" and replaces the last three 69 * characters with the "$truncate_string" if the "$text" is longer than 70 * "$length" and the last characters will be replaced with the +truncate_string+. 71 * If +break+ is specified and if it's present in +text+ and if its position is 72 * lesser than +length+, then the truncated +text+ will be limited to +break+. 73 * 74 */ 75 function truncate($text, $length = 30, $truncate_string = '...', $break = false) 76 { 77 if(utf8_strlen($text) <= $length){ 78 return $text; 79 } 80 81 if (false !== ($breakpoint = (empty($break) ? $length : utf8_strpos($text, $break))) && ($breakpoint >= utf8_strlen($truncate_string))) 82 { 83 if ($breakpoint > $length) 84 { 85 $breakpoint = $length; 86 } 87 return utf8_substr($text, 0, $breakpoint - utf8_strlen($truncate_string)) . $truncate_string; 88 } 89 return $text; 90 } 91 92 /** 93 * Highlights the string or array of strings "$phrase" where it is found in 94 * the "$text" by surrounding it like 95 * <strong class="highlight">I'm a highlight phrase</strong>. 96 * 97 * The highlighter can be specialized by passing "$highlighter" as string 98 * with \1 where the phrase is supposed to be inserted. 99 * 100 * Note: The "$phrase" is sanitized with preg_quote before use. 101 * 102 * Examples: 103 * 104 * <?=$text_helper->highlight('I am highlighting the phrase','highlighting');?> 105 * //outputs: I am <strong class="highlight">highlighting</strong> the phrase 106 * 107 * <?=$text_helper->highlight('I am highlighting the phrase', 108 * array('highlighting','the')?> 109 * //outputs: I am <strong class="highlight">highlighting</strong> <strong class="highlight">the</strong> phrase 110 * 111 */ 112 function highlight($text, $phrase, $highlighter = '<strong class="highlight">\1</strong>') 113 { 114 $phrase = is_array($phrase) ? join('|',array_map('preg_quote',$phrase)) : preg_quote($phrase); 115 return !empty($phrase) ? preg_replace('/('.$phrase.')/iu', $highlighter, $text) : $text; 116 } 117 118 /** 119 * Extracts an excerpt from the "$text" surrounding the "$phrase" with a 120 * number of characters on each side determined by "$radius". If the phrase 121 * isn't found, '' is returned. 122 * 123 * Example: 124 * 125 * <?=$text_helper->excerpt("hello my world", "my", 3);?> 126 * //outputs: ...lo my wo... 127 * 128 */ 129 function excerpt($text, $phrase, $radius = 100, $excerpt_string = '...') 130 { 131 if(empty($text)){ 132 return $text; 133 } 134 $phrase = preg_quote($phrase); 135 136 if(preg_match('/('.$phrase.')/iu',$text, $found)){ 137 $found_pos = utf8_strpos($text, $found[0]); 138 $start_pos = max($found_pos - $radius, 0); 139 $end_pos = min($found_pos + utf8_strlen($phrase) + $radius, utf8_strlen($text)); 140 141 $prefix = $start_pos > 0 ? $excerpt_string : ''; 142 $postfix = $end_pos < utf8_strlen($text) ? $excerpt_string : ''; 143 144 return $prefix.trim(utf8_substr($text,$start_pos,$end_pos-$start_pos)).$postfix; 145 } 146 return ''; 147 } 148 149 /** 150 * Attempts to pluralize the "$singular" word unless "$count" is 1. 151 */ 152 function pluralize($count, $singular, $plural = null) 153 { 154 if ($count==1) { 155 return $singular; 156 }elseif (!empty($plural)){ 157 return $plural; 158 }else{ 159 return AkInflector::conditionalPlural($count, $singular); 160 } 161 } 162 163 /** 164 * Word wrap long lines to line_width. 165 */ 166 function word_wrap($text, $line_width = 80, $break = "\n") 167 { 168 // No need to use an UTF-8 wordwrap function as we are using the default cut character. 169 return trim(wordwrap($text, $line_width, $break)); 170 } 171 172 /** 173 * Like word wrap but allows defining text indenting and boby indenting 174 */ 175 function format($text, $options = array()) 176 { 177 $default_options = array( 178 'columns' => 72, 179 'first_indent' => 4, 180 'body_indent' => 0, 181 'cut_words' => false 182 ); 183 184 $options = array_merge($default_options, $options); 185 186 $text = empty($text) && !empty($options['text']) ? $options['text'] : $text; 187 if(empty($text)) { 188 return ''; 189 } 190 $text = str_replace(array("\r","\t",' ',' '),array("\n",' ',' ',' '),$text); 191 $formated_text = ''; 192 foreach(explode("\n",$text."\n") as $paragraph) { 193 if(empty($paragraph)) { 194 continue; 195 } 196 $paragraph = ($options['first_indent'] > 0 ? str_repeat(' ',$options['first_indent']) : '' ).$paragraph; 197 $paragraph = wordwrap($paragraph, $options['columns']-$options['body_indent'], "\n", $options['cut_words']); 198 199 if($options['body_indent'] > 0) { 200 $paragraph = preg_replace('!^!m',str_repeat(' ',$options['body_indent']),$paragraph); 201 } 202 $formated_text .= $paragraph . "\n\n"; 203 } 204 return $formated_text; 205 } 206 207 208 /** 209 * Returns the "$text" with all the Textile codes turned into HTML-tags. 210 */ 211 function textilize($text, $options = array()) 212 { 213 $default_options = array( 214 'extended_mode' => true, 215 'allow_images' => true, 216 'rel' => '', 217 ); 218 $options = array_merge($default_options, $options); 219 require_once(AK_VENDOR_DIR.DS.'TextParsers'.DS.'Textile.php'); 220 if (!empty($text)) { 221 $Textile = new Textile(); 222 $text = trim($Textile->TextileThis($text, !$options['extended_mode'], '', !$options['allow_images'], true, $options['rel'])); 223 } 224 return $text; 225 } 226 227 /** 228 * Returns the "$text" with all the Textile codes turned into HTML-tags, but 229 * without the regular bounding <p> tag. 230 */ 231 function textilize_without_paragraph($text, $options = array()) 232 { 233 return preg_replace('/^<p([A-Za-z0-9& ;\-=",\/:\.\']+)?>(.+)<\/p>$/u','\2', TextHelper::textilize($text, $options)); 234 } 235 236 /** 237 * Returns "$text" transformed into HTML using very simple formatting rules 238 * Surrounds paragraphs with <tt><p></tt> tags, and converts line 239 * breaks into <tt><br /></tt> Two consecutive newlines(<tt>\n\n</tt>) 240 * are considered as a paragraph, one newline (<tt>\n</tt>) is considered a 241 * linebreak, three or more consecutive newlines are turned into two newlines 242 */ 243 function simple_format($text) 244 { 245 $rules = array( 246 '/(\\r\\n|\\r)/'=> "\n", 247 '/(\\n\\n+)/' => "\n\n", 248 '/(\\n\\n)/' => "</p><p>", 249 '/([^\\n])(\\n)([^\\n])/' => "\1\2<br />\3" 250 ); 251 $text = preg_replace(array_keys($rules), array_values($rules), $text); 252 $text = TagHelper::content_tag('p',$text); 253 return str_replace(array('<p></p>','</p><p>'),array('<br /><br />',"</p>\n<p>"),$text); 254 } 255 256 /** 257 * Turns all urls and email addresses into clickable links. The "$link" 258 * parameter can limit what should be linked. 259 * 260 * Options are "all" (default), "email_addresses", and "urls". 261 * 262 * Example: 263 * 264 * <?=$text_helper->auto_link("Go to http://www.akelos.org and say hello to bermi@example.com");?> 265 * //outputs: Go to <a href="http://www.akelos.org">http://www.akelos.org</a> and 266 * say hello to <a href="mailto:example.com">bermi@example.com</a> 267 * 268 */ 269 function auto_link($text, $link = 'all', $href_options = array(), $email_link_options = array()) 270 { 271 if (empty($text)){ 272 return ''; 273 } 274 275 switch ($link) { 276 case 'all': 277 return TextHelper::auto_link_urls( 278 TextHelper::auto_link_email_addresses($text, $email_link_options), 279 $href_options); 280 break; 281 282 case 'email_addresses': 283 return TextHelper::auto_link_email_addresses($text, $email_link_options); 284 break; 285 286 case 'urls': 287 return TextHelper::auto_link_urls($text, $href_options); 288 break; 289 290 default: 291 return TextHelper::auto_link($text, 'all', $href_options); 292 break; 293 } 294 } 295 296 297 /** 298 * Strips all HTML tags from the input, including comments. 299 * 300 * Returns the tag free text. 301 */ 302 function strip_tags($html) 303 { 304 return strip_tags($html); 305 } 306 307 /** 308 * Turns all links into words, like "<a href="something">else</a>" to "else". 309 */ 310 function strip_links($text) 311 { 312 return TextHelper::strip_selected_tags($text, 'a'); 313 } 314 315 /** 316 * Turns all email addresses into clickable links. You can provide an options 317 * array in order to generate links using UrlHelper::mail_to() 318 * 319 * Example: 320 * $text_helper->auto_link_email_addresses($post->body); 321 */ 322 function auto_link_email_addresses($text, $email_options = array()) 323 { 324 if(empty($email_options)){ 325 return preg_replace('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/', 326 "<a href='mailto:$1'>$1</a>",$text); 327 }elseif(preg_match_all('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/',$text, $match)){ 328 $emails = $match[0]; 329 foreach ($emails as $email){ 330 $encoded_emails[] = UrlHelper::mail_to($email, null, $email_options); 331 } 332 $text = str_replace($emails,$encoded_emails,$text); 333 } 334 return $text; 335 } 336 337 /** 338 * Works like PHP function strip_tags, but it only removes selected tags. 339 * Example: 340 * <?=$text_helper->strip_selected_tags( 341 * '<b>Person:</b> <strong>Salavert</strong>', 'strong');?> 342 * //outputs: <b>Person:</b> Salavert 343 */ 344 function strip_selected_tags($text, $tags = array()) 345 { 346 $args = func_get_args(); 347 $text = array_shift($args); 348 $tags = func_num_args() > 2 ? array_diff($args,array($text)) : (array)$tags; 349 foreach ($tags as $tag){ 350 if(preg_match_all('/<'.$tag.'[^>]*>([^<]*)<\/'.$tag.'>/iU', $text, $found)){ 351 $text = str_replace($found[0],$found[1],$text); 352 } 353 } 354 355 return preg_replace('/(<('.join('|',$tags).')(\\n|\\r|.)*\/>)/iU', '', $text); 356 } 357 358 359 /** 360 * Turns all urls into clickable links. 361 * 362 * Example: 363 * <?=$text_helper->auto_link_urls($post->body, array('all', 'target' => '_blank'));?> 364 */ 365 function auto_link_urls($text, $href_options = array()) 366 { 367 $extra_options = TagHelper::_tag_options($href_options); 368 $extra_options_array = var_export($extra_options,true); 369 return preg_replace_callback(AK_AUTO_LINK_REGEX, create_function( 370 '$matched', 371 'return TextHelper::_replace_url_with_link_callback($matched,'.$extra_options_array.');' 372 ), $text); 373 } 374 375 function _replace_url_with_link_callback($matched, $extra_options) 376 { 377 list($all, $a, $b, $c, $d) = $matched; 378 if (preg_match('/<a\s/i',$a)){ // don't replace URL's that are already linked 379 return $all; 380 }else{ 381 $text = $b.$c; 382 return $a.'<a href="'.($b=="www."?"http://www.":$b).$c.'"'.$extra_options.'>'.$text.'</a>'.$d; 383 } 384 } 385 386 /** 387 * Returns an array with all the urls found as key and their valid link url as value 388 * 389 * Example: 390 * $text_helper->get_urls_from_text('www.akelos.com'); 391 * //returns: array('www.akelos.com'=>'http://www.akelos.com'); 392 */ 393 function get_urls_from_text($text) 394 { 395 $urls = array(); 396 if(preg_match_all(AK_AUTO_LINK_REGEX, $text, $found_urls)){ 397 foreach ($found_urls[0] as $url){ 398 $urls[$url] = (strtolower(substr($url,0,4)) == 'http' ? $url : 'http://'.$url); 399 } 400 } 401 return $urls; 402 } 403 404 /** 405 * Returns an array with the linked urls found on a text 406 * 407 * Example: 408 * $text_helper->get_linked_urls_from_text('<a href="http://akelos.com">Akelos.com</a>'); 409 * //returns: array('http://akelos.com'); 410 */ 411 function get_linked_urls_from_text($text) 412 { 413 $linked_urls = array(); 414 if(preg_match_all('/<a [^>]*href[ ]?=[ \'"]?(['.AK_VALID_URL_CHARS_REGEX.']+)[ \'"]?[^>]*>/i', $text, $linked_urls_pieces)){ 415 $linked_urls = array_unique($linked_urls_pieces[1]); 416 } 417 return $linked_urls; 418 } 419 420 421 /** 422 * Returns an array with the image urls found on a text 423 * 424 * Example: 425 * $text_helper->get_linked_urls_from_text('<a href="http://akelos.com">Akelos.com</a>'); 426 * //returns: array('http://akelos.com/images/logo.gif'); 427 */ 428 function get_image_urls_from_html($text) 429 { 430 $linked_urls = array(); 431 if(preg_match_all('/<img [^>]*src[ ]?=[ \'"]?(['.AK_VALID_URL_CHARS_REGEX.']+)[ \'"]?[^>]*>/i', $text, $linked_urls_pieces)){ 432 $linked_urls = array_unique($linked_urls_pieces[1]); 433 } 434 return $linked_urls; 435 } 436 437 438 /** 439 * Cycles through items of an array every time it is called. 440 * This can be used to alternate classes for table rows: 441 * 442 * {loop items} 443 * <tr class="<?=$text_helper->cycle("even", "odd")?>"> 444 * ... use $item ... 445 * </tr> 446 * {end} 447 * 448 * You can use named cycles to prevent clashes in nested loops. You'll 449 * have to reset the inner cycle, manually: 450 * 451 * {loop items} 452 * <tr class="<?=$text_helper->cycle("even", "odd", array('name' => "row_class"))?> 453 * <td> 454 * {loop values} 455 * <span style="color:'<?=$text_helper->cycle("red", "green", "blue",array('name' => "colors"))?>'"> 456 * ... use $item ... 457 * </span> 458 * {end} 459 * <php $text_helper->reset_cycle("colors"); ?> 460 * </td> 461 * </tr> 462 * {end} 463 */ 464 function cycle($first_value, $values = null) 465 { 466 static $cycle_position; 467 $params = func_get_args(); 468 if(is_array($params[func_num_args()-1])){ 469 $options = array_pop($params); 470 $name = isset($options['name']) ? $options['name'] : 'default'; 471 }else{ 472 $name = 'default'; 473 } 474 475 if(isset($options['reset'])){ 476 $cycle_position[$options['reset']] = 0; 477 if($options['reset'] == 'all'){ 478 $cycle_position = array(); 479 } 480 return; 481 } 482 $cycle_position[$name] = !isset($cycle_position[$name]) ? 0 : $cycle_position[$name]; 483 $number_params = count($params); 484 $current_param = $cycle_position[$name] > $number_params-1 ? 0 : $cycle_position[$name]; 485 $cycle_position[$name] = $current_param+1; 486 return $params[$current_param]; 487 } 488 489 function reset_cycle($name) 490 { 491 TextHelper::cycle(array('reset'=>$name)); 492 } 493 494 495 /** 496 * Returns the text with all the Markdown codes turned into HTML-tags. 497 */ 498 function markdown($text) 499 { 500 if (!empty($text)) { 501 require_once(AK_VENDOR_DIR.DS.'TextParsers'.DS.'markdown.php'); 502 $text = trim(Markdown($text)); 503 } 504 return $text; 505 } 506 507 508 /** 509 * Gets a localized setting (date format,...). 510 */ 511 function locale($locale_setting, $locale = null) 512 { 513 return Ak::locale($locale_setting, $locale); 514 } 515 516 /** 517 * Translate strings to the current locale. 518 */ 519 function translate($string, $args = null, $locale_namespace = null) 520 { 521 return Ak::t($string, $args, empty($locale_namespace) ? 522 AkInflector::underscore($this->_controller->getControllerName()) : $locale_namespace); 523 } 524 525 /** 526 * Alias for translate 527 */ 528 function t($string, $args = null, $locale_namespace = null) 529 { 530 return TextHelper::translate($string, $args, $locale_namespace); 531 } 532 533 534 function humanize($text) 535 { 536 return AkInflector::humanize($text); 537 } 538 539 /** 540 * Converts an underscored or CamelCase word into a English 541 * sentence. 542 * 543 * The titleize function converts text like "WelcomePage", 544 * "welcome_page" or "welcome page" to this "Welcome 545 * Page". 546 * If second parameter is set to 'first' it will only 547 * capitalize the first character of the title. 548 * 549 * @access public 550 * @static 551 * @param string $word Word to format as tile 552 * @param string $uppercase If set to 'first' it will only uppercase the 553 * first character. Otherwise it will uppercase all 554 * the words in the title. 555 * @return string Text formatted as title 556 */ 557 function titleize($text, $uppercase = '') 558 { 559 return AkInflector::titleize($text, $uppercase); 560 } 561 562 /** 563 * Use this function to automatically handle flash messages. 564 * 565 * Examples: 566 * 567 * <?=$text_helper->flash();?> 568 * //will handle all flash messages automatically 569 * 570 * <?=$text_helper->flash(null,array('secconds_to_close'=>5));?> 571 * //will handle all flash messages automatically and will close in 5 secconds. NOTE. you need to include javascript dependencies for using interactive options 572 * 573 */ 574 function flash($message = null, $options = array(), $html_options = array()) 575 { 576 if(empty($message) && empty($this->_controller->flash)){ 577 return ''; 578 } 579 580 $options = empty($options) ? (empty($this->_controller->flash_options) ? array() : $this->_controller->flash_options) : $options; 581 582 $default_options = array( 583 'close_button' => false, 584 'seconds_to_close' => false, 585 'animate'=> true, 586 'effects'=> array( 587 ) 588 ); 589 590 $options = array_merge($default_options, $options); 591 if(empty($options['seconds_to_close']) && isset($options['close_in'])){ 592 $options['seconds_to_close'] = strtotime($options['close_in'])-time(); 593 } 594 595 $options['effects'] = empty($options['effects']) ? array() : $options['effects']; 596 $effects = !empty($options['effect']) && is_string($options['effect']) ? array_merge(array($options['effect']), $options['effects']) : $options['effects']; 597 598 $options['seconds_to_close'] = empty($options['seconds_to_close']) && !empty($options['seconds']) ? $options['seconds'] : $options['seconds_to_close']; 599 600 $html_options = array_merge(array('id'=>'flash','class'=>'flash'), $html_options); 601 602 $close_button = !empty($options['close_button']) ? $this->_controller->asset_tag_helper->image_tag($options['close_button']).' ' : ''; 603 604 if(empty($message)){ 605 $message = ''; 606 foreach ($this->_controller->flash as $k=>$v){ 607 if(is_string($v) && !empty($v)){ 608 $message .= TagHelper::content_tag('div', $v, array('id'=>'flash_'.$k)); 609 } 610 } 611 }elseif (is_array($message)){ 612 $message = ''; 613 foreach ($this->_controller->flash as $k=>$v){ 614 if(is_string($v) && !empty($v)){ 615 $message .= TagHelper::content_tag('div', $v, array('id'=>'flash_'.$k)); 616 } 617 } 618 } 619 if(empty($message)){ 620 return ''; 621 } 622 623 $flash_message = '<!--CACHE-SKIP-START-->'.TagHelper::content_tag('div', $close_button.$message,$html_options).'<!--CACHE-SKIP-END-->'; 624 625 if ($options['animate']) { 626 $animation_effects = ''; 627 if(!empty($effects)){ 628 foreach ($effects as $name=>$effect_options){ 629 if(is_numeric($name)){ 630 $animation_effects .= $this->_controller->scriptaculous_helper->visual_effect($effect_options, $html_options['id']); 631 }else{ 632 $animation_effects .= $this->_controller->scriptaculous_helper->visual_effect($name, $html_options['id'], $effect_options); 633 } 634 } 635 } 636 if (!empty($options['seconds_to_close'])) { 637 $animation_effects .= 'setTimeout(\'new Effect.Fade($("'.$html_options['id'].'"));\', '.($options['seconds_to_close']*1000).');'; 638 } 639 if(!empty($animation_effects)){ 640 $flash_message .= $this->_controller->javascript_helper->javascript_tag($animation_effects); 641 } 642 }elseif (!empty($options['seconds_to_close'])) { 643 $flash_message .= $this->_controller->javascript_helper->javascript_tag('setTimeout(\'$("'.$html_options['id'].'").hide();\', '.($options['seconds_to_close']*1000).');'); 644 } 645 646 return $flash_message; 647 } 648 649 /** 650 * Recodes "$text" into utf-8 from "$input_string_encoding" 651 */ 652 function utf8($text, $input_string_encoding = null) 653 { 654 return Ak::utf8($text, $input_string_encoding); 655 } 656 657 658 /** 659 * Will atempt to close unmatched tags. This is useful for truncating messages 660 * and not breaking the layout. 661 */ 662 function close_unmatched_html($html) 663 { 664 preg_match_all('/<(\w+)[^>\/]*?(?!\/)>/', $html, $start_tags); 665 preg_match_all('/<\/(\w+)[^>\/]*?>/', $html, $end_tags); 666 667 $start_tags = (array)@$start_tags[1]; 668 $end_tags = (array)@$end_tags[1]; 669 670 if(count($start_tags) == count($end_tags)){ 671 return $html; 672 } 673 $missing_tags = array_reverse(array_diff($start_tags, $end_tags)); 674 675 foreach ($missing_tags as $missing_tag){ 676 if(!in_array($missing_tag,array('hr','br','img','input',''))){ 677 $html .= "</{$missing_tag}>"; 678 } 679 } 680 return $html; 681 } 682 683 function html_escape($html) 684 { 685 static $charset; 686 if(empty($charset)){ 687 $charset = Ak::locale('charset'); 688 } 689 return htmlentities($html, ENT_COMPAT, $charset); 690 } 691 692 function h($html) 693 { 694 return TextHelper::html_escape($html); 695 } 696 } 697 698 ?>
tag. ', [['AkActionView/helpers','text_helper.php',227]], 0], 'h': ['h', '', [['AkActionView/helpers','text_helper.php',692]], 2], 'str_repeat': ['str_repeat', '', [], 7], 'explode': ['explode', '', [], 70], 'is_array': ['is_array', '', [], 263], 'preg_replace_callback': ['preg_replace_callback', '', [], 5], 'array_merge': ['array_merge', '', [], 196], 'count': ['count', '', [], 160], 'trim': ['trim', '', [], 188], 'strip_tags': ['strip_tags', '', [], 7], 'is_string': ['is_string', '', [], 80], 'in_array': ['in_array', '', [], 146], 'strtotime': ['strtotime', '', [], 7], 'array_reverse': ['array_reverse', '', [], 18], 'array_values': ['array_values', '', [], 26], 'time': ['time', '', [], 32], 'array_shift': ['array_shift', '', [], 71], 'array_pop': ['array_pop', '', [], 21], 'array_map': ['array_map', '', [], 50], 'define': ['define', '', [], 252], 'preg_quote': ['preg_quote', '', [], 6], 'wordwrap': ['wordwrap', '', [], 3], 'create_function': ['create_function', '', [], 3], 'max': ['max', '', [], 6], 'substr': ['substr', '', [], 199], 'strtolower': ['strtolower', '', [], 110], 'func_num_args': ['func_num_args', '', [], 23], 'defined': ['defined', '', [], 279], 'preg_match': ['preg_match', '', [], 94], 'htmlentities': ['htmlentities', '', [], 8], 'str_replace': ['str_replace', '', [], 182], 'func_get_args': ['func_get_args', '', [], 74], 'array_keys': ['array_keys', '', [], 151], 'preg_replace': ['preg_replace', '', [], 83], 'array_diff': ['array_diff', '', [], 66], 'array_unique': ['array_unique', '', [], 24], 'min': ['min', '', [], 3], 'preg_match_all': ['preg_match_all', '', [], 24], 'is_numeric': ['is_numeric', '', [], 42], 'var_export': ['var_export', '', [], 21]}; CLASS_DATA={ 'urlhelper': ['urlhelper', '', [['AkActionView/helpers','url_helper.php',21]], 3], 'akinflector': ['akinflector', 'AkInflector for pluralize and singularize English nouns. ', [['','AkInflector.php',19]], 317], 'ak': ['ak', 'Akelos Framework static functions ', [['','Ak.php',32]], 738], 'texthelper': ['texthelper', 'Provides a set of methods for working with text strings that can help unburden the level of inline AkelosFramework code in the templates. In the example below we iterate over a collection of posts provided to the template and print each title after making sure it doesn\'t run longer than 20 characters: {loop posts} Title: = $text_helper->truncate($post->title, 20) ?> {end} ', [['AkActionView/helpers','text_helper.php',44]], 22], 'taghelper': ['taghelper', 'Use these methods to generate HTML tags programmatically when you can\'t use a Builder. By default, they output XHTML compliant tags. ', [['AkActionView/helpers','tag_helper.php',20]], 64], 'akobject': ['akobject', 'Allows for __construct and __destruct to be used in PHP4. ', [['','AkObject.php',21]], 35]}; CONST_DATA={ 'AK_VENDOR_DIR': ['AK_VENDOR_DIR', '', [['','constants.php',178]], 29], 'AK_AUTO_LINK_REGEX': ['AK_AUTO_LINK_REGEX', '', [['AkActionView/helpers','text_helper.php',23]], 3], 'AK_VALID_URL_CHARS_REGEX': ['AK_VALID_URL_CHARS_REGEX', '', [['AkActionView/helpers','text_helper.php',22]], 4]};
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |