function persiantools_convert_data in PersianTools 7
2 calls to persiantools_convert_data()
- persiantools_ajax_render_alter in ./
persiantools.module - Implements hook_ajax_render_alter().
- persiantools_preprocess_html in ./
persiantools.module - Implements hook_preprocess_html().
File
- ./
persiantools.module, line 71 - Adds common features and fixes for persian pages.
Code
function persiantools_convert_data(&$data) {
global $language;
$lang = $language->language;
if ($lang != 'fa' && $lang != 'ar') {
return;
}
$skip_tags = '(<(textarea|script|style)( [^>]*)?>(.*?)<\\/\\3>\\s*)';
$normal_tags = '(<\\/?[^>]+>\\s*)?([^<]*)(?=<)';
$chained_tags = '/(?s)(' . $skip_tags . '|' . $normal_tags . ')([^<]*)(?=<)/';
preg_match_all($chained_tags, $data, $matches);
$new_data = '';
for ($i = 0; $i < count($matches[0]); $i++) {
if (strlen($matches[7][$i]) + strlen($matches[8][$i]) > 0) {
$matches[7][$i] = persiantools_convert_sm($matches[7][$i] . $matches[8][$i]);
}
$new_data .= $matches[2][$i] . $matches[6][$i] . $matches[7][$i];
}
$data = $new_data;
}