本文整理汇总了PHP中XTemplate::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP XTemplate::exists方法的具体用法?PHP XTemplate::exists怎么用?PHP XTemplate::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XTemplate
的用法示例。
在下文中一共展示了XTemplate::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheXTPL
function cacheXTPL($file, $cache_file, $preview_file = false)
{
global $beanList;
//now if we have a backup_file lets use that instead of the original
if ($preview_file) {
$file = $preview_file;
}
if (!isset($the_module)) {
$the_module = $_SESSION['studio']['module'];
}
$files = StudioParser::getFiles($the_module);
$xtpl = $files[$_SESSION['studio']['selectedFileId']]['php_file'];
$originalFile = $files[$_SESSION['studio']['selectedFileId']]['template_file'];
$type = StudioParser::getFileType($files[$_SESSION['studio']['selectedFileId']]['type']);
$buffer = sugar_file_get_contents($xtpl);
$cache_file = create_cache_directory('studio/' . $file);
$xtpl_cache = create_cache_directory('studio/' . $xtpl);
$module = $this->workingModule;
$form_string = "require_once('modules/" . $module . "/Forms.php');";
if ($type == 'edit' || $type == 'detail') {
if (empty($_REQUEST['record'])) {
$buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->assign_display_fields('{$module}'); \$0", $buffer);
} else {
$buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->retrieve('" . $_REQUEST['record'] . "');\n\$focus->assign_display_fields('{$module}');\n \$0", $buffer);
}
}
$_REQUEST['query'] = true;
if (substr_count($file, 'SearchForm') > 0) {
$temp_xtpl = new XTemplate($file);
if ($temp_xtpl->exists('advanced')) {
global $current_language;
$mods = return_module_language($current_language, 'DynamicLayout');
$mod = BeanFactory::getBean($module);
$this->populateRequestFromBuffer($file);
$mod->assign_display_fields($module);
$buffer = str_replace(array('echo $lv->display();', '$search_form->parse("advanced");', '$search_form->out("advanced");', '$search_form->parse("main");', '$search_form->out("main");'), '', $buffer);
$buffer = str_replace('echo get_form_footer();', '$search_form->parse("main");' . "\n" . '$search_form->out("main");' . "\necho '<br><b>" . translate('LBL_ADVANCED', 'DynamicLayout') . "</b><br>';" . '$search_form->parse("advanced");' . "\n" . '$search_form->out("advanced");' . "\n \$sugar_config['list_max_entries_per_page'] = 1;", $buffer);
}
} else {
if ($type == 'detail') {
$buffer = str_replace('header(', 'if(false) header(', $buffer);
}
}
$buffer = str_replace($originalFile, $cache_file, $buffer);
$buffer = "<?php\n\$sugar_config['list_max_entries_per_page'] = 1;\n ?>" . $buffer;
$buffer = str_replace($form_string, '', $buffer);
$buffer = $this->disableInputs($buffer);
$xtpl_fp_cache = sugar_fopen($xtpl_cache, 'w');
fwrite($xtpl_fp_cache, $buffer);
fclose($xtpl_fp_cache);
return $xtpl_cache;
}
示例2: get_xtpl_file_and_cache
function get_xtpl_file_and_cache($file)
{
include 'modules/DynamicLayout/HTMLPHPMapping.php';
global $beanList;
if (!empty($html_php_mapping_subpanel[$file])) {
$xtpl = $html_php_mapping_subpanel[$file];
} else {
if (!empty($html_php_mapping_edit[$file])) {
$xtpl = $html_php_mapping_edit[$file];
} else {
if (!empty($html_php_mapping_detail[$file])) {
$xtpl = $html_php_mapping_detail[$file];
} else {
if (!empty($html_php_mapping_other[$file])) {
$xtpl = $html_php_mapping_other[$file];
} else {
$xtpl = $file;
}
}
}
}
$xtpl = str_replace(array('.html', 'SearchForm'), array('.php', 'ListView'), $xtpl);
$xtpl_fp = fopen($xtpl, 'r');
$buffer = fread($xtpl_fp, filesize($xtpl));
fclose($xtpl_fp);
$cache_file = create_cache_directory('layout/' . $file);
$xtpl_cache = create_cache_directory('layout/' . $xtpl);
$module = get_module($file);
$form_string = "require_once('modules/" . $module . "/Forms.php');";
if (substr_count($file, 'DetailView') > 0) {
$buffer = str_replace('header(', 'if(false) header(', $buffer);
}
if (substr_count($file, 'DetailView') > 0 || substr_count($file, 'EditView') > 0) {
if (empty($_REQUEST['record'])) {
$buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->assign_display_fields('{$module}'); \$0", $buffer);
} else {
$buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->retrieve('" . $_REQUEST['record'] . "');\n\$focus->assign_display_fields('{$module}');\n \$0", $buffer);
}
}
$_REQUEST['query'] = true;
if (substr_count($file, 'SearchForm') > 0) {
$temp_xtpl = new XTemplate($file);
if ($temp_xtpl->exists('advanced')) {
global $current_language;
$mods = return_module_language($current_language, 'DynamicLayout');
$class_name = $beanList[$module];
if ($class_name == 'aCase') {
$class_file = 'Case';
} else {
$class_file = $class_name;
}
require_once "modules/{$module}/{$class_file}.php";
$mod = new $class_name();
populate_request_from_buffer($file);
$mod->assign_display_fields($module);
$buffer = str_replace(array('$search_form->parse("advanced");', '$search_form->out("advanced");', '$search_form->parse("main");', '$search_form->out("main");'), array('', '', '', ''), $buffer);
$buffer = str_replace('echo get_form_footer();', '$search_form->parse("main");' . "\n" . '$search_form->out("main");' . "\necho '<br><b>" . translate('LBL_ADVANCED', 'DynamicLayout') . "</b><br>';" . '$search_form->parse("advanced");' . "\n" . '$search_form->out("advanced");' . "\necho get_form_footer();\n \$sugar_config['list_max_entries_per_page'] = 1;", $buffer);
}
}
if (!empty($html_php_mapping_subpanel[$file])) {
global $beanList;
if (!empty($_REQUEST['mod_class'])) {
$bean = $beanList[$_REQUEST['mod_class']];
} else {
$bean = $beanList[$module];
}
$buffer = str_replace('replace_file_name', $file, $buffer);
if (empty($_REQUEST['record'])) {
$buffer = str_replace('global $focus_list;', "global \$focus_list;\n\$focus_list = new {$bean}();\n\$focus_list->assign_display_fields('{$module}');", $buffer);
} else {
$buffer = str_replace('global $focus_list;', "global \$focus_list;\n\$focus_list = new {$bean}();\n\$focus_list->retrieve('" . $_REQUEST['record'] . "');", $buffer);
}
}
if (!empty($html_php_mapping_subpanel[$file])) {
foreach ($html_php_mapping_subpanel as $key => $val) {
if ($val == $xtpl) {
$buffer = str_replace($key, $cache_file, $buffer);
}
}
} else {
$buffer = str_replace($file, $cache_file, $buffer);
}
$buffer = "<?php\n\$sugar_config['list_max_entries_per_page'] = 1;\n ?>" . $buffer;
$buffer = str_replace($form_string, '', $buffer);
$buffer = replace_inputs($buffer);
$xtpl_fp_cache = fopen($xtpl_cache, 'w');
fwrite($xtpl_fp_cache, $buffer);
fclose($xtpl_fp_cache);
return $xtpl_cache;
}