Esempio n. 1
0
 /**
  * Link to add content to the focused textarea
  * @param string  $title The content to be wrapped by <a> tags.
  * @param string  $fieldName This should be "Modelname.fieldname" or specific domId as #id.
  * @param mixed   $content String or array of markItUp! options (openWith, closeWith, replaceWith, placeHolder and more. See markItUp! documentation for more details : http://markitup.jaysalvat.com/documentation
  * @param array   $htmlAttributes Array of HTML attributes.
  * @param string  $confirmMessage JavaScript confirmation message.
  * @return string An <a /> element.
  */
 public function insert($title, $fieldName = null, $content = array(), $htmlAttributes = array(), $confirmMessage = false)
 {
     if (isset($fieldName)) {
         $content['target'] = $fieldName[0] === '#' ? $fieldName : '#' . parent::domId($fieldName);
     }
     if (!is_array($content)) {
         $content['replaceWith'] = $content;
     }
     $properties = '';
     foreach ($content as $k => $v) {
         $properties .= $k . ':"' . addslashes($v) . '",';
     }
     $properties = substr($properties, 0, -1);
     $htmlAttributes = array_merge($htmlAttributes, array('onclick' => '$.markItUp( { ' . $properties . ' } ); return false;'));
     return $this->Html->link($title, "#", $htmlAttributes, $confirmMessage, false);
 }