Пример #1
0
 /**
  * Display the template list.
  *
  * @return void
  */
 private function templates()
 {
     $input = JFactory::getApplication()->input;
     $profiling = false;
     if ($profiling) {
         //            jimport('joomla.error.profiler');
         $this->profiler = JProfiler::getInstance('EasyCreator');
     }
     $this->task = $input->get('task');
     $this->ecr_project = $input->get('ecr_project');
     $this->path = ECRPATH_EXTENSIONTEMPLATES;
     $this->file_path = $input->getPath('file_path');
     $this->file_name = $input->getPath('file_name');
     $this->com_type = $input->get('com_type');
     $this->template = $input->get('template');
     $this->comTypes = EcrProjectHelper::getProjectTypes();
     $cache = JFactory::getCache();
     $cache->setCaching(1);
     if ($profiling) {
         $this->profiler->mark('start get templates');
     }
     $this->templates = EcrProjectTemplateHelper::getTemplateList();
     if ($profiling) {
         $this->profiler->mark('end get cached templates');
     }
     if ($profiling) {
         echo '<pre>' . print_r($this->profiler->getBuffer(), true) . '</pre>';
     }
     $this->setLayout('templates');
 }
Пример #2
0
 /**
  * Gets Information about a specific template.
  *
  * @param string $tplType Template type
  * @param string $tplName Template name
  *
  * @return object stdClass Template info.
  */
 public static function getTemplateInfo($tplType, $tplName)
 {
     if (false == JFile::exists(ECRPATH_EXTENSIONTEMPLATES . DS . $tplType . DS . $tplName . DS . 'manifest.xml')) {
         return false;
     }
     $xml = EcrProjectHelper::getXML(ECRPATH_EXTENSIONTEMPLATES . DS . $tplType . DS . $tplName . DS . 'manifest.xml');
     $info = new stdClass();
     $info->folder = $tplName;
     $info->name = (string) $xml->name;
     $info->description = jgettext((string) $xml->description);
     $info->version = (string) $xml->version;
     $info->jVersion = (string) $xml->jVersion;
     $info->phpVersion = (string) $xml->phpVersion;
     $info->dbTables = (string) $xml->dbTables;
     $info->author = (string) $xml->author;
     $info->authorUrl = (string) $xml->authorUrl;
     $info->complements = array();
     if (isset($xml->complements->complement)) {
         foreach ($xml->complements->complement as $complement) {
             $c = new stdClass();
             $c->folder = (string) $complement->folder;
             $c->version = (string) $complement->version;
             $c->targetDir = (string) $complement->targetDir;
             $info->complements[] = $c;
         }
     }
     $info->info = '';
     $info->info .= jgettext(ucfirst($tplType)) . ' ' . $info->name . ' ' . $info->version . '::' . $info->description;
     $info->info .= $info->author ? '<br /><span style=\'color: blue;\'>Author:</span> ' . $info->author : '';
     $info->info .= '<br /><strong>Joomla!:</strong> ' . $info->jVersion;
     $info->info .= '<br /><strong>PHP:</strong> ' . $info->phpVersion;
     $info->info .= $info->dbTables ? '<br /><span style=\'color: orange;\'>dbTables:</span> ' . $info->dbTables : '';
     $info->info .= '<br />ECR Folder: ' . $info->folder;
     return $info;
 }
Пример #3
0
 /**
  * Perform the action.
  *
  * @param EcrProjectZiper $ziper
  *
  * @return \EcrProjectAction
  */
 public function run(EcrProjectZiper $ziper)
 {
     $project = EcrProjectHelper::getProject();
     $updateserver = new EcrProjectUpdateserver($project);
     $fileList = $ziper->getCreatedFiles();
     if (0 == count($fileList)) {
         return $this->abort('ERROR: No files to transfer', $ziper);
     }
     $path = ECRPATH_UPDATESERVER . '/' . $project->comName . '/' . $this->releaseState;
     $urlPath = ECRPATH_UPDATESERVER_URL . '/' . $project->comName . '/' . $this->releaseState;
     $urls = array();
     /* @ var EcrProjectZiperCreatedfile $f */
     foreach ($fileList as $f) {
         $dest = $path . '/' . $f->name;
         if (false == JFile::copy($f->path, $dest)) {
             return $this->abort(sprintf('ERROR: Can not copy the file %s to %s', $f->path, $dest), $ziper);
         }
         $ziper->logger->log(sprintf('The file<br />%s<br />has been copied to<br />%s', $f->path, $dest));
         $alternate = $f->alternateDownload;
         $urls[] = $alternate ?: $urlPath . '/' . $f->name;
     }
     $release = new EcrProjectUpdateserverRelease();
     $release->state = $this->releaseState;
     $release->downloads = $urls;
     $release->description = 'Bescreibung...';
     $updateserver->addRelease($release);
     return $this;
 }
