/** * 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; }
/** * Save Field */ function save($data) { // Trim out any whitespace/empty tags $data = preg_replace('/^(\\s|<(\\w+)>( |\\s)*<\\/\\2>|<br \\/>)*/', '', $data); $data = preg_replace('/(\\s|<(\\w+)>( |\\s)*<\\/\\2>|<br \\/>)*$/', '', $data); // Entitize curly braces within codeblocks $data = preg_replace_callback('/<code>(.*?)<\\/code>/s', create_function('$matches', 'return str_replace(array("{","}"), array("{","}"), $matches[0]);'), $data); // Remove Firebug 1.5.2+ div $data = preg_replace('/<div firebugversion=(.|\\t|\\n|\\s)*<\\/div>/', '', $data); // Decode double quote entities (") // - Eventually CKEditor will stop converting these in the first place // http://dev.ckeditor.com/ticket/6645 $data = str_replace('"', '"', $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('<!--read_more-->', '<!--read_more-->', $data); return $data; }