Ejemplo n.º 1
0
 public function highlightErrors($xhtml)
 {
     $highlighted_xhtml = array();
     if (!empty($this->_linesToHighlight)) {
         $xhtml_arr = preg_split('/\\n|\\r/', $xhtml);
         foreach ($xhtml_arr as $k => $xhtml_line) {
             $pos = $k + $this->_startLine;
             $highlighted_xhtml[$k] = $pos . "    ";
             $xhtml_line = htmlentities($xhtml_line);
             if (isset($this->_linesToHighlight[$pos])) {
                 foreach ($this->_linesToHighlight[$pos] as $highlight_details) {
                     $highlighted_xhtml[$k] .= AkTextHelper::highlight($xhtml_line, $highlight_details['phrase'], '<strong style="border:2px solid #' . $highlight_details['color'] . ';padding:1px; margin:1px; background: #ffc;">\\1</strong>');
                 }
             } else {
                 $highlighted_xhtml[$k] .= $xhtml_line;
             }
             $highlighted_xhtml[$k] .= "<br />\n";
         }
     }
     return empty($highlighted_xhtml) ? $xhtml : join($highlighted_xhtml);
 }
Ejemplo n.º 2
0
 /**
  * Use this method in your view to generate a return for the AJAX autocomplete requests.
  *
  * Example action:
  *
  *   function auto_complete_for_item_title()
  *   {
  *     $this->items = $Item->find('all', array('conditions' => array('strtolower($description).' LIKE ?', '%' . strtolower($this->_controller->Request->getRawPostData(). '%' ))))
  *     return $this->_controller->render(array('inline'=> '<?= $javascript_macros->auto_complete_result(@$items, 'description') ?>'));
  *   }
  *
  * The auto_complete_result can of course also be called from a view belonging to the 
  * auto_complete action if you need to decorate it further.
  *
  * @deprecated 
  */
 public function auto_complete_result($entries, $field, $phrase = null)
 {
     if (empty($entries)) {
         return '';
     }
     foreach ($entries as $entry) {
         $items[] = AkTagHelper::content_tag('li', !empty($phrase) ? AkTextHelper::highlight(AkTextHelper::html_escape($entry[$field]), $phrase) : AkTextHelper::html_escape(@$entry[$field]));
     }
     return AkTagHelper::content_tag('ul', join('', array_unique($items)));
 }