Пример #4
0
 protected function setUp()
 {
     defined('ECR_DEBUG') or define('ECR_DEBUG', 0);
     defined('JPATH_COMPONENT') or define('JPATH_COMPONENT', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easycreator');
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'projecthelper.php';
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'html.php';
     $this->project = EcrProjectHelper::newProject('empty');
 }
Пример #5
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();
 }
Пример #6
0
 /**
  * Draws a project selector
  *
  * @return void
  */
 public static function project()
 {
     $projects = EcrProjectHelper::getProjectList();
     $projectTypes = EcrProjectHelper::getProjectTypes();
     $ecr_project = JFactory::getApplication()->input->get('ecr_project');
     $class = '';
     if ($ecr_project == 'ecr_new_project') {
         $class = 'img3 icon16-add';
     } else {
         if ($ecr_project == 'ecr_register_project') {
             $class = 'img3 icon16-import';
         } else {
             if ($ecr_project) {
                 try {
                     $project = EcrProjectHelper::getProject();
                     $class = 'img3 icon12-' . $project->type;
                 } catch (Exception $e) {
                     $do = 'nothing';
                     unset($do);
                 }
             }
         }
     }
     echo '<span class="' . $class . '">';
     echo NL . '<select style="font-size: 1.2em;" name="ecr_project" id="ecr_project" onchange="switchProject();">';
     echo NL . '<option value="">' . jgettext('Project') . '...</option>';
     $selected = $ecr_project == 'ecr_new_project' ? ' selected="selected"' : '';
     $class = ' class="img3 icon16-add"';
     echo NL . '<option' . $class . ' value="ecr_new_project"' . $selected . '>' . jgettext('New Project') . '</option>';
     $selected = $ecr_project == 'ecr_register_project' ? ' selected="selected"' : '';
     $class = ' class="img3 icon16-import"';
     echo NL . '<option' . $class . ' value="ecr_register_project"' . $selected . '>' . jgettext('Register Project') . '</option>';
     /* @var EcrProjectBase $pType */
     foreach ($projectTypes as $pTag => $pType) {
         if (isset($projects[$pTag]) && count($projects[$pTag])) {
             echo NL . '<optgroup label="' . $pType->translateTypePlural() . '">';
             /* @var EcrProjectBase $project */
             foreach ($projects[$pTag] as $project) {
                 $displayName = $project->name;
                 if ($project->scope) {
                     $displayName .= ' (' . $project->scope . ')';
                 }
                 $selected = $project->fileName == $ecr_project ? ' selected="selected"' : '';
                 $class = ' class="img12 icon12-' . $pTag . '"';
                 echo NL . '<option' . $class . ' value="' . $project->fileName . '" label="' . $project->name . '"' . $selected . '>' . $displayName . '</option>';
             }
             echo NL . '</optgroup>';
         }
     }
     echo NL . '</select></span>';
 }
Пример #7
0
 /**
  * Draws a project selector.
  *
  * @return void
  */
 public static function projectSelector()
 {
     //--Get the project helper
     JLoader::import('helpers.projecthelper', JPATH_COMPONENT_ADMINISTRATOR);
     //--Get existing projects
     $projects = EcrProjectHelper::getProjectList();
     $selectedProject = JFactory::getApplication()->input->get('ecr_project');
     if (!isset($projects['component'])) {
         JFactory::getApplication()->enqueueMessage(jgettext('No projects found'), 'error');
         return;
     }
     echo jgettext('Registered projects');
     echo '<ol style="list-style-type: none; text-align: left;">';
     foreach ($projects['component'] as $project) {
         $selected = $project->comName == $selectedProject ? '_selected' : '';
         echo '<li class="ecr_button' . $selected . '" onclick="drawProject(\'' . $project->comName . '\');">' . $project->name . '</li>';
     }
     echo '</ol>';
 }
Пример #8
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();
 }
Пример #9
0
 /**
  * Constructor.
  *
  * @param string $path
  */
 public function __construct($path = '')
 {
     if ('' != $path) {
         $xml = EcrProjectHelper::getXML($path);
         if ($xml) {
             $this->title = (string) $xml->title;
             $this->link = (string) $xml->link->attributes()->href;
             $this->author = (string) $xml->author->name;
             foreach ($xml->entry as $entry) {
                 $i = new EcrProjectFeedItem();
                 $i->title = (string) $entry->title;
                 $i->link = $entry->link ? (string) $entry->link->attributes()->href : '';
                 $i->id = (string) $entry->id;
                 $i->summary = (string) $entry->summary;
                 $i->updated = (string) $entry->updated;
                 $i->author = (string) $entry->author->name;
                 $this->items[] = $i;
             }
         }
     }
 }
