forked from laposa/onyx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.php
144 lines (109 loc) · 2.96 KB
/
default.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Copyright (c) 2009-2015 Onxshop Ltd (https://onxshop.com)
* Licensed under the New BSD License. See the file LICENSE.txt for details.
*
*/
class Onxshop_Controller_Node_Default extends Onxshop_Controller {
/**
* main action
*/
public function mainAction() {
$this->processLayout();
return true;
}
/**
* process containers
*/
public function processContainers() {
/**
* check node id value
*/
if (!is_numeric($this->GET['id'])) {
msg("node/default: id not numeric", 'error');
return false;
} else {
$node_id = $this->GET['id'];
}
/**
* initialize
*/
require_once('models/common/common_node.php');
$Node = new common_node();
$node_data = $Node->nodeDetail($node_id);
//find child nodes
$contentx = $Node->parseChildren($node_id);
//assign to this controller as CONTAINER variable
if (is_array($contentx)) {
foreach ($contentx as $content) {
$container[$content['container']] .= $content['content'];
}
}
/**
* node add icons
* front-end node edit and node move (sort) icons are inserted in controller/node
*
*/
if ($_SESSION['fe_edit_mode'] == 'edit' || $_SESSION['fe_edit_mode'] == 'move') {
//normally we support container.0 to container.6 in default templates, but why not to have some reserve, e.g. 20
$min_container_id = 0;
$max_container_id = 20;
for ($key = $min_container_id; $key < ($max_container_id + 1); $key++) {
$container[$key] = "<div class='onxshop_layout_container' id='onxshop_layout_container_{$node_id}_{$key}'>{$container[$key]}</div>";
}
}
$this->tpl->assign("CONTAINER", $container);
$this->tpl->assign("NODE", $node_data);
}
/**
* process layout
*/
public function processLayout() {
}
/**
* getImageSizeOptions
*
*/
function getImageSizeOptions($node_data) {
/**
* image size: set width
*/
if (is_numeric($node_data['component']['image_width'])) {
$image_width = $node_data['component']['image_width'];
} else {
$node_data['component']['image_width'] = 0;
$image_width = 0;
}
/**
* image size: check constrain and set appropriate height
*/
switch ($node_data['component']['image_constrain']) {
case '1-1':
$image_height = $image_width;
break;
default:
case '2_39-1': // 2.39:1
$image_height = (int)($image_width / 2.39 * 1);
break;
case '16-9':
$image_height = (int)($image_width / 16 * 9);
break;
case '4-3':
$image_height = (int)($image_width / 4 * 3);
break;
case '0':
$image_height = 0;
break;
}
/**
* image size: fill cropping option
*
*/
if (is_numeric($node_data['component']['image_fill'])) $image_fill = $node_data['component']['image_fill'];
else $image_fill = 1;
/**
* return array
*/
return array('width'=>$image_width, 'height'=>$image_height, 'fill'=>$image_fill);
}
}