PluginProbe ʕ •ᴥ•ʔ
AI Copilot – Content Generator / 1.5.4
AI Copilot – Content Generator v1.5.4
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
helpers 1 week ago tables 1 week ago aIProviderInterface.php 1 week ago assets.php 1 week ago baseObject.php 1 week ago builderBlock.php 1 week ago controller.php 1 week ago date.php 1 week ago db.php 1 week ago dispatcher.php 1 week ago errors.php 1 week ago field.php 1 week ago fieldAdapter.php 1 week ago frame.php 1 week ago helper.php 1 week ago html.php 1 week ago installer.php 1 week ago installerDbUpdater.php 1 week ago integration.php 1 week ago modInstaller.php 1 week ago model.php 1 week ago module.php 1 week ago req.php 1 week ago response.php 1 week ago table.php 1 week ago uri.php 1 week ago user.php 1 week ago utils.php 1 week ago validator.php 1 week ago view.php 1 week ago
module.php
207 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 public function exec( $task = '' ) {
107 if ($task) {
108 $controller = $this->getController();
109 if ($controller) {
110 return $controller->exec($task);
111 }
112 }
113 return null;
114 }
115 public function getController() {
116 if (!$this->_controller) {
117 $this->_createController();
118 }
119 return $this->_controller;
120 }
121 protected function _createController() {
122 if (!file_exists($this->getModDir() . 'controller.php')) {
123 return false; // EXCEPTION!!!
124 }
125 if ($this->_controller) {
126 return true;
127 }
128 if (file_exists($this->getModDir() . 'controller.php')) {
129 $className = '';
130 if (waicImport($this->getModDir() . 'controller.php')) {
131 $className = waicToeGetClassName($this->getCode() . 'Controller');
132 }
133 if (!empty($className)) {
134 $this->_controller = new $className($this->getCode());
135 $this->_controller->init();
136 return true;
137 }
138 }
139 return false;
140 }
141 /**
142 * Method to call module helper if it exists
143 *
144 * @return class WaicHelper
145 */
146 public function getHelper() {
147 if (!$this->_helper) {
148 $this->_createHelper();
149 }
150 return $this->_helper;
151 }
152 /**
153 * Method to create class of module helper
154 *
155 * @return class WaicHelper
156 */
157 protected function _createHelper() {
158 if ($this->_helper) {
159 return true;
160 }
161 if (file_exists($this->getModDir() . 'helper.php')) {
162 $helper = $this->getCode() . 'Helper';
163 waicImportClass($helper, $this->getModDir() . 'helper.php');
164 if (class_exists($helper)) {
165 $this->_helper = new $helper($this->_code);
166 $this->_helper->init();
167 return true;
168 }
169 }
170 }
171 public function setCode( $code ) {
172 $this->_code = $code;
173 }
174 public function getCode() {
175 return $this->_code;
176 }
177 public function onAdmin() {
178 return $this->_onAdmin;
179 }
180 public function getModel( $modelName = '' ) {
181 return $this->getController()->getModel($modelName);
182 }
183 public function getView( $viewName = '' ) {
184 return $this->getController()->getView($viewName);
185 }
186 public function install() {
187 }
188 public function uninstall() {
189 }
190 public function activate() {
191 }
192 /**
193 * Returns the available tabs
194 *
195 * @return array of tab
196 */
197 public function getTabs() {
198 return array();
199 }
200 public function getConstant( $name ) {
201 $thisClassRefl = new ReflectionObject($this);
202 return $thisClassRefl->getConstant($name);
203 }
204 public function loadAssets() { }
205 public function loadAdminAssets() { }
206 }
207