/** * put your comment there... * */ public function downloadCodeFileAction() { // BlockId, currentActiveFile. $blockId = $_GET['blockId']; $fileId = $_GET['fileId']; $returnAs = $_GET['returnAs']; // Get current File Code. $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver()); $codeFile = $tblCodeFile->set('id', $fileId)->set('blockId', $blockId)->load()->getData(); // Return as downloadable-file or JSON. if ($returnAs == 'file') { // Get Download File info. $extension = $codeFile->type ? cssJSToolbox::$config->templates->types[$codeFile->type]->extension : 'txt'; $file = "{$codeFile->name}.{$extension}"; // Response Header parameters. header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"{$file}\""); //<<< Note the " " surrounding the file name header('Content-Transfer-Encoding: binary'); header('Connection: Keep-Alive'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . strlen($codeFile->code)); // AJAX Controller parameters. $this->httpContentType = 'application/octet-stream'; } // Output code. $this->response = $codeFile->code; }
/** * put your comment there... * * @param mixed $blockId */ public function create(&$pin = null) { // Import dependecnes. cssJSToolbox::import('tables:block-pins.php'); // Change metabox status to be created. $this->setState(self::STATE_CREATED); // Add post pin to pins table. $blockPinsTable = new CJTBlockPinsTable($this->dbDriver); // Pin data. $pin = (object) array(); // Import CJTBlockModel class. CJTModel::import('block'); /** @todo Only temporary in version 6.0. Later versions should group all post types by post type name! */ switch ($this->getPost()->post_type) { case 'page': $pin->pin = 'pages'; $pin->flag = CJTBlockModel::PINS_PAGES_CUSTOM_PAGE; break; default: $pin->pin = 'posts'; $pin->flag = CJTBlockModel::PINS_POSTS_CUSTOM_POST; break; } $pin->value = $this->getPost()->ID; // Add pin record. $blockPinsTable->insertRaw($this->getMetaboxId(), array($pin)); // Chains! return $this; }
/** * put your comment there... * * @param mixed $strings * @param mixed $content * @return CJT_Framework_Developer_Interface_Block_Shortcode_Parameters_Parameters */ public function loadString($strings, $content) { // Get the name of the CONTENT PARAMETER -- If EXISTS! // THEN PUSH IT AS ITS PASSED AS SHORTCODR ATTRIBUTE. if ($contentParameter = $this->getContentParameter()) { $strings[$contentParameter->getDefinition()->getName(true)] = $content; } // Load all parameters with shortcde parameters. foreach ($this->getParams() as $name => $param) { // Dont override default value unless parameter is passed! if (isset($strings[$name])) { $param->loadString($strings[$name]); } // Validate type! if (!$param->validate()) { echo cssJSToolbox::getText("Invalid Shortcode parameter: {$type->getMessage()}"); } // Remove the value from the stringsValue allow validating if // any invalid parameter name is passed! // See after the loop. unset($strings[$name]); } // If there is any string values still exists then invalid parameter is passed. if (!empty($strings)) { echo cssJSToolbox::getText("Invalid Shortcode parameter(s) has been passed! Please check parameters name."); } return $this; }
/** * put your comment there... * * @param mixed $blocks */ protected function getBlocksIterator($blocks) { // Import iterator class file! cssJSToolbox::import('includes:installer:upgrade:0.2:includes:block.class.php'); // Instantiate blocks iterator object! return new CJTInstallerBlocks02($blocks); }
/** * put your comment there... * */ public function menu() { // Setup Page. $pageHookId = add_submenu_page(CJTPlugin::PLUGIN_REQUEST_ID, cssJSToolbox::getText('CJT Manage - Packages'), cssJSToolbox::getText('Packages'), 'administrator', CJTPlugin::PLUGIN_REQUEST_ID . '-packages', array(&$this->controller, '_doAction')); // Process when its installed!! add_action("load-{$pageHookId}", array($this, 'getPage')); }
/** * put your comment there... * */ public function upgrade() { // Save backup in backup table! $backup = $this->current(); // Change 'time' field to 'created'! // Convert formatted date to mysal date! $backup['created'] = $backup['time']; // User author Id instead of name and change 'author' field to 'owner'! $backup['owner'] = get_user_by('login', $backup['author'])->ID; $backup['type'] = 'blocks'; // For now we support only blocks backups! // Load blocks into blocks iterator before destroying deprectaed fields. $blocks = new CJTInstallerBlocks03($backup['data'], CJTInstallerBlocks03::BLOCK_TYPE_BACKUP); // Remove deprecated fields! $backup = array_diff_key($backup, array_flip(array('time', 'author', 'data'))); /// Add backup and get its ID using OLD style table (not xTable)!! // Import dependecneis. cssJSToolbox::import('tables:backups.php'); // Insert backup record. $backupsTable = new CJTBackupsTable(cssJSToolbox::getInstance()->getDBDriver()); $backupsTable->insert($backup); $backupId = $backupsTable->getDBDriver()->processQueue()->getInsertId(); // Insert all blocks! foreach ($blocks as &$block) { // Associate every block with the created backup! $block['backupId'] = $backupId; // Upgrade block! $blocks->upgrade(); $blocks->model->save(); } return $this; }
/** * Delete single package. * * This method is going to delete the package * and all the templates and blocks associated to it, * therefor it'll unlink/break-down the relationship * between those templates and blocks. * * @param Integer Package Id. * @return CJTPackageModel Return $this. */ public function delete($id) { // Initialize. $modelTemplates = CJTModel::getInstance('templates-manager'); $dbd = cssJSToolbox::getInstance()->getDBDriver(); $assoObjectsQueryTmp = 'SELECT objectId FROM #__cjtoolbox_package_objects WHERE packageId = %d AND objectType = "%s" AND relType = "%s";'; // Delete the package. CJTxTable::getInstance('package')->set('id', $id)->delete(); // Delete blocks. $blockIds = array_keys($dbd->select(sprintf($assoObjectsQueryTmp, $id, 'block', 'add'))); if (!empty($blockIds)) { // Delete blocks! CJTModel::getInstance('blocks')->delete($blockIds)->save(); } // Delete templates. $modelTemplates->inputs['ids'] = array_keys($dbd->select(sprintf($assoObjectsQueryTmp, $id, 'template', 'add'))); // Templates muct be in trash state before deleted! $modelTemplates->inputs['state'] = 'trash'; // Move to Trash + Delete only if there is at least one Id! empty($modelTemplates->inputs['ids']) or $modelTemplates->changeState() and $modelTemplates->delete(); // Delete package objects map. CJTxTable::getInstance('package-objects')->set('packageId', $id)->delete(array('packageId')); }
/** * put your comment there... * */ protected function enableAction() { // Initializing! $model = $this->model; $cjtWebServer = cssJSToolbox::getCJTWebSiteURL(); $extensions =& CJTPlugin::getInstance()->extensions(); // Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate // license key! $activeLicenses = $model->getStatedLicenses(); // Import EDD updater Class! cssJSToolbox::import('framework:third-party:easy-digital-download:auto-upgrade.class.php'); // Activate Automatic upgrade for all activated licenses/components! foreach ($activeLicenses as $name => $state) { // Get extension def doc. // Act only if extension has XMl DOC! This might happened i fthe extension // removed while its key still in the database if ($extDef = $extensions->getDefDoc(dirname($state['component']['pluginBase']))) { // Check CJT Server only if updateSrc points to Wordpress Repository $updateSrcServer = (string) $extDef->license->attributes()->updateSrc; if (!$updateSrcServer || $updateSrcServer == 'CJT') { // Initializingn vars for a single state/component! $pluginFile = ABSPATH . PLUGINDIR . '/' . $state['component']['pluginBase']; // Stop using Cached Data as it causes issue, always // get fresh plugin data. $plugin = get_plugin_data($pluginFile); $license =& $state['license']; // Edd API parameter to be send along with he check! $requestParams = array('version' => $plugin['Version'], 'author' => $plugin['AuthorName'], 'license' => $license['key'], 'item_name' => $name); // Set EDD Automatic Updater! $updated = new CJT_EDD_SL_Plugin_Updater($cjtWebServer, $pluginFile, $requestParams); } } } }
/** * put your comment there... * */ protected function enableAction() { // Initializing! $model = $this->model; $cjtWebServer = cssJSToolbox::getCJTWebSiteURL(); $extensions =& CJTPlugin::getInstance()->extensions(); // Get all CJT-Plugins (Include CJT Plugin itself + all its extensions) that has activate // license key! $activeLicenses = $model->getStatedLicenses(); // Activate Automatic upgrade for all activated licenses/components! foreach ($activeLicenses as $name => $state) { // Get extension def doc. // Act only if extension has XMl DOC! This might happened i fthe extension // removed while its key still in the database if ($extDef = $extensions->getDefDoc(dirname($state['component']['pluginBase']))) { // Check CJT Server only if updateSrc points to Wordpress Repository $updateSrcServer = (string) $extDef->license->attributes()->updateSrc; if (!$updateSrcServer || $updateSrcServer == 'CJT') { // Initializingn vars for a single state/component! $pluginFile = ABSPATH . PLUGINDIR . '/' . $state['component']['pluginBase']; $license =& $state['license']; // Set EDD Automatic Updater! try { CJTStoreUpdate::autoUpgrade($name, $license['key'], $pluginFile); } catch (CJTServicesAPICallException $exception) { die('CJT AUTO-UPGRADE EXCAPTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); } } } } }
/** * put your comment there... * * @param mixed $tpl */ public function display($tpl = null) { $this->component = $this->getModel('setup')->getCJTComponentData(); $this->securityToken = cssJSToolbox::getSecurityToken(); // Display view. echo $this->getTemplate($tpl); }
/** * put your comment there... * */ public function menu() { // Blocks Manager page! The only Wordpress menu item we've. $pageHookId = add_menu_page(cssJSToolbox::getText('CSS & Javascript Toolbox'), cssJSToolbox::getText('CSS & Javascript Toolbox'), 'administrator', CJTPlugin::PLUGIN_REQUEST_ID, array(&$this->controller, '_doAction'), CJTOOLBOX_VIEWS_URL . '/blocks/manager/public/images/menu.png'); // Process request if installed! add_action("load-{$pageHookId}", array($this, 'getPage')); }
/** * put your comment there... * */ protected function prepareItems() { CJTxTable::import('author'); $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR; // Query all dates (without time!) or internal authors. $query = " SELECT DISTINCT(DATE(t.creationDate)) `text`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`;"; $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query); }
/** * put your comment there... * */ public function database() { // Upgrade database tables. cssJSToolbox::import('framework:installer:dbfile.class.php'); CJTDBFileInstaller::getInstance(cssJSToolbox::resolvePath('includes:installer:upgrade:1.0-CE:db:mysql:structure.sql'))->exec(); // Chaining. return $this; }
/** * put your comment there... * */ public function menu() { // Extensions page. add_submenu_page(CJTPlugin::PLUGIN_REQUEST_ID, null, cssJSToolbox::getText('Extensions'), 'administrator', null); // Hack Extensions menu item to point to Plugins page! $GLOBALS['submenu'][CJTPlugin::PLUGIN_REQUEST_ID][self::MENU_POSITION_INDEX][2] = admin_url('plugins.php?s=' . self::PLUGINS_PAGE_SEARCH_TERM); // When plugins page loaded! add_action('load-plugins.php', array($this, 'route'), 10, 0); }
/** * put your comment there... * */ public function finalize() { // Upgrade database internal version number using // installer class. cssJSToolbox::import('includes:installer:installer:installer.class.php'); CJTInstaller::getInstance()->finalize(); // Chaining. return $this; }
/** * put your comment there... * */ protected function prepareItems() { CJTxTable::import('author'); $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR; // Query CJT Authors + Wordpress build-in local users. $query = " SELECT a.id, a.name `text`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tRIGHT JOIN #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tON a.id = t.authorId\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`"; // Get all exists authors $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query); }
/** * put your comment there... * * @param mixed $formId * @return CJT_Models_Block_Parameters_Form_Groups */ public function __construct($formId) { // Initialize. $this->formId = $formId; $dbDriver = cssJSToolbox::getInstance()->getDBDriver(); // Query groups. $groups = $dbDriver->select("SELECT * FROM #__cjtoolbox_form_groups g LEFT JOIN #__cjtoolbox_form_group_xfields xf ON g.id = xf.groupId WHERE g.formId = {$this->formId};", ARRAY_A); parent::__construct($groups); }
/** * put your comment there... * */ public function getPackageInfo() { // Initialize. $driver = cssJSToolbox::getInstance()->getDBDriver(); // Query package info for the current block. $query = "SELECT p.id, p.author, p.webSite\n\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_packages p RIGHT JOIN #__cjtoolbox_package_objects o\n\t\t\t\t\t\t\t\t\t\t\tON p.id = o.packageId AND o.objectType = 'block'\n\t\t\t\t\t\t\t\t\t\t\tWHERE o.objectId = {$this->id};"; // Exec! $packageInfo = $driver->getRow($query, ARRAY_A); return $packageInfo; }
/** * put your comment there... * */ protected function prepareItems() { // Query CJT Authors + Wordpress build-in local users. $query = ' SELECT o.ID id, o.user_login `text` FROM #__wordpress_users o RIGHT JOIN #__cjtoolbox_templates t ON o.ID = t.ownerId ORDER BY `text`'; // Get all exists authors $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query); }
/** * put your comment there... * */ public function template() { static $template = null; // Instantiate Template library only when used. if (!$template) { cssJSToolbox::import('framework:developer:lib:template:template.php'); $template = new CJT_Framework_Developer_Lib_Template($this->source); } return $template; }
/** * put your comment there... * */ protected function prepareItems() { // Import dependencies. CJTxTable::import('template-revision'); CJTxTable::import('author'); $lastVersionFlag = CJTTemplateRevisionTable::FLAG_LAST_REVISION; $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR; // Query all dates (without time!). $query = " SELECT DISTINCT(DATE(r.dateCreated)) `text` \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_template_revisions r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tON r.templateId = t.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (r.attributes & {$lastVersionFlag}) AND (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`"; $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query); }
/** * put your comment there... * */ public function exec() { // Initialize! $driver = cssJSToolbox::getInstance()->getDBDriver(); // Execute all statements! foreach ($this->statements as $statement) { // Terminate the statement with ; $statement = "{$statement};"; // Execute statement! $driver->exec($statement); } }
/** * put your comment there... * */ public function getItems() { // Initializing! $driver = cssJSToolbox::getInstance()->getDBDriver(); // Get common quiery parts!@ $query = $this->getItemsQuery(); // Add fields list! $query['select'] = 'b.id, b.name title, b.owner, f.name formTitle'; $query = "SELECT {$query['select']} FROM {$query['from']} WHERE {$query['where']};"; // Retrieve blocks! return $driver->select($query); }
/** * put your comment there... * * @param mixed $tpl */ public function display($tpl = null) { // Get item. $this->item = $this->model->getItem(); // For all items that has no value show "Not Available" foreach ((array) $this->item as $prop => $value) { if (!$this->item->{$prop}) { $this->item->{$prop} = cssJSToolbox::getText('N/A'); } } echo $this->getTemplate($tpl); }
/** * put your comment there... * * @param mixed $tpl */ public function display($tpl = null) { // Initialize. $model = $this->getModel('packages'); // Cache view vars. $this->itemsTotal = $model->getItemsTotal(); $this->itemsPerPage = $model->getItemsPerPage(); $this->items = $model->getItems(); $this->securityToken = cssJSToolbox::getSecurityToken(); // Display view. echo $this->getTemplate($tpl); }
/** * put your comment there... * */ public static function uninstall() { // For the uninstaller to be run eraseData setting must be enabled. cssJSToolbox::import('models:settings:uninstall.php'); $settings = new CJTSettingsUninstallPage(); if ($settings->eraseData) { // Get the only instance we've for the main access point! $mainAccessPointObject = self::$instance; // Load default controller! $mainAccessPointObject->controllerName = 'default'; $controller = $mainAccessPointObject->route(false)->setAction('uninstall')->_doAction(); } }
/** * put your comment there... * * @param mixed $tpl */ public function display($tpl = null) { // Initialize. $model =& $this->model; // Set vars! $this->securityToken = cssJSToolbox::getSecurityToken(); $this->component = $this->getRequestParameter('component'); $this->cjtWebSite = cssJSToolbox::getCJTWebSiteURL(); $this->licenseTypes = $model->getExtensionProductTypes($this->component); $this->license = $model->getStateStruct($this->licenseTypes, 'license'); // Display view. echo $this->getTemplate($tpl); }
/** * put your comment there... * * @param mixed $value */ public function setValue($value) { // Pass to child params. foreach ($this->params as $name => $param) { // Get child parameter value. $paramValue = isset($value[$name]) ? $value[$name] : null; // Set child parameter value. $param->setValue($paramValue); if (!$param->validate()) { echo cssJSToolbox::getText('Invalid structure parameter passed!'); } } return $this; }
/** * put your comment there... * */ protected function prepareItems() { if (isset($this->options['result']) && $this->options['result'] == 'fullList') { $this->items['published']['text'] = cssJSToolbox::getText('published'); $this->items['draft']['text'] = cssJSToolbox::getText('draft'); $this->items['trash']['text'] = cssJSToolbox::getText('trash'); } else { CJTxTable::import('author'); $internalAuthorsFlag = CJTAuthorTable::FLAG_SYS_AUTHOR; // Query all template state exluding Internal authors. $query = "SELECT DISTINCT(state) `text` \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_templates t\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN #__cjtoolbox_authors a\n\t\t\t\t\t\t\t\t\t\t\t\t\tON t.authorId = a.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (a.attributes & {$internalAuthorsFlag}) = 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `text`"; $this->items = cssJSToolbox::getInstance()->getDBDriver()->select($query); } }
/** * put your comment there... * */ protected function assignValues() { // Initialize. $driver = cssJSToolbox::getInstance()->getDBDriver(); // For every parameter assign the values. foreach ($this->getParams() as $param) { // Query all values. $recset = $driver->select("SELECT * \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM #__cjtoolbox_parameter_typedef\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE parameterId = {$param->getId()}", ARRAY_A); foreach ($recset as $valueRow) { $param->addValue(new CJT_Models_Block_Parameters_Form_Value($valueRow)); } } return $this; }