Passed
Push — master ( 53f74f...bb09c2 )
by alexandr
03:03
created

ACP_Pages_Story::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * RooCMS - Open Source Free Content Managment System
4
 * @copyright © 2010-2021 alexandr Belov aka alex Roosso. All rights reserved.
5
 * @author    alex Roosso <[email protected]>
6
 * @link      http://www.roocms.com
7
 * @license   http://www.gnu.org/licenses/gpl-3.0.html
8
 *
9
 * You should have received a copy of the GNU General Public License v3
10
 * along with this program.  If not, see http://www.gnu.org/licenses/
11
 */
12
13
14
//#########################################################
15
// Anti Hack
16
//---------------------------------------------------------
17
if(!defined('RooCMS') || !defined('ACP')) {
18
	die('Access Denied');
19
}
20
//#########################################################
21
22
23
/**
24
 * Class ACP_Pages_Story
25
 */
26
class ACP_Pages_Story {
27
28
	/**
29
	 * Edit content
30
	 *
31
	 * @param int $sid - Structure id
32
	 */
33
	public function edit($sid) {
34
35
		global $db, $files, $img, $parse, $tpl, $smarty;
36
37
		# download structure data
38
		$q = $db->query("SELECT id AS sid, title, alias, meta_description, meta_keywords FROM ".STRUCTURE_TABLE." WHERE id='".$sid."'");
39
		$data = $db->fetch_assoc($q);
40
41
42
		# download content
43
		$datacontent = [];
44
		$q = $db->query("SELECT id, sid, sort, content, date_modified FROM ".PAGES_STORY_TABLE." WHERE sid='".$sid."' ORDER BY sort ASC, sid ASC");
45
		while($row = $db->fetch_assoc($q)) {
46
			$data['lm'] = $parse->date->unix_to_rus($row['date_modified'], true, true, true);
47
			$datacontent[] = $row;
48
49
50
			# download attached images
51
			$attachimg = $img->load_images("page_story_id=".$row['id']);
52
			$smarty->assign("attachimg", $attachimg);
53
54
			# show attached images
55
			$attachedimages[$row['id']] = $tpl->load_template("attached_images", true);
56
57
58
			# download attached files
59
			$attachfile = $files->load_files("page_story_id=".$row['id']);
60
			$smarty->assign("attachfile", $attachfile);
61
62
			# show attached files
63
			$attachedfiles[$row['id']] = $tpl->load_template("attached_files", true);
64
		}
65
66
		$smarty->assign("data", $data);
67
		$smarty->assign("datacontent", $datacontent);
68
69
		# show attached images and files
70
		$smarty->assign("attachedimages", $attachedimages);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $attachedimages does not seem to be defined for all execution paths leading up to this point.
Loading history...
71
		$smarty->assign("attachedfiles", $attachedfiles);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $attachedfiles does not seem to be defined for all execution paths leading up to this point.
Loading history...
72
73
		# show upload files & images form
74
		$tpl->load_image_upload_tpl("imagesupload");
75
		$tpl->load_files_upload_tpl("filesupload");
76
77
		$content = $tpl->load_template("pages_edit_story", true);
78
		$smarty->assign("content", $content);
79
	}
80
81
82
	/**
83
	 * Update page content
84
	 *
85
	 * @param mixed $data - this object data params
86
	 */
87
	public function update($data) {
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

87
	public function update(/** @scrutinizer ignore-unused */ $data) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
88
89
90
	}
91
92
93
	/**
94
	 * Remove page
95
	 *
96
	 * @param int $sid - Structure id
97
	 */
98
	public function delete($sid) {
0 ignored issues
show
Unused Code introduced by
The parameter $sid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
	public function delete(/** @scrutinizer ignore-unused */ $sid) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
100
101
	}
102
}
103