Пример #10
0
 /**
  * Standard display method.
  *
  * @param null|string $tpl The name of the template file to parse;
  *
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     $input = JFactory::getApplication()->input;
     $task = $input->get('task');
     $this->builder = new EcrProjectBuilder();
     ecrLoadMedia('wizard');
     $params = JComponentHelper::getParams('com_easycreator');
     $this->templateList = EcrProjectTemplateHelper::getTemplateList();
     $tplType = $input->get('tpl_type');
     $tplFolder = $input->get('tpl_name');
     $desc = isset($this->templateList[$tplType][$tplFolder]) ? $this->templateList[$tplType][$tplFolder]->description : '';
     $project = EcrProjectHelper::newProject('empty');
     $project->type = $input->get('tpl_type');
     $project->tplName = $input->get('tpl_name');
     $project->version = $input->getString('version', '1.0');
     $project->description = $input->getString('description', $desc);
     $project->listPostfix = $input->get('list_postfix', 'List');
     $project->JCompat = $input->getString('jcompat');
     //-- Sanitize project name
     $project->name = $input->get('com_name');
     $disallows = array('_');
     $project->name = str_replace($disallows, '', $project->name);
     //-- Credits
     $s = $input->getString('author');
     $project->author = $s ? $s : $params->get('cred_author');
     $s = $input->getString('authorEmail');
     $project->authorEmail = $s ? $s : $params->get('cred_author_email');
     $s = $input->getString('authorUrl');
     $project->authorUrl = $s ? $s : $params->get('cred_author_url');
     $s = $input->getString('license');
     $project->license = $s ? $s : $params->get('cred_license');
     $s = $input->getString('copyright');
     $project->copyright = $s ? $s : $params->get('cred_copyright');
     $this->project = $project;
     if ($task && method_exists($this, $task)) {
         $this->{$task}();
     }
     parent::display($tpl);
     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
 /**
  * Standard display method.
  *
  * @param string $tpl The name of the template file to parse;
  *
  * @throws Exception
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     $input = JFactory::getApplication()->input;
     //-- Add javascript
     ecrScript('codeeye', 'pollrequest', 'logconsole');
     //-- Add css
     ecrStylesheet('codeeye');
     $this->ecr_project = $input->get('ecr_project');
     $this->task = $input->get('task');
     //--Get the project
     try {
         $this->project = EcrProjectHelper::getProject();
         if (0 == count($this->project->copies)) {
             throw new Exception(jgettext('No files found'));
         }
     } catch (Exception $e) {
         EcrHtml::message($e);
         EcrHtml::formEnd();
         return;
     }
     if (in_array($this->task, get_class_methods($this))) {
         //--Execute the task
         $this->{$this->task}();
         if ($this->task == 'display_snip') {
             //--Raw view
             parent::display($tpl);
             return;
         }
     } else {
         if ($this->task) {
             echo sprintf('UNDEFINED Task "%s" in %s', $this->task, __CLASS__) . '<br />';
         }
     }
     //--Draw the submenu
     echo $this->displayBar();
     parent::display($tpl);
     EcrHtml::formEnd();
 }
Пример #13
0
 /**
  * Standard display method.
  *
  * @param string $tpl The name of the template file to parse;
  *
  * @return void
  */
 public function display($tpl = null)
 {
     $response = array();
     //-- Get the project
     try {
         $project = EcrProjectHelper::getProject();
     } catch (Exception $e) {
         $response['status'] = 0;
         $response['text'] = $e->getMessage();
         EcrHtml::formEnd();
         return;
     }
     //try
     $this->matrix = new EcrProjectMatrix($project, 'pcharts');
     $response['status'] = 1;
     $files = array();
     $size = array();
     $lines = array();
     foreach ($this->matrix->projectData as $type => $data) {
         $files[] = $data['files'];
         $size[] = $data['size'];
         if (isset($data['lines'])) {
             $lines[] = $data['lines'];
         }
     }
     //foreach
     $response['files'] = implode(',', $files);
     $response['size'] = implode(',', $size);
     $response['lines'] = implode(',', $lines);
     $response['labels'] = implode(',', array_keys($this->matrix->projectData));
     ob_start();
     parent::display();
     $response['table'] = ob_get_contents();
     ob_end_clean();
     $response['text'] = 'Hi U';
     echo json_encode($response);
 }
