Browse Source

версия 1.6

master
root 8 years ago
parent
commit
4727bc64bb
  1. 12
      README.md
  2. 844
      editdoc/class.editdoc.php
  3. 11
      editdoc/lang/ru.txt
  4. 140
      editdoc/module.php
  5. 96
      editdoc/sql.php
  6. 561
      editdoc/templates/admin_edit.tpl

12
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

844
editdoc/class.editdoc.php

@ -1,380 +1,580 @@
<?php
class editdoc
{
/**
* Метод, предназначенный для получения структуры документа из БД
*
* @param int $document_id идентификатор Документа
* return - возвращает документ положенный в структуру ....
**/
public static function documentGet($document_id,$rubric_id=0){
global $AVE_DB;
//var_dump($document_id);
$document_id=(int)$document_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";
$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
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 "<pre>";
//var_dump($result);
//echo "</pre>";
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="<form method=\"post\">\r\n
<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
";
$row['editdoc_fill_filters'] = unserialize(base64_decode($row['editdoc_fill_filters']));
foreach($data['header'] as $k => $v)
$tmpl.=" <div id=\"edit_doc_header_$k\">[header:$k]</div>\r\n";
$rubs = array();
foreach($data['body'] as $k => $v)
$tmpl.=" <div id=\"edit_doc_body_$k\"><label>".$v[0]."</label>[body:$k]</div>\r\n";
$sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_rubrics");
$tmpl.='<input type="submit" value="Сохранить"></form>';
$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 = "<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";
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'] : "<?\r\n return '0';\r\n?>");
$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']['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_meta_keywords'][0]=($array['header']['document_meta_keywords'] ? $array['header']['document_meta_keywords'] : "<?\r\n return '';\r\n?>");
$res['header']['document_meta_description'][0]=($array['header']['document_meta_description'] ? $array['header']['document_meta_description'] : "<?\r\n return '';\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_status'][0]=($array['header']['document_status'] ? $array['header']['document_status'] : "<?\r\n return '0';\r\n?>");
$res['header']['document_deleted'][0]=($array['header']['document_deleted'] ? $array['header']['document_deleted']: "<?\r\n return '0';\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_linked_navi_id'][0]=($array['header']['document_linked_navi_id'] ? $array['header']['document_linked_navi_id'] : "<?\r\n return '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())
{
$func='get_field_'.$result['rubric_field_type'];
if(!is_callable($func)) $func='get_field_default';
$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']);
$field=str_ireplace('{{ХХХХ}}',$val,$field);
$a=array(
'0'=>$result['rubric_field_title'],
'1'=>(
$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)
);
$res['body'][$result['Id']]=$a;
foreach($data['header'] as $k => $v)
$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)
$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>";
$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("<?php
//header('Location: /'.rewrite_link('index.php?id='.\$GLOBALS['mod_editdoc'][".$import_id."]));
//exit();
?>"))) . "'
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']
: "<?\r\n\treturn '0';\r\n?>");
$res['header']['document_title'][0] = ($array['header']['document_title']
? $array['header']['document_title']
: "<?\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_alias'][0] = ($array['header']['document_alias']
? $array['header']['document_alias']
: "<?\r\n\treturn '';\r\n?>");
$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
id = '" . $import_id . "'
";
rubric_id = ".$id
);
while ($result = $sql->FetchAssocArray())
{
$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";
$field .= '<input type="text" id="field_' . $result['Id'] . '" placeholder="[title:' . $result['Id'] . ']" name="feld['.$result['Id'].']" value="<?= $field_' . $result['Id'] . '; ?>">';
$a = array(
'0' => $result['rubric_field_title'],
'1' => ($array['body'][$result['Id']]
? $array['body'][$result['Id']]
: "<?\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?>"
),
'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 = "<?\r\n\t//Debug::_echo(\$_REQUEST, true);\r\n?>";
$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
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).'<?
};';
eval($exp);
$ret='editdoc_reth_'.$import_id.'_'.$k;
$data['header'][$k]=$ret($data);
if($data['header'][$k]===NULL){
$save=false;
//вот тут сохранение будет
$save = true;
foreach($row['editdoc_fill_filters']['header'] as $k => $v)
{
$exp = '
function editdoc_reth_' . $import_id . '_' . $k . '($data)
{
?>'.trim($v).'<?
};
';
eval($exp);
$ret = 'editdoc_reth_' . $import_id . '_' . $k;
$data['header'][$k] = $ret($data);
if($data['header'][$k] === NULL)
{
$save=false;
}
}
}
$data['header']['rubric_id']=$row['editdoc_rub'];
foreach($row['editdoc_fill_filters']['body'] as $k=>$v)
{
$exp='
function editdoc_retb_'.$import_id.'_'.$k.'($data){
?>'.trim($v).'<?
};';
eval($exp);
$ret='editdoc_retb_'.$import_id.'_'.$k;
$data['body'][$k]=$ret($data);
if($data['body'][$k]===NULL){
$save=false;
$data['header']['rubric_id']=$row['editdoc_rub'];
foreach($row['editdoc_fill_filters']['body'] as $k => $v)
{
$exp = '
function editdoc_retb_'.$import_id.'_'.$k.'($data)
{
?>'.trim($v).'<?
};
';
eval($exp);
$ret = 'editdoc_retb_' . $import_id . '_' . $k;
$data['body'][$k] = $ret($data);
if($data['body'][$k] === NULL)
{
$save = false;
}
}
$d = $data['header'];
$d['doc_title'] = $d['document_title'];
$d['feld'] = $data['body'];
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');
if ($save)
{
// Код перед сохранением
eval(' ?>'.$row['editdoc_before_edit'].'<? ');
// Надо перед сохранением уточнить являюсь ли я хозяином документа .....не забыть!!!!!!!!!! а то админы тут делов наделают
$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'].'<? ');
}
}
$d=$data['header'];
$d['doc_title']=$d['document_title'];
$d['feld']=$data['body'];
require(BASE_DIR . '/lib/redactor/ckeditor/ckeditor.php');
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');
if($save){
//надо перед сохранением уточнить являюсь ли я хозяином документа .....не забыть!!!!!!!!!! а то админы тут делов наделают
$GLOBALS['mod_editdoc'][$import_id]=@$AVE_Document->documentSave((int)$row['editdoc_rub'],$document_id,$d,true);
eval(' ?>'.$row['editdoc_afteredit'].'<? ');
}
}
$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(' ?>'.$template.'<? ');
$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.'<? ');
}
}
}
?>

