示例#1
0
 /**
  * Method to create the manifest file.
  *
  * @param EcrProjectBase $project The project.
  *
  * @return boolean true on success
  */
 public function create(EcrProjectBase $project)
 {
     if (!$project->type) {
         $this->setError(__METHOD__ . ' - Invalid project given');
         return false;
     }
     $this->project = $project;
     $this->manifest = new EcrXMLElement('<?xml version="1.0" encoding="utf-8" ?><extension />');
     if (false == $this->manifest instanceof EcrXMLElement) {
         $this->setError('Could not create XML builder');
         return false;
     }
     try {
         $this->setUp()->processCredits()->processInstall()->processUpdates()->processSite()->processAdmin()->processMedia()->processPackageModules()->processPackagePlugins()->processPackageElements()->processParameters();
     } catch (Exception $e) {
         EcrHtml::message($e);
         return false;
     }
     if ($this->project->isNew) {
         //--New project
         $path = JPath::clean($this->project->basepath . '/' . $this->project->getJoomlaManifestName());
     } else {
         //--Building project
         $path = JPath::clean($this->project->basepath . '/' . JFile::getName(EcrProjectHelper::findManifest($this->project)));
     }
     $xml = $this->formatXML();
     if (false == JFile::write($path, $xml)) {
         $this->setError('Could not save XML file!');
         return false;
     }
     return true;
 }
示例#2
0
 /**
  * Build a new Joomla! extension from request.
  *
  * @return mixed Redirect on success | boolean false on error
  */
 public function starterstart()
 {
     $input = JFactory::getApplication()->input;
     $builder = new EcrProjectBuilder();
     $type = $input->get('tpl_type');
     $name = $input->get('tpl_name');
     $comName = $input->get('com_name');
     if (!($newProject = $builder->build($type, $name, $comName))) {
         //-- Error
         EcrHtml::message('An error happened while creating your project', 'error');
         JFactory::getApplication()->enqueueMessage(jgettext('An error happened while creating your project'), 'error');
         $builder->printErrors();
         EcrHtml::formEnd();
         return false;
     }
     if ('test' == $input->get('ecr_test_mode')) {
         //-- Exiting in test mode
         echo '<h2>Exiting in test mode...</h2>';
         echo $builder->printLog();
         $builder->printErrors();
         EcrHtml::formEnd();
         return true;
     }
     $ecr_project = JFile::stripExt($newProject->getEcrXmlFileName());
     $uri = 'index.php?option=com_easycreator&controller=stuffer&ecr_project=' . $ecr_project;
     $this->setRedirect($uri, jgettext('Your project has been created'));
 }
示例#3
0
 /**
  * Get insert options.
  *
  * @return void|boolean false on error
  */
 public function getOptions()
 {
     $ecr_project = JFactory::getApplication()->input->get('ecr_project');
     $basePathDest = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . $ecr_project;
     if (JFile::exists($basePathDest . DS . 'CHANGELOG.php')) {
         EcrHtml::message(jgettext('This project already has a changelog'), 'error');
         return false;
     }
     EcrHtmlOptions::logging();
     EcrHtmlButton::submitParts();
 }
示例#4
0
 /**
  * Constructor.
  *
  * @param EcrProjectBase $project
  *
  * @throws DomainException
  */
 public function __construct(EcrProjectBase $project)
 {
     $this->project = $project;
     $comParams = JComponentHelper::getComponent('com_easycreator')->params;
     $this->localPath = $comParams->get('local_updateserver_dir');
     $this->serverUrl = $comParams->get('updateserver_url');
     $this->serverTitle = $comParams->get('updateserver_title');
     $this->releaseUrl = $comParams->get('updateserver_release_url') ?: $this->serverUrl;
     $this->developmentUrl = $comParams->get('updateserver_development_url') ?: $this->serverUrl;
     //-- Check the base directory
     if (false == JFolder::exists(ECRPATH_UPDATESERVER)) {
         if (false == JFolder::copy(JPATH_COMPONENT_ADMINISTRATOR . '/data/updateserver', ECRPATH_UPDATESERVER)) {
             throw new DomainException(sprintf('%s - Can not create the update server directory: %s', __METHOD__, ECRPATH_UPDATESERVER));
         }
         EcrHtml::message(sprintf(jgettext('The update server directory has been created in: %s'), ECRPATH_UPDATESERVER));
     }
     //-- Check the extension directory
     $base = ECRPATH_UPDATESERVER . '/' . $this->project->comName;
     if (false == JFolder::exists($base)) {
         if (false == JFolder::create($base)) {
             throw new DomainException(sprintf('%s - Can not create the extension update server directory: %s', __METHOD__, $base));
         }
         EcrHtml::message(sprintf(jgettext('The update server extension directory has been created in: %s'), $base));
         JFolder::create($base . '/release');
         JFolder::create($base . '/development');
         JFile::copy(ECRPATH_UPDATESERVER . '/index.html', $base . '/index.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/template_extension.html', $base . '/template.html');
         JFile::copy(ECRPATH_UPDATESERVER . '/updateserver.css', $base . '/updateserver.css');
         JFile::copy(ECRPATH_UPDATESERVER . '/favicon.ico', $base . '/favicon.ico');
         /* @var SimpleXMLElement $xml */
         $xml = EcrProjectHelper::getXML('<updates/>', false);
         $xml->addChild('name', $this->project->name);
         $buffer = $xml->asFormattedXML();
         //-- @todo: The file name "extension.xml" is the J! default - customize.
         JFile::write($base . '/extension.xml', $buffer);
         JFile::write($base . '/development.xml', $buffer);
         $feed = new EcrProjectFeed();
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Release Feed';
         $feed->link = $this->releaseUrl . '/release-feed.xml';
         $feed->id = $feed->link;
         $feed->author = 'XX-Author';
         $feed->updated = date(DATE_ATOM);
         $buffer = $feed->printPretty();
         JFile::write($base . '/release-feed.xml', $buffer);
         $feed->title = $this->serverTitle . ' - ' . $this->project->name . ' - Development Feed';
         $feed->link = $this->developmentUrl . '/development-feed.xml';
         $feed->id = $feed->link;
         $buffer = $feed->printPretty();
         JFile::write($base . '/development-feed.xml', $buffer);
         //-- Copy the Joomla! manifest
         JFile::copy($this->project->getJoomlaManifestPath() . '/' . $this->project->getJoomlaManifestName(), $base . '/manifest.xml');
         $this->update();
     }
 }
