Exemple #1
0
 /**
  * Get fields from form file
  *
  * @param	SimpleXMLElement	$form	Form file
  *
  * @return	mixed	Fields array on success, false otherwise
  */
 public function getFields(SimpleXMLElement $form, $table = 0)
 {
     JDeveloperLoader::importHelper("field");
     // Check if xml file contains form information
     if ($form->getName() != "form") {
         return false;
     }
     // Get fields
     $fields = array();
     foreach ($form->fieldset->children() as $_field) {
         $field = array();
         $field["id"] = 0;
         $field["name"] = (string) $_field["name"];
         $field["type"] = (string) $_field["type"];
         $field["table"] = $table;
         $field["label"] = (string) ucfirst($_field["name"]);
         $field["dbtype"] = JDeveloperHelperField::getDbType((string) $_field["type"]);
         $field["rule"] = isset($_field["validate"]) ? (string) $_field["validate"] : "";
         $field["maxlength"] = isset($_field["size"]) ? (string) $_field["size"] : "10";
         $field["params"] = array();
         $field["params"]["class"] = isset($_field["class"]) ? (string) $_field["class"] : "inputbox";
         $field["params"]["default"] = isset($_field["default"]) ? (string) $_field["default"] : "";
         $field["params"]["filter"] = isset($_field["filter"]) ? (string) $_field["filter"] : "";
         $field["params"]["readonly"] = isset($_field["readonly"]) ? "1" : "0";
         $field["params"]["frontend_list"] = "1";
         $field["params"]["frontend_item"] = "1";
         $field["params"]["listfilter"] = "0";
         $field["params"]["searchable"] = "0";
         $field["params"]["sortable"] = "0";
         $fields[] = $field;
     }
     return $fields;
 }
Exemple #2
0
 /**
  * Method to get an array of data items.
  *
  * @return  array  An array of data items
  *
  * @since   12.2
  */
 public function getItems()
 {
     JDeveloperLoader::import("archive");
     $extension = JTable::getInstance("Extension", "JTable");
     // Get a storage key.
     $store = $this->getStoreId('getItems');
     // Load the list items.
     $items = parent::getItems();
     // Add information
     foreach ($items as $item) {
         // Is Component already installed?
         $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("mod_", $item->name, $item->version);
         $item->installed = JDeveloperInstall::isInstalled("module", "mod_" . $item->name);
         if ($item->installed) {
             $extension->load(array("name" => "mod_" . $item->name, "type" => "module"));
             $item->enabled = (bool) $extension->enabled;
         } else {
             $item->enabled = false;
         }
     }
     // If emtpy or an error, just return.
     if (empty($items)) {
         return array();
     }
     // Add the items to the internal cache.
     $this->cache[$store] = $items;
     return $this->cache[$store];
 }
