コード例 #1
0
 /**
  * doExecute
  *
  * @return  mixed
  */
 public function doExecute()
 {
     // Load SQL file.
     @($installFile = file_get_contents($this->config['dir.src'] . '/sql/install.sql'));
     @($uninstallFile = file_get_contents($this->config['dir.src'] . '/sql/uninstall.sql'));
     $installSql = String::parseVariable($installFile, $this->config['replace']);
     $uninstallSql = String::parseVariable($uninstallFile, $this->config['replace']);
     // Prevent import twice
     $table = '#__' . $this->config['name'] . '_' . $this->config['replace.controller.list.name.lower'];
     $db = Container::getInstance()->get('db');
     try {
         $db->getTableColumns($table);
     } catch (\RuntimeException $e) {
         // Import sql
         $this->controller->out('Importing SQL to table: ' . $table);
         $this->executeSql($installSql);
         $this->controller->out('Imported');
     }
     if (!strpos($installSql, $table)) {
         // Write SQL file to project.
         @($fp = fopen($this->config['dir.dest'] . '/sql/install.sql', 'a+'));
         @fputs($fp, "\n\n\n" . $installSql);
         @fclose($fp);
         @($fp = fopen($this->config['dir.dest'] . '/sql/uninstall.sql', 'a+'));
         @fputs($fp, "\n\n" . $uninstallSql);
         @fclose($fp);
     }
 }
コード例 #2
0
 /**
  * doRender
  *
  * @param string            $name
  * @param XulEngine         $engine
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \LogicException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $grid = $data->xulControl->grid;
     $cells = static::renderChildren($engine, $element, $data);
     $grid->addRow(XmlHelper::getAttributes($element));
     foreach ($cells as $key => $cell) {
         $content = String::parseVariable($cell, $data);
         $attribs = XmlHelper::getAttributes($element);
         $grid->setRowCell($key, $content, $attribs);
     }
     reset($element);
     return $cells;
 }
コード例 #3
0
 /**
  * copyFile
  *
  * @param string $src
  * @param string $dest
  * @param array  $replace
  *
  * @return  void
  */
 protected function copyFile($src, $dest, $replace = array())
 {
     // Replace dest file name.
     $dest = String::parseVariable($dest, $replace);
     if (is_file($dest)) {
         $this->io->out('File exists: ' . $dest);
     } else {
         $content = String::parseVariable(file_get_contents($src), $replace);
         if (File::write($dest, $content)) {
             $this->io->out('File created: ' . $dest);
         }
     }
 }
コード例 #4
0
 /**
  * doRender
  *
  * @param string            $name
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @throws \UnexpectedValueException
  * @return  mixed
  */
 protected static function doRender($name, XulEngine $engine, \SimpleXmlElement $element, $data)
 {
     $formVar = XmlHelper::get($element, 'form', 'form');
     $fieldset = XmlHelper::get($element, 'name');
     if (!$fieldset) {
         throw new \UnexpectedValueException('Need "name" attribute in XUL <fieldset> element.');
     }
     $form = $data->{$formVar};
     if (!$form instanceof \JForm) {
         throw new \UnexpectedValueException(sprintf('No form data found in $data->%s.', $formVar));
     }
     $option = $data->view->option ?: 'LIB_WINDWALKER';
     $label = XmlHelper::get($element, 'label', $option . '_EDIT_FIELDSET_' . $fieldset);
     $label = String::parseVariable($label, $data);
     $html = '<legend>' . \JText::_(strtoupper($label)) . '</legend>';
     foreach ($form->getFieldset($fieldset) as $field) {
         $html .= $field->getControlGroup() . "\n\n";
     }
     $html = HtmlBuilder::create('fieldset', $html, XmlHelper::getAttributes($element));
     return $html;
 }
コード例 #5
0
ファイル: finder.php プロジェクト: beingsane/quickcontent
 /**
  * convertPath
  *
  * @param string $path
  *
  * @return  string
  */
 protected function convertPath($path)
 {
     $user = Container::getInstance()->get('user');
     $date = DateHelper::getDate();
     $replace = array('username' => $user->username, 'name' => $user->name, 'session' => \JFactory::getSession()->getId(), 'year' => $date->year, 'month' => $date->month, 'day' => $date->day);
     return String::parseVariable($path, $replace);
 }
コード例 #6
0
 /**
  * getArguments
  *
  * @param \SimpleXmlElement $element
  * @param mixed             $data
  *
  * @return  array
  */
 protected static function getArguments($element, $data, $argumrntTag = 'argument')
 {
     $args = $element->xpath($argumrntTag);
     $return = array();
     foreach ($args as $arg) {
         if (isset($arg['data'])) {
             $return[] = ArrayHelper::getByPath($data, (string) $arg['data']);
         } else {
             if (strtolower($arg) == 'null') {
                 $arg = null;
             }
             if (strtolower($arg) == 'false') {
                 $arg = false;
             }
             $return[] = String::parseVariable((string) $arg, $data);
         }
     }
     return $return;
 }
コード例 #7
0
 /**
  * replaceVariable
  *
  * @param $attributes
  * @param $data
  *
  * @return  mixed
  */
 protected static function replaceVariable($attributes, $data)
 {
     foreach ($attributes as &$attr) {
         $attr = String::parseVariable($attr, $data);
     }
     return $attributes;
 }
コード例 #8
0
 /**
  * getSubsystemText
  *
  * @param \SplFileinfo $file
  *
  * @return  string
  */
 protected function getSubsystemText(\SplFileinfo $file)
 {
     $text = file_get_contents($file);
     $text = substr($text, strpos($text, '; {{controller.item.name.cap}}') - strlen($text));
     return String::parseVariable($text, $this->config['replace']);
 }