/** * The constructor */ public function __construct($config = array()) { parent::__construct(); $app = JFactory::getApplication(); if (!isset($config['item_id']) || empty($config['item_id'])) { throw new JDeveloperException($this->_name . ": No table id given"); } // Get table data $this->table = $this->getModel('table')->getItem($config['item_id']); // Get component data $this->component = $this->getModel('component')->getItem($this->table->component); // Get component data $this->fields = $this->getModel('fields')->getTableFields($this->table->id); // Get component directory $this->createDir = $this->component->createDir; $this->filePath = $this->templateFile; // Set template base dirs $this->templateDirs[0] = JDeveloperXTD . "/templates/component"; $this->templateDirs[1] = JDeveloperTEMPLATES . "/component"; $this->template = $this->getTemplate(); if ($this->template === false) { throw new JDeveloperException($this->getErrors()); } // Get the template header $params = JComponentHelper::getParams('com_jdeveloper'); $header = new JDeveloperTemplate(JDeveloperTEMPLATES . '/fileheader.txt'); $header->addPlaceholders(array('Author' => $params->get('author'), 'Copyright' => $params->get('copyright'), 'License' => $params->get('license'), 'Version' => $this->component->version, 'Extension' => ucfirst($this->component->display_name))); self::$templateHeader = $header->getBuffer(); }
protected function initialize() { // Table language keys $this->getLanguage()->addKeys(array('VIEW_' . $this->table->plural . '_TITLE' => $this->table->plural, 'VIEW_' . $this->table->singular . '_TITLE' => $this->table->singular, 'FIELD_' . $this->table->pk . '_LABEL' => ucfirst($this->table->pk), 'FIELD_' . $this->table->pk . '_DESC' => ucfirst($this->table->pk), 'FIELD_' . $this->table->pk . '_ORDERING_ASC' => JText::sprintf('COM_JDEVELOPER_ORDER_ASC', ucfirst($this->table->pk)), 'FIELD_' . $this->table->pk . '_ORDERING_DESC' => JText::sprintf('COM_JDEVELOPER_ORDER_DESC', ucfirst($this->table->pk))), $this->table->name); // Submenu language keys $this->getLanguage()->addKeys(array('SUBMENU_' . $this->table->name => $this->table->plural), "", true); // Fields language keys foreach ($this->fields as $field) { $pfx = $this->table->name . '_FIELD_' . $field->name; $this->getLanguage()->addKeys(array("LABEL" => ucfirst($field->name), "DESC" => ucfirst($field->description), "ORDERING_ASC" => JText::sprintf('COM_JDEVELOPER_ORDER_ASC', ucfirst($field->name)), "ORDERING_DESC" => JText::sprintf('COM_JDEVELOPER_ORDER_DESC', ucfirst($field->name)), "KEEP" => JText::sprintf('COM_JDEVELOPER_KEEP_VALUE', ucfirst($field->name)), "FILTER" => '- Select ' . ucfirst($field->name) . ' -'), $pfx); foreach ($field->options as $key => $option) { $this->getLanguage()->addKeys(array("OPTION_" . strtoupper($key) => $option), $pfx); } } // Relation language keys if (isset($this->table->params["relations"])) { foreach ($this->table->params["relations"] as $relation) { $table = $this->getModel("Table")->getItem($relation); $pfx = $this->table->name . '_FIELD_' . $table->singular; $this->getLanguage()->addKeys(array("LABEL" => ucfirst($table->singular), "DESC" => ucfirst($table->singular), "ORDERING_ASC" => JText::sprintf('COM_JDEVELOPER_ORDER_ASC', ucfirst($table->singular)), "ORDERING_DESC" => JText::sprintf('COM_JDEVELOPER_ORDER_DESC', ucfirst($table->singular)), "KEEP" => JText::sprintf('COM_JDEVELOPER_KEEP_VALUE', ucfirst($table->singular)), "FILTER" => '- Select ' . ucfirst($table->singular) . ' -'), $pfx); } } // System translations $this->getLanguage("sys")->addKeys(array($this->table->plural => $this->table->plural, $this->table->singular => $this->table->singular), "", false); return parent::initialize(); }
/** * @see JDeveloperCreateTable::initialize() */ protected function initialize() { $model_table = $this->getModel("Table"); // Get param item $this->item_params = $model_table->getParamsFormItem($this->table->id); $this->item_images = $model_table->getImagesFormItem($this->table->id); // Initialise template $this->template->addPlaceHolders(array("fields" => $this->fields(), "relations" => $this->relations(), "form_fields" => $this->getFormFields(), "form" => $this->getForm($this->table->form_id))); return parent::initialize(); }
public function create() { $template = $this->getTemplate(); if (isset($this->table->params["relations"])) { foreach ($this->table->params["relations"] as $relation) { $table = $this->getModel("Table")->getItem($relation); $template->addPlaceholders(array("header" => self::$templateHeader, "rel_name" => strtolower($table->singular), "rel_mainfield" => $table->mainfield, "rel_pk" => $table->pk, "rel_table_db" => $table->dbname), true); $template->addAreas(array("catidORaccess" => $table->jfields["catid"] || $table->jfields["access"], "access" => $table->jfields["access"], "catid" => $table->jfields["catid"], "created_by" => $table->jfields["created_by"])); $buffer = $template->getBuffer(); parent::write($this->createDir . "/admin/models/fields/" . strtolower($table->singular) . ".php"); } } }
protected function initialize() { $this->template->addPlaceHolders(array('getItem' => $this->_getItem())); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceHolders(array('filters' => $this->filters(), 'relations' => $this->relations())); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceholders(array('pk' => $this->table->pk, 'relations' => $this->relations(), 'sql' => $this->sql(), 'table_db' => $this->table->dbname)); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceHolders(array('filter_fields' => $this->filterFields(), 'filterby' => $this->filterBy(), 'relations' => $this->relations(), 'setstates' => $this->setStates(), 'where_clause' => $this->search())); $this->template->addAreas(array('catidORaccess' => (bool) $this->table->jfields['catid'] || (bool) $this->table->jfields['access'])); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceHolders(array('table_body' => $this->tableBody(), 'table_head' => $this->tableHead())); return parent::initialize(); }
protected function initialize() { $name = strtoupper($this->component->name); $this->addLanguageKeys(array("COM_" . $name . "_CATEGORIES_VIEW_DEFAULT_TITLE", "COM_" . $name . "_CATEGORIES_VIEW_DEFAULT_DESC"), "sys"); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceHolders(array('fieldboxes' => $this->fieldboxes())); return parent::initialize(); }
protected function initialize() { $this->template->addAreas(array('feed' => (bool) $this->table->params['frontend_feed'])); return parent::initialize(); }
/** * 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))); }
protected function initialize() { $this->template->addPlaceHolders(array('ordering' => !empty($table['ordering']) ? "'ordering' => JText::_('JGRID_HEADING_ORDERING')," . PHP_EOL : "", 'sort_fields' => $this->sortFields())); $this->template->addPlaceHolders(array('table' => $this->table->name), true); return parent::initialize(); }
protected function initialize() { $this->template->addPlaceHolders(array('tablebody' => $this->tablebody())); $this->template->addPlaceHolders(array('mainfield' => $this->fields[0]->name), true); return parent::initialize(); }
protected function initialize() { $name = strtoupper($this->component->name) . "_" . strtoupper($this->table->name); $this->addLanguageKeys(array("COM_" . $name . "_VIEW_ITEM_TITLE", "COM_" . $name . "_VIEW_ITEM_DESC"), "sys"); return parent::initialize(); }