protected function initialize() { $buffer = array(); foreach ($this->tables as $table) { $create = JDeveloperCreate::getInstance("table.admin.sql", array("item_id" => $table->id)); $buffer[] = $create->getBuffer(); } $this->template = new JDeveloperTemplate(implode("\n\n", $buffer), false); return parent::initialize(); }
/** * Get config form */ private function getForm($parent_id) { $model = $this->getModel("Form"); $table = $model->getTable(); $buffer = ""; foreach ($model->getChildren($parent_id, 1) as $child) { $name = $child->tag == "action" ? "form.action" : "form.child"; $create = JDeveloperCreate::getInstance($name, array("item_id" => $child->id)); if (!$table->isLeaf($child->id)) { $create->getTemplate()->addPlaceholders(array("children" => $this->getForm($child->id))); } else { $create->getTemplate()->addPlaceholders(array("children" => "", "component" => $this->component->name, "title" => str_replace(".", "_", $child->name)), true); } $result = $create->getBuffer(); $result = explode("\n", $result); $buffer .= implode("\n\t", $result); } return $buffer; }
/** * Get config form * * @return string */ private function getForm($parent_id) { $model = $this->getModel("Form"); $table = $model->getTable(); $buffer = ""; foreach ($model->getChildren($parent_id, 1) as $child) { if ($child->level == 2 && $child->tag == "field") { continue; } $name = $child->tag == "field" ? "form.field" : "form.child"; $create = JDeveloperCreate::getInstance($name, array("item_id" => $child->id)); if (!$table->isLeaf($child->id)) { $create->getTemplate()->addPlaceholders(array("children" => $this->getForm($child->id))); } else { $create->getTemplate()->addPlaceholders(array("children" => "")); } $result = $create->getBuffer(); $result = explode("\n", $result); $buffer .= implode("\n\t", $result); } return $buffer; }
<?php /** * @package JDeveloper * @subpackage Views * * @copyright Copyright (C) 2014, Tilo-Lars Flasche. All rights reserved. * @license GNU General Public License version 2 or later */ defined('_JEXEC') or die; JDeveloperLoader::import("create"); $input = JFactory::getApplication()->input; $id = $input->get("id", 0, "int"); if ($id) { echo JHtml::_("code.form", JDeveloperCreate::getInstance("table.admin.form.singular", array("item_id" => $id))->getBuffer()); }
<?php /** * @package JDeveloper * @subpackage Views * * @copyright Copyright (C) 2014, Tilo-Lars Flasche. All rights reserved. * @license GNU General Public License version 2 or later */ defined('_JEXEC') or die; JDeveloperLoader::import("create"); echo JHtml::_("code.form", JDeveloperCreate::getInstance("component.admin.config", array("item_id" => $this->item->id))->getBuffer());
/** * Install table */ public function install() { $user = JFactory::getUser(); // Check if action is allowed if (!$user->authorise('components.install', 'com_jdeveloper')) { $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning'); return; } // Get table data $app = JFactory::getApplication(); $id = $app->input->get('id', 0, 'int'); $model = JModelLegacy::getInstance("Table", "JDeveloperModel"); $item = $model->getItem($id); $component = JModelLegacy::getInstance("Component", "JDeveloperModel")->getItem($item->component); $this->setRedirect(JRoute::_("index.php?option=com_jdeveloper&view=component&id=" . $component->id, false)); // If component is installed, install table if (JDeveloperInstall::isInstalled('component', 'com_' . $component->name)) { // If table is already installed, the procedure is finished here if ($model->isInstalled($item->id)) { return; } // Get SQL code of table and send SQL install query to database $sql = JDeveloperCreate::getInstance("table.admin.sql", array("item_id" => $item->id))->getBuffer(); $db = JFactory::getDbo(); $db->setQuery($sql)->execute(); $this->setMessage("COM_JDEVELOPER_TABLE_MESSAGE_TABLE_INSTALLED", "error"); } else { $this->setMessage("COM_JDEVELOPER_TABLE_MESSAGE_COMPONENT_NOT_INSTALLED", "error"); } }
/** * Execute Create Instance * * @param string $path Path of create files */ public static function execute($config = array()) { $item = JModelLegacy::getInstance("Template", "JDeveloperModel")->getItem($config['item_id']); $dir = $item->createDir; // Create folders JFolder::create($dir . "/css"); JFolder::create($dir . "/html"); JFolder::create($dir . "/images"); JFolder::create($dir . "/js"); JFolder::create($dir . "/less"); // Copy files JFile::copy(JDeveloperTEMPLATES . "/template/template.css", $dir . "/css/template.css"); foreach (JFolder::files(JDeveloperCREATE . "/template", "php\$") as $file) { $class = JDeveloperCreate::getInstance("template." . JFile::stripExt($file), $config); if (!$class->create()) { $errors = $class->getErrors(); if (!empty($errors)) { throw new JDeveloperException($errors); } } } JDeveloperCreate::getInstance("language.template", $config)->create(); JDeveloperCreate::getInstance("language.template.sys", $config)->create(); JFile::copy(JDeveloperTEMPLATES . "/template/favicon.ico", $dir . "/favicon.ico"); }
/** * Get other XML fields * * @return string */ private function getForm($parent_id = 0) { $model = $this->getModel("Form"); $table = $model->getTable(); $buffer = ""; foreach ($model->getChildren($parent_id, 1) as $child) { // Exclude level 2 fields if ($child->level == 2 && $child->tag == "field") { continue; } // Exclude params if not activated if (!$this->table->jfields["params"] && $this->item_params->id == $child->id) { continue; } // Exclude images if not activated if (!$this->table->jfields["images"] && $this->item_images->id == $child->id) { continue; } // Select template name $name = $child->tag == "field" ? "form.field" : "form.child"; // Get Create subclass instance $create = JDeveloperCreate::getInstance($name, array("item_id" => $child->id)); // Check if item has children if (!$table->isLeaf($child->id)) { $create->getTemplate()->addPlaceholders(array("children" => $this->getForm($child->id))); } else { $create->getTemplate()->addPlaceholders(array("children" => "")); } // Add rendered template to return value $result = $create->getBuffer(); $result = explode("\n", $result); $buffer .= implode("\n\t", $result); } return $buffer; }
/** * Execute Create Instance * * @param string $client (admin | site) * @param array $config Configuration */ public static function execute($client, $config = array()) { $client = str_replace(".", DS, $client); $component = JModelLegacy::getInstance("Component", "JDeveloperModel")->getItem($config["item_id"]); // Create folders JFolder::create($component->createDir . "/admin/controllers"); JFolder::create($component->createDir . "/admin/models"); JFolder::create($component->createDir . "/admin/models/forms"); JFolder::create($component->createDir . "/admin/tables"); JFolder::create($component->createDir . "/admin/views"); if ($component->site) { JFolder::create($component->createDir . "/site/controllers"); JFolder::create($component->createDir . "/site/models"); JFolder::create($component->createDir . "/site/views"); } // Get each file from this folder and get instance of create class foreach (JFolder::files(JDeveloperCREATE . "/component/{$client}", "php\$") as $file) { $class = JDeveloperCreate::getInstance("component.{$client}." . JFile::stripExt($file), $config); if (!$class->create()) { $errors = $class->getErrors(); if (!empty($errors)) { throw new JDeveloperException($errors); } } } }
/** * Execute Create Instance * * @param string $path Path of create files */ public static function execute($config = array()) { foreach (JFolder::files(JDeveloperCREATE . "/plugin", "php\$") as $file) { $class = JDeveloperCreate::getInstance("plugin." . JFile::stripExt($file), $config); if (!$class->create()) { $errors = $class->getErrors(); if (!empty($errors)) { throw new JDeveloperException($errors); } } } JDeveloperCreate::getInstance("language.plugin", $config)->create(); JDeveloperCreate::getInstance("language.plugin.sys", $config)->create(); }
/** * Get the template * * @param string $type The extension type (component, module, plugin, template) * @param string $name The template name * @param int $item_id The extension id (primary key of table shere item is stored) * * @return string The template */ private function _getSource($type, $name, $item_id) { $input = JFactory::getApplication()->input; $dir = JDeveloperCREATE . "/" . implode("/", explode(".", $type)); foreach (JFolder::files($dir, "php\$") as $file) { $create = JDeveloperCreate::getInstance($type . "." . JFile::stripExt($file), array("item_id" => $item_id)); if ($create->templateFile == $name) { return $create->getBuffer(); } } return ""; }
<?php /** * @package JDeveloper * @subpackage Views * * @copyright Copyright (C) 2014, Tilo-Lars Flasche. All rights reserved. * @license GNU General Public License version 2 or later */ defined('_JEXEC') or die; JDeveloperLoader::import("create"); $input = JFactory::getApplication()->input; $id = $input->get("id", 0, "int"); $table = $this->getModel()->getTable(); if ($id) { $result = JDeveloperCreate::getInstance("form.form", array("item_id" => $this->item->id))->getBuffer(); } if ($input->get("format", "") == "xml") { echo $result; } else { echo JHtml::_("code.form", $result); }
/** * Execute Create Instance * * @param string $client (admin | site) * @param array $config Configuration */ public static function execute($client, $config = array()) { $client = str_replace(".", DS, $client); $component = JModelLegacy::getInstance("Component", "JDeveloperModel")->getItem($config["item_id"]); // Get each file from this folder and get instance of create class foreach (JFolder::files(JDeveloperCREATE . "/table/{$client}", "php\$") as $file) { // Execute create classes for each table foreach (JModelLegacy::getInstance("Tables", "JDeveloperModel")->getComponentTables($component->id) as $table) { $table_config = array("item_id" => $table->id); $class = JDeveloperCreate::getInstance("table.{$client}." . JFile::stripExt($file), $table_config); if (!$class->create()) { $errors = $class->getErrors(); if (!empty($errors)) { throw new JDeveloperException($errors); } } } } }