|
|
@ -1,67 +1,122 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
class editdoc |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Editdoc |
|
|
|
|
|
|
|
{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Метод, предназначенный для получения структуры документа из БД |
|
|
|
* Метод, предназначенный для получения структуры документа из БД |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int $document_id идентификатор Документа |
|
|
|
* @param int $document_id идентификатор Документа |
|
|
|
* return - возвращает документ положенный в структуру .... |
|
|
|
* return - возвращает документ положенный в структуру .... |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
public static function documentGet($document_id,$rubric_id=0){ |
|
|
|
public static function documentGet($document_id, $rubric_id = 0) |
|
|
|
|
|
|
|
{ |
|
|
|
global $AVE_DB; |
|
|
|
global $AVE_DB; |
|
|
|
//var_dump($document_id); |
|
|
|
|
|
|
|
$document_id=(int)$document_id; |
|
|
|
$document_id = (int)$document_id; |
|
|
|
$rubric_id=(int)$rubric_id; |
|
|
|
$rubric_id = (int)$rubric_id; |
|
|
|
if($document_id==0&&$rubric_id==0)return false; |
|
|
|
|
|
|
|
$sql="SELECT * FROM " . PREFIX . "_documents WHERE Id='$document_id' and document_author_id=".$_SESSION['user_id']." LIMIT 1"; |
|
|
|
if ($document_id == 0 && $rubric_id == 0) |
|
|
|
$rows=$AVE_DB->Query($sql); |
|
|
|
return false; |
|
|
|
if($rows->NumRows()>0)$rubric_id=0; |
|
|
|
|
|
|
|
if($rubric_id>0)$rows=$AVE_DB->Query("SELECT * FROM " . PREFIX . "_documents LIMIT 1"); |
|
|
|
$sql = " |
|
|
|
while ($row = $rows->FetchAssocArray()) { |
|
|
|
SELECT |
|
|
|
$header=$row; |
|
|
|
* |
|
|
|
} |
|
|
|
FROM |
|
|
|
if($rubric_id>0)foreach($header as $k=>&$v)$v=""; |
|
|
|
" . PREFIX . "_documents |
|
|
|
$felds=array(); |
|
|
|
WHERE |
|
|
|
$feldsType=array(); |
|
|
|
Id = '" . $document_id . "' |
|
|
|
if(!$rubric_id>0){ |
|
|
|
AND |
|
|
|
$rows=$AVE_DB->Query(" |
|
|
|
document_author_id = " . $_SESSION['user_id'] . " |
|
|
|
|
|
|
|
LIMIT 1 |
|
|
|
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rows = $AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($rows->NumRows() > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rubric_id = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($rubric_id > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rows = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_documents LIMIT 1"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ($row = $rows->FetchAssocArray()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$header = $row; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($rubric_id > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach($header as $k => &$v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$v = ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$felds = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$feldsType = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(! $rubric_id > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rows = $AVE_DB->Query(" |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
doc.Id AS df_id, |
|
|
|
doc.Id AS df_id, |
|
|
|
rub.*, |
|
|
|
rub.*, |
|
|
|
rubric_field_default, |
|
|
|
rubric_field_default, |
|
|
|
doc.field_value |
|
|
|
doc.field_value |
|
|
|
FROM " . PREFIX . "_rubric_fields AS rub |
|
|
|
FROM |
|
|
|
LEFT JOIN " . PREFIX . "_document_fields AS doc ON rubric_field_id = rub.Id |
|
|
|
" . PREFIX . "_rubric_fields AS rub |
|
|
|
WHERE document_id = '" . $document_id . "' AND rubric_id |
|
|
|
LEFT JOIN |
|
|
|
ORDER BY rubric_field_position ASC |
|
|
|
" . PREFIX . "_document_fields AS doc |
|
|
|
|
|
|
|
ON rubric_field_id = rub.Id |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
document_id = '" . $document_id . "' |
|
|
|
|
|
|
|
AND rubric_id |
|
|
|
|
|
|
|
ORDER BY |
|
|
|
|
|
|
|
rubric_field_position ASC |
|
|
|
"); |
|
|
|
"); |
|
|
|
}else{ |
|
|
|
} |
|
|
|
$rows=$AVE_DB->Query(" |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rows = $AVE_DB->Query(" |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
0 as df_id, |
|
|
|
0 as df_id, |
|
|
|
rub.*, |
|
|
|
rub.*, |
|
|
|
rubric_field_default, |
|
|
|
rubric_field_default, |
|
|
|
rubric_field_default as field_value |
|
|
|
rubric_field_default as field_value |
|
|
|
FROM " . PREFIX . "_rubric_fields AS rub |
|
|
|
FROM |
|
|
|
WHERE rub.rubric_id = '" . $rubric_id . "' |
|
|
|
" . PREFIX . "_rubric_fields AS rub |
|
|
|
ORDER BY rubric_field_position ASC |
|
|
|
WHERE |
|
|
|
|
|
|
|
rub.rubric_id = '" . $rubric_id . "' |
|
|
|
|
|
|
|
ORDER BY |
|
|
|
|
|
|
|
rubric_field_position ASC |
|
|
|
"); |
|
|
|
"); |
|
|
|
} |
|
|
|
} |
|
|
|
while ($row = $rows->FetchAssocArray()) { |
|
|
|
|
|
|
|
$felds[$row['Id']]=$row['df_id'] ? $row['field_value'] : $row['rubric_field_default']; |
|
|
|
while ($row = $rows->FetchAssocArray()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$felds[$row['Id']]=$row['df_id'] |
|
|
|
|
|
|
|
? $row['field_value'] |
|
|
|
|
|
|
|
: $row['rubric_field_default']; |
|
|
|
|
|
|
|
|
|
|
|
$feldsType[$row['Id']]['type']=$row['rubric_field_type']; |
|
|
|
$feldsType[$row['Id']]['type']=$row['rubric_field_type']; |
|
|
|
|
|
|
|
|
|
|
|
$feldsType[$row['Id']]['title']=$row['rubric_field_title']; |
|
|
|
$feldsType[$row['Id']]['title']=$row['rubric_field_title']; |
|
|
|
} |
|
|
|
} |
|
|
|
$result['header']=$header; |
|
|
|
|
|
|
|
$result['body']=$felds; |
|
|
|
$result['header'] = $header; |
|
|
|
$result['feld_type']=$feldsType; |
|
|
|
$result['body'] = $felds; |
|
|
|
//echo "<pre>"; |
|
|
|
$result['feld_type'] = $feldsType; |
|
|
|
//var_dump($result); |
|
|
|
|
|
|
|
//echo "</pre>"; |
|
|
|
// Debug::_echo($result, true); |
|
|
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function EditDocList($tpl_dir) |
|
|
|
public static function EditDocList($tpl_dir) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
|
global $AVE_DB, $AVE_Template; |
|
|
@ -89,6 +144,7 @@ class editdoc |
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_list.tpl')); |
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_list.tpl')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Добавление нового |
|
|
|
* Добавление нового |
|
|
|
* |
|
|
|
* |
|
|
@ -113,6 +169,7 @@ class editdoc |
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); |
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Редактирование |
|
|
|
* Редактирование |
|
|
|
* |
|
|
|
* |
|
|
@ -127,9 +184,12 @@ class editdoc |
|
|
|
if (is_numeric($import_id)) |
|
|
|
if (is_numeric($import_id)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
SELECT * |
|
|
|
SELECT |
|
|
|
FROM " . PREFIX . "_module_editdoc |
|
|
|
* |
|
|
|
WHERE id = '" . $import_id . "' |
|
|
|
FROM |
|
|
|
|
|
|
|
" . PREFIX . "_module_editdoc |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
id = '" . $import_id . "' |
|
|
|
"); |
|
|
|
"); |
|
|
|
|
|
|
|
|
|
|
|
$row = $sql->FetchAssocArray(); |
|
|
|
$row = $sql->FetchAssocArray(); |
|
|
@ -137,40 +197,59 @@ class editdoc |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
$row['editdoc_name'] = ''; |
|
|
|
$row['editdoc_name'] = ''; |
|
|
|
$row['editdoc_fill_filters']=''; |
|
|
|
$row['editdoc_fill_filters'] = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$row['editdoc_fill_filters']=unserialize(base64_decode($row['editdoc_fill_filters'])); |
|
|
|
$template = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$row['editdoc_fill_filters'] = unserialize(base64_decode($row['editdoc_fill_filters'])); |
|
|
|
|
|
|
|
|
|
|
|
$rubs = array(); |
|
|
|
$rubs = array(); |
|
|
|
|
|
|
|
|
|
|
|
$sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); |
|
|
|
$sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); |
|
|
|
|
|
|
|
|
|
|
|
while ($result = $sql->FetchRow()) |
|
|
|
while ($result = $sql->FetchRow()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push($rubs, $result); |
|
|
|
array_push($rubs, $result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('rubs',$rubs); |
|
|
|
$AVE_Template->assign('rubs',$rubs); |
|
|
|
$data=editdoc::getRubricFields($row['editdoc_rub'],$row['editdoc_fill_filters']); |
|
|
|
|
|
|
|
//$data=editdoc::documentGet(null,$import_id); |
|
|
|
|
|
|
|
if(!$row['editdoc_template']){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmpl="<form method=\"post\">\r\n |
|
|
|
$data = editdoc::getRubricFields($row['editdoc_rub'],$row['editdoc_fill_filters']); |
|
|
|
<input type=\"hidden\" name=\"editdoc_action\" value=\"$import_id\">\r\n |
|
|
|
|
|
|
|
<input type=\"hidden\" name=\"editdoc_doc_id\" value=\"<?php echo @\$_REQUEST['editdoc_doc_id']?>\">\r\n
|
|
|
|
//$data = editdoc::documentGet(null, $import_id); |
|
|
|
"; |
|
|
|
|
|
|
|
|
|
|
|
if($row['editdoc_template'] == '') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$tmpl = "<form method=\"post\">\r\n\t<input type=\"hidden\" name=\"editdoc_action\" value=\"$import_id\">\r\n\t<input type=\"hidden\" name=\"editdoc_doc_id\" value=\"<?php echo (isset(\$_REQUEST['editdoc_doc_id']) ? \$_REQUEST['editdoc_doc_id'] : ''); ?>\">\r\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data['header'] as $k => $v) |
|
|
|
foreach($data['header'] as $k => $v) |
|
|
|
$tmpl.=" <div id=\"edit_doc_header_$k\">[header:$k]</div>\r\n"; |
|
|
|
$tmpl .= "\t<div id=\"edit_doc_header_$k\">\r\n\t\t[header:$k]\r\n\t</div>\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmpl .= "\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
foreach($data['body'] as $k => $v) |
|
|
|
foreach($data['body'] as $k => $v) |
|
|
|
$tmpl.=" <div id=\"edit_doc_body_$k\"><label>".$v[0]."</label>[body:$k]</div>\r\n"; |
|
|
|
$tmpl .= "\t<div id=\"edit_doc_body_$k\">\r\n\t\t<label for=\"field_$k\">[title:$k]</label>\r\n\t\t[body:$k]\r\n\t</div>\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmpl .= "\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmpl .= "\t<input type=\"submit\" value=\"Сохранить\">\r\n</form>"; |
|
|
|
|
|
|
|
|
|
|
|
$tmpl.='<input type="submit" value="Сохранить"></form>'; |
|
|
|
$row['editdoc_template'] = $tmpl; |
|
|
|
$row['editdoc_template']=$tmpl; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$template = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('data',$data); |
|
|
|
$AVE_Template->assign('template', $template); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('data', $data); |
|
|
|
|
|
|
|
|
|
|
|
unset($row['editdoc_fill_filters']); |
|
|
|
unset($row['editdoc_fill_filters']); |
|
|
|
|
|
|
|
|
|
|
|
$AVE_Template->assign($row); |
|
|
|
$AVE_Template->assign($row); |
|
|
|
|
|
|
|
|
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); |
|
|
|
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -206,47 +285,107 @@ class editdoc |
|
|
|
public static function getRubricFields($id,$array) |
|
|
|
public static function getRubricFields($id,$array) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $AVE_DB; |
|
|
|
global $AVE_DB; |
|
|
|
$res=array(); |
|
|
|
|
|
|
|
if(!is_array($array))$array=Array(); |
|
|
|
$res = array(); |
|
|
|
$res=Array(); |
|
|
|
|
|
|
|
$res['header']=array(); |
|
|
|
if(! is_array($array)) |
|
|
|
$res['header']['document_parent'][0]=($array['header']['document_parent'] ? $array['header']['document_parent'] : "<?\r\n return '0';\r\n?>");
|
|
|
|
$array = array(); |
|
|
|
$res['header']['document_title'][0]=($array['header']['document_title'] ? $array['header']['document_title'] : "<?\r\n return \$_REQUEST['document_title'] ? \$_REQUEST['document_title'] : \$data['header']['document_title'] ;\r\n?>");
|
|
|
|
|
|
|
|
$res['header']['document_alias'][0]=($array['header']['document_alias'] ? $array['header']['document_alias'] : "<?\r\n return '';\r\n?>");
|
|
|
|
$res['header'] = array(); |
|
|
|
$res['header']['document_published'][0]=($array['header']['document_published'] ? $array['header']['document_published'] : "<?\r\n \$res= \$_REQUEST['document_published'] ? \$_REQUEST['document_published'] : \$data['header']['document_published'];\r\n return (\$res ? \$res : date('d.m.Y H:i'));\r\n?>");
|
|
|
|
|
|
|
|
$res['header']['document_expire'][0]=($array['header']['document_expire'] ? $array['header']['document_expire'] : "<?\r\n \$res= \$_REQUEST['document_expire'] ? \$_REQUEST['document_expire'] : \$data['header']['document_expire'];\r\n return (\$res ? \$res : date('d.m.Y H:i',strtotime('+20 years')));\r\n?>");
|
|
|
|
$res['header']['document_parent'][0]= ($array['header']['document_parent'] |
|
|
|
$res['header']['document_meta_keywords'][0]=($array['header']['document_meta_keywords'] ? $array['header']['document_meta_keywords'] : "<?\r\n return '';\r\n?>");
|
|
|
|
? $array['header']['document_parent'] |
|
|
|
$res['header']['document_meta_description'][0]=($array['header']['document_meta_description'] ? $array['header']['document_meta_description'] : "<?\r\n return '';\r\n?>");
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
$res['header']['document_in_search'][0]=($array['header']['document_in_search'] ? $array['header']['document_in_search'] : "<?\r\n return '0';\r\n?>");
|
|
|
|
|
|
|
|
$res['header']['document_meta_robots'][0]=($array['header']['document_meta_robots'] ? $array['header']['document_meta_robots'] : "<?\r\n return 'index,follow';\r\n?>");
|
|
|
|
$res['header']['document_title'][0] = ($array['header']['document_title'] |
|
|
|
$res['header']['document_status'][0]=($array['header']['document_status'] ? $array['header']['document_status'] : "<?\r\n return '0';\r\n?>");
|
|
|
|
? $array['header']['document_title'] |
|
|
|
$res['header']['document_deleted'][0]=($array['header']['document_deleted'] ? $array['header']['document_deleted']: "<?\r\n return '0';\r\n?>");
|
|
|
|
: "<?\r\n\treturn \$_REQUEST['document_title']\r\n\t\t? \$_REQUEST['document_title']\r\n\t\t: \$data['header']['document_title'] ;\r\n?>");
|
|
|
|
$res['header']['document_count_print'][0]=($array['header']['document_count_print'] ? $array['header']['document_count_print'] : "<?\r\n return '0';\r\n?>");
|
|
|
|
|
|
|
|
$res['header']['document_count_view'][0]=($array['header']['document_count_view'] ? $array['header']['document_count_view'] : "<?\r\n return '0';\r\n?>");
|
|
|
|
$res['header']['document_alias'][0] = ($array['header']['document_alias'] |
|
|
|
$res['header']['document_linked_navi_id'][0]=($array['header']['document_linked_navi_id'] ? $array['header']['document_linked_navi_id'] : "<?\r\n return '0';\r \n?>");
|
|
|
|
? $array['header']['document_alias'] |
|
|
|
foreach($res['header'] as $k=>$v)$res['header'][$k][1]=(isset($array['template'][$k]) ? $array['template'][$k] :''); |
|
|
|
: "<?\r\n\treturn '';\r\n?>");
|
|
|
|
$sql = $AVE_DB->Query("select * from ".PREFIX."_rubric_fields where rubric_id=".$id); |
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_published'][0] = ($array['header']['document_published'] |
|
|
|
|
|
|
|
? $array['header']['document_published'] |
|
|
|
|
|
|
|
: "<?\r\n\t\$res = \$_REQUEST['document_published']\r\n\t\t? \$_REQUEST['document_published']\r\n\t\t: \$data['header']['document_published'];\r\n\n\treturn (\$res ? \$res : date('d.m.Y H:i'));\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_expire'][0] = ($array['header']['document_expire'] |
|
|
|
|
|
|
|
? $array['header']['document_expire'] |
|
|
|
|
|
|
|
: "<?\r\n\t\$res = \$_REQUEST['document_expire']\r\n\t\t? \$_REQUEST['document_expire']\r\n\t\t: \$data['header']['document_expire'];\r\n\n\treturn (\$res ? \$res : date('d.m.Y H:i',strtotime('+20 years')));\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_meta_keywords'][0] = ($array['header']['document_meta_keywords'] |
|
|
|
|
|
|
|
? $array['header']['document_meta_keywords'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_meta_description'][0] = ($array['header']['document_meta_description'] |
|
|
|
|
|
|
|
? $array['header']['document_meta_description'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_in_search'][0] = ($array['header']['document_in_search'] |
|
|
|
|
|
|
|
? $array['header']['document_in_search'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_meta_robots'][0] = ($array['header']['document_meta_robots'] |
|
|
|
|
|
|
|
? $array['header']['document_meta_robots'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn 'index,follow';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_status'][0]=($array['header']['document_status'] |
|
|
|
|
|
|
|
? $array['header']['document_status'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_deleted'][0]=($array['header']['document_deleted'] |
|
|
|
|
|
|
|
? $array['header']['document_deleted'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_count_print'][0]=($array['header']['document_count_print'] |
|
|
|
|
|
|
|
? $array['header']['document_count_print'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_count_view'][0] = ($array['header']['document_count_view'] |
|
|
|
|
|
|
|
? $array['header']['document_count_view'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res['header']['document_linked_navi_id'][0] = ($array['header']['document_linked_navi_id'] |
|
|
|
|
|
|
|
? $array['header']['document_linked_navi_id'] |
|
|
|
|
|
|
|
: "<?\r\n\treturn '0';\r\n?>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($res['header'] as $k => $v) |
|
|
|
|
|
|
|
$res['header'][$k][1]=(isset($array['template'][$k]) |
|
|
|
|
|
|
|
? $array['template'][$k] |
|
|
|
|
|
|
|
:''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
|
|
|
|
SELECT |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
FROM |
|
|
|
|
|
|
|
".PREFIX."_rubric_fields |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
rubric_id = ".$id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
while ($result = $sql->FetchAssocArray()) |
|
|
|
while ($result = $sql->FetchAssocArray()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$func='get_field_'.$result['rubric_field_type']; |
|
|
|
$field = "<?\r\n\t\$field_" . $result['Id'] . " = htmlspecialchars(stripslashes(isset(\$_REQUEST['feld'][" . $result['Id'] . "])\r\n\t\t? \$_REQUEST['feld'][" . $result['Id'] . "]\r\n\t\t: \$data['body'][" . $result['Id'] . "])\r\n\t);\r\n?>\r\n";
|
|
|
|
if(!is_callable($func)) $func='get_field_default'; |
|
|
|
$field .= '<input type="text" id="field_' . $result['Id'] . '" placeholder="[title:' . $result['Id'] . ']" name="feld['.$result['Id'].']" value="<?= $field_' . $result['Id'] . '; ?>">';
|
|
|
|
$val='<?php echo htmlspecialchars(stripslashes($_REQUEST["feld"]['.$result['Id'].'] ? ($_REQUEST["feld"]['.$result['Id'].']) : $data["body"]['.$result['Id'].']));?>';
|
|
|
|
|
|
|
|
$field=$func("{{ХХХХ}}",'edit',$result['Id'],'',0,$x,0,0,$result['rubric_field_default']); |
|
|
|
$a = array( |
|
|
|
$field=str_ireplace('{{ХХХХ}}',$val,$field); |
|
|
|
'0' => $result['rubric_field_title'], |
|
|
|
$a=array( |
|
|
|
'1' => ($array['body'][$result['Id']] |
|
|
|
'0'=>$result['rubric_field_title'], |
|
|
|
? $array['body'][$result['Id']] |
|
|
|
'1'=>( |
|
|
|
: "<?\r\n\treturn (isset(\$_REQUEST['feld'][".$result['Id']."])\r\n\t\t? \$_REQUEST['feld'][".$result['Id']."]\r\n\t\t: \$data['body'][".$result['Id']."]);\r\n?>"
|
|
|
|
$array['body'][$result['Id']] ? |
|
|
|
|
|
|
|
$array['body'][$result['Id']]: |
|
|
|
|
|
|
|
"<?\r\n return (isset(\$_REQUEST['feld'][".$result['Id']."]) ? \$_REQUEST['feld'][".$result['Id']."] : \$data['body'][".$result['Id']."]);\r\n?>"
|
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
'2'=>(isset($array['template'][$result['Id']]) ? $array['template'][$result['Id']] : $field) |
|
|
|
'2' => (isset($array['template'][$result['Id']]) |
|
|
|
|
|
|
|
? $array['template'][$result['Id']] |
|
|
|
|
|
|
|
: $field) |
|
|
|
); |
|
|
|
); |
|
|
|
$res['body'][$result['Id']]=$a; |
|
|
|
|
|
|
|
|
|
|
|
$res['body'][$result['Id']] = $a; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $res; |
|
|
|
return $res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Сохранение импорта |
|
|
|
* Сохранение импорта |
|
|
|
* |
|
|
|
* |
|
|
@ -258,48 +397,62 @@ class editdoc |
|
|
|
|
|
|
|
|
|
|
|
function stripslashes_deep($value) |
|
|
|
function stripslashes_deep($value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$value = is_array($value) ? |
|
|
|
$value = is_array($value) |
|
|
|
array_map('stripslashes_deep', $value) : |
|
|
|
? array_map('stripslashes_deep', $value) |
|
|
|
stripslashes($value); |
|
|
|
: stripslashes($value); |
|
|
|
|
|
|
|
|
|
|
|
return $value; |
|
|
|
return $value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$v=base64_encode(serialize(stripslashes_deep($_REQUEST['document']))); |
|
|
|
$template = base64_encode(serialize(stripslashes_deep($_REQUEST['document']))); |
|
|
|
|
|
|
|
|
|
|
|
if (is_numeric($import_id)) |
|
|
|
if (is_numeric($import_id)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$sql=" |
|
|
|
$sql=" |
|
|
|
UPDATE " . PREFIX . "_module_editdoc |
|
|
|
UPDATE |
|
|
|
|
|
|
|
" . PREFIX . "_module_editdoc |
|
|
|
SET |
|
|
|
SET |
|
|
|
`editdoc_name` = '" . ($_REQUEST['editdoc_name']) . "', |
|
|
|
editdoc_name = '" . $_REQUEST['editdoc_name'] . "', |
|
|
|
".($_REQUEST['editdoc_rub']> '' ? "`editdoc_rub` = '" . ($_REQUEST['editdoc_rub']) . "'," : "")." |
|
|
|
editdoc_last_change = '" . time() . "', |
|
|
|
`editdoc_lastchange` = '" . ($_REQUEST['editdoc_lastchange']) . "', |
|
|
|
editdoc_fill_filters = '" . $template . "', |
|
|
|
`editdoc_fill_filters` = '" . $v . "', |
|
|
|
editdoc_template = '" . $_REQUEST['editdoc_template'] . "', |
|
|
|
`editdoc_template` = '" . $_REQUEST['editdoc_template'] . "', |
|
|
|
editdoc_use_revisions = '" . ($_REQUEST['editdoc_use_revisions'] ? $_REQUEST['editdoc_use_revisions'] : 0) . "', |
|
|
|
`editdoc_afteredit` = '" . (($_REQUEST['editdoc_afteredit'] ? $_REQUEST['editdoc_afteredit'] : addslashes("<?php
|
|
|
|
editdoc_use_rubric_code = '" . ($_REQUEST['editdoc_use_rubric_code'] ? $_REQUEST['editdoc_use_rubric_code'] : 0) . "', |
|
|
|
//header('Location: /'.rewrite_link('index.php?id='.\$GLOBALS['mod_editdoc'][".$import_id."])); |
|
|
|
editdoc_use_log_save = '" . ($_REQUEST['editdoc_use_log_save'] ? $_REQUEST['editdoc_use_log_save'] : 0) . "', |
|
|
|
//exit(); |
|
|
|
editdoc_before_edit = '" . $_REQUEST['editdoc_before_edit'] . "', |
|
|
|
?>"))) . "' |
|
|
|
editdoc_after_edit = '" . $_REQUEST['editdoc_after_edit'] . "' |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
id = '" . $import_id . "' |
|
|
|
id = '" . $import_id . "' |
|
|
|
"; |
|
|
|
"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
$sql=" |
|
|
|
|
|
|
|
INSERT |
|
|
|
$editdoc_before_edit = "<?\r\n\t//Debug::_echo(\$_REQUEST, true);\r\n?>";
|
|
|
|
INTO " . PREFIX . "_module_editdoc |
|
|
|
$editdoc_after_edit = "<?\r\n\t//header('Location: /' . rewrite_link('index.php?id=' . \$GLOBALS['mod_editdoc'][\$import_id]));\r\n\t//exit();\r\n?>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = " |
|
|
|
|
|
|
|
INSERT INTO |
|
|
|
|
|
|
|
" . PREFIX . "_module_editdoc |
|
|
|
SET |
|
|
|
SET |
|
|
|
id = '', |
|
|
|
id = '', |
|
|
|
`editdoc_name` = '" . ($_REQUEST['editdoc_name']) . "', |
|
|
|
editdoc_name = '" . $_REQUEST['editdoc_name'] . "', |
|
|
|
".($_REQUEST['editdoc_rub']> '' ? "`editdoc_rub` = '" . ($_REQUEST['editdoc_rub']) . "'," : "")." |
|
|
|
editdoc_rub = '" . $_REQUEST['editdoc_rub'] . "', |
|
|
|
`editdoc_lastchange` = '" . ($_REQUEST['editdoc_lastchange']) . "', |
|
|
|
editdoc_last_change = '" . time() . "', |
|
|
|
`editdoc_fill_filters` = '" . $v . "', |
|
|
|
editdoc_fill_filters = '" . $template . "', |
|
|
|
`editdoc_template` = '" . ($_REQUEST['editdoc_template']) . "', |
|
|
|
editdoc_template = '" . $_REQUEST['editdoc_template'] . "', |
|
|
|
`editdoc_afteredit` = '" . ($_REQUEST['editdoc_afteredit']) . "' |
|
|
|
editdoc_before_edit = '" . addslashes($editdoc_before_edit) . "', |
|
|
|
|
|
|
|
editdoc_after_edit = '" . addslashes($editdoc_after_edit) . "' |
|
|
|
"; |
|
|
|
"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AVE_DB->Query($sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$editor_id = $AVE_DB->InsertId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=edit&id=' . $editor_id . '&cp=' . SESSION); |
|
|
|
|
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$AVE_DB->Query($sql); |
|
|
|
$AVE_DB->Query($sql); |
|
|
|
header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); |
|
|
|
header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); |
|
|
|
} |
|
|
|
} |
|
|
@ -311,70 +464,117 @@ class editdoc |
|
|
|
if (is_numeric($import_id)) |
|
|
|
if (is_numeric($import_id)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
$sql = $AVE_DB->Query(" |
|
|
|
SELECT * |
|
|
|
SELECT |
|
|
|
FROM " . PREFIX . "_module_editdoc |
|
|
|
* |
|
|
|
WHERE id = '" . $import_id . "' |
|
|
|
FROM |
|
|
|
|
|
|
|
" . PREFIX . "_module_editdoc |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
id = '" . $import_id . "' |
|
|
|
"); |
|
|
|
"); |
|
|
|
|
|
|
|
|
|
|
|
$row = $sql->FetchAssocArray(); |
|
|
|
$row = $sql->FetchAssocArray(); |
|
|
|
$row['editdoc_fill_filters']=unserialize(base64_decode($row['editdoc_fill_filters'])); |
|
|
|
|
|
|
|
$document_id=(isset($_REQUEST['editdoc_doc_id']) ? (int)$_REQUEST['editdoc_doc_id'] : null); |
|
|
|
$row['editdoc_fill_filters'] = unserialize(base64_decode($row['editdoc_fill_filters'])); |
|
|
|
$data=editdoc::documentGet($document_id,(int)$row['editdoc_rub']); |
|
|
|
|
|
|
|
|
|
|
|
$document_id = (isset($_REQUEST['editdoc_doc_id']) |
|
|
|
|
|
|
|
? (int)$_REQUEST['editdoc_doc_id'] |
|
|
|
|
|
|
|
: null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = editdoc::documentGet($document_id, (int)$row['editdoc_rub']); |
|
|
|
|
|
|
|
|
|
|
|
//Пришла форма |
|
|
|
//Пришла форма |
|
|
|
if(isset($_REQUEST['editdoc_action']) && $_REQUEST['editdoc_action']==$import_id){ |
|
|
|
if(isset($_REQUEST['editdoc_action']) && $_REQUEST['editdoc_action'] == $import_id) |
|
|
|
|
|
|
|
{ |
|
|
|
//вот тут сохранение будет |
|
|
|
//вот тут сохранение будет |
|
|
|
$save=true; |
|
|
|
$save = true; |
|
|
|
foreach($row['editdoc_fill_filters']['header'] as $k=>$v) |
|
|
|
|
|
|
|
|
|
|
|
foreach($row['editdoc_fill_filters']['header'] as $k => $v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$exp = ' |
|
|
|
|
|
|
|
function editdoc_reth_' . $import_id . '_' . $k . '($data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$exp=' |
|
|
|
|
|
|
|
function editdoc_reth_'.$import_id.'_'.$k.'($data){ |
|
|
|
|
|
|
|
?>'.trim($v).'<? |
|
|
|
?>'.trim($v).'<? |
|
|
|
};'; |
|
|
|
}; |
|
|
|
|
|
|
|
'; |
|
|
|
|
|
|
|
|
|
|
|
eval($exp); |
|
|
|
eval($exp); |
|
|
|
$ret='editdoc_reth_'.$import_id.'_'.$k; |
|
|
|
|
|
|
|
$data['header'][$k]=$ret($data); |
|
|
|
$ret = 'editdoc_reth_' . $import_id . '_' . $k; |
|
|
|
if($data['header'][$k]===NULL){ |
|
|
|
|
|
|
|
|
|
|
|
$data['header'][$k] = $ret($data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($data['header'][$k] === NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
$save=false; |
|
|
|
$save=false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data['header']['rubric_id']=$row['editdoc_rub']; |
|
|
|
$data['header']['rubric_id']=$row['editdoc_rub']; |
|
|
|
|
|
|
|
|
|
|
|
foreach($row['editdoc_fill_filters']['body'] as $k=>$v) |
|
|
|
foreach($row['editdoc_fill_filters']['body'] as $k => $v) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$exp = ' |
|
|
|
|
|
|
|
function editdoc_retb_'.$import_id.'_'.$k.'($data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$exp=' |
|
|
|
|
|
|
|
function editdoc_retb_'.$import_id.'_'.$k.'($data){ |
|
|
|
|
|
|
|
?>'.trim($v).'<? |
|
|
|
?>'.trim($v).'<? |
|
|
|
};'; |
|
|
|
}; |
|
|
|
|
|
|
|
'; |
|
|
|
|
|
|
|
|
|
|
|
eval($exp); |
|
|
|
eval($exp); |
|
|
|
$ret='editdoc_retb_'.$import_id.'_'.$k; |
|
|
|
|
|
|
|
$data['body'][$k]=$ret($data); |
|
|
|
$ret = 'editdoc_retb_' . $import_id . '_' . $k; |
|
|
|
if($data['body'][$k]===NULL){ |
|
|
|
|
|
|
|
$save=false; |
|
|
|
$data['body'][$k] = $ret($data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($data['body'][$k] === NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$save = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$d=$data['header']; |
|
|
|
$d = $data['header']; |
|
|
|
$d['doc_title']=$d['document_title']; |
|
|
|
|
|
|
|
$d['feld']=$data['body']; |
|
|
|
$d['doc_title'] = $d['document_title']; |
|
|
|
require(BASE_DIR . '/lib/redactor/ckeditor/ckeditor.php'); |
|
|
|
|
|
|
|
require_once(BASE_DIR.'/class/class.docs.php'); |
|
|
|
$d['feld'] = $data['body']; |
|
|
|
$AVE_Document=new AVE_Document(); |
|
|
|
|
|
|
|
@$AVE_Document->documentPermissionFetch($row['editdoc_rub']); |
|
|
|
require_once(BASE_DIR . '/class/class.docs.php'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AVE_Document = new AVE_Document(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$AVE_Document->documentPermissionFetch($row['editdoc_rub']); |
|
|
|
|
|
|
|
|
|
|
|
require_once(BASE_DIR.'/admin/functions/func.admin.common.php'); |
|
|
|
require_once(BASE_DIR.'/admin/functions/func.admin.common.php'); |
|
|
|
if($save){ |
|
|
|
|
|
|
|
//надо перед сохранением уточнить являюсь ли я хозяином документа .....не забыть!!!!!!!!!! а то админы тут делов наделают |
|
|
|
|
|
|
|
$GLOBALS['mod_editdoc'][$import_id]=@$AVE_Document->documentSave((int)$row['editdoc_rub'],$document_id,$d,true); |
|
|
|
|
|
|
|
eval(' ?>'.$row['editdoc_afteredit'].'<? '); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if ($save) |
|
|
|
$template=$row['editdoc_template']; |
|
|
|
{ |
|
|
|
foreach($row['editdoc_fill_filters']["body"] as $k=>$v)$template=str_ireplace("[body:$k]",$row['editdoc_fill_filters']["template"][$k],$template); |
|
|
|
// Код перед сохранением |
|
|
|
foreach($row['editdoc_fill_filters']["header"] as $k=>$v)$template=str_ireplace("[header:$k]",$row['editdoc_fill_filters']["template"][$k],$template); |
|
|
|
eval(' ?>'.$row['editdoc_before_edit'].'<? '); |
|
|
|
eval(' ?>'.$template.'<? '); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
// Надо перед сохранением уточнить являюсь ли я хозяином документа .....не забыть!!!!!!!!!! а то админы тут делов наделают |
|
|
|
|
|
|
|
$GLOBALS['mod_editdoc'][$import_id] = @$AVE_Document->documentSave((int)$row['editdoc_rub'], $document_id, $d, true, $row['editdoc_use_rubric_code'], $row['editdoc_use_revisions'], $row['editdoc_use_log_save']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Код после сохранения |
|
|
|
|
|
|
|
eval(' ?>'.$row['editdoc_after_edit'].'<? '); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$template = $row['editdoc_template']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($row['editdoc_fill_filters']["body"] as $k => $v) |
|
|
|
|
|
|
|
$template = str_ireplace("[body:$k]", $row['editdoc_fill_filters']["template"][$k], $template); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($row['editdoc_fill_filters']["header"] as $k => $v) |
|
|
|
|
|
|
|
$template = str_ireplace("[header:$k]", $row['editdoc_fill_filters']["template"][$k], $template); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data['feld_type'] as $k => $v) |
|
|
|
|
|
|
|
$template = str_ireplace("[type:$k]", $v['type'], $template); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($data['feld_type'] as $k => $v) |
|
|
|
|
|
|
|
$template = str_ireplace("[title:$k]", $v['title'], $template); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eval(' ?>'.$template.'<? '); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
?> |
|
|
|
?> |