Пример #14
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();
 }
Пример #15
0
 private function printList()
 {
     $this->out('*** Project List ***');
     $list = EcrProjectHelper::getProjectList();
     foreach ($list as $type => $items) {
         $this->out('===========================');
         $this->out($type);
         $this->out('===========================');
         foreach ($items as $item) {
             $this->out($item->name . ' (' . $item->comName . ')');
         }
     }
 }
Пример #16
0
 /**
  * @return string
  */
 private function getDebug()
 {
     if (false == ECR_DEBUG) {
         return '';
     }
     $debug = array();
     $base = ECRPATH_UPDATESERVER . '/' . $this->project->comName;
     $debug[] = '<h3 class="debug">Debug</h3>';
     foreach (JFolder::folders($base) as $state) {
         $path = 'release' == $state ? 'extension' : $state;
         $debug[] = '<div class="path">' . $path . '.xml</div>';
         if (JFile::exists($base . '/' . $path . '.xml')) {
             $xml = EcrProjectHelper::getXML($base . '/' . $path . '.xml');
             $debug[] = '<pre class="code">' . htmlentities($xml->asFormattedXML()) . '</pre>';
         } else {
             $debug[] = 'NOT FOUND<br />';
         }
         $path = $state . '-feed';
         $debug[] = '<div class="path">' . $path . '.xml</div>';
         if (JFile::exists($base . '/' . $path . '.xml')) {
             $xml = EcrProjectHelper::getXML($base . '/' . $path . '.xml');
             $debug[] = '<pre class="code">' . htmlentities($xml->asFormattedXML()) . '</pre>';
         } else {
             $debug[] = 'NOT FOUND<br />';
         }
     }
     return '<div class="debug">' . implode("\n", $debug) . '</div>';
 }
Пример #17
0
 /**
  * DoIt
  *
  * @throws Exception
  * @return void
  */
 public function doExecute()
 {
     require JPATH_BASE . '/helpers/loader.php';
     require JPATH_BASE . '/includes/defines.php';
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     var_dump(getcwd());
     var_dump($this->input->args);
     // Known project types
     $types = EcrProjectHelper::getProjectTypes();
     // Known project "Tags" - short forms
     $tags = EcrProjectHelper::getProjectTypesTags();
     // Predefined actions
     $actions = $this->getActions();
     var_dump($actions);
     var_dump($tags);
     // @todo What do you want to do today ? =;)
     return;
     $this->input->set('ecr_project', 'wap_fuuuschubidu');
     $builder = new EcrProjectBuilder();
     $type = 'webapp';
     //getCmd('tpl_type');
     $name = 'mvc_1';
     //getCmd('tpl_name');
     $comName = 'wap_gugugugu';
     //getCmd('com_name');
     if (in_array($type, array('cliapp', 'webapp'))) {
         define('JPATH_SITE', __DIR__);
     }
     $newProject = $builder->build($type, $name, $comName);
     if (!$newProject) {
         //-- Error
         $this->out('An error happened while creating your project');
         //            JFactory::getApplication()->enqueueMessage(jgettext('An error happened while creating your project'), 'error');
         //          $builder->printErrors();
         $errors = $builder->getErrors();
         var_dump($errors);
         //EcrHtml::formEnd();
         return;
     }
     if ('test' == JFactory::getApplication()->input->get('ecr_test_mode')) {
         //-- Exiting in test mode
         echo '<h2>Exiting in test mode...</h2>';
         echo $builder->printLog();
         $builder->printErrors();
         EcrHtml::formEnd();
         return;
     }
     $ecr_project = JFile::stripExt($newProject->getEcrXmlFileName());
     //   $uri = 'index.php?option=com_easycreator&controller=stuffer&ecr_project='.$ecr_project;
     $this->out('Your project has been created');
     echo ECRPATH_DATA;
     $project = EcrProjectHelper::getProject();
     var_dump($project);
 }
Пример #18
0
foreach ($allTables as $k => $table) {
    $db->setQuery(sprintf($infoQuery, $dbName, $dbPrefix . $table->name));
    $status = $db->loadAssocList();
    $db->setQuery(sprintf($columnQuery, $dbPrefix . $table->name));
    $fields = $db->loadAssocList();
    $table->status = isset($status[0]) ? $status[0] : array();
    $table->hasInstall = array_key_exists($table->name, $discoveredTables) ? $discoveredTables[$table->name]->install : false;
    $table->isRegistered = array_key_exists($table->name, $this->project->tables) ? true : false;
    $table->inDB = in_array($dbPrefix . $table->name, $dbTables) ? true : false;
    if (count($fields)) {
        $table->addFields($fields);
    }
    $tables[] = $table;
}
//foreach
$autocodeList = EcrProjectHelper::getAutoCodeList();
?>