11
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 = "Обработчик"
EDITDOC_HEADER_CORE = "Обработчик"
EDITDOC_USE_CODE = "Использовать <strong>Исполняемый код рубрики</strong>"
EDITDOC_USE_REVISIONS = "Сохранять ревизии документов"
EDITDOC_NOT_TEMPLATE = "Данные формы отсутствуют. Представлены демонстративные данные."
EDITDOC_TAG_HEADER = "Поле параметров документа"
EDITDOC_TAG_BODY = "Поле тела документа"
EDITDOC_TAG_TITLE = "Заголовок поля"
EDITDOC_TAG_TYPE = "Тип поля"

140
editdoc/module.php

@ -1,77 +1,83 @@
<?php
/**
* AVE.cms - Модуль Публикатор документов
*
* @package AVE.cms
* @subpackage module_EditDoc
* @filesource
*/
if(!defined('BASE_DIR')) exit;
if (defined('ACP'))
{
$modul['ModuleName'] = "Публикатор документов";
$modul['ModuleSysName'] = "editdoc";
$modul['ModuleVersion'] = "1.0.2";
$modul['ModuleDescription'] = "Данный модуль предназначен для создания форм ввода и редактирования документов на сайте";
$modul['ModuleAutor'] = "Ave.cms Team";
$modul['ModuleCopyright'] = "&copy; 2012 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'] = "<?php mod_editdoc(''$1''); ?>";
}
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'] = "&copy; 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'] = "<?php mod_editdoc(''$1''); ?>";
}
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;
}
}
?>

96
editdoc/sql.php