示例#5
0
 /**
  * Standard display method.
  *
  * @param string $tpl The name of the template file to parse;
  *
  * @return void
  */
 public function display($tpl = null)
 {
     try {
         $this->form = $this->get('Form');
         $this->legacyTemplate = version_compare(ECR_JVERSION, '3.0') < 0 ? '25' : 'default';
         parent::display($tpl);
     } catch (Exception $e) {
         EcrHtml::message($e);
     }
     EcrHtml::formEnd();
 }
示例#6
0
 /**
  * Get insert options.
  *
  * @return void|boolean false on error
  */
 public function getOptions()
 {
     // $project = EcrProjectHelper::getProject();
     $ecr_project = JFactory::getApplication()->input->get('ecr_project');
     $basePathDest = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . $ecr_project;
     if (JFile::exists($basePathDest . DS . 'install' . DS . 'script.php')) {
         EcrHtml::message(jgettext('This project already has an install file - consider removing it'), 'error');
         return false;
     }
     EcrHtmlOptions::logging();
     EcrHtmlButton::submitParts();
     return $this;
 }
示例#7
0
 public function __get($what)
 {
     if (in_array($what, array())) {
         return $this->{$what};
     }
     if ('queryType' == $what) {
         if (isset($this->query->type)) {
             return $this->query->type;
         }
         return '';
     }
     EcrHtml::message(get_class($this) . ' - Undefined property: ' . $what, 'error');
 }
示例#8
0
 /**
  * Standard display method.
  *
  * @param null|string $tpl The name of the template file to parse;
  *
  * @throws Exception
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     $input = JFactory::getApplication()->input;
     ecrScript('stuffer');
     $this->ecr_project = $input->get('ecr_project');
     try {
         //-- Get the project
         $this->project = EcrProjectHelper::getProject();
         if ('package' == $this->project->type && !$this->project->creationDate) {
             //-- This is a hack to detect that a package has no install manifest :(
             throw new Exception(jgettext('Invalid project'));
         }
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
         return;
     }
     $task = $input->get('task', 'stuffer');
     $tmpl = $input->get('tmpl');
     //-- We are loosing the controller name when coming from other tasks - config :(
     $input->set('controller', 'stuffer');
     if ($task != 'display_snip' && $task != 'aj_reflection' && $tmpl != 'component') {
         //-- Draw h1 header
         //EcrHtml::header(jgettext('Configure'), $this->project, 'ecr_settings');
         //-- Draw the submenu if task is not for a raw view
         echo $this->displayBar($task);
     }
     if (in_array($task, get_class_methods($this))) {
         //-- Execute the task
         $this->{$task}();
         if ($task == 'display_snip') {
             //-- Raw view
             parent::display($tpl);
             return;
         }
     } else {
         if ($task) {
             echo 'UNDEFINED..' . $task . '<br />';
         }
         $this->stuffer();
     }
     $this->task = $task;
     $this->tmpl = $tmpl;
     parent::display($tpl);
     EcrHtml::formEnd();
 }
示例#9
0
 /**
  * Standard display method.
  *
  * @param null|string $tpl The name of the template file to parse;
  *
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     ecrLoadMedia('ziper');
     $task = JFactory::getApplication()->input->get('task');
     try {
         $this->project = EcrProjectHelper::getProject();
         $this->preset = $this->project->presets['default'];
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
         return;
     }
     if (in_array($task, get_class_methods($this))) {
         $this->{$task}();
     }
     //-- Draw the submenu
     echo $this->displayBar();
     parent::display($tpl);
     EcrHtml::formEnd();
 }
示例#10
0
 /**
  * Save the configuration.
  *
  * @throws Exception
  * @return void
  */
 public function save_config()
 {
     try {
         $component = JComponentHelper::getComponent('com_easycreator');
         $table = JTable::getInstance('extension');
         $table->load($component->id);
         $params = JFactory::getApplication()->input->get('params', array(), 'array');
         if (!$table->bind(array('params' => $params)) || !$table->check() || !$table->store()) {
             throw new Exception($table->getError());
         }
         $ecr_project = JFactory::getApplication()->input->get('ecr_project');
         $adds = '';
         if (strpos($ecr_project, 'ecr') !== 0) {
             $adds = $ecr_project ? '&view=stuffer&ecr_project=' . $ecr_project : '';
         }
         $this->setRedirect('index.php?option=com_easycreator' . $adds, jgettext('Configuration has been saved'));
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
     }
 }
示例#11
0
 /**
  * Edit AutoCode.
  *
  * @return void
  */
 public function edit()
 {
     $input = JFactory::getApplication()->input;
     try {
         //-- Get the project
         $project = EcrProjectHelper::getProject();
     } catch (Exception $e) {
         EcrHtml::message($e);
         return;
     }
     //try
     $group = $input->get('group');
     $part = $input->get('part');
     $element = $input->get('element');
     $scope = $input->get('scope');
     $key = "{$scope}.{$group}.{$part}.{$element}";
     $AutoCode = EcrProjectHelper::getAutoCode($key);
     if (!$AutoCode) {
         echo '<h4 style="color: red;">AutoCode not found</h4>';
         echo $key;
         return;
     }
     if (!method_exists($AutoCode, 'edit')) {
         echo '<h4 style="color: red;">EDIT function not found</h4>';
         echo $key;
         return;
     }
     if (!isset($project->autoCodes[$AutoCode->getKey()])) {
         echo '<h4 style="color: red;">AutoCode not found in project</h4>';
         echo $AutoCode->getKey();
         return;
     }
     echo '<div style="color: blue; font-weight: bold; text-align:center;">' . ucfirst($group) . ' - ' . ucfirst($part) . '</div>';
     //-- Additional request vars
     echo '<input type="hidden" name="group" value="' . $group . '" />';
     echo '<input type="hidden" name="part" value="' . $part . '" />';
     echo $AutoCode->edit($project->autoCodes[$AutoCode->getKey()]);
     return;
 }