<input type="hidden" name="table_name" id="table_name" />

<div id="addElementMessage"></div>

<div id="addBox">
        <div class="closeButton" onclick="document.id('addBox').style.display='none';">X</div>
        <div id="addPartShow" >
            <strong style="color: red;"><?php 
echo jgettext('Select an element');
?>
</strong>
        </div>
</div>
Пример #19
0
 /**
  * Process plugins in a package.
  *
  * @deprecated removed for J! 1.6
  *
  * @throws Exception
  * @return EcrProjectManifest
  */
 private function processPackagePlugins()
 {
     if (0 == count($this->project->plugins)) {
         return $this;
     }
     $pluginsElement = $this->manifest->addChild('plugins');
     foreach ($this->project->plugins as $item) {
         //-- Get the project
         $project = EcrProjectHelper::getProject('plg_' . $item->scope . '_' . $item->name);
         $f = JPATH_ROOT . DS . EcrProjectHelper::findManifest($project);
         $plgElement = $pluginsElement->addChild('plugin');
         $plgElement->addAttribute('plugin', $item->name);
         $plgElement->addAttribute('group', $item->scope);
         $plgElement->addAttribute('title', $item->title);
         if ($item->ordering) {
             $plgElement->addAttribute('order', $item->ordering);
         }
         $plgFilesElement = $plgElement->addChild('files');
         $plgFilesElement->addAttribute('folder', 'plg_' . $item->scope . '_' . $item->name);
         foreach ($project->copies as $copy) {
             if (JFolder::exists($copy)) {
                 $tName = str_replace('plugins' . DS . $item->scope . DS, '', $copy);
                 $plgFolderElement = $plgFilesElement->addChild('folder', $tName);
             } else {
                 if (JFile::exists($copy)) {
                     $plgFileElement = $plgFilesElement->addChild('file', JFile::getName($copy));
                 } else {
                     //-- @todo error
                     $this->_addLog('Not found<br />SRC: ' . $copy, 'FILE NOT FOUND');
                 }
             }
         }
         if (count($project->langs)) {
             $plgLangsElement = $plgElement->addChild('languages');
             $plgLangsElement->addAttribute('folder', 'plg_' . $item->scope . '_' . $item->name . '/language');
             foreach ($project->langs as $tag => $scopes) {
                 $plgFileElement = $plgLangsElement->addChild('language', $tag . '.' . $project->getLanguageFileName());
                 $plgFileElement->addAttribute('tag', $tag);
             }
         }
         $xml = EcrProjectHelper::getXML($f);
         if (false == $xml) {
             throw new Exception(sprintf(jgettext('Unable to load the xml file %s'), $f));
         }
         $paramsElement = $plgElement->addChild('params');
         if (isset($xml->params->param)) {
             foreach ($xml->params->param as $param) {
                 $paramElement = $paramsElement->addChild('param');
                 foreach ($param->attributes() as $name => $value) {
                     $paramElement->addAttribute($name, (string) $value);
                 }
                 if (isset($param->option)) {
                     foreach ($param->option as $option) {
                         $optionElement = $paramElement->addChild('option', (string) $option);
                         foreach ($option->attributes() as $Name => $Value) {
                             $optionElement->addAttribute($Name, (string) $Value);
                         }
                     }
                 }
             }
         }
     }
     return $this;
 }
Пример #20
0
 /**
  * Prepare adding a part.
  *
  * Setup substitutes
  *
  * @param string $ecr_project Project name
  * @param array  $substitutes Substitutes to add
  *
  * @return boolean
  */
 public function prepareAddPart($ecr_project, $substitutes = array())
 {
     try {
         $project = EcrProjectHelper::getProject($ecr_project);
         $this->addSubstitute('ECR_COM_NAME', $project->name);
         $this->addSubstitute('ECR_COM_COM_NAME', $project->comName);
         $this->addSubstitute('ECR_UPPER_COM_COM_NAME', strtoupper($project->comName));
         $this->addSubstitute('ECR_AUTHORNAME', $project->author);
         $this->addSubstitute('ECR_AUTHORURL', $project->authorUrl);
         $this->addSubstitute('ECR_ACT_DATE', date('d-M-Y'));
         foreach ($substitutes as $key => $value) {
             $this->addSubstitute($key, $value);
         }
         $path = ECRPATH_EXTENSIONTEMPLATES . '/std/header/' . $project->headerType . '/header.txt';
         //-- Read the header file
         $header = JFile::exists($path) ? JFile::read($path) : '';
         //-- Replace vars in header
         $this->substitute($header);
         $this->addSubstitute('##*HEADER*##', $header);
         return true;
     } catch (Exception $e) {
         $this->logger->log('Unable to load the project ' . $ecr_project . ' - ' . $e->getMessage(), 'ERROR');
         return false;
     }
 }
    </div>
    <?php 