Exemple #3
0
 /**
  * Create ZIP file of plugins
  *
  * @param	array	$ids	The primary keys of the items
  */
 public function create($ids = array())
 {
     // Initialize
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=plugin', false));
     if (empty($ids)) {
         $ids = $app->input->get('cid', array(), 'array');
     }
     // Check access
     if (!$user->authorise('plugins.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('plugin', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create Plugin for each id
     foreach ($ids as $id) {
         $plugin = $this->getModel()->getItem($id);
         $path = $plugin->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create Plugin
         try {
             JDeveloperCreatePlugin::execute(array("item_id" => $id));
         } catch (JDeveloperException $e) {
             $this->setMessage($e->getMessage(), "error");
             return;
         }
         // Create HTML files for each folder, zip the folder and delete the folder
         JDeveloperArchive::html($path);
         // Create ZIP archive and delete folder
         JDeveloperArchive::zip($path);
         JFolder::delete($path);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_PLUGIN_MESSAGE_ZIP_CREATED', count($ids)));
 }
Exemple #4
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Controllers
 *
 * @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("controllers.list");
/**
 * JDeveloper Forms Controller
 *
 * @package     JDeveloper
 * @subpackage  Controllers
 */
class JDeveloperControllerForms extends JDeveloperControllerList
{
    /**
     * The URL view list variable.
     *
     * @var    string
     * @since  12.2
     */
    protected $view_list = 'Forms';
    /**
     * Rebuild the nested set tree.
     *
     * @return  bool  False on failure or error, true on success.
     *
Exemple #5
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  JDeveloper
 *
 * @copyright  	Copyright (C) 2014, Tilo-Lars Flasche. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */
defined('_JEXEC') or die;
require_once JDeveloperLIB . "/loader.php";
require_once JPATH_COMPONENT_ADMINISTRATOR . "/config.php";
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
JDeveloperLoader::import("archive");
Exemple #6
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)
 {
     JDeveloperLoader::import("create");
     $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  Create.Component
 *
 * @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("component", JDeveloperCREATE);
/**
 * Table Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Component
 */
class JDeveloperCreateComponentAdminViewComponent extends JDeveloperCreateComponent
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "admin.views.component.view.html.php";
    /**
     * Check whether file should be created or not
     *
     * @return	boolean
     */
    protected function condition()
Exemple #8
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());
}
Exemple #9
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Controllers
 *
 * @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("controllers.item");
/**
 * JDeveloper Template Controller
 *
 * @package     JDeveloper
 * @subpackage  Controllers
 */
class JDeveloperControllerTemplate extends JDeveloperControllerItem
{
}
Exemple #10
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Models
 *
 * @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("models.extension");
/**
 * JDeveloper Module Model
 *
 * @package     JDeveloper
 * @subpackage  Models
 */
class JDeveloperModelModule extends JDeveloperModelExtension
{
    /**
     * Method to get a table object, load it if necessary.
     *
     * @param   string  $name     The table name. Optional.
     * @param   string  $prefix   The class prefix. Optional.
     * @param   array   $options  Configuration array for model. Optional.
     *
     * @return  JTable  A JTable object
     *
     * @since   12.2
     * @throws  Exception
     */
Exemple #11
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Component
 *
 * @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("component", JDeveloperCREATE);
JDeveloperLoader::importHelper("table");
/**
 * Component Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Component
 */
class JDeveloperCreateComponentAdminUpdate extends JDeveloperCreateComponent
{
    protected function condition()
    {
        return !empty($this->tables);
    }
    public function initialize()
    {
        $buffer = array();
        $model = $this->getModel("Field");
        $db = JFactory::getDbo();
        foreach ($this->tables as $table) {
            if (in_array($table->dbname, $db->getTableList())) {
Exemple #12
0
 /**
  * Create component ids
  *
  * @param	array	$ids	The component 
  */
 public function create($ids = array())
 {
     // Initialize
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=component', false));
     if (empty($ids)) {
         $ids = $app->input->get('cid', array(), 'array');
     }
     // Check access
     if (!$user->authorise('components.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('component', JDeveloperCREATE);
     JDeveloperLoader::import('table', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create component for each id
     foreach ($ids as $id) {
         $component = $this->getModel()->getItem($id);
         $path = $component->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create component
         JDeveloperCreateComponent::execute("admin", array("item_id" => $id));
         JDeveloperCreateTable::execute("admin", array("item_id" => $id));
         // Create component for frontend
         if ($component->get('site', 0)) {
             JDeveloperCreateComponent::execute("site", array("item_id" => $id));
             JDeveloperCreateTable::execute("site", array("item_id" => $id));
         }
         // Get language files content
         $buffer = JDeveloperLanguage::getInstance("com_" . $component->name)->sort()->toINI();
         $buffer_sys = JDeveloperLanguage::getInstance("com_" . $component->name . "_sys")->sort()->toINI();
         // Write language files
         foreach ($component->params["languages"] as $lang) {
             JFile::write($component->createDir . "/admin/language/{$lang}.com_" . strtolower($component->name) . ".ini", $buffer);
             JFile::write($component->createDir . "/admin/language/{$lang}.com_" . strtolower($component->name) . ".sys.ini", $buffer_sys);
             $component->site ? JFile::write($component->createDir . "/site/language/{$lang}.com_" . strtolower($component->name) . ".ini", $buffer) : null;
         }
         // Create HTML files for each folder
         JDeveloperArchive::html($path . '/admin');
         (int) $component->get('site', 0) ? JDeveloperArchive::html($path . '/site') : null;
         // Create ZIP archive and delete folder
         JDeveloperArchive::zip($path);
         JFolder::delete($path);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_COMPONENT_CREATED', count($ids)));
 }
Exemple #13
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Models
 *
 * @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("models.list");
/**
 * JDeveloper Forms Model
 *
 * @package     JDeveloper
 * @subpackage  Models
 */
class JDeveloperModelForms extends JDeveloperModelList
{
    /**
     * Constructor.
     *
     * @param   array  $config  An optional associative array of configuration settings.
     */
    public function __construct($config = array())
    {
        if (empty($config['filter_fields'])) {
            $config['filter_fields'] = array('a.name', 'name', 'a.alias', 'alias', 'a.created_by', 'created_by', 'author_id', 'a.ordering', 'ordering', 'lft', 'a.lft', 'rgt', 'a.rgt', 'level', 'a.level', 'path', 'a.path', 'ordering', 'state', 'name', 'type', 'label', 'description', 'default', 'maxlength', 'validation');
        }
        parent::__construct($config);
    }
Exemple #14
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Library
 *
 * @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("library", JDeveloperCREATE);
/**
 * Library Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Library
 */
class JDeveloperCreateLibraryManifest extends JDeveloperCreateLibrary
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "library.xml";
    protected function initialize()
    {
        $this->template->addPlaceHolders(array("author" => $this->item->get('author'), "author_email" => $this->item->get('author_email'), "author_url" => $this->item->get('author_url'), "copyright" => $this->item->get('copyright'), "creationdate" => date("M Y"), "licence" => $this->item->get('licence'), "languages" => $this->lang(), "version" => $this->item->get('version')));
        return parent::initialize();
    }
    /**
Exemple #15
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Form
 *
 * @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("form", JDeveloperCREATE);
/**
 * Form Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Form
 */
class JDeveloperCreateFormChild extends JDeveloperCreateForm
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "form_child.xml";
    /**
     * @see	JDeveloperCreate
     */
    protected function initialize()
    {
        $this->template->addAreas(array("filter" => (bool) $this->item->filter, "validation" => (bool) $this->item->validation, "disabled" => (bool) $this->item->disabled, "readonly" => (bool) $this->item->readonly, "required" => (bool) $this->item->required, "list" => !empty($this->item->options)));
Exemple #16
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Template
 *
 * @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("template", JDeveloperCREATE);
/**
 * Template Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Template
 */
class JDeveloperCreateTemplateHtml extends JDeveloperCreateTemplate
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "index.php";
}
Exemple #17
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Plugin
 *
 * @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("plugin", JDeveloperCREATE);
/**
 * Plugin Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Plugin
 */
class JDeveloperCreatePluginFolder extends JDeveloperCreatePlugin
{
    /**
     * Get the template object
     *
     * @return	JDeveloperTemplate
     */
    protected function getTemplate()
    {
        $this->templateFile = $this->item->folder . ".php";
        return parent::getTemplate();
    }
    /**
     * @see JDeveloperCreate
Exemple #18
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Models
 *
 * @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("models.admin");
/**
 * JDeveloper Field Model
 *
 * @package     JDeveloper
 * @subpackage  Models
 */
class JDeveloperModelField extends JDeveloperModelAdmin
{
    /**
     * Method to get a table object, load it if necessary.
     *
     * @param   string  $name     The table name. Optional.
     * @param   string  $prefix   The class prefix. Optional.
     * @param   array   $options  Configuration array for model. Optional.
     *
     * @return  JTable  A JTable object
     *
     * @since   12.2
     * @throws  Exception
     */
Exemple #19
0
 /**
  * Get an JDeveloperCreate object
  *
  * @param	string	$name	The class name
  * @param	array	$config	The configuration data
  *
  * @return	mixed	instance of JDeveloperCreate on success, false otherwise
  */
 public static function getInstance($name, $config = array())
 {
     $class = "JDeveloperCreate" . JDeveloperLoader::getClassname($name);
     if (!class_exists($class)) {
         JDeveloperLoader::import($name, JDeveloperCREATE);
     }
     if (class_exists($class)) {
         return new $class($config);
     } else {
         throw new Exception("Could not find class <i>{$class}</i>");
     }
 }
Exemple #20
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Models
 *
 * @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("models.admin");
JDeveloperLoader::import("install");
/**
 * JDeveloper Component Model
 *
 * @package     JDeveloper
 * @subpackage  Models
 */
class JDeveloperModelComponent extends JDeveloperModelAdmin
{
    /**
     * Method to delete one or more records.
     *
     * @param   array  &$pks  An array of record primary keys.
     *
     * @return  boolean  True if successful, false if an error occurs.
     */
    public function delete(&$pks)
    {
        // Delete tables which belong to the component
        if ((int) JComponentHelper::getParams('com_jdeveloper')->get('delete_tables')) {
Exemple #21
0
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Library
 *
 * @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("module", JDeveloperCREATE);
/**
 * Library Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Libray
 */
class JDeveloperCreateLibraryBase extends JDeveloperCreateLibrary
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "library.php";
}
Exemple #22
0
 /**
  * Import fields from xml file
  */
 public function fieldsFromForm()
 {
     JDeveloperLoader::import("install");
     $this->setRedirect(JRoute::_("index.php?option=com_jdeveloper&view=import&active=fields", false));
     $jform = $this->input->post->get("jform", array(), "array");
     if (empty($jform["table"])) {
         $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_ERROR_NO_TABLE_GIVEN"), "error");
         return;
     }
     // Get data
     $files = $this->input->files->get("jform", array(), "files");
     $manifest = JFile::upload($files["formfile"]["tmp_name"], JDeveloperINSTALL . "/import_fields.xml", false);
     $xml = new SimpleXMLElement(JDeveloperINSTALL . "/import_fields.xml", null, true);
     // Get fields from xml file
     $model = $this->getModel("ImportXml");
     if (false === ($fields = $model->getFields($xml, $jform["table"]))) {
         $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_MESSAGE_FIELDS_ERROR") . ": " . JText::_("COM_JDEVELOPER_IMPORT_ERROR_NO_FORM_FILE"), "error");
         JDeveloperInstall::cleanInstallDir();
         return;
     }
     // Save fields
     $model = $this->getModel("Field");
     foreach ($fields as $field) {
         if ($field["name"] == "id") {
             continue;
         }
         $model->save($field);
     }
     JDeveloperInstall::cleanInstallDir();
     $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_MESSAGE_FIELDS_SUCCESS"));
 }
<?php

/**
 * @package     JDeveloper
 * @subpackage  Create.Table
 *
 * @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("table", JDeveloperCREATE);
/**
 * Table Create Class
 *
 * @package     JDeveloper
 * @subpackage  Create.Table
 */
class JDeveloperCreateTableSiteModelSingular extends JDeveloperCreateTable
{
    /**
     * The template file
     *
     * @var	string
     */
    protected $templateFile = "site.models.singular.php";
    /**
     * Check whether file should be created or not
     *
     * @return	boolean
     */
    protected function condition()
Exemple #24
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed    Object on success, false on failure.
  *
  * @since   12.2
  */
 public function getItem($pk = null)
 {
     JDeveloperLoader::import("create");
     if (false === ($item = parent::getItem($pk))) {
         return false;
     }
     $db = JFactory::getDbo();
     $params = JComponentHelper::getParams('com_jdeveloper');
     // Create database table name
     if (!empty($item->component)) {
         $component = JModelLegacy::getInstance('Component', 'JDeveloperModel')->getItem($item->component);
         // Only add component name to table name if it is not added already
         if (!preg_match("/^" . $component->name . "/", $item->name)) {
             $item->dbname = $params->get('add_component_name_to_table_name') ? $component->name . '_' . $item->name : $item->name;
         } else {
             $item->dbname = $item->name;
         }
     } else {
         $item->dbname = $item->name;
     }
     // Set first table field as main field
     $db->setQuery("SELECT f.name FROM #__jdeveloper_fields AS f WHERE f.table = " . $db->quote($item->id) . " ORDER BY f.ordering");
     $item->mainfield = $db->loadResult();
     // Get Joomla core fields
     $registry = new JRegistry();
     $registry->loadString($item->jfields);
     $item->jfields = $registry->toArray();
     // Get related form item
     $table = JTable::getInstance("Form", "JDeveloperTable");
     $item->form_id = 0;
     if ($table->load(array("tag" => "form", "relation" => "table." . $item->id . ".form"), true)) {
         $item->form_id = $table->id;
     }
     // Get form params id
     $item->form_params_id = 0;
     if ($table->load(array("tag" => "fields", "name" => "params", "relation" => "table." . $item->id . ".form"), true)) {
         $item->form_params_id = $table->id;
     }
     // Get form images id
     $item->form_images_id = 0;
     if ($table->load(array("tag" => "fields", "name" => "images", "relation" => "table." . $item->id . ".form"), true)) {
         $item->form_images_id = $table->id;
     }
     return $item;
 }