| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Disllow direct access. |
| 7 | 7 | defined('ABSPATH') or die('Access denied'); |
| @@ -6,15 +6,15 @@ | ||
| 6 | 6 | // Disllow direct access. |
| 7 | 7 | defined('ABSPATH') or die('Access denied'); |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | -* | |
| 10 | +* | |
| 11 | 11 | */ |
| 12 | 12 | class CJTTemplateModel extends CJTHookableClass { |
| 13 | - | |
| 13 | + | |
| 14 | 14 | /** |
| 15 | 15 | * put your comment there... |
| 16 | - * | |
| 16 | + * | |
| 17 | 17 | * @var mixed |
| 18 | 18 | */ |
| 19 | 19 | public $inputs; |
| 20 | 20 | |
| @@ -19,23 +19,23 @@ | ||
| 19 | 19 | public $inputs; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * put your comment there... |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * @var mixed |
| 25 | 25 | */ |
| 26 | 26 | protected $onloadcodefile = array('parameters' => array('code', 'item')); |
| 27 | - | |
| 27 | + | |
| 28 | 28 | /** |
| 29 | 29 | * put your comment there... |
| 30 | - * | |
| 30 | + * | |
| 31 | 31 | * @var mixed |
| 32 | 32 | */ |
| 33 | 33 | protected $onqueryitem = array('parameters' => array('query')); |
| 34 | - | |
| 34 | + | |
| 35 | 35 | /** |
| 36 | 36 | * put your comment there... |
| 37 | - * | |
| 37 | + * | |
| 38 | 38 | * @param mixed $code |
| 39 | 39 | */ |
| 40 | 40 | public function decryptCode($encodedCode) { |
| 41 | 41 | /// base 64 code! |
| @@ -43,12 +43,12 @@ | ||
| 43 | 43 | // Decode! |
| 44 | 44 | $code = base64_decode($code64); |
| 45 | 45 | return $code; |
| 46 | 46 | } |
| 47 | - | |
| 47 | + | |
| 48 | 48 | /** |
| 49 | 49 | * put your comment there... |
| 50 | - * | |
| 50 | + * | |
| 51 | 51 | * @param mixed $code |
| 52 | 52 | */ |
| 53 | 53 | public function encryptCode($code) { |
| 54 | 54 | // Base 64 Encode! |
| @@ -56,12 +56,12 @@ | ||
| 56 | 56 | // Hide inside PHP tags! |
| 57 | 57 | $encodedCode = "<?php defined(\"ABS_PATH\") or die(\"Access Denied\"); '{$code64}'; ?>"; |
| 58 | 58 | return $encodedCode; |
| 59 | 59 | } |
| 60 | - | |
| 60 | + | |
| 61 | 61 | /** |
| 62 | 62 | * put your comment there... |
| 63 | - * | |
| 63 | + * | |
| 64 | 64 | * @param mixed $name |
| 65 | 65 | */ |
| 66 | 66 | public function exists($name) { |
| 67 | 67 | // Find by name. |
| @@ -70,25 +70,25 @@ | ||
| 70 | 70 | // Template object if exists with E_ALL complain! |
| 71 | 71 | return (($existsItem = $this->getTemplateBy()) && property_exists($existsItem, 'id') && $existsItem->id) ? |
| 72 | 72 | $existsItem : FALSE; |
| 73 | 73 | } |
| 74 | - | |
| 74 | + | |
| 75 | 75 | /** |
| 76 | 76 | * put your comment there... |
| 77 | - * | |
| 77 | + * | |
| 78 | 78 | */ |
| 79 | 79 | public function getItem() { |
| 80 | 80 | $tManager = CJTModel::create('templates-manager'); |
| 81 | 81 | $query = $tManager->getItemsQuery(); |
| 82 | - $query['select'] = 'SELECT t.id, | |
| 82 | + $query['select'] = 'SELECT t.id, | |
| 83 | 83 | t.queueName, |
| 84 | - t.name, | |
| 85 | - t.type, | |
| 86 | - t.description, | |
| 87 | - t.creationDate, | |
| 84 | + t.name, | |
| 85 | + t.type, | |
| 86 | + t.description, | |
| 87 | + t.creationDate, | |
| 88 | 88 | t.keywords, |
| 89 | 89 | r.dateCreated lastModified, |
| 90 | - t.state, | |
| 90 | + t.state, | |
| 91 | 91 | a.name author, |
| 92 | 92 | r.changeLog, |
| 93 | 93 | r.version, |
| 94 | 94 | r.file, |
| @@ -108,12 +108,12 @@ | ||
| 108 | 108 | $item->code = $this->onloadcodefile($code, $item); |
| 109 | 109 | // Return PHP StdClass object. |
| 110 | 110 | return $item; |
| 111 | 111 | } |
| 112 | - | |
| 112 | + | |
| 113 | 113 | /** |
| 114 | 114 | * Query Block based on the passed paramaters. |
| 115 | - * | |
| 115 | + * | |
| 116 | 116 | */ |
| 117 | 117 | public function getTemplateBy() { |
| 118 | 118 | // import dependencies. |
| 119 | 119 | cssJSToolbox::import('framework:db:mysql:xtable.inc.php'); |
| @@ -124,9 +124,9 @@ | ||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * put your comment there... |
| 128 | - * | |
| 128 | + * | |
| 129 | 129 | */ |
| 130 | 130 | public function save() { |
| 131 | 131 | // import libraries. |
| 132 | 132 | cssJSToolbox::import('framework:db:mysql:xtable.inc.php'); |
| @@ -135,21 +135,18 @@ | ||
| 135 | 135 | $currentUser = get_userdata(get_current_user_id()); |
| 136 | 136 | $dbDriver = cssJSToolbox::getInstance()->getDBDriver(); |
| 137 | 137 | $saveId = isset($this->inputs['item']['template']['id']) ? $this->inputs['item']['template']['id'] : null; |
| 138 | 138 | // Load template data is exists (load), change values (setData). |
| 139 | - $template = CJTxTable::getInstance('template'); | |
| 140 | - if ($saveId) { | |
| 141 | - $template->set('id', $saveId)->load(); | |
| 142 | - } | |
| 143 | - $template->setData($this->inputs['item']['template']) | |
| 144 | - ->setQueueName(); | |
| 139 | + $template = CJTxTable::getInstance('template')->set('id', $saveId) | |
| 140 | + ->load() | |
| 141 | + ->setData($this->inputs['item']['template']) | |
| 142 | + ->setQueueName(); | |
| 145 | 143 | $templateDirName = $template->get('queueName'); |
| 146 | - $contentDir = end( explode( DIRECTORY_SEPARATOR, dirname( dirname( plugin_dir_path( CJTOOLBOX_PLUGIN_FILE ) ) ) ) ); | |
| 147 | - $templateDir = "$contentDir/{$fSConfig->contentDir}/{$fSConfig->templatesDir}/{$templateDirName}"; | |
| 144 | + $templateDir = "wp-content/{$fSConfig->contentDir}/{$fSConfig->templatesDir}/{$templateDirName}"; | |
| 148 | 145 | if (!$template->get('id')) { // Add new Template |
| 149 | - // Search for author for the current local Wordpress user. | |
| 146 | + // Search for author for the current local Wordpress user. | |
| 150 | 147 | // If not created in the Authors table create one! If created get the ID! |
| 151 | - $author = CJTxTable::getInstance('author', null, "SELECT * FROM #__cjtoolbox_authors | |
| 148 | + $author = CJTxTable::getInstance('author', null, "SELECT * FROM #__cjtoolbox_authors | |
| 152 | 149 | WHERE name = '{$currentUser->user_login}' |
| 153 | 150 | AND (attributes & 2);"); |
| 154 | 151 | // Create Wordpress user in Authors table. |
| 155 | 152 | if (!$author->get('id')) { |
| @@ -179,11 +176,11 @@ | ||
| 179 | 176 | $lastRevisionNo = ((int) ($dbDriver->getRow("SELECT max(revisionNo) revisionNo |
| 180 | 177 | FROM #__cjtoolbox_template_revisions |
| 181 | 178 | WHERE templateId = {$template->get('id')}")->revisionNo)); |
| 182 | 179 | // Checki if there is a previous revision and if there is changes!! |
| 183 | - $lastRevision = CJTxTable::getInstance('template-revision', null, | |
| 184 | - "SELECT * | |
| 185 | - FROM #__cjtoolbox_template_revisions | |
| 180 | + $lastRevision = CJTxTable::getInstance('template-revision', null, | |
| 181 | + "SELECT * | |
| 182 | + FROM #__cjtoolbox_template_revisions | |
| 186 | 183 | WHERE templateId = {$template->get('id')} AND revisionNo = {$lastRevisionNo}" |
| 187 | 184 | ); |
| 188 | 185 | // Only add Revision if it has any field changed! |
| 189 | 186 | $revisionData = $this->inputs['item']['revision']; |
| @@ -229,9 +226,9 @@ | ||
| 229 | 226 | } |
| 230 | 227 | // Return revision object. |
| 231 | 228 | return $revision->getData(); |
| 232 | 229 | } |
| 233 | - | |
| 230 | + | |
| 234 | 231 | } // End class. |
| 235 | 232 | |
| 236 | 233 | // Hookable! |
| 237 | 234 | CJTTemplateModel::define('CJTTemplateModel', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |