Beispiel #1
1
 /**
  * Prepare and sanitise the table data prior to saving.
  *
  * @param   JTable  $table  A reference to a JTable object.
  *
  * @return  void
  *
  * @since   12.2
  */
 protected function prepareTable($table)
 {
     require_once JDeveloperLIB . "/template.php";
     $type = $table->get("type", "");
     $dir = JDeveloperTEMPLATES . "/fields/formfields/" . $type . ".php";
     if ($table->id == 0 && JFile::exists($dir)) {
         $template = new JDeveloperTemplate($dir);
         $template->addAreas(array("header" => false));
         $template->addPlaceholders(array("name" => $table->name), true);
         $table->source = $template->getBuffer();
     }
 }
Beispiel #2
0
 /**
  * The constructor
  */
 public function __construct($config = array())
 {
     parent::__construct();
     $app = JFactory::getApplication();
     if (!isset($config['item_id']) || empty($config['item_id'])) {
         throw new Exception($this->_name . ": No plugin id given");
     }
     // Get plugin data
     $this->item = $this->getModel('plugin')->getItem($config['item_id']);
     $this->type = "plg_" . strtolower($this->item->folder) . "_" . strtolower($this->item->name);
     // Create plugin directory
     $this->createDir = $this->item->createDir;
     // Set template base dirs
     $this->templateDirs[0] = JDeveloperXTD . "/templates/plugin";
     $this->templateDirs[1] = JDeveloperTEMPLATES . "/plugin";
     $this->template = $this->getTemplate();
     if ($this->template === false) {
         throw new JDeveloperException($this->getErrors());
     }
     // Get the plugin header
     $params = JComponentHelper::getParams('com_jdeveloper');
     $header = new JDeveloperTemplate(JDeveloperTEMPLATES . DS . 'fileheader.txt');
     $header->addPlaceholders(array('Author' => $params->get('author'), 'Copyright' => $params->get('copyright'), 'Extension' => ucfirst($this->item->name), 'License' => $params->get('license'), 'Version' => $this->item->version));
     self::$templateHeader = $header->getBuffer();
 }
Beispiel #3
0
 /**
  * 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();
 }
Beispiel #4
0
 /**
  * Prepare and sanitise the table data prior to saving.
  *
  * @param   JTable  $table  A reference to a JTable object.
  *
  * @return  void
  *
  * @since   12.2
  */
 protected function prepareTable($table)
 {
     require_once JDeveloperLIB . "/template.php";
     $dir = JDeveloperTEMPLATES . "/component/admin/models/rules/rule.php";
     if ($table->id == 0) {
         $template = new JDeveloperTemplate($dir);
         $template->addAreas(array("header" => false));
         $template->addPlaceholders(array("name" => $table->name), true);
         $table->source = $template->getBuffer();
     }
 }