示例#12
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     //-- @Joomla!-version-check
     switch (ECR_JVERSION) {
         case '2.5':
             $this->reservedNames = array('cms', 'joomla', 'phpmailer', 'phputf8', 'simplepie');
             break;
         case '3.0':
         case '3.1':
             $this->reservedNames = array('cms', 'compat', 'joomla', 'legacy', 'phpmailer', 'phputf8', 'simplepie');
             break;
         case '3.2':
         case '3.3':
             $this->reservedNames = array('cms', 'compat', 'fof', 'framework', 'idna_convert', 'joomla', 'legacy', 'phpmailer', 'phputf8', 'simplepie');
             break;
         case '3.4':
             $this->reservedNames = array('cms', 'compat', 'fof', 'framework', 'idna_convert', 'joomla', 'legacy', 'phpmailer', 'phputf8', 'simplepie', 'vendor');
             break;
         default:
             EcrHtml::message(__METHOD__ . ' - Unknown J! version');
             break;
     }
 }
示例#13
0
 /**
  * Standard display method.
  *
  * @param null|string $tpl The name of the template file to parse;
  *
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     ecrStylesheet('deploy');
     ecrScript('deploy', 'php2js', 'pollrequest');
     $task = JFactory::getApplication()->input->get('task');
     try {
         $this->project = EcrProjectHelper::getProject();
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
         return;
     }
     //-- Draw h1 header
     //EcrHtml::header(jgettext('Deploy'), $this->project, 'ecr_deploy');
     if (in_array($task, get_class_methods($this))) {
         //-- Execute the task
         $this->{$task}();
         $this->setLayout($task);
     }
     //-- Draw the submenu
     echo $this->displayBar();
     parent::display($tpl);
     EcrHtml::formEnd();
 }
示例#14
0
<?php

defined('_JEXEC') || die('=;)');
/**
 * @package    EasyCreator
 * @subpackage Views
 * @author     Nikolai Plath (elkuku)
 * @author     Created on 25-Apr-2011
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */
$path = $this->project->getZipPath();
$base_href = 0 === strpos($path, ECRPATH_BUILDS) ? JURI::Root() . 'administrator/components/com_easycreator/builds/' . $this->project->comName : 'file://' . $path;
echo '<div class="img icon16-server path">' . $path . '</div>';
if (false == JFolder::exists($path)) {
    EcrHtml::message(jgettext('Archive is empty'), 'warning');
    return;
}
$folders = JFolder::folders($path);
natcasesort($folders);
$folders = array_reverse($folders);
$i = 0;
foreach ($folders as $folder) {
    echo '<div style="background-color: #B2CCE5; font-size: 1.3em; font-weight: bold; padding-left: 1em;">';
    echo $this->project->comName . ' ' . $folder;
    echo '</div>';
    $base_path = $path . DS . $folder;
    $files = JFolder::files($base_path . DS);
    if (0 == count($files)) {
        echo '<strong style="color: red;">' . jgettext('No ZIP files found') . '</strong>';
        continue;
    }
示例#15
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @throws Exception
  * @return  void
  */
 public function display($tpl = null)
 {
     $input = JFactory::getApplication()->input;
     $task = $input->get('task');
     $this->hideLangs = $input->get('hide_langs', array(), 'array');
     $this->scope = $input->get('scope');
     try {
         $this->project = EcrProjectHelper::getProject();
         if ('ini' != $this->project->langFormat && !class_exists('g11nExtensionHelper')) {
             throw new Exception(sprintf('The g11n library must be available to process %s language files.', $this->project->langFormat));
         }
         if ('ini' != $this->project->langFormat) {
             //-- Here goes g11n =;)
             echo $this->displayBarG11n($task);
         } else {
             if ('' == $this->scope) {
                 $this->scope = 'site';
                 if ($this->project->type == 'plugin') {
                     //-- @todo special treatment for plugins
                     $this->scope = 'admin';
                 }
             }
             if (0 == count($this->project->langs)) {
                 $this->easyLanguage = false;
             } else {
                 $this->easyLanguage = new EcrLanguage($this->project, $this->scope, $this->hideLangs);
                 if ($input->get('tmpl') != 'component') {
                     //--draw selector
                     echo $this->displayBar($task);
                 }
             }
         }
         /**
          * Handle the 'task' value -> call a function
          * Softly exit on undefined
          */
         if (in_array($task, get_class_methods($this))) {
             //--Execute the task
             $this->{$task}();
         } else {
             if ($task) {
                 echo 'UNDEFINED: ' . $task . '<br />';
                 EcrHtml::formEnd();
                 return;
             }
         }
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
         return;
     }
     //try
     parent::display($tpl);
     EcrHtml::formEnd();
 }
示例#16
0
/**
 * Loads EasyCreator Helpers.
 *
 * @param string $name Path in JLoader dot syntax.
 *
 * @deprecated - 2B replaced by the autoloader
 *
 * @return mixed [string path | boolean false on error]
 */
function ecrLoadHelper($name)
{
    static $helpers = array();
    if (isset($helpers[$name])) {
        return $helpers[$name];
    }
    if (!JFile::exists(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/' . str_replace('.', '/', $name) . '.php')) {
        EcrHtml::message(sprintf(jgettext('Helper file not found : %s'), $name), 'error');
        $helpers[$name] = false;
        return $helpers[$name];
    }
    $helpers[$name] = JLoader::import('helpers.' . $name, JPATH_COMPONENT_ADMINISTRATOR);
    return $helpers[$name];
}
示例#17
0
 /**
  * Creates a test directory for UnitTests.
  *
  * @param string $type The type
  *
  * @return void
  */
 private function create_test_dir($type)
 {
     $input = JFactory::getApplication()->input;
     $ecr_project = $input->get('ecr_project');
     $input->set('view', 'codeeye');
     if (!$ecr_project) {
         EcrHtml::message(jgettext('No project selected'), 'error');
         return;
     }
     if (!JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . $ecr_project)) {
         EcrHtml::message(jgettext('Invalid project'), 'error');
         return;
     }
     if (!JFolder::create(JPATH_ADMINISTRATOR . DS . 'components' . DS . $ecr_project . DS . 'tests' . DS . $type)) {
         EcrHtml::message(jgettext('Unable to create tests directory'), 'error');
         return;
     }
     EcrHtml::message(jgettext('The tests directory has been created'));
 }
示例#18
0
 /**
  * Parse the update files.
  *
  * @return array
  */
 public function parseFiles()
 {
     if (!$this->fileList) {
         return array();
     }
     $creates = array();
     $db = JFactory::getDbo();
     foreach ($this->fileList as $version => $path) {
         if (false == JFile::exists($path)) {
             continue;
         }
         $this->log('Parsing file at: ' . $path);
         $contents = JFile::read($path);
         $qs = $db->splitSql($contents);
         $this->log(sprintf('Found %d queries', count($qs)));
         $creates[$version] = array();
         $item = new stdClass();
         $item->version = $version;
         $item->tables = array();
         try {
             foreach ($qs as $q) {
                 $q = trim($q);
                 if ('' == $q) {
                     continue;
                 }
                 $this->adapter->setQuery($q);
                 if ('create' != $this->adapter->queryType) {
                     //-- Not a CREATE query
                     continue;
                 }
                 /*
                 $parsed = $this->adapter->parseCreate();
                 
                 $t = new stdClass;
                 $t->name = $parsed['table_names'][0];
                 $t->fields = $parsed['column_defs'];
                 $t->raw = $q;
                 
                 $item->tables[$t->name] = $t;
                 */
                 $parsed = $this->adapter->parseCreate();
                 $item->tables[$parsed->name] = $parsed;
             }
             $creates[$version] = $item;
         } catch (Exception $e) {
             EcrHtml::message($e);
             $this->log('Exception: ' . $e->getMessage());
         }
     }
     $previous = null;
     $parsedQueries = array();
     foreach ($creates as $item) {
         $statement = '';
         //-- @todo: bad coder :(
         if (false == is_object($item)) {
             continue;
         }
         $qq = new stdClass();
         $qq->version = $item->version;
         $qq->query = '';
         if (!$previous) {
             $previous = $item;
             $parsedQueries[] = $qq;
             continue;
         }
         foreach ($item->tables as $table) {
             if (false == array_key_exists($table->name, $previous->tables)) {
                 //-- New table
                 $this->log('Found a new table ' . $table->name);
                 $statement .= $table->raw . NL;
                 continue;
             }
             //-- Computing alter table statements
             $alter = '';
             $alters = array();
             foreach ($table->fields as $fName => $field) {
                 if (false == array_key_exists($fName, $previous->tables[$table->name]->fields)) {
                     //-- New column
                     $this->log(sprintf('Found a new column %s in table %s', $fName, $table->name));
                     $alters[] = $this->adapter->getStatement('addColumn', $fName, $field);
                     continue;
                 }
                 $pField = $previous->tables[$table->name]->fields[$fName];
                 if ($pField->type != $field->type || $pField->length != $field->length) {
                     //-- Different length
                     $alters[] = $this->adapter->getStatement('modifyColumn', $fName, $field);
                     $this->log(sprintf('Modified column %s in table %s (different type or length)', $fName, $table->name));
                 } else {
                     foreach ($field->constraints as $c) {
                         foreach ($pField->constraints as $pC) {
                             if (!isset($pC['type']) || !isset($c['type'])) {
                                 continue;
                             }
                             if ($pC['type'] == $c['type']) {
                                 //-- Different value
                                 if ($pC['value'] != $c['value']) {
                                     $alters[] = $this->adapter->getStatement('modifyColumn', $fName, $field);
                                     $this->log(sprintf('Modified column %s in table %s - different type %s', $fName, $table->name, $c['type']));
                                 }
                                 continue 2;
                             }
                         }
                     }
                 }
             }
             foreach ($previous->tables[$table->name]->fields as $fName => $field) {
                 if (false == array_key_exists($fName, $table->fields)) {
                     $alters[] = $this->adapter->getStatement('dropColumn', $fName, $field);
                     $this->log(sprintf('Dropping column %s from table %s', $fName, $table->name));
                 }
             }
             $statement .= $this->adapter->getAlterTable($table, $alters);
             $this->log(sprintf('%d alter statements', count($alters)));
         }
         $qq->query = $statement;
         $parsedQueries[] = $qq;
         $previous = $item;
     }
     return $parsedQueries;
 }
示例#19
0
 /**
  * Test if a file exists and then inlude it.
  *
  * @param string $fileName The file name
  *
  * @return boolean
  */
 private function requireIfExists($fileName)
 {
     if (file_exists($fileName)) {
         include_once $fileName;
         return true;
     }
     if (ECR_DEBUG) {
         EcrHtml::message(sprintf(jgettext('File %s not found'), $fileName), 'error');
     }
     return false;
 }
示例#20
0
 /**
  * Get JText Keys from a given file.
  *
  * @param string $fileName Full path to file
  *
  * @return array keys as key, file names as value
  */
 public function getKeys($fileName)
 {
     $definitions = array();
     $cmds = array();
     if ($this->project->langFormat == 'ini') {
         $cmds['php1'] = 'JText::_';
         $cmds['php2'] = 'JText::sprintf';
         $cmds['php3'] = 'JText::printf';
         $cmds['js'] = 'Joomla.JText._';
     } else {
         $cmds['php1'] = 'jgettext';
         $cmds['php2'] = 'jgettext';
         $cmds['php3'] = 'jgettext';
         $cmds['js'] = 'jgettext';
     }
     //--RegEx pattern for JText in PHP files
     $patternPHP = "/" . $cmds['php1'] . "\\(\\s*\\'(.*)\\'\\s*\\)|" . $cmds['php1'] . "\\(\\s*\"(.*)\"\\s*\\)" . "|" . $cmds['php1'] . "\\(\\s*\\'(.*)\\'\\s*\\,|" . $cmds['php1'] . "\\(\\s*\"(.*)\"\\s*\\," . "|" . $cmds['php2'] . "\\(\\s*\\'(.*)\\'|" . $cmds['php2'] . "\\(\\s*\"(.*)\"" . "|" . $cmds['php3'] . "\\(\\s*\\'(.*)\\'|" . $cmds['php3'] . "\\(\\s*\"(.*)\"";
     if ($this->project->langFormat == 'ini') {
         // JHtml::_('grid.sort', 'FOO', ...)
         $patternPHP .= "|JHtml::_\\(\\'grid\\.sort\\'\\, \\'(.*)\\'" . "|JToolBarHelper::custom\\(\\'.*\\'\\,\\s*\\'.*\\'\\,\\s*\\'.*'\\,\\s*\\'(.*)\\'/iU";
         //(.*))\'/iU";//, 'publish.png', 'publish_f2.png', 'COM_USERS_TOOLBAR_ACTIVATE', true);/iU";
     } else {
         $patternPHP .= '/iU';
     }
     //--RegEx pattern for Joomla.JText in Javascript files
     $patternJs = "/" . $cmds['js'] . "\\(\\s*\"(.*)\"|" . $cmds['js'] . "\\(\\s*\\'(.*)\\'" . "|" . $cmds['js'] . "\\(\\s*\\'(.*)\\'\\s*\\)|" . $cmds['js'] . "\\(\\s*\"(.*)\"\\s*\\)/iU";
     //--RegEx pattern for JText in PHP files
     //        $pattern = "/JText::_\(\s*\'(.*)\'\s*\)|JText::_\(\s*\"(.*)\"\s*\)".
     //            "|JText::sprintf\(\s*\"(.*)\"|JText::sprintf\(\s*\'(.*)\'".
     //            "|JText::printf\(\s*\'(.*)\'|JText::printf\(\s*\"(.*)\"/iU";
     //
     //        //--RegEx pattern for Joomla.JText in Javascript files
     //        $patternJs =
     //        //--In case there is the second parameter (default) set
     //            "/Joomla.JText._\(\s*\"(.*)\"|Joomla.JText._\(\s*\'(.*)\'".
     //        //--'''normal''' use...
     //               "|Joomla.JText._\(\s*\'(.*)\'\s*\)|JText::_\(\s*\"(.*)\"\s*\)/iU";
     switch (JFile::getExt($fileName)) {
         case 'php':
             //--Search PHP files
             $contents = JFile::read($fileName);
             preg_match_all($patternPHP, $contents, $matches, PREG_SET_ORDER);
             foreach ($matches as $match) {
                 foreach ($match as $key => $m) {
                     $m = ltrim($m);
                     $m = rtrim($m);
                     if ($m == '' || $key == 0) {
                         continue;
                     }
                     $definitions[$m] = $fileName;
                 }
                 //foreach
             }
             //foreach
             break;
         case 'js':
             //--Search Javascript files
             $contents = JFile::read($fileName);
             preg_match_all($patternJs, $contents, $matches, PREG_SET_ORDER);
             foreach ($matches as $match) {
                 foreach ($match as $key => $m) {
                     $m = ltrim($m);
                     $m = rtrim($m);
                     if ($m == '' || $key == 0) {
                         continue;
                     }
                     $definitions[$m] = $fileName;
                 }
                 //foreach
             }
             //foreach
             break;
         case 'xml':
             //--Search XML files
             $xmlDoc = EcrProjectHelper::getXML($fileName);
             if ($xmlDoc) {
                 if ((string) $xmlDoc->description) {
                     $definitions[(string) $xmlDoc->description] = $fileName;
                 }
                 foreach ($xmlDoc->params as $params) {
                     $s = (string) $params->attributes()->group;
                     if ($s) {
                         $definitions[$s] = $fileName;
                     }
                     foreach ($params->param as $param) {
                         $s = (string) $param->attributes()->label;
                         if ($s) {
                             $definitions[$s] = $fileName;
                         }
                         $s = (string) $param->attributes()->default;
                         if ($s != (int) $s) {
                             //-- Don't add numbers
                             if ($s) {
                                 $definitions[$s] = $fileName;
                             }
                         }
                         $s = (string) $param->attributes()->description;
                         if ($s) {
                             $definitions[$s] = $fileName;
                         }
                         foreach ($param->option as $option) {
                             $s = (string) $option;
                             if ($s) {
                                 $definitions[$s] = $fileName;
                             }
                         }
                         //foreach
                     }
                     //foreach
                 }
                 //foreach
             }
             break;
         default:
             EcrHtml::message('Unknown file extension: ' . JFile::getExt($fileName), 'error');
             break;
     }
     //switch
     return $definitions;
 }
示例#21
0
 /**
  * Gets the DTD for the extension type.
  *
  * @param string $jVersion Joomla! version
  *
  * @return mixed [array index array on success | false if not found]
  */
 public function getDTD($jVersion)
 {
     $dtd = false;
     //-- @Joomla!-version-check
     switch (ECR_JVERSION) {
         case '2.5':
         case '3.0':
         case '3.1':
         case '3.2':
         case '3.3':
         case '3.4':
             break;
         default:
             EcrHtml::message(__METHOD__ . ' - Unknown J! version');
             break;
     }
     return $dtd;
 }
示例#22
0
 /**
  * Auto discover tables.
  *
  * @param EcrProjectBase $project The Project.
  *
  * @return array
  */
 public function discoverTables(EcrProjectBase $project)
 {
     $db = JFactory::getDBO();
     $dbTables = $db->getTableList();
     $dbPrefix = $db->getPrefix();
     $tables = array();
     $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . $project->comName;
     $listPostfix = $project->listPostfix;
     if (!JFolder::exists($path)) {
         return $tables;
     }
     $files = JFolder::files($path, '^install|.sql$|.xml$', true, true);
     if (!count($files) && !$project->tables) {
         return $tables;
     }
     if ($project->tables) {
         $files[] = $project->tables;
     }
     foreach ($files as $file) {
         if (is_array($file)) {
             $tableNames = array();
             foreach ($file as $f) {
                 $tableNames[] = (string) $f->name;
             }
             //foreach
         } else {
             if (!($fContents = JFile::read($file))) {
                 EcrHtml::message('File read error', 'error');
                 return $tables;
             }
             preg_match_all('%CREATE\\sTABLE([A-Z\\s]*)[`]?+\\#__([a-z0-9_]*)[`]?+%', $fContents, $matches);
             if (!count($matches[2])) {
                 continue;
             }
             $tableNames = $matches[2];
         }
         foreach ($tableNames as $m) {
             $m = (string) $m;
             if (array_key_exists($m, $tables)) {
                 if (!is_array($file)) {
                     $ext = JFile::getExt($file);
                     $tables[$m]->install = $ext;
                 }
             } else {
                 $t = new EcrTable($m);
                 $t->install = is_array($file) ? '' : JFile::getExt($file);
                 $t->inDB = in_array($dbPrefix . $m, $dbTables) ? true : false;
                 foreach ($this->types as $tName => $tType) {
                     $t->{$tName} = array();
                     foreach ($this->scopes as $scope) {
                         if ($scope->tag == 'admin' && ($tName == 'viewitem' || $tName == 'catview')) {
                             continue;
                         }
                         $path = JPATH_ROOT . $scope->folder . DS . 'components' . DS . $project->comName . DS . $tType[0];
                         switch ($tType[0]) {
                             case 'views':
                                 $fName = $tName == 'viewform' || $tName == 'viewitem' ? $m : $m . $listPostfix;
                                 if (JFolder::exists($path . DS . $fName)) {
                                     $t->{$tName}[] = $scope->tag;
                                 }
                                 break;
                             case 'models':
                                 $fName = $tName == 'modelform' ? $m : $m . $listPostfix;
                                 if (JFile::exists($path . DS . $fName . '.php')) {
                                     $t->{$tName}[] = $scope->tag;
                                 }
                                 break;
                             default:
                                 $fName = $m . '.php';
                                 if (file_exists($path . DS . $fName)) {
                                     $t->{$tName}[] = $scope->tag;
                                 }
                                 break;
                         }
                         //switch
                     }
                     //foreach
                 }
                 //foreach
                 $tables[$m] = $t;
             }
         }
         //foreach
     }
     //foreach
     return $tables;
 }
示例#23
0
 private function prepareUpdate()
 {
     jimport('joomla.filesystem.archive');
     $buildsPath = $this->project->getZipPath();
     if (!JFolder::exists($buildsPath)) {
         return false;
     }
     $folders = JFolder::folders($buildsPath);
     if (!$folders) {
         return false;
     }
     $tmpPath = '';
     $tmpPath .= JFactory::getConfig()->get('tmp_path');
     $tmpPath .= '/' . $this->project->comName . '_update_' . time();
     $this->log('Temp path is set to ' . $tmpPath);
     if (!JFolder::create($tmpPath)) {
         EcrHtml::message('Unable to create temp folder for update', 'error');
         $this->log('Can not create the temp folder ' . $tmpPath);
         return false;
     }
     foreach ($folders as $folder) {
         JFolder::create($tmpPath . '/' . $folder);
         $this->log('Processing version ' . $folder);
         $files = JFolder::files($buildsPath . '/' . $folder);
         if (!$files) {
             continue;
         }
         $this->log(sprintf('Found %d package(s) ', count($files)));
         if (1 == count($files)) {
             //-- Only one file found in folder - take it
             $source = $buildsPath . '/' . $folder . '/' . $files[0];
         } else {
             //-- @todo tmp solution for multiple file :-?
             //-- ===echo 'more files found....picking '.$files[0];
             //-- Temp
             $source = $buildsPath . '/' . $folder . '/' . $files[0];
         }
         $this->log('Processing package: ' . $source);
         $destination = $tmpPath . '/' . $folder;
         if (!JArchive::extract($source, $destination)) {
             EcrHtml::message(sprintf('Unable to extract the package %s to %s', $source, $destination), 'error');
             return false;
         }
     }
     //foreach
     $this->tmpPath = $tmpPath;
     return true;
 }
示例#24
0
ecrStylesheet('icon');
ecrScript('php2js');
$input = JFactory::getApplication()->input;
$useGoogle = JComponentHelper::getParams('com_easycreator')->get('use_google_trans_api');
$fieldID = $input->getInt('field_id');
$adIds = $input->getString('ad_ids');
$baseLink = 'index.php?option=com_easycreator&tmpl=component&controller=ajax&format=raw';
$baseLink .= '&ecr_project=' . $input->get('ecr_project');
$baseLink .= '&scope=' . $this->scope;
$baseLink .= '&trans_lang=' . $this->trans_lang;
$baseLink .= '&trans_key=' . $this->trans_key;
$ret_type = $input->get('ret_type', 'ini');
$langTag = substr($this->trans_lang, 0, 2);
if ($this->trans_lang != 'en-GB' && !$this->trans_default) {
    //-- No default translation available - this is an error !
    EcrHtml::message(array(jgettext('Unable to translate without default translation'), sprintf(jgettext('Please translate %s first'), 'en-GB')), 'error');
    return;
}
$translation = '';
$extensionPrefix = strtolower($this->project->extensionPrefix);
if ($this->translation) {
    $translation = $this->translation == '**TRANSLATE**' ? '' : $this->translation;
} else {
    if ($this->trans_lang == 'en-GB') {
        $translation = strtolower($this->trans_key);
        if ($extensionPrefix && strpos($translation, $extensionPrefix) === 0) {
            $translation = substr($translation, strlen($extensionPrefix));
        }
        $translation = ucfirst($translation);
        $translation = str_replace('_', ' ', $translation);
    }
示例#25
0
 /**
  * Get a list of known core projects.
  *
  * @param string $scope The scope - admin or site.
  *
  * @return array
  */
 public function getCoreProjects($scope)
 {
     $projects = array();
     //-- @Joomla!-version-check
     switch (ECR_JVERSION) {
         case '2.5':
             switch ($scope) {
                 case 'authentication':
                     $projects = array('gmail', 'joomla', 'ldap');
                     break;
                 case 'captcha':
                     $projects = array('recaptcha');
                     break;
                 case 'content':
                     $projects = array('emailcloak', 'geshi', 'joomla', 'loadmodule', 'pagebreak', 'pagenavigation', 'vote', 'finder');
                     break;
                 case 'editors':
                     $projects = array('none', 'tinymce', 'codemirror');
                     break;
                 case 'editors-xtd':
                     $projects = array('article', 'image', 'pagebreak', 'readmore');
                     break;
                 case 'extension':
                     $projects = array('joomla');
                     break;
                 case 'finder':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
                     break;
                 case 'quickicon':
                     $projects = array('extensionupdate', 'joomlaupdate');
                     break;
                 case 'search':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
                     break;
                 case 'system':
                     $projects = array('cache', 'debug', 'finder', 'highlight', 'languagefilter', 'languagecode', 'log', 'logout', 'p3p', 'redirect', 'remember', 'sef');
                     break;
                 case 'user':
                     $projects = array('contactcreator', 'joomla', 'profile');
                     break;
                 default:
                     EcrHtml::message(sprintf(jgettext('%s - Unknown scope: %s'), __METHOD__, $scope), 'error');
                     break;
             }
             //switch
             break;
         case '3.0':
         case '3.1':
             switch ($scope) {
                 case 'authentication':
                     $projects = array('gmail', 'joomla', 'ldap');
                     break;
                 case 'captcha':
                     $projects = array('recaptcha');
                     break;
                 case 'content':
                     $projects = array('emailcloak', 'geshi', 'joomla', 'loadmodule', 'pagebreak', 'pagenavigation', 'vote', 'finder');
                     break;
                 case 'editors':
                     $projects = array('none', 'tinymce', 'codemirror');
                     break;
                 case 'editors-xtd':
                     $projects = array('article', 'image', 'pagebreak', 'readmore');
                     break;
                 case 'extension':
                     $projects = array('joomla');
                     break;
                 case 'finder':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
                     break;
                 case 'quickicon':
                     $projects = array('extensionupdate', 'joomlaupdate');
                     break;
                 case 'search':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
                     break;
                 case 'system':
                     $projects = array('cache', 'debug', 'finder', 'highlight', 'languagefilter', 'languagecode', 'log', 'logout', 'p3p', 'redirect', 'remember', 'sef');
                     break;
                 case 'user':
                     $projects = array('contactcreator', 'joomla', 'profile');
                     break;
                 default:
                     EcrHtml::message(sprintf(jgettext('%s - Unknown scope: %s'), __METHOD__, $scope), 'error');
                     break;
             }
             //switch
             break;
         case '3.2':
             switch ($scope) {
                 case 'authentication':
                     $projects = array('gmail', 'joomla', 'ldap', 'cookie');
                     break;
                 case 'captcha':
                     $projects = array('recaptcha');
                     break;
                 case 'content':
                     $projects = array('emailcloak', 'finder', 'joomla', 'loadmodule', 'pagebreak', 'pagenavigation', 'vote');
                     break;
                 case 'editors':
                     $projects = array('none', 'tinymce', 'codemirror');
                     break;
                 case 'editors-xtd':
                     $projects = array('article', 'image', 'pagebreak', 'readmore');
                     break;
                 case 'extension':
                     $projects = array('joomla');
                     break;
                 case 'finder':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks', 'tags');
                     break;
                 case 'quickicon':
                     $projects = array('extensionupdate', 'joomlaupdate');
                     break;
                 case 'search':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
                     break;
                 case 'system':
                     $projects = array('cache', 'debug', 'highlight', 'languagefilter', 'languagecode', 'log', 'logout', 'p3p', 'redirect', 'remember', 'sef');
                     break;
                 case 'user':
                     $projects = array('contactcreator', 'joomla', 'profile');
                     break;
                 case 'twofactorauth':
                     $projects = array('totp', 'yubikey');
                     break;
                 default:
                     EcrHtml::message(sprintf(jgettext('%s - Unknown scope: %s'), __METHOD__, $scope), 'error');
                     break;
             }
             break;
         case '3.3':
         case '3.4':
             switch ($scope) {
                 case 'authentication':
                     $projects = array('gmail', 'joomla', 'ldap', 'cookie');
                     break;
                 case 'captcha':
                     $projects = array('recaptcha');
                     break;
                 case 'content':
                     $projects = array('contact', 'emailcloak', 'finder', 'joomla', 'loadmodule', 'pagebreak', 'pagenavigation', 'vote');
                     break;
                 case 'editors':
                     $projects = array('none', 'tinymce', 'codemirror');
                     break;
                 case 'editors-xtd':
                     $projects = array('article', 'image', 'pagebreak', 'readmore');
                     break;
                 case 'extension':
                     $projects = array('joomla');
                     break;
                 case 'finder':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks', 'tags');
                     break;
                 case 'quickicon':
                     $projects = array('extensionupdate', 'joomlaupdate');
                     break;
                 case 'search':
                     $projects = array('categories', 'contacts', 'content', 'newsfeeds', 'tags', 'weblinks');
                     break;
                 case 'system':
                     $projects = array('cache', 'debug', 'highlight', 'languagefilter', 'languagecode', 'log', 'logout', 'p3p', 'redirect', 'remember', 'sef');
                     break;
                 case 'user':
                     $projects = array('contactcreator', 'joomla', 'profile');
                     break;
                 case 'twofactorauth':
                     $projects = array('totp', 'yubikey');
                     break;
                 case 'installer':
                     $projects = array('webinstaller');
                     break;
                 default:
                     EcrHtml::message(sprintf(jgettext('%s - Unknown scope: %s'), __METHOD__, $scope), 'error');
                     break;
             }
             //switch
             break;
         default:
             JFactory::getApplication()->enqueueMessage(__METHOD__ . ' - Unknown J! version', 'error');
             return array();
     }
     //switch
     return $projects;
 }
示例#26
0
<?php

/**
 * @package    EasyCreator
 * @subpackage	Views
 * @author		Nikolai Plath (elkuku)
 * @author		Created on 11-Sep-2008
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */
//-- No direct access
defined('_JEXEC') || die('=;)');
if (!$this->sel_language) {
    EcrHtml::message(jgettext('Please choose a language'));
    return;
}
$cutAfter = JFactory::getApplication()->input->getInt('cut_after', 30);
?>

<table>
	<tr valign="top">
		<td>
			<?php 
drawTable($this->default_language, jgettext('Default language'), $cutAfter, false);
?>
		</td>
		<td>
			<?php 
drawTable($this->translated_language, jgettext('Translated language'), $cutAfter, false);
?>
		</td>
		<td>
示例#27
0
 /**
  * Display the check results.
  *
  * @param JObject $file A file object
  *
  * @return void
  */
 public static function displayResults(stdClass $file)
 {
     //--Check if file exists
     if ($file->exists) {
         echo '<span class="img icon16-check_ok hasTip" title="' . jgettext('Found') . '"/>';
     } else {
         echo '<span class="img icon16-check_fail hasTip" title="' . jgettext('Not found') . '" />';
         EcrHtmlButton::createLanguageFile($file->lang, $file->scope);
         return;
     }
     //--Check if file is UTF-8 encoded
     if ($file->isUFT8) {
         if ($file->isUFT8 == 'NOT CHECKED') {
             echo '<span class="img icon16-yellowled hasTip" title="' . jgettext('Not checked for UTF-8') . '" />';
         } else {
             echo '<span class="img icon16-check_ok hasTip" title="' . jgettext('UTF-8') . '" />';
         }
     } else {
         EcrHtml::message(array(jgettext('File is not UTF-8 encoded'), $file->name), 'error');
     }
     //--Detect BOM
     if ($file->hasBOM) {
         if ($file->hasBOM == 'NOT CHECKED') {
             echo '<span class="img icon16-yellowled hasTip" title="' . jgettext('Not checked for BOM') . '" />';
         } else {
             EcrHtmlButton::removeBOM($file->fileName);
         }
     } else {
         echo '<span class="img icon16-check_ok hasTip" title="' . jgettext('No BOM') . '" />';
     }
 }
示例#28
0
 /**
  * @param $property
  *
  * @return mixed
  * @throws UnexpectedValueException
  */
 public function __get($property)
 {
     if (in_array($property, array('presets'))) {
         return $this->{$property};
     }
     //return $property;
     EcrHtml::message(__METHOD__ . ' - Undefined property: ' . $property, 'error');
 }
示例#29
0
 /**
  * Get a list of known core projects.
  *
  * @param string $scope The scope - admin or site.
  *
  * @return array
  */
 public function getCoreProjects($scope)
 {
     $projects = array();
     switch ($scope) {
         case 'admin':
             //-- @Joomla!-version-check
             switch (ECR_JVERSION) {
                 case '2.5':
                     $projects = array('bluestork', 'hathor', 'system');
                     break;
                 case '3.0':
                 case '3.1':
                 case '3.2':
                 case '3.3':
                 case '3.4':
                     $projects = array('isis', 'hathor', 'system');
                     break;
                 default:
                     EcrHtml::message(__METHOD__ . ' - Unsupported JVersion');
                     break;
             }
             break;
         case 'site':
             //-- @Joomla!-version-check
             switch (ECR_JVERSION) {
                 case '2.5':
                     $projects = array('atomic', 'beez_20', 'beez5', 'system');
                     break;
                 case '3.0':
                 case '3.1':
                 case '3.2':
                 case '3.3':
                 case '3.4':
                     $projects = array('beez3', 'protostar', 'system');
                     if ('3.2' == ECR_JVERSION) {
                         $projects[] = 'booone';
                     }
                     break;
                 default:
                     EcrHtml::message(__METHOD__ . ' - Unsupported JVersion');
                     break;
             }
             break;
         default:
             EcrHtml::message(__METHOD__ . ' - Unknown scope: ' . $scope);
             return array();
             break;
     }
     return $projects;
 }
示例#30
0
			</td>
			<?php 
}
?>
		</tr>
	</table>
</div>

<?php 
if (!$this->selected_xml) {
    EcrHtml::message(jgettext('Please select a XML file'));
    $this->drawDocLinks();
    return;
}
if (!$this->params->params) {
    EcrHtml::message(jgettext('No parameters defined'), 'notice');
    $this->drawDocLinks();
    return;
}
?>

<div id="divParameters">
	<!-- To be filled by js -->
</div>

<?php 
$jsCntSpacers = 0;
$js = '';
foreach ($this->params->params as $group) {
    ?>
	<script type="text/javascript">addGroup('<?php