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"); } }
/** * @see JDeveloperCreate */ protected function initialize() { // standart placeholders $this->template->addAreas($this->getDefaultAreas()); $this->template->addPlaceHolders($this->getDefaultPlaceholders(), true); return parent::initialize(); }
/** * @see JDeveloperCreate */ public function write($path = '') { if ($path == '') { $path = $this->templateFile; $path = str_replace(".", DS, JFile::stripExt($path)) . "." . JFile::getExt($path); $path = str_replace('#name#', $this->item->name, $path); $path = str_replace('#version#', $this->item->version, $path); $path = $this->createDir . "/" . $path; $path = strtolower($path); } return parent::write(strtolower($path)); }
/** * 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; }
/** * @see JDeveloperCreate */ public function write($path = '') { if ($path == '') { $path = $this->filePath; $path = str_replace(".", DIRECTORY_SEPARATOR, JFile::stripExt($path)) . "." . JFile::getExt($path); $path = str_replace('component', $this->component->name, $path); $path = str_replace('install' . DS . 'mysql' . DS . 'utf8', 'install.mysql.utf8', $path); $path = str_replace('uninstall' . DS . 'mysql' . DS . 'utf8', 'uninstall.mysql.utf8', $path); $path = str_replace('view' . DS . 'feed', 'view.feed', $path); $path = str_replace('view' . DS . 'html', 'view.html', $path); $path = str_replace('version', $this->component->version, $path); $path = $this->createDir . "/" . $path; } return parent::write(strtolower($path)); }
/** * 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); }
/** * @see JDeveloperCreate */ public function write($path = '') { return parent::write(strtolower($path)); }
/** * @see JDeveloperCreate */ public function write($path = '') { if ($path == '') { $path = $this->filePath; $path = str_replace(".", DIRECTORY_SEPARATOR, JFile::stripExt($path)) . "." . JFile::getExt($path); $path = str_replace('component', $this->component->name, $path); $path = str_replace('view' . DS . 'feed', 'view.feed', $path); $path = str_replace('view' . DS . 'html', 'view.html', $path); $path = str_replace('plural', $this->table->plural, $path); $path = str_replace('singular', $this->table->singular, $path); $path = $this->createDir . "/" . $path; } return parent::write(strtolower($path)); }
/** * @see JDeveloperCreate */ public function write($path = '') { if ($path == '') { $path = $this->templateFile; $path = str_replace(".", DS, JFile::stripExt($path)) . "." . JFile::getExt($path); $path = preg_replace('/module/', 'mod_' . strtolower($this->item->name), $path); $path = $this->createDir . "/" . $path; $path = strtolower($path); } return parent::write($path); }