-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModAjax.php
58 lines (42 loc) · 1.46 KB
/
ModAjax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
use Core2\Mod\Minsk115;
require_once DOC_ROOT . "core2/inc/ajax.func.php";
require_once 'classes/autoload.php';
/**
* @property \ModSourcesController $modSources
*/
class ModAjax extends ajaxFunc {
/**
* @param array $data
* @return xajaxResponse
* @throws Zend_Db_Adapter_Exception
* @throws Exception
*/
public function axSavePage(array $data): xajaxResponse {
$fields = [
'title' => 'req',
'url' => 'req',
'content' => 'req',
];
if ($this->ajaxValidate($data, $fields)) {
return $this->response;
}
if ( ! empty($data['control']['source_url'])) {
$parse_url = parse_url($data['control']['source_url']);
$data['control']['source_domain'] = $parse_url['host'] ?? '';
}
$content = $data['control']['content'];
unset($data['control']['content']);
$page_id = $this->saveData($data);
$page_content = $this->modSources->dataSourcesSitesPagesContents->getRowByPageId($page_id);
$page_content->content = $content;
$page_content->hash = md5($content);
$page_content->save();
if (empty($this->error)) {
$this->response->script("CoreUI.notice.create('Сохранено');");
$this->response->script("load('index.php?module=sources&action=index');");
}
$this->done($data);
return $this->response;
}
}