Example #1
0
 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();
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
<?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());
}
Example #5
0
<?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());
Example #6
0
 /**
  * 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");
     }
 }
Example #7
0
 /**
  * @see	JDeveloperCreate
  */
 protected function initialize()
 {
     // standart placeholders
     $this->template->addAreas($this->getDefaultAreas());
     $this->template->addPlaceHolders($this->getDefaultPlaceholders(), true);
     return parent::initialize();
 }
Example #8
0
 /**
  * @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));
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 /**
  * @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));
 }
Example #11
0
 /**
  * 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 "";
 }
Example #12
0
<?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);
}
Example #13
0
 /**
  * @see	JDeveloperCreate
  */
 public function write($path = '')
 {
     return parent::write(strtolower($path));
 }
Example #14
0
 /**
  * @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));
 }
Example #15
0
 /**
  * @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);
 }