config_load($lang_file, 'lang'); $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars()); $AVE_Template->config_load($lang_file, 'admin'); $res = ''; switch ($action) { case 'edit': $field_value = clean_php($field_value); $field_param = explode('|', $field_value); $clean_field_value = $field_param[0]; if (isset($field_param[1])) { $clean_field_value .= '|' . $field_param[1]; } $doc_id = 0; $document_name_to_display = ''; if (preg_match('/id=([0-9]+)/i', $clean_field_value, $matches)) { $doc_id = (int)$matches[1]; } if ($doc_id > 0) { $document_data = get_document($doc_id); if ($document_data && !empty($document_data['document_title'])) { $document_name_to_display = $document_data['document_title']; } elseif ($doc_id === 1) { $document_name_to_display = 'Главная страница'; } } $AVE_Template->assign('display_value', $document_name_to_display); $AVE_Template->assign('field_id', $field_id); $AVE_Template->assign('field_value', $clean_field_value); $tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl); return $AVE_Template->fetch($tpl_file); break; case 'doc': case 'req': $field_value = clean_php($field_value); $field_param = explode('|', $field_value); $doc_id = 0; if (preg_match('/id=([0-9]+)/i', $field_param[0], $matches)) { $doc_id = (int)$matches[1]; } $url_href = ''; $anchor = ''; $alias = ''; $title = ''; $bread = ''; $user_anchor = isset($field_param[1]) ? $field_param[1] : ''; if ($doc_id > 0) { $document_data = get_document($doc_id); if ($document_data) { $alias = isset($document_data['document_alias']) ? $document_data['document_alias'] : ''; $title = isset($document_data['document_title']) ? $document_data['document_title'] : ''; $bread = isset($document_data['document_breadcrum_title']) ? $document_data['document_breadcrum_title'] : ''; // Формируем готовую ссылку (URL) if ($alias === '/') { $url_href = '/'; } else { $url_href = '/' . trim($alias, '/'); if (defined('URL_SUFF') && URL_SUFF) { $url_href .= URL_SUFF; } } // Формируем Анкор (текст ссылки) $anchor = !empty($user_anchor) ? $user_anchor : (!empty($title) ? $title : $url_href); } } else { // Если внешняя ссылка $url_href = $field_param[0]; $anchor = !empty($user_anchor) ? $user_anchor : $field_param[0]; $url_href = str_replace(array('http:/', 'https:/'), array('http://', 'https://'), str_replace('//', '/', $url_href)); } if (!$tpl_empty && !empty($tpl)) { $res = $tpl; // СТРОГОЕ СОБЛЮДЕНИЕ ОБЩЕГО СТАНДАРТА + ДОП. ПАРАМЕТРЫ $doc_data_indexed = array( $doc_id, // 0 - ID $title, // 1 - Название $alias, // 2 - Алиас $bread, // 3 - Крошки $url_href, // 4 - Готовый URL $anchor // 5 - Текст ссылки (Анкор) ); foreach ($doc_data_indexed as $idx => $val) { $res = str_ireplace('[tag:parametr:' . $idx . ']', $val, $res); } } else { $res = '' . $anchor . ''; } return $res; break; case 'api' : return clean_php($field_value); break; case 'name' : return $AVE_Template->get_config_vars('name'); break; } return ($res ? $res : $field_value); } ?>