PluginProbe
CSS & JavaScript Toolbox / 9.3.1
CSS & JavaScript Toolbox v9.3.1
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / controllers / template.php

template.php in CSS & JavaScript Toolbox 9.3.1, at controllers/template.php

102 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version $ Id; ?FILE_NAME ?DATE ?TIME ?AUTHOR $
4 */
5
6 // Disallow direct access.
7 defined('ABSPATH') or die("Access denied");
8
9 // import dependencies.
10 cssJSToolbox::import('framework:mvc:controller-ajax.inc.php');
11
12 /**
13 *
14 * DESCRIPTION
15 *
16 * @author ??
17 * @version ??
18 */
19 class CJTTemplateController extends CJTAjaxController {
20
21 /**
22 * put your comment there...
23 *
24 * @var mixed
25 */
26 protected $controllerInfo = array('model' => 'template');
27
28 /**
29 * put your comment there...
30 *
31 * @var mixed
32 */
33 protected $onsave = array('parameters' => array('data'));
34
35 /**
36 *
37 * Initialize new object.
38 *
39 * @return void
40 */
41 public function __construct() {
42 // Initialize parent!
43 parent::__construct();
44 // Add actions.
45 $this->registryAction('edit');
46 $this->registryAction('save');
47 $this->registryAction('info');
48 $this->registryAction('getTemplateBy');
49 }
50
51 /**
52 * put your comment there...
53 *
54 */
55 protected function editAction() {
56 $this->model->inputs['id'] = (int) $_REQUEST['id'];
57 // Display the view.
58 parent::displayAction();
59 }
60
61 /**
62 * put your comment there...
63 *
64 */
65 protected function getTemplateByAction() {
66 // Initialize.
67 $returns = array_flip($_GET['returns']);
68 // Set inputs.
69 $inputs =& $this->model->inputs;
70 $inputs['filter'] = $_GET['filter'];
71 // Query Block.
72 $this->response = array_intersect_key((array) $this->model->getTemplateBy(), $returns);
73 }
74
75 /**
76 * put your comment there...
77 *
78 */
79 protected function infoAction() {
80 $this->model->inputs['id'] = (int) $_REQUEST['id'];
81 // Display the view.
82 parent::displayAction();
83 }
84
85 /**
86 * put your comment there...
87 *
88 */
89 protected function saveAction() {
90 // Read inputs
91 $item = filter_input(INPUT_POST, 'item', FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY);
92 // Posted template data is in the item array, the others is just for making the request!
93 $this->model->inputs['item'] = $this->onsave($item);
94 if ($revision = $this->model->save()) {
95 $this->response = array('revision' => $revision);
96 }
97 }
98
99 } // End class.
100
101 // Hookable!
102 CJTTemplateController::define('CJTTemplateController', array('hookType' => CJTWordpressEvents::HOOK_FILTER));