Beispiel #5
0
 public static function getTableSql($id)
 {
     require_once JDeveloperLIB . DS . 'template.php';
     $template = new JDeveloperTemplate(JDeveloperPath::dots2ds(JDeveloperTEMPLATES . DS . 'com.admin.sql.install.mysql.utf8.create.sql'));
     $table = JModelLegacy::getInstance('Table', 'JDeveloperModel')->getItem($id);
     $component = JModelLegacy::getInstance('Table', 'JDeveloperModel')->getItem($table->component);
     $fields = JModelLegacy::getInstance('Fields', 'JDeveloperModel')->getTableFields($table->id);
     if ($component === false) {
         $component = new JObject(array('name' => ''));
     }
     $template->addAreas(array('access' => (bool) $table->get('access', 0), 'alias' => (bool) $table->get('alias', 0), 'asset_id' => (bool) $table->get('asset_id', 0), 'catid' => (bool) $table->get('catid', 0), 'checked_out' => (bool) $table->get('checked_out', 0), 'created' => (bool) $table->get('created', 0), 'created_by' => (bool) $table->get('created_by', 0), 'created_by_alias' => (bool) $table->get('created_by_alias', 0), 'hits' => (bool) $table->get('hits', 0), 'language' => (bool) $table->get('language', 0), 'metadata' => (bool) $table->get('metadata', 0), 'metadesc' => (bool) $table->get('metadesc', 0), 'metakey' => (bool) $table->get('metakey', 0), 'modified' => (bool) $table->get('modified', 0), 'modified_by' => (bool) $table->get('modified_by', 0), 'ordering' => (bool) $table->get('ordering', 0), 'params' => !empty($table->params), 'publish' => (bool) $table->get('publish_up', 0) || (bool) $table->get('publish_down', 0), 'publish_up' => (bool) $table->get('publish_up', 0), 'publish_down' => (bool) $table->get('publish_down', 0), 'published' => (bool) $table->get('published', 0), 'tags' => false, 'version' => (bool) $table->get('version', 0)));
     $template->addPlaceholders(array('table_db' => JComponentHelper::getParams('com_jdeveloper')->get('add_component_name_to_table_name') ? $component->name . '_' . $table->name : $table->name, 'pk' => $table->pk, 'sql' => '<br>' . self::sqlFields($fields)));
     $buffer = $template->getBuffer();
     $buffer = preg_replace('/(CREATE TABLE IF NOT EXISTS|NOT NULL|CHARACTER SET|COLLATE|AUTO_INCREMENT|PRIMARY KEY|DEFAULT|COMMENT|unsigned)/', "<span style=\"color:blue\">\$0</span>", $buffer);
     $buffer = preg_replace('/`.*`/', "<span style=\"color:orange\">\$0</span>", $buffer);
     $buffer = preg_replace('/\'.*\'/', "<span style=\"color:#999999\">\$0</span>", $buffer);
     return $buffer;
 }
Beispiel #6
0
 /**
  * Create a package
  */
 public function create()
 {
     jimport('joomla.filesystem.folder');
     require_once JDeveloperLIB . '/archive.php';
     require_once JDeveloperLIB . '/path.php';
     require_once JDeveloperLIB . '/template.php';
     $data = $this->input->post->get('jform', array(), 'array');
     $params = JComponentHelper::getParams($this->option);
     $files = array();
     $path = JDeveloperArchive::getArchiveDir() . "/" . 'pkg_' . $data['name'];
     while (JFile::exists($path . '.zip')) {
         $data['name'] = JString::increment($data['name']);
     }
     JFolder::create($path);
     foreach ($data['files'] as $file) {
         if (preg_match('/^pkg_/', $file)) {
             $files[] = "<file type=\"package\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^com_/', $file)) {
             $files[] = "<file type=\"component\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^mod_/', $file)) {
             $files[] = "<file type=\"module\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^tpl_/', $file)) {
             $files[] = "<file type=\"template\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^plg_/', $file)) {
             $files[] = "<file type=\"plugin\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         JFile::copy(JDeveloperArchive::getArchiveDir() . DS . $file, $path . DS . $file, null, true);
     }
     $template = new JDeveloperTemplate(JDeveloperTEMPLATES . "/pkg/manifest.xml");
     $template->addPlaceholders(array('author' => $params->get('author'), 'author_email' => $params->get('email'), 'author_url' => $params->get('website'), 'copyright' => $params->get('copyright'), 'date' => date("M Y"), 'description' => $data['description'], 'files' => implode("\n\t\t", $files), 'license' => $params->get('license'), 'name' => $data['name'], 'version' => $data['version']));
     $buffer = $template->getBuffer();
     JFile::write($path . '/pkg_' . $data['name'] . '.xml', $buffer);
     JDeveloperArchive::html($path);
     JDeveloperArchive::zip($path);
     JFolder::delete($path);
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_PACKAGE_CREATED', $data['name']));
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=packages', false));
 }