Beispiel #1
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)
 {
     $input = JFactory::getApplication()->input;
     $type = $input->get("type", "");
     $client = $input->get("client", "");
     $extName = $input->get("name", "");
     $path = $input->get("path", "");
     $item = new JObject();
     $item->client = $client;
     $item->type = $type;
     $item->name = $extName;
     $item->path = $path;
     switch ($type) {
         case "component":
             if ($client == "admin") {
                 $filepath = JDeveloperPath::dots2ds(JPATH_ADMINISTRATOR . "/components/com_" . $extName . "/" . $path);
             } else {
                 $filepath = JDeveloperPath::dots2ds(JPATH_SITE . "/components/com_" . $extName . "/" . $path);
             }
             if ($filepath === false) {
                 throw new Exception(JText::_("COM_JDEVELOPER_FILEMANAGER_FILE_NOT_FOUND"));
             }
             $item->source = JFile::read($filepath);
             $item->filepath = $filepath;
             break;
     }
     return $item;
 }
Beispiel #2
0
 /**
  * @see	JDeveloperCreate
  */
 protected function getTemplate()
 {
     if (false === ($path = JDeveloperPath::dots2ds(JDeveloperTEMPLATES . "/fields/" . $this->templateFile))) {
         $this->setError($this->name . ": Template <i>{$this->templateFile}</i> not found");
     }
     $this->template = new JDeveloperTemplate($path);
     return $this->template;
 }
Beispiel #3
0
 /**
  * Import class
  *
  * @param	string	The classname
  * @param	string	The base path where to look for the class file
  */
 public static function import($class, $basepath = "")
 {
     if (empty($basepath)) {
         $basepath = JDeveloperLIB;
     }
     $path = JDeveloperPath::dots2ds($basepath . "/" . $class . ".php");
     if ($path === false) {
         throw new Exception(get_class() . ": Path <i>{$class}</i> not found in <i>{$basepath}</i>");
     }
     require_once $path;
 }
Beispiel #4
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 #5
0
 /**
  * Load subtemplate
  *
  * @param	string	$filename	The name of the subtemplate
  * @param	string	$sep		The seperator
  *
  * @return	JDeveloperTemplate		The subtemplate object
  */
 protected function loadSubtemplate($filename, $sep = '.')
 {
     $templateFile = JFile::stripExt($this->templateFile) . $sep . $filename;
     foreach ($this->templateDirs as $templateDir) {
         $dir = JDeveloperPath::dots2ds($templateDir . "/" . $templateFile);
         if ($dir !== false) {
             return new JDeveloperTemplate($dir);
         }
     }
     return false;
 }
Beispiel #6
0
 /**
  * @see	JDeveloperCreate
  */
 public function loadSubtemplate($filename, $sep = '.')
 {
     $sub = parent::loadSubtemplate($filename);
     if ($sub === false) {
         $templateFile = JFile::stripExt($this->templateFile) . $sep . $filename;
         $templateFile = preg_replace("/^site/", "admin", $templateFile);
         foreach ($this->templateDirs as $templateDir) {
             $dir = JDeveloperPath::dots2ds($templateDir . "/" . $templateFile);
             if ($dir !== false) {
                 return new JDeveloperTemplate($dir);
             }
         }
         $this->setError($this->_name . ": Subtemplate <i>'{$basepath}.{$filename}'</i> not found");
         throw new JDeveloperException($this->getErrors());
     }
     return $sub;
 }