echo jgettext('Unregistered Projects');
?>
</div>
<?php 
foreach ($projectScopes as $comType => $projectScope) {
    $scopes = explode(',', $projectScope);
    ?>
<div class="ecr_floatbox">
    <?php 
    echo '<div class="boxHeader img icon12-' . $comType . '" style=" min-width: 150px;">';
    echo $projectTypes[$comType]->translateTypePlural();
    echo '</div>';
    foreach ($scopes as $scope) {
        $unregisteredProjects = EcrProjectHelper::getUnregisteredProjects($comType, $scope, $showCore);
        if ($comType != 'component' && $scope) {
            ?>
            <div style="background-color: #F2F2F2; color: green; padding: 0.3em; font-weight: bold;">
                <?php 
            echo ucfirst($scope);
            ?>
            </div>
            <?php 
        }
        if (0 == count($unregisteredProjects)) {
            ?>
            <div style="color: #ccc; text-align: center;">
                <?php 
            echo jgettext('None found');
            ?>
Пример #22
0
 /**
  * Create the zip file.
  *
  * @throws EcrExceptionZiper
  * @return EcrProjectZiper
  */
 private function createArchive()
 {
     if (false == $this->validBuild) {
         return $this;
     }
     $zipTypes = array('Zip' => 'zip', 'Tgz' => 'tar.gz', 'Bz2' => 'bz2');
     $this->logger->log('Start adding files');
     if ($this->build_dir != ECRPATH_BUILDS) {
         $zipDir = $this->build_dir . DS . $this->project->version;
     } else {
         $zipDir = $this->build_dir . DS . $this->project->comName . DS . $this->project->version;
     }
     //-- Build the file list
     $files = JFolder::files($this->temp_dir, '.', true, true);
     $this->logger->log('TOTAL: ' . count($files) . ' files');
     if (false == JFolder::exists($zipDir)) {
         if (false == JFolder::create($zipDir)) {
             throw new EcrExceptionZiper(__METHOD__ . ' - ERROR creating folder ' . $zipDir);
         }
     }
     if (0 === strpos($this->project->getZipPath(), ECRPATH_BUILDS)) {
         $hrefBase = JURI::root() . str_replace(JPATH_ROOT, '', ECRPATH_BUILDS) . '/' . $this->project->comName . '/' . $this->project->version;
         $hrefBase = str_replace('/\\', '/', $hrefBase);
         $hrefBase = str_replace('\\', '/', $hrefBase);
     } else {
         $hrefBase = 'file://' . $this->project->getZipPath() . DIRECTORY_SEPARATOR . $this->project->version;
     }
     $customFileName = EcrProjectHelper::formatFileName($this->project, JFactory::getApplication()->input->getString('cst_format'));
     $fileName = $this->project->getFileName() . $customFileName;
     foreach ($zipTypes as $zipType => $ext) {
         if (false == $this->preset->{'archive' . $zipType}) {
             continue;
         }
         $this->logger->log('creating ' . $zipType);
         switch ($ext) {
             case 'zip':
                 //-- Translate win path to unix path - for PEAR..
                 $p = str_replace('\\', '/', $this->temp_dir);
                 if (false == EcrArchive::createZip($zipDir . DS . $fileName . '.zip', $files, $p)) {
                     throw new EcrExceptionZiper(__METHOD__ . ' - ERROR Packing routine for ' . $ext);
                 }
                 break;
             case 'bz2':
                 ecrLoadHelper('PEAR');
                 if (false == extension_loaded('bz2')) {
                     PEAR::loadExtension('bz2');
                 }
                 if (false == extension_loaded('bz2')) {
                     JFactory::getApplication()->enqueueMessage(jgettext('The extension "bz2" couldn\'t be found.'), 'error');
                     JFactory::getApplication()->enqueueMessage(jgettext('Please make sure your version of PHP was built with bz2 support.'), 'error');
                     $this->logger->log('PHP extension bz2 not found', 'PHP ERROR');
                 } else {
                     //-- Translate win path to unix path - for PEAR..
                     $p = str_replace('\\', '/', $this->temp_dir);
                     $result = $archive = EcrArchive::createTgz($zipDir . DS . $fileName . '.' . $ext, $files, 'bz2', $p);
                     if (!$result->listContent()) {
                         throw new EcrExceptionZiper(__METHOD__ . 'ERROR Packing routine for ' . $ext);
                     }
                 }
                 break;
             case 'tar.gz':
                 $result = $archive = EcrArchive::createTgz($zipDir . DS . $fileName . '.' . $ext, $files, 'gz', $this->temp_dir);
                 if (!$result->listContent()) {
                     throw new EcrExceptionZiper(__METHOD__ . 'ERROR Packing routine for ' . $ext);
                 }
                 break;
             default:
                 throw new EcrExceptionZiper(__METHOD__ . 'undefined packing type ' . $ext);
                 break;
         }
         $this->logger->log('Packing routine for ' . $ext . ' finished');
         $this->downloadLinks[] = $hrefBase . '/' . $fileName . '.' . $ext;
         /*
         $f = new EcrProjectZiperCreatedfile($zipDir.DS.$fileName.'.'.$ext);
         $this->createdFiles[] = $zipDir.DS.$fileName.'.'.$ext;
         $f = new EcrProjectZiperCreatedfile($zipDir.DS.$fileName.'.'.$ext);
         */
         $this->createdFiles[] = new EcrProjectZiperCreatedfile($zipDir . DS . $fileName . '.' . $ext, $hrefBase . '/' . $fileName . '.' . $ext);
     }
     return $this;
 }
Пример #23
0
 /**
  * Creates a new file from request parameters.
  *
  * @return bool true on success
  * @throws Exception
  */
 public static function createFileFromRequest()
 {
     $input = JFactory::getApplication()->input;
     $project = EcrProjectHelper::getProject();
     if (!($scope = $input->get('lng_scope'))) {
         throw new Exception(jgettext('No scope given'));
     }
     if (!($lang = $input->get('lngcreate_lang'))) {
         throw new Exception(jgettext('No language given'));
     }
     $fileName = self::getFileName($lang, $scope, $project);
     $fileContents = '';
     $fileContents .= '; @version $Id' . '$' . NL;
     //Splitted to avoid property being setted
     $fileContents .= '; ' . $project->comName . ' ' . $scope . ' language file' . NL;
     $fileContents .= '; @created on ' . date('d-M-Y') . NL;
     if (JFile::exists($fileName)) {
         throw new Exception(sprintf(jgettext('The file %s already exists'), $fileName));
     }
     if (!JFile::write($fileName, $fileContents)) {
         throw new Exception(sprintf(jgettext('Unable to write the file %s'), $fileName));
     }
     return true;
 }
Пример #24
0
 /**
  * Install View.
  *
  * @return void
  */
 private function install()
 {
     $this->installFiles = EcrProjectHelper::findInstallFiles($this->project);
     $this->setLayout('install');
 }
Пример #25
0
$projects = EcrProjectHelper::getProjectList();
$toolImgBase = '&lt;span class=\'img icon16-%s\' style=\'padding-left: 20px; height: 14px;\'&gt;&lt;/span&gt;';
$toolImg = new stdClass();
$toolImg->config = sprintf($toolImgBase, 'ecr_config');
$toolImg->language = sprintf($toolImgBase, 'locale');
$toolImg->codeeye = sprintf($toolImgBase, 'xeyes');
$toolImg->ziper = sprintf($toolImgBase, 'package');
$toolImg->deploy = sprintf($toolImgBase, 'deploy');
?>
<div class="projectListHeader registered"><?php 
echo jgettext('Registered Projects');
?>
</div>
<?php 
/* @var EcrProjectBase $pType */
foreach (EcrProjectHelper::getProjectTypes() as $pTag => $pType) {
    if (!isset($projects[$pTag]) || !count($projects[$pTag])) {
        continue;
    }
    ?>
<div class="ecr_floatbox">
    <?php 
    $count = isset($projects[$pTag]) ? count($projects[$pTag]) : 0;
    echo '<div class="boxHeader img icon12-' . $pTag . '">';
    echo sprintf($pType->translateTypeCount($count), $count);
    echo '</div>';
    foreach ($projects[$pTag] as $project) {
        ?>
        <div class="projectListRow btn hasTip"
             title="<?php 
        echo jgettext('Configure') . $toolImg->config . '::' . $project->name;
Пример #26
0
 /**
  * Deletes a translation.
  *
  * @throws Exception
  * @return void
  */
 public function delete_translation()
 {
     $input = JFactory::getApplication()->input;
     ob_start();
     try {
         if (!($scope = $input->get('scope'))) {
             throw new Exception(jgettext('No scope given'));
         }
         $project = EcrProjectHelper::getProject();
         if (!count($project->langs)) {
             throw new Exception(jgettext('No languages found'));
         }
         $easyLanguage = new EcrLanguage($project, $scope, array());
         $trans_lang = $input->get('trans_lang');
         $trans_key = $input->getString('trans_key');
         $easyLanguage->deleteTranslation($trans_lang, $trans_key);
     } catch (Exception $e) {
         $this->response['status'] = 1;
         $this->response['text'] .= $e->getMessage();
     }
     //try
     $buffer = ob_get_clean();
     if ($buffer) {
         $this->response['status'] = 1;
         $this->response['text'] .= $buffer;
     }
     echo json_encode($this->response);
     jexit();
 }
Пример #27
0
 /**
  * Show the formatted log of a unit test.
  *
  * @param string $fileName Full path to XML log file
  *
  * @todo move ?
  *
  * @return string
  */
 public function showFormattedLog($fileName)
 {
     $ret = '';
     if (!JFile::exists($fileName)) {
         return 'file not found..';
     }
     if (!filesize($fileName)) {
         return 'file size is 0..';
     }
     $xmlObject = EcrProjectHelper::getXML($fileName);
     if (!$xmlObject instanceof SimpleXMLElement) {
         return 'unable to load xml parser..';
     }
     foreach ($xmlObject->testsuite as $testSuite) {
         $ret .= $this->outputSingleTest($testSuite);
         $ts = $testSuite->testsuite;
         if ($ts instanceof SimpleXMLElement && isset($ts->testcase)) {
             foreach ($ts as $t) {
                 $ret .= $this->outputSingleTest($t);
             }
             //foreach
         }
     }
     //foreach
     return $ret;
 }
Пример #28
0
 public function loadPreset()
 {
     try {
         $this->response->data = EcrProjectHelper::getProject()->getPreset(JFactory::getApplication()->input->get('preset'))->toJson();
     } catch (Exception $e) {
         $this->response->message = $e->getMessage();
         $this->response->debug = $e->getTraceAsString();
         $this->response->status = 1;
     }
     echo $this->response;
     jexit();
 }
Пример #29
0
                            <?php 
echo jgettext('Extension templates parts');
?>
                        </div>
                        <ul>
                            <?php 
foreach (EcrProjectHelper::getPartsGroups() as $group) {
    $js = " onmousedown=\"setAction('', '" . $path . DS . "parts', '" . $group . "');\"";
    ?>
                                <li class="pft-directory"><?php 
    echo '<div' . $js . '>' . jgettext($group) . '</div>';
    ?>
                                    <ul>
                                        <?php 
    foreach (EcrProjectHelper::getParts($group) as $part) {
        $easyPart = EcrProjectHelper::getPart($group, $part, '', '');
        if ($easyPart) {
            $toolTip = $group . '::' . $part;
            $title = $part;
            if (method_exists($easyPart, 'info')) {
                $info = $easyPart->info();
                $title = $info->title;
                $toolTip = $info->title;
                if ($info->description) {
                    $toolTip .= '::' . $info->description;
                }
            }
            $js = " onmousedown=\"setAction('', '" . $path . DS . 'parts' . DS . $group . "', '" . $part . "');\"";
            echo '<li class="pft-directory">';
            echo '<div' . $js . ' class="hasTip" title="' . $toolTip . '">';
            echo '<span class="img icon16-info"/>' . $title;
Пример #30
0
 /**
  * Get a list of registered projects.
  *
  * @param string $type Project type
  *
  * @return array
  */
 public static function getProjectList($type = '')
 {
     static $projectList;
     if (!$projectList) {
         $projectList = array();
         if (!JFolder::exists(ECRPATH_SCRIPTS)) {
             return $projectList;
         }
         $xmlfiles = JFolder::files(ECRPATH_SCRIPTS, '.xml$', true, true);
         if (!$xmlfiles) {
             return $projectList;
         }
         foreach ($xmlfiles as $fileName) {
             $xml = EcrProjectHelper::getXML($fileName);
             if (!$xml) {
                 continue;
             }
             if ($xml->getName() != 'easyproject') {
                 continue;
             }
             $p = new stdClass();
             $p->type = (string) $xml->attributes()->type;
             $p->name = (string) $xml->name;
             $p->comName = (string) $xml->comname;
             $p->scope = (string) $xml->attributes()->scope;
             $p->position = (string) $xml->position;
             $p->ordering = (string) $xml->ordering;
             $p->fileName = JFile::stripExt(JFile::getName($fileName));
             $projectList[$p->type][] = $p;
         }
         //foreach
     }
     if ($type) {
         return isset($projectList[$type]) ? $projectList[$type] : array();
     }
     return $projectList;
 }