PluginProbe ʕ •ᴥ•ʔ
AI Copilot – Content Generator / 1.2.0
AI Copilot – Content Generator v1.2.0
1.5.4 1.4.21 1.4.18 1.4.19 1.4.20 trunk 1.0.4 1.1.0 1.2.0 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.17 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.9
ai-copilot-content-generator / classes / module.php
ai-copilot-content-generator / classes Last commit date
tables 1 year ago assets.php 1 year ago baseObject.php 1 year ago cache.php 1 year ago controller.php 1 year ago date.php 1 year ago db.php 1 year ago dispatcher.php 1 year ago errors.php 1 year ago field.php 1 year ago fieldAdapter.php 1 year ago frame.php 1 year ago helper.php 1 year ago html.php 1 year ago installer.php 1 year ago installerDbUpdater.php 1 year ago modInstaller.php 1 year ago model.php 1 year ago module.php 1 year ago req.php 1 year ago response.php 1 year ago table.php 1 year ago uri.php 1 year ago user.php 1 year ago utils.php 1 year ago validator.php 1 year ago view.php 1 year ago
module.php
211 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 abstract class WaicModule extends WaicBaseObject {
6 protected $_controller = null;
7 protected $_helper = null;
8 protected $_code = '';
9 protected $_onAdmin = false;
10 protected $_typeID = 0;
11 protected $_type = '';
12 protected $_label = '';
13 /*
14 * ID in modules table
15 */
16 protected $_id = 0;
17 /**
18 * If module is not in primary package - here wil be it's path
19 */
20 protected $_externalDir = '';
21 protected $_externalPath = '';
22 protected $_isExternal = false;
23
24 public function __construct( $d) {
25 $this->setTypeID($d['type_id']);
26 $this->setCode($d['code']);
27 $this->setLabel($d['label']);
28 if (isset($d['id'])) {
29 $this->_setID($d['id']);
30 }
31 if (isset($d['ex_plug_dir']) && !empty($d['ex_plug_dir'])) {
32 $this->isExternal(true);
33 $this->setExternalDir( WaicUtils::getExtModDir($d['ex_plug_dir']) );
34 $this->setExternalPath( WaicUtils::getExtModPath($d['ex_plug_dir']) );
35 }
36 }
37 public function isExternal( $newVal = null ) {
38 if (is_null($newVal)) {
39 return $this->_isExternal;
40 }
41 $this->_isExternal = $newVal;
42 }
43 public function getModDir() {
44 if (empty($this->_externalDir)) {
45 return WAIC_MODULES_DIR . $this->getCode() . WAIC_DS;
46 } else {
47 return $this->_externalDir . $this->getCode() . WAIC_DS;
48 }
49 }
50 public function getModPath() {
51 if (empty($this->_externalPath)) {
52 return WAIC_MODULES_PATH . $this->getCode() . '/';
53 } else {
54 return $this->_externalPath . $this->getCode() . '/';
55 }
56 }
57 public function getModRealDir() {
58 return dirname(__FILE__) . WAIC_DS;
59 }
60 public function setExternalDir( $dir ) {
61 $this->_externalDir = $dir;
62 }
63 public function getExternalDir() {
64 return $this->_externalDir;
65 }
66 public function setExternalPath( $path ) {
67 $this->_externalPath = $path;
68 }
69 public function getExternalPath() {
70 return $this->_externalPath;
71 }
72 /*
73 * Set ID for module, protected - to limit opportunity change this value
74 */
75 protected function _setID( $id ) {
76 $this->_id = $id;
77 }
78 /**
79 * Get module ID from modules table in database
80 *
81 * @return int ID of module
82 */
83 public function getID() {
84 return $this->_id;
85 }
86 public function setTypeID( $typeID ) {
87 $this->_typeID = $typeID;
88 }
89 public function getTypeID() {
90 return $this->_typeID;
91 }
92 public function setType( $type ) {
93 $this->_type = $type;
94 }
95 public function getType() {
96 return $this->_type;
97 }
98 public function getLabel() {
99 return $this->_label;
100 }
101 public function setLabel( $label ) {
102 $this->_label = $label;
103 }
104 public function init() {
105
106 }
107 public function exec( $task = '' ) {
108 if ($task) {
109 $controller = $this->getController();
110 if ($controller) {
111 return $controller->exec($task);
112 }
113 }
114 return null;
115 }
116 public function getController() {
117 if (!$this->_controller) {
118 $this->_createController();
119 }
120 return $this->_controller;
121 }
122 protected function _createController() {
123 if (!file_exists($this->getModDir() . 'controller.php')) {
124 return false; // EXCEPTION!!!
125 }
126 if ($this->_controller) {
127 return true;
128 }
129 if (file_exists($this->getModDir() . 'controller.php')) {
130 $className = '';
131 if (waicImport($this->getModDir() . 'controller.php')) {
132 $className = waicToeGetClassName($this->getCode() . 'Controller');
133 }
134 if (!empty($className)) {
135 $this->_controller = new $className($this->getCode());
136 $this->_controller->init();
137 return true;
138 }
139 }
140 return false;
141 }
142 /**
143 * Method to call module helper if it exists
144 *
145 * @return class WaicHelper
146 */
147 public function getHelper() {
148 if (!$this->_helper) {
149 $this->_createHelper();
150 }
151 return $this->_helper;
152 }
153 /**
154 * Method to create class of module helper
155 *
156 * @return class WaicHelper
157 */
158 protected function _createHelper() {
159 if ($this->_helper) {
160 return true;
161 }
162 if (file_exists($this->getModDir() . 'helper.php')) {
163 $helper = $this->getCode() . 'Helper';
164 waicImportClass($helper, $this->getModDir() . 'helper.php');
165 if (class_exists($helper)) {
166 $this->_helper = new $helper($this->_code);
167 $this->_helper->init();
168 return true;
169 }
170 }
171 }
172 public function setCode( $code ) {
173 $this->_code = $code;
174 }
175 public function getCode() {
176 return $this->_code;
177 }
178 public function onAdmin() {
179 return $this->_onAdmin;
180 }
181 public function getModel( $modelName = '' ) {
182 return $this->getController()->getModel($modelName);
183 }
184 public function getView( $viewName = '' ) {
185 return $this->getController()->getView($viewName);
186 }
187 public function install() {
188
189 }
190 public function uninstall() {
191
192 }
193 public function activate() {
194
195 }
196 /**
197 * Returns the available tabs
198 *
199 * @return array of tab
200 */
201 public function getTabs() {
202 return array();
203 }
204 public function getConstant( $name ) {
205 $thisClassRefl = new ReflectionObject($this);
206 return $thisClassRefl->getConstant($name);
207 }
208 public function loadAssets() { }
209 public function loadAdminAssets() { }
210 }
211