From 4727bc64bbbf8bf10260efbd748a9bacc4cf2d99 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 14 Apr 2017 22:24:10 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=201.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +- editdoc/class.editdoc.php | 844 +++++++++++++++++++------------ editdoc/lang/ru.txt | 11 +- editdoc/module.php | 140 ++--- editdoc/sql.php | 96 ++-- editdoc/templates/admin_edit.tpl | 561 ++++++++++---------- 6 files changed, 954 insertions(+), 710 deletions(-) diff --git a/README.md b/README.md index 88697f6..a4ae465 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ ## editdoc -# Модуль Публикатор документов v1.0.2 +### Модуль Публикатор документов v1.6 -## После того, как впервые будет создан новый публикатор, ОБЯЗАТЕЛЬНО сделайте пересохранение этого публикатора, -## даже если вы ничего в нем не меняли, кнопкой СОХРАНИТЬ! +### Данный модуль предназначен для создания форм ввода и редактирования документов на сайте -## Данный модуль предназначен для создания форм ввода и редактирования документов на сайте +#### Перед копированием модуля в папку modules, удалите файл README.md, копируйте только корневую папку editdoc со всем ее содержимым внутри! +Обсуждение модуля на форуме: [forum.ave-cms.ru](https://forum.ave-cms.ru/viewtopic.php?f=12&t=116&p=1683#p1683) -## Перед копированием модуля в папку modules, удалите файл README.md, копируйте только корневую папку editdoc со всем ее содержимым внутри! +### Changelog: -## Changelog: +14.04.2017 - версия 1.6 - подробности на форуме 04.08.2016 - версия 1.0.2 Правки для работы модуля в AVE.CMS 3.0 v1.5 diff --git a/editdoc/class.editdoc.php b/editdoc/class.editdoc.php index 154a1e2..7c1dce3 100644 --- a/editdoc/class.editdoc.php +++ b/editdoc/class.editdoc.php @@ -1,380 +1,580 @@ 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 - doc.Id AS df_id, - rub.*, - rubric_field_default, - doc.field_value - FROM " . PREFIX . "_rubric_fields AS rub - LEFT JOIN " . 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(" + + class Editdoc + { + /** + * Метод, предназначенный для получения структуры документа из БД + * + * @param int $document_id идентификатор Документа + * return - возвращает документ положенный в структуру .... + **/ + public static function documentGet($document_id, $rubric_id = 0) + { + global $AVE_DB; + + $document_id = (int)$document_id; + $rubric_id = (int)$rubric_id; + + if ($document_id == 0 && $rubric_id == 0) + return false; + + $sql = " SELECT - 0 as df_id, - rub.*, - rubric_field_default, - rubric_field_default as field_value - FROM " . PREFIX . "_rubric_fields AS rub - 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']; - $feldsType[$row['Id']]['type']=$row['rubric_field_type']; - $feldsType[$row['Id']]['title']=$row['rubric_field_title']; + * + FROM + " . PREFIX . "_documents + WHERE + Id = '" . $document_id . "' + AND + document_author_id = " . $_SESSION['user_id'] . " + LIMIT 1 + "; + + $rows = $AVE_DB->Query($sql); + + if ($rows->NumRows() > 0) + { + $rubric_id = 0; } - $result['header']=$header; - $result['body']=$felds; - $result['feld_type']=$feldsType; - //echo "
";
-		//var_dump($result);
-		//echo "
"; - return $result; - } - - public static function EditDocList($tpl_dir) - { - global $AVE_DB, $AVE_Template; - $imports = array(); + if ($rubric_id > 0) + { + $rows = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_documents LIMIT 1"); + } - $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_module_editdoc"); + while ($row = $rows->FetchAssocArray()) + { + $header = $row; + } - while ($result = $sql->FetchRow()) - { - array_push($imports, $result); - } + if ($rubric_id > 0) + { + foreach($header as $k => &$v) + { + $v = ''; + } + } - $rubs = array(); + $felds = array(); + + $feldsType = array(); + + if(! $rubric_id > 0) + { + $rows = $AVE_DB->Query(" + SELECT + doc.Id AS df_id, + rub.*, + rubric_field_default, + doc.field_value + FROM + " . PREFIX . "_rubric_fields AS rub + LEFT JOIN + " . 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(" + SELECT + 0 as df_id, + rub.*, + rubric_field_default, + rubric_field_default as field_value + FROM + " . PREFIX . "_rubric_fields AS rub + WHERE + rub.rubric_id = '" . $rubric_id . "' + ORDER BY + rubric_field_position ASC + "); + } - $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); + while ($row = $rows->FetchAssocArray()) + { + $felds[$row['Id']]=$row['df_id'] + ? $row['field_value'] + : $row['rubric_field_default']; - while ($result = $sql->FetchRow()) - { - array_push($rubs, $result); - } + $feldsType[$row['Id']]['type']=$row['rubric_field_type']; - $AVE_Template->assign('editdocs', $imports); - $AVE_Template->assign('rubs', $rubs); - $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_list.tpl')); - } + $feldsType[$row['Id']]['title']=$row['rubric_field_title']; + } - /** - * Добавление нового - * - * @param int $import_id идентификатор - * @param string $tpl_dir - путь к папке с шаблонами модуля - * - */ - public static function EditDocNew($tpl_dir) - { - global $AVE_DB, $AVE_Template; + $result['header'] = $header; + $result['body'] = $felds; + $result['feld_type'] = $feldsType; - $rubs = array(); + // Debug::_echo($result, true); + + return $result; + } - $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); - while ($result = $sql->FetchRow()) + public static function EditDocList($tpl_dir) { - array_push($rubs, $result); - } + global $AVE_DB, $AVE_Template; - $AVE_Template->assign('rubs',$rubs); - $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); - } + $imports = array(); - /** - * Редактирование - * - * @param int $import_id идентификатор - * @param string $tpl_dir - путь к папке с шаблонами модуля - * - */ - public static function EditDocEdit($import_id, $tpl_dir) - { - global $AVE_DB, $AVE_Template,$AVE_Document; + $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_module_editdoc"); - if (is_numeric($import_id)) - { - $sql = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_module_editdoc - WHERE id = '" . $import_id . "' - "); + while ($result = $sql->FetchRow()) + { + array_push($imports, $result); + } + + $rubs = array(); + + $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); - $row = $sql->FetchAssocArray(); + while ($result = $sql->FetchRow()) + { + array_push($rubs, $result); + } + + $AVE_Template->assign('editdocs', $imports); + $AVE_Template->assign('rubs', $rubs); + $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_list.tpl')); } - else + + + /** + * Добавление нового + * + * @param int $import_id идентификатор + * @param string $tpl_dir - путь к папке с шаблонами модуля + * + */ + public static function EditDocNew($tpl_dir) { - $row['editdoc_name'] = ''; - $row['editdoc_fill_filters']=''; + global $AVE_DB, $AVE_Template; + + $rubs = array(); + + $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); + + while ($result = $sql->FetchRow()) + { + array_push($rubs, $result); + } + + $AVE_Template->assign('rubs',$rubs); + $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); } - $row['editdoc_fill_filters']=unserialize(base64_decode($row['editdoc_fill_filters'])); - $rubs = array(); - $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); - while ($result = $sql->FetchRow()) + + /** + * Редактирование + * + * @param int $import_id идентификатор + * @param string $tpl_dir - путь к папке с шаблонами модуля + * + */ + public static function EditDocEdit($import_id, $tpl_dir) { - array_push($rubs, $result); - } + global $AVE_DB, $AVE_Template,$AVE_Document; + + if (is_numeric($import_id)) + { + $sql = $AVE_DB->Query(" + SELECT + * + FROM + " . PREFIX . "_module_editdoc + WHERE + id = '" . $import_id . "' + "); + + $row = $sql->FetchAssocArray(); + } + else + { + $row['editdoc_name'] = ''; + $row['editdoc_fill_filters'] = ''; + } - $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']){ + $template = false; - $tmpl="
\r\n - \r\n - \">\r\n - "; + $row['editdoc_fill_filters'] = unserialize(base64_decode($row['editdoc_fill_filters'])); - foreach($data['header'] as $k => $v) - $tmpl.="
[header:$k]
\r\n"; + $rubs = array(); - foreach($data['body'] as $k => $v) - $tmpl.="
[body:$k]
\r\n"; + $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics"); - $tmpl.='
'; - $row['editdoc_template']=$tmpl; - } + while ($result = $sql->FetchRow()) + { + array_push($rubs, $result); + } - $AVE_Template->assign('data',$data); - unset($row['editdoc_fill_filters']); - $AVE_Template->assign($row); - $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); - } + $AVE_Template->assign('rubs',$rubs); + $data = editdoc::getRubricFields($row['editdoc_rub'],$row['editdoc_fill_filters']); - /** - * Удаление - * - * @param int $import_id идентификатор - */ - public static function EditDocDelete($import_id) - { - global $AVE_DB; + //$data = editdoc::documentGet(null, $import_id); - if (is_numeric($import_id)) - { - $AVE_DB->Query(" - DELETE - FROM " . PREFIX . "_module_editdoc - WHERE id = '" . $import_id . "' - "); - } + if($row['editdoc_template'] == '') + { + $tmpl = "
\r\n\t\r\n\t\">\r\n\n"; - header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); - } - - - /** - * Получение полей Документа - * - * @param inc $id - идентификатор рубрики - * @param array $array - массив со значениями - */ - public static function getRubricFields($id,$array) - { - global $AVE_DB; - $res=array(); - if(!is_array($array))$array=Array(); - $res=Array(); - $res['header']=array(); - $res['header']['document_parent'][0]=($array['header']['document_parent'] ? $array['header']['document_parent'] : ""); - $res['header']['document_title'][0]=($array['header']['document_title'] ? $array['header']['document_title'] : ""); - $res['header']['document_alias'][0]=($array['header']['document_alias'] ? $array['header']['document_alias'] : ""); - $res['header']['document_published'][0]=($array['header']['document_published'] ? $array['header']['document_published'] : ""); - $res['header']['document_expire'][0]=($array['header']['document_expire'] ? $array['header']['document_expire'] : ""); - $res['header']['document_meta_keywords'][0]=($array['header']['document_meta_keywords'] ? $array['header']['document_meta_keywords'] : ""); - $res['header']['document_meta_description'][0]=($array['header']['document_meta_description'] ? $array['header']['document_meta_description'] : ""); - $res['header']['document_in_search'][0]=($array['header']['document_in_search'] ? $array['header']['document_in_search'] : ""); - $res['header']['document_meta_robots'][0]=($array['header']['document_meta_robots'] ? $array['header']['document_meta_robots'] : ""); - $res['header']['document_status'][0]=($array['header']['document_status'] ? $array['header']['document_status'] : ""); - $res['header']['document_deleted'][0]=($array['header']['document_deleted'] ? $array['header']['document_deleted']: ""); - $res['header']['document_count_print'][0]=($array['header']['document_count_print'] ? $array['header']['document_count_print'] : ""); - $res['header']['document_count_view'][0]=($array['header']['document_count_view'] ? $array['header']['document_count_view'] : ""); - $res['header']['document_linked_navi_id'][0]=($array['header']['document_linked_navi_id'] ? $array['header']['document_linked_navi_id'] : ""); - 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()) - { - $func='get_field_'.$result['rubric_field_type']; - if(!is_callable($func)) $func='get_field_default'; - $val=''; - $field=$func("{{ХХХХ}}",'edit',$result['Id'],'',0,$x,0,0,$result['rubric_field_default']); - $field=str_ireplace('{{ХХХХ}}',$val,$field); - $a=array( - '0'=>$result['rubric_field_title'], - '1'=>( - $array['body'][$result['Id']] ? - $array['body'][$result['Id']]: - "" - ), - '2'=>(isset($array['template'][$result['Id']]) ? $array['template'][$result['Id']] : $field) - ); - $res['body'][$result['Id']]=$a; + foreach($data['header'] as $k => $v) + $tmpl .= "\t
\r\n\t\t[header:$k]\r\n\t
\r\n"; + + $tmpl .= "\r\n"; + + foreach($data['body'] as $k => $v) + $tmpl .= "\t
\r\n\t\t\r\n\t\t[body:$k]\r\n\t
\r\n"; + + $tmpl .= "\r\n"; + + $tmpl .= "\t\r\n
"; + + $row['editdoc_template'] = $tmpl; + } + else + { + $template = true; + } + + $AVE_Template->assign('template', $template); + + $AVE_Template->assign('data', $data); + + unset($row['editdoc_fill_filters']); + + $AVE_Template->assign($row); + + $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_edit.tpl')); } - return $res; - } - /** - * Сохранение импорта - * - * @param int $import_id идентификатор импорта - */ - public static function EditDocSave($import_id = null) - { - global $AVE_DB; - function stripslashes_deep($value) + /** + * Удаление + * + * @param int $import_id идентификатор + */ + public static function EditDocDelete($import_id) { - $value = is_array($value) ? - array_map('stripslashes_deep', $value) : - stripslashes($value); + global $AVE_DB; + + if (is_numeric($import_id)) + { + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_editdoc + WHERE id = '" . $import_id . "' + "); + } - return $value; + header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); } - $v=base64_encode(serialize(stripslashes_deep($_REQUEST['document']))); - if (is_numeric($import_id)) + /** + * Получение полей Документа + * + * @param inc $id - идентификатор рубрики + * @param array $array - массив со значениями + */ + public static function getRubricFields($id,$array) { - $sql=" - UPDATE " . PREFIX . "_module_editdoc - SET - `editdoc_name` = '" . ($_REQUEST['editdoc_name']) . "', - ".($_REQUEST['editdoc_rub']> '' ? "`editdoc_rub` = '" . ($_REQUEST['editdoc_rub']) . "'," : "")." - `editdoc_lastchange` = '" . ($_REQUEST['editdoc_lastchange']) . "', - `editdoc_fill_filters` = '" . $v . "', - `editdoc_template` = '" . $_REQUEST['editdoc_template'] . "', - `editdoc_afteredit` = '" . (($_REQUEST['editdoc_afteredit'] ? $_REQUEST['editdoc_afteredit'] : addslashes(""))) . "' + global $AVE_DB; + + $res = array(); + + if(! is_array($array)) + $array = array(); + + $res['header'] = array(); + + $res['header']['document_parent'][0]= ($array['header']['document_parent'] + ? $array['header']['document_parent'] + : ""); + + $res['header']['document_title'][0] = ($array['header']['document_title'] + ? $array['header']['document_title'] + : ""); + + $res['header']['document_alias'][0] = ($array['header']['document_alias'] + ? $array['header']['document_alias'] + : ""); + + $res['header']['document_published'][0] = ($array['header']['document_published'] + ? $array['header']['document_published'] + : ""); + + $res['header']['document_expire'][0] = ($array['header']['document_expire'] + ? $array['header']['document_expire'] + : ""); + + $res['header']['document_meta_keywords'][0] = ($array['header']['document_meta_keywords'] + ? $array['header']['document_meta_keywords'] + : ""); + + $res['header']['document_meta_description'][0] = ($array['header']['document_meta_description'] + ? $array['header']['document_meta_description'] + : ""); + + $res['header']['document_in_search'][0] = ($array['header']['document_in_search'] + ? $array['header']['document_in_search'] + : ""); + + $res['header']['document_meta_robots'][0] = ($array['header']['document_meta_robots'] + ? $array['header']['document_meta_robots'] + : ""); + + $res['header']['document_status'][0]=($array['header']['document_status'] + ? $array['header']['document_status'] + : ""); + + $res['header']['document_deleted'][0]=($array['header']['document_deleted'] + ? $array['header']['document_deleted'] + : ""); + + $res['header']['document_count_print'][0]=($array['header']['document_count_print'] + ? $array['header']['document_count_print'] + : ""); + + $res['header']['document_count_view'][0] = ($array['header']['document_count_view'] + ? $array['header']['document_count_view'] + : ""); + + $res['header']['document_linked_navi_id'][0] = ($array['header']['document_linked_navi_id'] + ? $array['header']['document_linked_navi_id'] + : ""); + + 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 - id = '" . $import_id . "' - "; + rubric_id = ".$id + ); + + while ($result = $sql->FetchAssocArray()) + { + $field = "\r\n"; + $field .= ''; + + $a = array( + '0' => $result['rubric_field_title'], + '1' => ($array['body'][$result['Id']] + ? $array['body'][$result['Id']] + : "" + ), + '2' => (isset($array['template'][$result['Id']]) + ? $array['template'][$result['Id']] + : $field) + ); + + $res['body'][$result['Id']] = $a; + } + + return $res; } - else + + + /** + * Сохранение импорта + * + * @param int $import_id идентификатор импорта + */ + public static function EditDocSave($import_id = null) { - $sql=" - INSERT - INTO " . PREFIX . "_module_editdoc - SET - id = '', - `editdoc_name` = '" . ($_REQUEST['editdoc_name']) . "', - ".($_REQUEST['editdoc_rub']> '' ? "`editdoc_rub` = '" . ($_REQUEST['editdoc_rub']) . "'," : "")." - `editdoc_lastchange` = '" . ($_REQUEST['editdoc_lastchange']) . "', - `editdoc_fill_filters` = '" . $v . "', - `editdoc_template` = '" . ($_REQUEST['editdoc_template']) . "', - `editdoc_afteredit` = '" . ($_REQUEST['editdoc_afteredit']) . "' - "; + global $AVE_DB; + + function stripslashes_deep($value) + { + $value = is_array($value) + ? array_map('stripslashes_deep', $value) + : stripslashes($value); + + return $value; + } + + $template = base64_encode(serialize(stripslashes_deep($_REQUEST['document']))); + + if (is_numeric($import_id)) + { + $sql=" + UPDATE + " . PREFIX . "_module_editdoc + SET + editdoc_name = '" . $_REQUEST['editdoc_name'] . "', + editdoc_last_change = '" . time() . "', + editdoc_fill_filters = '" . $template . "', + editdoc_template = '" . $_REQUEST['editdoc_template'] . "', + editdoc_use_revisions = '" . ($_REQUEST['editdoc_use_revisions'] ? $_REQUEST['editdoc_use_revisions'] : 0) . "', + editdoc_use_rubric_code = '" . ($_REQUEST['editdoc_use_rubric_code'] ? $_REQUEST['editdoc_use_rubric_code'] : 0) . "', + editdoc_use_log_save = '" . ($_REQUEST['editdoc_use_log_save'] ? $_REQUEST['editdoc_use_log_save'] : 0) . "', + editdoc_before_edit = '" . $_REQUEST['editdoc_before_edit'] . "', + editdoc_after_edit = '" . $_REQUEST['editdoc_after_edit'] . "' + WHERE + id = '" . $import_id . "' + "; + } + else + { + + $editdoc_before_edit = ""; + $editdoc_after_edit = ""; + + $sql = " + INSERT INTO + " . PREFIX . "_module_editdoc + SET + id = '', + editdoc_name = '" . $_REQUEST['editdoc_name'] . "', + editdoc_rub = '" . $_REQUEST['editdoc_rub'] . "', + editdoc_last_change = '" . time() . "', + editdoc_fill_filters = '" . $template . "', + editdoc_template = '" . $_REQUEST['editdoc_template'] . "', + 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); + header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); } - $AVE_DB->Query($sql); - header('Location:index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp=' . SESSION); - } - - static function EditDocDo($import_id) - { - global $AVE_DB, $AVE_Document; - - if (is_numeric($import_id)) + + static function EditDocDo($import_id) { - $sql = $AVE_DB->Query(" - SELECT * - FROM " . PREFIX . "_module_editdoc - WHERE id = '" . $import_id . "' - "); - $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); - $data=editdoc::documentGet($document_id,(int)$row['editdoc_rub']); - //Пришла форма - if(isset($_REQUEST['editdoc_action']) && $_REQUEST['editdoc_action']==$import_id){ - //вот тут сохранение будет - $save=true; - foreach($row['editdoc_fill_filters']['header'] as $k=>$v) + global $AVE_DB, $AVE_Document; + + if (is_numeric($import_id)) + { + $sql = $AVE_DB->Query(" + SELECT + * + FROM + " . PREFIX . "_module_editdoc + WHERE + id = '" . $import_id . "' + "); + + $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); + + $data = editdoc::documentGet($document_id, (int)$row['editdoc_rub']); + + //Пришла форма + if(isset($_REQUEST['editdoc_action']) && $_REQUEST['editdoc_action'] == $import_id) { - $exp=' - function editdoc_reth_'.$import_id.'_'.$k.'($data){ - ?>'.trim($v).' $v) + { + $exp = ' + function editdoc_reth_' . $import_id . '_' . $k . '($data) + { + ?>'.trim($v).'$v) - { - $exp=' - function editdoc_retb_'.$import_id.'_'.$k.'($data){ - ?>'.trim($v).' $v) + { + $exp = ' + function editdoc_retb_'.$import_id.'_'.$k.'($data) + { + ?>'.trim($v).'documentPermissionFetch($row['editdoc_rub']); + + require_once(BASE_DIR.'/admin/functions/func.admin.common.php'); + + if ($save) + { + // Код перед сохранением + eval(' ?>'.$row['editdoc_before_edit'].'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'].'documentPermissionFetch($row['editdoc_rub']); - 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'].'$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(' ?>'.$template.' $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.' \ No newline at end of file diff --git a/editdoc/lang/ru.txt b/editdoc/lang/ru.txt index b7593ea..3ef2ec4 100644 --- a/editdoc/lang/ru.txt +++ b/editdoc/lang/ru.txt @@ -1,3 +1,4 @@ +[admin] EDITDOC_EDIT = "Публикатор" EDITDOC_EDIT_TIP = "В данном разделе предоставлены все публикаторы документов." EDITDOC_ID = "Id" @@ -29,6 +30,7 @@ EDITDOC_EDIT_H = "Редактирование публикатора" EDITDOC_TABLE_HEADER = "?" EDITDOC_SAVEDIT_NEXT = "Сохранить и продолжить редактирование" EDITDOC_SAVED = "Шаблон публикатора успешно сохранен" +EDITDOC_HEADER_BEFORE = "Код перед сохранением документа" EDITDOC_HEADER_AFTER = "Код после успешного добавления документа" EDITDOC_HEADER_BODY = "Основное содержимое документа" EDITDOC_HEADER_HEAD = "Параметры документа" @@ -36,4 +38,11 @@ EDITDOC_HEADER_FORM = "Шаблон вывода формы в публично EDITDOC_HEADER_FORM = "Параметры документа" EDITDOC_HEADER_PHP = "Шаблон PHP" EDITDOC_HEADER_INSTR = "Инструмент ввода" -EDITDOC_HEADER_CORE = "Обработчик" \ No newline at end of file +EDITDOC_HEADER_CORE = "Обработчик" +EDITDOC_USE_CODE = "Использовать Исполняемый код рубрики" +EDITDOC_USE_REVISIONS = "Сохранять ревизии документов" +EDITDOC_NOT_TEMPLATE = "Данные формы отсутствуют. Представлены демонстративные данные." +EDITDOC_TAG_HEADER = "Поле параметров документа" +EDITDOC_TAG_BODY = "Поле тела документа" +EDITDOC_TAG_TITLE = "Заголовок поля" +EDITDOC_TAG_TYPE = "Тип поля" \ No newline at end of file diff --git a/editdoc/module.php b/editdoc/module.php index f2888ba..27b450c 100644 --- a/editdoc/module.php +++ b/editdoc/module.php @@ -1,77 +1,83 @@ "; -} - - -function mod_editdoc($id) -{ - global $AVE_DB, $AVE_Core, $AVE_Template; - if (! (is_file(BASE_DIR . '/modules/editdoc/class.editdoc.php') && - @require_once(BASE_DIR . '/modules/editdoc/class.editdoc.php'))) module_error(); - echo editdoc::EditDocDo($id); - -} -/** - * Администрирование - */ - -if (defined('ACP') && !empty($_REQUEST['moduleaction'])) -{ - if (! (is_file(BASE_DIR . '/modules/editdoc/class.editdoc.php') && - @require_once(BASE_DIR . '/modules/editdoc/class.editdoc.php'))) module_error(); - - $tpl_dir = BASE_DIR . '/modules/editdoc/templates/'; - $lang_file = BASE_DIR . '/modules/editdoc/lang/' . $_SESSION['user_language'] . '.txt'; - - $AVE_Template->config_load($lang_file); - switch ($_REQUEST['moduleaction']) + /** + * AVE.cms - Модуль Публикатор документов + * + * @package AVE.cms + * @subpackage module_EditDoc + * @filesource + */ + + if (! defined('BASE_DIR')) + exit; + + if (defined('ACP')) { - case '1': - editdoc::EditDocList($tpl_dir); - break; + $modul['ModuleName'] = "Публикатор документов"; + $modul['ModuleSysName'] = "editdoc"; + $modul['ModuleVersion'] = "1.6"; + $modul['ModuleDescription'] = "Данный модуль предназначен для создания форм ввода и редактирования документов на сайте"; + $modul['ModuleAutor'] = "Ave.cms Team"; + $modul['ModuleCopyright'] = "© 2017 Ave-cms.ru"; + $modul['ModuleIsFunction'] = 1; + $modul['ModuleTemplate'] = 0; + $modul['ModuleAdminEdit'] = 1; + $modul['ModuleFunction'] = "mod_editdoc"; + $modul['ModuleTag'] = '[mod_editdoc:XXX]'; + $modul['ModuleTagLink'] = null; + $modul['ModuleAveTag'] = '#\\\[mod_editdoc:(\\\d+)]#'; + $modul['ModulePHPTag'] = ""; + } - case 'del': - editdoc::EditDocDelete($_REQUEST['id']); - break; - case 'new': - editdoc::EditDocNew($tpl_dir); - break; + //======================================================= + // Вызов модуля по тегу + //======================================================= + function mod_editdoc($id) + { + global $AVE_DB, $AVE_Core, $AVE_Template; - case 'edit': - editdoc::EditDocEdit(isset($_REQUEST['id']) ? $_REQUEST['id'] : null, $tpl_dir); - break; + if (! (is_file(BASE_DIR . '/modules/editdoc/class.editdoc.php') && @require_once(BASE_DIR . '/modules/editdoc/class.editdoc.php'))) + module_error(); - case 'saveedit': - editdoc::EditDocSave(isset($_REQUEST['id']) ? $_REQUEST['id'] : null); - break; + echo Editdoc::EditDocDo($id); } -} + + //======================================================= + // Управление модулем в Панели управления + //======================================================= + if (defined('ACP') && !empty($_REQUEST['moduleaction'])) + { + if (! (is_file(BASE_DIR . '/modules/editdoc/class.editdoc.php') && @require_once(BASE_DIR . '/modules/editdoc/class.editdoc.php'))) + module_error(); + + $tpl_dir = BASE_DIR . '/modules/editdoc/templates/'; + $lang_file = BASE_DIR . '/modules/editdoc/lang/' . $_SESSION['user_language'] . '.txt'; + + $AVE_Template->config_load($lang_file, 'admin'); + + switch ($_REQUEST['moduleaction']) + { + case '1': + Editdoc::EditDocList($tpl_dir); + break; + + case 'del': + Editdoc::EditDocDelete($_REQUEST['id']); + break; + + case 'new': + Editdoc::EditDocNew($tpl_dir); + break; + + case 'edit': + Editdoc::EditDocEdit(isset($_REQUEST['id']) ? $_REQUEST['id'] : null, $tpl_dir); + break; + + case 'saveedit': + Editdoc::EditDocSave(isset($_REQUEST['id']) ? $_REQUEST['id'] : null); + break; + } + } ?> \ No newline at end of file diff --git a/editdoc/sql.php b/editdoc/sql.php index d885b89..378ab24 100644 --- a/editdoc/sql.php +++ b/editdoc/sql.php @@ -1,52 +1,50 @@ \ No newline at end of file diff --git a/editdoc/templates/admin_edit.tpl b/editdoc/templates/admin_edit.tpl index f2945d0..c8a41ae 100644 --- a/editdoc/templates/admin_edit.tpl +++ b/editdoc/templates/admin_edit.tpl @@ -1,120 +1,148 @@ - - - - - - - - - -{literal} - -{/literal} - -
{#EDITDOC_INSERT_H#}
+
+
{#EDITDOC_INSERT_H#}
+
-
+
{#EDITDOC_INSERT#} -
+
+{if $template != true} + +{/if} +
{if $smarty.request.id != ''} +{include file="$codemirror_connect"} +
-
{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}
+
+
{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}
+
+ + + + + + + + + + + + + + + + +
{#EDITDOC_NAME#} +
+ +
+
{#EDITDOC_RUBRICS#} + +
{#EDITDOC_USE_CODE#} +
+ +
+
{#EDITDOC_USE_REVISIONS#} +
+ +
+
+
+ +
+
+
{#EDITDOC_HEADER_FORM#}
+
+ + + - - + + + - + |  + [header:XXX] |  + [body:XXX] |  + [title:XXX] |  + [type:XXX] | + + + + + + + +
{#EDITDOC_NAME#}
{#EDITDOC_HEADER_PHP#}
{#EDITDOC_RUBRICS#} - -
+ +
+ |  + OL |  + UL |  + LI |  + P |  + B |  + I |  + H1 |  + H2 |  + H3 |  + H4 |  + H5 |  + DIV |  + A |  + IMG |  + SPAN |  + PRE |  + BR |  + TAB | +
-
-
-
{#EDITDOC_HEADER_FORM#}
- - - - - - - - - - - - - - - -
{#EDITDOC_HEADER_PHP#}
- -
- |  - OL |  - UL |  - LI |  - P |  - B |  - I |  - H1 |  - H2 |  - H3 |  - H4 |  - H5 |  - DIV |  - A |  - IMG |  - SPAN |  - PRE |  - BR |  - TAB | -
- -
- -
-
{#EDITDOC_HEADER_HEAD#}
- +
+
{#EDITDOC_HEADER_HEAD#}
+
- - - + + + @@ -124,32 +152,35 @@ - {foreach from=$data.header key=k item=v} - - - - - - {/foreach} + {foreach from=$data.header key=k item=v} + + + + + + {/foreach}
 
- $data['header']['{$k}'] - -
-
-
-
+ $data['header']['{$k}'] + +
+ {include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_header_$k" textarea_id="document_header_$k" height=100} +
+
+ {include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_template_$k" textarea_id="document_template_$k" height=100} +
-
-
{#EDITDOC_HEADER_BODY#}
+
+
{#EDITDOC_HEADER_BODY#}
+
- - - + + + @@ -165,10 +196,16 @@ $data['body']['{$k}'] {/foreach} @@ -176,60 +213,113 @@
  -
+
+ +
+ {include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_body_$k" textarea_id="document_body_$k" height=120}
-
+
+ +
+ {include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_body_template_$k" textarea_id="document_body_template_$k" height=120}
-
-
{#EDITDOC_HEADER_AFTER#}
- - - - - - - - - - - - - - - - - -
{#EDITDOC_HEADER_PHP#}
- -
- |  - OL |  - UL |  - LI |  - P |  - B |  - I |  - H1 |  - H2 |  - H3 |  - H4 |  - H5 |  - DIV |  - A |  - IMG |  - SPAN |  - PRE |  - BR |  - TAB | -
- - -  или  - -
+ +
+
+
{#EDITDOC_HEADER_BEFORE#}
+
+ + + + + + + + + + + + + + + +
{#EDITDOC_HEADER_PHP#}
+ +
+ |  + OL |  + UL |  + LI |  + P |  + B |  + I |  + H1 |  + H2 |  + H3 |  + H4 |  + H5 |  + DIV |  + A |  + IMG |  + SPAN |  + PRE |  + BR |  + TAB | +
+
+ +
+
+
{#EDITDOC_HEADER_AFTER#}
+ + + + + + + + + + + + + + +
{#EDITDOC_HEADER_PHP#}
+ +
+ |  + OL |  + UL |  + LI |  + P |  + B |  + I |  + H1 |  + H2 |  + H3 |  + H4 |  + H5 |  + DIV |  + A |  + IMG |  + SPAN |  + PRE |  + BR |  + TAB | +
+
+
+ + +   + +
+
+
+ + +{include file="$codemirror_editor" conn_id="" textarea_id='editdoc_template' ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' height=420} +{include file="$codemirror_editor" conn_id="2" textarea_id='editdoc_before_edit' ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' height=440} +{include file="$codemirror_editor" conn_id="3" textarea_id='editdoc_after_edit' ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' height=440} + - {else} - -
-
{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}
- - - - - - - - - - - - - - -
{#EDITDOC_NAME#}
{#EDITDOC_RUBRICS#} - -
- -
+{else} +
+
+
{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}
- {/if} + + + + + + + + + + + + + +
{#EDITDOC_NAME#}
{#EDITDOC_RUBRICS#} + +
+ +
+ +
+ +{/if}




\ No newline at end of file