Esempio n. 1
0
 /**
  * Convert URLs to Wygwam Tags.
  *
  * @param $html
  * @return mixed
  */
 private function _convert_urls_to_tags($html)
 {
     $asset_ids = $this->EE->input->post('wygwam_asset_ids');
     $asset_urls = $this->EE->input->post('wygwam_asset_urls');
     // If they select any files using Assets.
     if (!empty($asset_ids) && !empty($asset_urls) && count($asset_ids) == count($asset_urls)) {
         // Convert Asset URLs to tags
         Wygwam_helper::replace_asset_urls($html, $asset_ids, $asset_urls);
     }
     // Convert file URLs to tags
     Wygwam_helper::replace_file_urls($html);
     // Convert page URLs to tags
     Wygwam_helper::replace_page_urls($html);
     return $html;
 }
Esempio n. 2
0
 /**
  * Save Field
  */
 function save($data)
 {
     // Trim out any whitespace/empty tags
     $data = preg_replace('/^(\\s|<(\\w+)>(&nbsp;|\\s)*<\\/\\2>|<br \\/>)*/', '', $data);
     $data = preg_replace('/(\\s|<(\\w+)>(&nbsp;|\\s)*<\\/\\2>|<br \\/>)*$/', '', $data);
     // Entitize curly braces within codeblocks
     $data = preg_replace_callback('/<code>(.*?)<\\/code>/s', create_function('$matches', 'return str_replace(array("{","}"), array("&#123;","&#125;"), $matches[0]);'), $data);
     // Remove Firebug 1.5.2+ div
     $data = preg_replace('/<div firebugversion=(.|\\t|\\n|\\s)*<\\/div>/', '', $data);
     // Decode double quote entities (&quot;)
     //  - Eventually CKEditor will stop converting these in the first place
     //    http://dev.ckeditor.com/ticket/6645
     $data = str_replace('&quot;', '"', $data);
     // Convert file URLs to tags
     Wygwam_helper::replace_file_urls($data);
     // Convert page URLs to tags
     Wygwam_helper::replace_page_urls($data);
     // Preserve Read More comments
     //  - For whatever reason, SafeCracker is converting HTML comment brackets into entities
     $data = str_replace('&lt;!--read_more--&gt;', '<!--read_more-->', $data);
     return $data;
 }