@ -1,52 +1,50 @@
<?php
/**
* AVE.cms - Модуль Публикатор документов
*
* @package AVE.cms
* @subpackage module_EditDoc
* @filesource
*/
/**
* mySQL-запросы для установки, обновления и удаления модуля
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
//$module_sql_deinstall[] = "DROP TABLE IF EXISTS CPPREFIX_module_editdoc;";
$module_sql_install[] = "CREATE TABLE IF NOT EXISTS CPPREFIX_module_editdoc (
`id` mediumint(5) unsigned NOT NULL auto_increment,
`editdoc_lastchange` int(10) unsigned default NULL,
`editdoc_name` varchar(255) NOT NULL,
`editdoc_rub` int(10) unsigned default NULL,
`editdoc_template` longtext NOT NULL,
`editdoc_fill_filters` longtext NOT NULL,
`editdoc_afteredit` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
// Обновление модуля
$module_sql_update[] = "
UPDATE
`CPPREFIX_module`
SET
ModuleAveTag = '" . $modul['ModuleAveTag'] . "',
ModulePHPTag = '" . $modul['ModulePHPTag'] . "',
ModuleVersion = '" . $modul['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $modul['ModuleSysName'] . "'
LIMIT 1;
";
$module_sql_update[] = "
RENAME TABLE
`CPPREFIX_modul_editdoc`
TO
`CPPREFIX_module_editdoc`
";
/**
* AVE.cms - Модуль Публикатор документов
*
* @package AVE.cms
* @subpackage module_EditDoc
* @filesource
*/
/**
* mySQL-запросы для установки, обновления и удаления модуля
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
// Удаление модуля
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `CPPREFIX_module_editdoc`;";
// Установка модуля
$module_sql_install[] = "CREATE TABLE `CPPREFIX_module_editdoc` (
`id` mediumint(5) unsigned NOT NULL AUTO_INCREMENT,
`editdoc_name` varchar(255) NOT NULL,
`editdoc_rub` mediumint(5) DEFAULT NULL,
`editdoc_template` longtext NOT NULL,
`editdoc_fill_filters` longtext NOT NULL,
`editdoc_before_edit` longtext NOT NULL,
`editdoc_after_edit` longtext NOT NULL,
`editdoc_use_revisions` enum('0','1') NOT NULL DEFAULT '0',
`editdoc_use_rubric_code` enum('0','1') NOT NULL DEFAULT '0',
`editdoc_use_log_save` enum('0','1') NOT NULL DEFAULT '0',
`editdoc_last_change` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
// Обновление модуля
$module_sql_update[] = "
UPDATE
`CPPREFIX_module`
SET
ModuleAveTag = '" . $modul['ModuleAveTag'] . "',
ModulePHPTag = '" . $modul['ModulePHPTag'] . "',
ModuleVersion = '" . $modul['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $modul['ModuleSysName'] . "'
LIMIT 1;
";
?>

561
editdoc/templates/admin_edit.tpl vendored

@ -1,120 +1,148 @@
<link rel="stylesheet" href="{$ABS_PATH}lib/redactor/codemirror/lib/codemirror.css">
<script src="{$ABS_PATH}lib/redactor/codemirror/lib/codemirror.js" type="text/javascript"></script>
<script src="{$ABS_PATH}lib/redactor/codemirror/mode/xml/xml.js"></script>
<script src="{$ABS_PATH}lib/redactor/codemirror/mode/javascript/javascript.js"></script>
<script src="{$ABS_PATH}lib/redactor/codemirror/mode/css/css.js"></script>
<script src="{$ABS_PATH}lib/redactor/codemirror/mode/clike/clike.js"></script>
<script src="{$ABS_PATH}lib/redactor/codemirror/mode/php/php.js"></script>
{literal}
<style type="text/css">
.activeline {background: #e8f2ff !important;}
</style>
{/literal}
<div class="title"><h5>{#EDITDOC_INSERT_H#}</h5></div>
<div class="title">
<h5>{#EDITDOC_INSERT_H#}</h5>
</div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
<div class="body">
{#EDITDOC_INSERT#}
</div>
</div>
</div>
<div class="breadCrumbHolder module">
<div class="breadCrumb module">
<ul>
<li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li><a href="index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp={$sess}">{#EDITDOC_LIST_LINK#}</a></li>
<li><strong class="code">{if $smarty.request.id != ''}{$editdoc_name|escape}{else}{$smarty.request.editdoc_name}{/if}</strong></li>
</ul>
<ul>
<li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li><a href="index.php?do=modules&action=modedit&mod=editdoc&moduleaction=1&cp={$sess}">{#EDITDOC_LIST_LINK#}</a></li>
<li><strong class="code">{if $smarty.request.id != ''}{$editdoc_name|escape}{else}{$smarty.request.editdoc_name}{/if}</strong></li>
</ul>
</div>
</div>
{if $template != true}
<ul class="messages first">
<li class="highlight red">
<strong>{#EDITDOC_NOT_TEMPLATE#}</strong>
</li>
</ul>
{/if}
<form id="save_editdoc" action="index.php?do=modules&action=modedit&mod=editdoc&moduleaction=saveedit&cp={$sess}" method="post" class="mainForm">
{if $smarty.request.id != ''}
{include file="$codemirror_connect"}
<div class="widget first">
<div class="head"><h5 class="iFrames">{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}</h5></div>
<div class="head">
<h5 class="iFrames">{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<tr>
<td>{#EDITDOC_NAME#}</td>
<td>
<div class="pr12">
<input name="editdoc_name" class="mousetrap" type="text" value="{$editdoc_name|escape}" size="200" />
</div>
</td>
</tr>
<tr>
<td>{#EDITDOC_RUBRICS#}</td>
<td>
<select name="editdoc_rub" {if $smarty.request.id != ''}disabled="disabled"{/if} size="4">
{foreach from=$rubs item=rub}
{if $rub->Id == $editdoc_rub}
<option value="{$rub->Id}" selected>{$rub->rubric_title}</option>
{else}
<option value="{$rub->Id}">{$rub->rubric_title}</option>
{/if}
{/foreach}
</select>
</td>
</tr>
<tr>
<td>{#EDITDOC_USE_CODE#}</td>
<td>
<div class="pr12">
<input type="checkbox" value="1" name="editdoc_use_rubric_code" class="float" {if $editdoc_use_rubric_code}checked="checked"{/if} />
</div>
</td>
</tr>
<tr>
<td>{#EDITDOC_USE_REVISIONS#}</td>
<td>
<div class="pr12">
<input type="checkbox" value="1" name="editdoc_use_revisions" class="float" {if $editdoc_use_revisions}checked="checked"{/if} />
</div>
</td>
</tr>
</table>
</div>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#EDITDOC_HEADER_FORM#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<thead>
<tr>
<td>{#EDITDOC_NAME#}</td>
<td><div class="pr12"><input name="editdoc_name" class="mousetrap" type="text" value="{if $smarty.request.id != ''}{$editdoc_name|escape}{else}{$smarty.request.editdoc_name}{/if}" size="80" /></div></td>
<td>{#EDITDOC_HEADER_PHP#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>{#EDITDOC_RUBRICS#}</td>
<td>
<select name="editdoc_rub" {if $smarty.request.id != ''}disabled="disabled"{/if} size="4">
{foreach from=$rubs item=rub}
{if $rub->Id==$editdoc_rub}
<option value="{$rub->Id}" selected>{$rub->rubric_title}</option>
{else}
<option value="{$rub->Id}">{$rub->rubric_title}</option>
{/if}
{/foreach}
</select>
</td>
|&nbsp;
<a href="javascript:void(0);" class="topDir" title="{#EDITDOC_TAG_HEADER#}" onclick="textSelection('[header:', ']');"><strong>[header:XXX]</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class="topDir" title="{#EDITDOC_TAG_BODY#}" onclick="textSelection('[body:', ']');"><strong>[body:XXX]</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class="topDir" title="{#EDITDOC_TAG_TITLE#}" onclick="textSelection('[title:', ']');"><strong>[title:XXX]</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class="topDir" title="{#EDITDOC_TAG_TYPE#}" onclick="textSelection('[type:', ']');"><strong>[type:XXX]</strong></a>&nbsp;|
</td>
</tr>
<tr>
<td>
<textarea class="mousetrap" {$read_only} name="editdoc_template" id="editdoc_template" wrap="off" style="width:100%; height:340px">{$editdoc_template|default:$prefab|escape:html}</textarea>
</td>
</tr>
<tr>
<td>
|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<ol>', '</ol>');"><strong>OL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<ul>', '</ul>');"><strong>UL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<li>', '</li>');"><strong>LI</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<p class=&quot;&quot;>', '</p>');"><strong>P</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<strong>', '</strong>');"><strong>B</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<em>', '</em>');"><strong>I</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h1>', '</h1>');"><strong>H1</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h2>', '</h2>');"><strong>H2</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h3>', '</h3>');"><strong>H3</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h4>', '</h4>');"><strong>H4</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h5>', '</h5>');"><strong>H5</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<div class=&quot;&quot; id=&quot;&quot;>', '</div>');"><strong>DIV</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<a href=&quot;&quot; title=&quot;&quot;>', '</a>');"><strong>A</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<img src=&quot;&quot; alt=&quot;&quot; />', '');"><strong>IMG</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<span>', '</span>');"><strong>SPAN</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<pre>', '</pre>');"><strong>PRE</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<br />', '');"><strong>BR</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('\t', '');"><strong>TAB</strong></a>&nbsp;|
</td>
</tr>
</tbody>
</table>
</div>
<div class="widget first">
<div class="head"><h5 class="iFrames">{#EDITDOC_HEADER_FORM#}</h5></div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<thead>
<tr>
<td>{#EDITDOC_HEADER_PHP#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea class="mousetrap" {$read_only} name="editdoc_template" id="editdoc_template" wrap="off" style="width:100%; height:340px">{$editdoc_template|default:$prefab|escape:html}</textarea>
</td>
</tr>
<tr>
<td>
|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<ol>', '</ol>');"><strong>OL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<ul>', '</ul>');"><strong>UL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<li>', '</li>');"><strong>LI</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<p class=&quot;&quot;>', '</p>');"><strong>P</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<strong>', '</strong>');"><strong>B</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<em>', '</em>');"><strong>I</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h1>', '</h1>');"><strong>H1</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h2>', '</h2>');"><strong>H2</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h3>', '</h3>');"><strong>H3</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h4>', '</h4>');"><strong>H4</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<h5>', '</h5>');"><strong>H5</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<div class=&quot;&quot; id=&quot;&quot;>', '</div>');"><strong>DIV</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<a href=&quot;&quot; title=&quot;&quot;>', '</a>');"><strong>A</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<img src=&quot;&quot; alt=&quot;&quot; />', '');"><strong>IMG</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<span>', '</span>');"><strong>SPAN</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<pre>', '</pre>');"><strong>PRE</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('<br />', '');"><strong>BR</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection('\t', '');"><strong>TAB</strong></a>&nbsp;|
</td>
</tr>
</tbody>
</table>
</div>
<div class="widget first">
<div class="head"><h5 class="iFrames">{#EDITDOC_HEADER_HEAD#}</h5></div>
<div class="head">
<h5 class="iFrames">{#EDITDOC_HEADER_HEAD#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="20%" />
<col width="40%" />
<col width="40%" />
<col width="16%" />
<col width="42%" />
<col width="42%" />
<thead>
<tr>
<td>&nbsp;</td>
@ -124,32 +152,35 @@
</thead>
<tbody>
{foreach from=$data.header key=k item=v}
<tr>
<td>
<strong>$data['header']['{$k}']</strong>
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[header][{$k}]" id="document_header_{$k}" cols="60" rows="7">{$v[0]|default:$prefab|escape:html}</textarea></div>
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[template][{$k}]" id="document_template_{$k}" cols="60" rows="7">{$v[1]|default:$prefab|escape:html}</textarea></div>
</td>
</tr>
{/foreach}
{foreach from=$data.header key=k item=v}
<tr>
<td>
<strong>$data['header']['{$k}']</strong>
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[header][{$k}]" id="document_header_{$k}" cols="60" rows="7">{$v[0]|default:$prefab|escape:html}</textarea></div>
{include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_header_$k" textarea_id="document_header_$k" height=100}
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[template][{$k}]" id="document_template_{$k}" cols="60" rows="7">{$v[1]|default:$prefab|escape:html}</textarea></div>
{include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_template_$k" textarea_id="document_template_$k" height=100}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="widget first">
<div class="head"><h5 class="iFrames">{#EDITDOC_HEADER_BODY#}</h5></div>
<div class="head">
<h5 class="iFrames">{#EDITDOC_HEADER_BODY#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<col width="20%" />
<col width="40%" />
<col width="40%" />
<col width="16%" />
<col width="42%" />
<col width="42%" />
<thead>
<tr>
<td>&nbsp;</td>
@ -165,10 +196,16 @@
$data['body']['{$k}']
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[body][{$k}]" id="document_body_{$k}" cols="70" rows="7">{$v[1]|default:$prefab|escape:html}</textarea></div>
<div class="pr12">
<textarea class="mousetrap" name="document[body][{$k}]" id="document_body_{$k}">{$v[1]|default:$prefab|escape:html}</textarea>
</div>
{include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_body_$k" textarea_id="document_body_$k" height=120}
</td>
<td>
<div class="pr12"><textarea class="mousetrap" name="document[template][{$k}]" id="document_template_{$k}" cols="70" rows="7">{$v[2]|default:$prefab|escape:html}</textarea></div>
<div class="pr12">
<textarea class="mousetrap" name="document[template][{$k}]" id="document_body_template_{$k}">{$v[2]|default:$prefab|escape:html}</textarea>
</div>
{include file="$codemirror_editor" ctrls='$("#save_editdoc").ajaxSubmit(sett_options);' conn_id="document_body_template_$k" textarea_id="document_body_template_$k" height=120}
</td>
</tr>
{/foreach}
@ -176,60 +213,113 @@
</table>
</div>
<div class="widget first">
<div class="head"><h5 class="iFrames">{#EDITDOC_HEADER_AFTER#}</h5></div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<thead>
<tr>
<td>{#EDITDOC_HEADER_PHP#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea {$read_only} name="editdoc_afteredit" id="editdoc_afteredit" wrap="off" style="width:100%; height:340px">{$editdoc_afteredit|default:$prefab|escape:html}</textarea>
</td>
</tr>
<tr>
<td>
|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<ol>', '</ol>');"><strong>OL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<ul>', '</ul>');"><strong>UL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<li>', '</li>');"><strong>LI</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<p class=&quot;&quot;>', '</p>');"><strong>P</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<strong>', '</strong>');"><strong>B</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<em>', '</em>');"><strong>I</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h1>', '</h1>');"><strong>H1</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h2>', '</h2>');"><strong>H2</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h3>', '</h3>');"><strong>H3</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h4>', '</h4>');"><strong>H4</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h5>', '</h5>');"><strong>H5</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<div class=&quot;&quot; id=&quot;&quot;>', '</div>');"><strong>DIV</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<a href=&quot;&quot; title=&quot;&quot;>', '</a>');"><strong>A</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<img src=&quot;&quot; alt=&quot;&quot; />', '');"><strong>IMG</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<span>', '</span>');"><strong>SPAN</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<pre>', '</pre>');"><strong>PRE</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<br />', '');"><strong>BR</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('\t', '');"><strong>TAB</strong></a>&nbsp;|
</td>
</tr>
<tr>
<td colspan="3">
<input type="hidden" name="id" value="{$id}">
<input name="submit" type="submit" class="basicBtn" value="{#EDITDOC_SAVEDIT#}" />
&nbsp;или&nbsp;
<input type="submit" class="blackBtn SaveEdit" name="next_edit" value="{#EDITDOC_SAVEDIT_NEXT#}" />
</td>
</tr>
</tbody>
</table>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#EDITDOC_HEADER_BEFORE#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<thead>
<tr>
<td>{#EDITDOC_HEADER_PHP#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea {$read_only} name="editdoc_before_edit" id="editdoc_before_edit" wrap="off" style="width:100%; height:340px">{$editdoc_before_edit|default:$prefab|escape:html}</textarea>
</td>
</tr>
<tr>
<td>
|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<ol>', '</ol>');"><strong>OL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<ul>', '</ul>');"><strong>UL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<li>', '</li>');"><strong>LI</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<p class=&quot;&quot;>', '</p>');"><strong>P</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<strong>', '</strong>');"><strong>B</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<em>', '</em>');"><strong>I</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h1>', '</h1>');"><strong>H1</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h2>', '</h2>');"><strong>H2</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h3>', '</h3>');"><strong>H3</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h4>', '</h4>');"><strong>H4</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<h5>', '</h5>');"><strong>H5</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<div class=&quot;&quot; id=&quot;&quot;>', '</div>');"><strong>DIV</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<a href=&quot;&quot; title=&quot;&quot;>', '</a>');"><strong>A</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<img src=&quot;&quot; alt=&quot;&quot; />', '');"><strong>IMG</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<span>', '</span>');"><strong>SPAN</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<pre>', '</pre>');"><strong>PRE</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('<br />', '');"><strong>BR</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection2('\t', '');"><strong>TAB</strong></a>&nbsp;|
</td>
</tr>
</tbody>
</table>
</div>
<div class="widget first">
<div class="head">
<h5 class="iFrames">{#EDITDOC_HEADER_AFTER#}</h5>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<thead>
<tr>
<td>{#EDITDOC_HEADER_PHP#}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<textarea {$read_only} name="editdoc_after_edit" id="editdoc_after_edit" wrap="off" style="width:100%; height:340px">{$editdoc_after_edit|default:$prefab|escape:html}</textarea>
</td>
</tr>
<tr>
<td>
|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<ol>', '</ol>');"><strong>OL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<ul>', '</ul>');"><strong>UL</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<li>', '</li>');"><strong>LI</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<p class=&quot;&quot;>', '</p>');"><strong>P</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<strong>', '</strong>');"><strong>B</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<em>', '</em>');"><strong>I</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<h1>', '</h1>');"><strong>H1</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<h2>', '</h2>');"><strong>H2</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<h3>', '</h3>');"><strong>H3</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<h4>', '</h4>');"><strong>H4</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<h5>', '</h5>');"><strong>H5</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<div class=&quot;&quot; id=&quot;&quot;>', '</div>');"><strong>DIV</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<a href=&quot;&quot; title=&quot;&quot;>', '</a>');"><strong>A</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<img src=&quot;&quot; alt=&quot;&quot; />', '');"><strong>IMG</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<span>', '</span>');"><strong>SPAN</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<pre>', '</pre>');"><strong>PRE</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('<br />', '');"><strong>BR</strong></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="textSelection3('\t', '');"><strong>TAB</strong></a>&nbsp;|
</td>
</tr>
</tbody>
</table>
<div class="rowElem" id="saveBtn">
<div class="saveBtn">
<input type="hidden" name="id" value="{$id}">
<input type="submit" class="basicBtn" value="{#EDITDOC_SAVEDIT#}" />
&nbsp;
<input type="submit" class="blackBtn SaveEdit" name="next_edit" value="{#EDITDOC_SAVEDIT_NEXT#}" />
</div>
</div>
</div>
{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}
<script language="javascript">
var sett_options = {ldelim}
var sett_options = {ldelim}
url: 'index.php?do=modules&action=modedit&mod=editdoc&moduleaction=saveedit&cp={$sess}',
beforeSubmit: Request,
success: Response
success: Response
{rdelim}
function Request(){ldelim}
@ -244,127 +334,68 @@
$(document).ready(function(){ldelim}
Mousetrap.bind(['ctrl+s', 'meta+s'], function(e) {ldelim}
if (e.preventDefault) {ldelim}
e.preventDefault();
{rdelim} else {ldelim}
// internet explorer
e.returnValue = false;
{rdelim}
$("#save_editdoc").ajaxSubmit(sett_options);
if (e.preventDefault) {ldelim}
e.preventDefault();
{rdelim} else {ldelim}
// internet explorer
e.returnValue = false;
{rdelim}
$("#save_editdoc").ajaxSubmit(sett_options);
return false;
{rdelim});
$(".SaveEdit").click(function(e){ldelim}
if (e.preventDefault) {ldelim}
e.preventDefault();
{rdelim} else {ldelim}
// internet explorer
e.returnValue = false;
{rdelim}
$("#save_editdoc").ajaxSubmit(sett_options);
$(".SaveEdit").click(function(e){ldelim}
if (e.preventDefault) {ldelim}
e.preventDefault();
{rdelim} else {ldelim}
// internet explorer
e.returnValue = false;
{rdelim}
$("#save_editdoc").ajaxSubmit(sett_options);
return false;
{rdelim});
{rdelim});
{literal}
var editor = CodeMirror.fromTextArea(document.getElementById("editdoc_template"), {
extraKeys: {"Ctrl-S": function(cm){$("#save_editdoc").ajaxSubmit(sett_options);}},
lineNumbers: true,
lineWrapping: true,
matchBrackets: true,
mode: "application/x-httpd-php",
indentUnit: 4,
indentWithTabs: true,
enterMode: "keep",
tabMode: "shift",
onChange: function(){editor.save();},
onCursorActivity: function() {
editor.setLineClass(hlLine, null, null);
hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");
}
});
function getSelectedRange() {
return { from: editor.getCursor(true), to: editor.getCursor(false) };
}
function textSelection(startTag,endTag) {
var range = getSelectedRange();
editor.replaceRange(startTag + editor.getRange(range.from, range.to) + endTag, range.from, range.to)
editor.setCursor(range.from.line, range.from.ch + startTag.length);
}
var hlLine = editor.setLineClass(0, "activeline");
var editor2 = CodeMirror.fromTextArea(document.getElementById("editdoc_afteredit"), {
extraKeys: {"Ctrl-S": function(cm){$("#save_editdoc").ajaxSubmit(sett_options);}},
lineNumbers: true,
lineWrapping: true,
matchBrackets: true,
mode: "application/x-httpd-php",
indentUnit: 4,
indentWithTabs: true,
enterMode: "keep",
tabMode: "shift",
onChange: function(){editor2.save();},
onCursorActivity: function() {
editor2.setLineClass(hlLine, null, null);
hlLine = editor2.setLineClass(editor2.getCursor().line, null, "activeline");
}
});
function getSelectedRange2() {
return { from: editor2.getCursor(true), to: editor2.getCursor(false) };
}
function textSelection2(startTag,endTag) {
var range = getSelectedRange2();
editor2.replaceRange(startTag + editor2.getRange(range.from, range.to) + endTag, range.from, range.to)
editor2.setCursor(range.from.line, range.from.ch + startTag.length);
}
var hlLine = editor2.setLineClass(0, "activeline");
{/literal}
</script>
{else}
<div class="widget first">
<div class="head"><h5 class="iFrames">{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}</h5></div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<tr>
<td>{#EDITDOC_NAME#}</td>
<td><div class="pr12"><input name="editdoc_name" class="mousetrap" type="text" value="{if $smarty.request.id != ''}{$editdoc_name|escape}{else}{$smarty.request.editdoc_name}{/if}" size="80" /></div></td>
</tr>
<tr>
<td>{#EDITDOC_RUBRICS#}</td>
<td>
<select name="editdoc_rub" {if $smarty.request.id != ''}disabled="disabled"{/if}>
{foreach from=$rubs item=rub}
{if $rub->Id==$editdoc_rub}
<option value="{$rub->Id}" selected>{$rub->rubric_title}</option>
{else}
<option value="{$rub->Id}">{$rub->rubric_title}</option>
{/if}
{/foreach}
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input name="submit" type="submit" class="basicBtn" value="{#EDITDOC_SAVE#}" />
</td>
</tr>
</table>
{else}
<div class="widget first">
<div class="head">
<h5 class="iFrames">{if $smarty.request.id != ''}{#EDITDOC_EDIT_H#}{else}{#EDITDOC_INSERT_H#}{/if}</h5>
</div>
{/if}
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<tr>
<td>{#EDITDOC_NAME#}</td>
<td><div class="pr12"><input name="editdoc_name" class="mousetrap" type="text" value="{if $smarty.request.id != ''}{$editdoc_name|escape}{else}{$smarty.request.editdoc_name}{/if}" size="80" /></div></td>
</tr>
<tr>
<td>{#EDITDOC_RUBRICS#}</td>
<td>
<select name="editdoc_rub" {if $smarty.request.id != ''}disabled="disabled"{/if}>
{foreach from=$rubs item=rub}
{if $rub->Id==$editdoc_rub}
<option value="{$rub->Id}" selected>{$rub->rubric_title}</option>
{else}
<option value="{$rub->Id}">{$rub->rubric_title}</option>
{/if}
{/foreach}
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input name="submit" type="submit" class="basicBtn" value="{#EDITDOC_SAVE#}" />
</td>
</tr>
</table>
</div>
{/if}
</form>
<br /><br /><br /><br /><br />
Loading…
Cancel
Save