File manager - Edit - /home/jardides/www/Jardi-design/old/administrator/components/com_templateck/views/templates/view.html.php
Back
<?php /** * @name Template Creator CK 3 * @package com_templateck * @copyright Copyright (C) 2013. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr */ // No direct access defined('_JEXEC') or die; jimport('joomla.application.component.view'); jimport('joomla.filesystem.folder'); /** * View class for a list of Templateck. */ class TemplateckViewTemplates extends JViewLegacy { protected $items; protected $pagination; protected $state; /** * Display the view */ public function display($tpl = null) { //$this->sqlFix = $this->get('SqlCheck'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->checkDbIntegrity(); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/templateck.php'; $state = $this->get('State'); $canDo = TemplateckHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_TEMPLATECK_TITLE_TEMPLATES'), 'templates.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/templateinfos'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('templateinfos.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('template.edit', 'JTOOLBAR_EDIT'); JToolBarHelper::custom('templateinfos.copy', 'tck-copyTemplate', 'tck-copyTemplate', 'CK_COPY_TEMPLATE'); JToolBarHelper::custom('templateinfos.installGabarit', 'tck-installGabarit', 'tck-installGabarit', 'CK_INSTALL_GABARIT', false); JToolBarHelper::custom('templateinfos.exportGabarit', 'tck-exportGabarit', 'tck-exportGabarit', 'CK_EXPORT_GABARIT', true); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); } else { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::trash('templates.delete'); } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { // JToolBarHelper::deleteList('', 'templates.delete','JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('templates.delete', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_templateck'); } } /** * private function to check if the template templatecreatorck is installed */ function _checkIfTemplateInstalled() { $app = JFactory::getApplication(); if (JFolder::exists(JPATH_ROOT . '/templates/templatecreatorck')) { return; } else { $app->enqueueMessage(JText::_('TEMPLATE_TEMPLATECREATORCK_NOT_INSTALLED'), 'error'); } return; } private function checkDbIntegrity() { $this->searchColumn('widgets'); $this->searchColumn('modules'); $this->searchTable('layouts'); } private function searchColumn($name) { $db = JFactory::getDbo(); // test if the widget columns not exists $query = "SHOW COLUMNS FROM #__templateck_templates LIKE '" . $name . "'"; $db->setQuery($query); if ($db->query()) { if ( $db->loadResult()) { //echo 'existe deja!';return; } else { // add the SQL field to the main table $db->setQuery('ALTER TABLE `#__templateck_templates` ADD `' . $name . '` text NOT NULL;'); if (!$db->query()) { echo '<p class="alert alert-danger">Error during table ' . $name . ' update process !</p>'; } else { echo '<p class="alert alert-success">Table ' . $name . ' updated !</p>'; } } } else { echo 'SQL error - Check existing ' . $name . ' column'; return false; } } /** * Look if the table exists, if not then create it * * @param type $tableName */ private function searchTable($tableName) { $db = JFactory::getDbo(); $tablesList = $db->getTableList(); $tableExists = in_array($db->getPrefix() . 'templateck_' . $tableName, $tablesList); // test if the table not exists if (! $tableExists) { $query = "CREATE TABLE IF NOT EXISTS #__templateck_" . $tableName . " ( `id` int(11) NOT NULL AUTO_INCREMENT, `template_id` int(11) NOT NULL, `type` text NOT NULL, `htmlcode` longtext NOT NULL, `styles` text NOT NULL, `published` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) )"; $db->setQuery($query); // // add the SQL field to the main table // $query = 'ALTER TABLE `' . $table . '` ADD `' . $name . '` text NOT NULL;'; if (! $db->query($query)) { echo '<p class="alert alert-danger">Error during table ' . $tableName . ' creation process !</p>'; } else { echo '<p class="alert alert-success">Table ' . $tableName . ' created with success !</p>'; } } } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings