コード例 #1
0
ファイル: config.php プロジェクト: cuongnd/etravelservice
 /**
  * Standard display method.
  *
  * @param bool       $cachable   If true, the view output will be cached
  * @param array|bool $urlparams  An array of safe url parameters and their variable types,
  *                               for valid values see {@link JFilterInput::clean()}.
  *
  * @return \JController|void
  */
 public function display($cachable = false, $urlparams = false)
 {
     if (class_exists('g11n')) {
         g11n::loadLanguage('com_easycreator.config');
     }
     JFactory::getApplication()->input->set('view', 'config');
     parent::display($cachable, $urlparams);
 }
コード例 #2
0
ファイル: loader.php プロジェクト: cuongnd/etravelservice
    //-- 2) Check the libraries folder
    if (!jimport('g11n.language')) {
        //-- 3) Load a dummy language handler -> english only !
        ecrLoadHelper('g11n_dummy');
        ecrScript('g11n_dummy', 'php2js');
    }
}
if (class_exists('g11n')) {
    //-- TEMP@@debug
    if (ECR_DEV_MODE && ECR_DEBUG_LANG) {
        //-- @@DEBUG
        g11n::cleanStorage();
        g11n::setDebug(ECR_DEBUG_LANG);
    }
    //-- Get our special language file
    g11n::loadLanguage();
}
/*
 * Functions
 */
/**
 * Autoloader.
 *
 * @param $className
 *
 * @return mixed
 */
function easy_creator_loader($className)
{
    if (0 !== strpos($className, 'Ecr')) {
        return;
コード例 #3
0
        ecrLoadHelper('g11n_dummy');
    }
}
try {
    if (class_exists('g11n')) {
        // TEMP@@debug
        // @   g11n::cleanStorage();//@@DEBUG
        g11n::setDebug($debug);
        // Get our special language file
        g11n::loadLanguage();
    }
} catch (Exception $e) {
    JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
$document = JFactory::getDocument();
// Add css
$document->addStyleSheet('media/com_easycreator/site/css/default.css');
// Add javascript
$document->addScript('media/com_easycreator/site/js/easycreator.js');
// Include standard html
JLoader::import('helpers.html', JPATH_COMPONENT);
// Require the base controller
require_once JPATH_COMPONENT . DS . 'controller.php';
$controller = new EasyCreatorController();
easyHTML::start();
// Perform the Request task
$controller->execute(JFactory::getApplication()->input->get('task'));
easyHTML::end();
$debug && class_exists('g11n') ? g11n::debugPrintTranslateds() : null;
// Redirect if set by the controller
$controller->redirect();
コード例 #4
0
ファイル: script.php プロジェクト: cuongnd/etravelservice
    /**
     * Method to install the component.
     *
     * @param $parent
     *
     * @return boolean
     */
    public function install($parent)
    {
        // $parent is the class calling this method
        //    $parent->getParent()->setRedirectURL('index.php?option=ECR_COM_COM_NAME');
        //echo '<p>'.JText::_('ECR_UPPER_COM_COM_NAME_INSTALL_TEXT').'</p>';
        $logo = JURI::root(true) . '/media/com_easycreator/admin/images/ico/icon-128-easycreator.png';
        try {
            if (!jimport('g11n.language')) {
                //-- Get our special language file
                JLoader::import('helpers.g11n_dummy', JPATH_ADMINISTRATOR . '/components/com_easycreator');
                ?>
            <div style="padding: 0.3em; background-color: #ffc;">
                <h3 style="color: red;">EasyCreator is in "English ONLY" mode !</h3>

                <h3 style="color: red;">
                    If you like EasyCreator in your language, just install the g11n language library :
                </h3>

                <h3 style="color: red;">
                    <a href="http://joomlacode.org/gf/project/elkuku/frs/?action=FrsReleaseBrowse&frs_package_id=5915">
                        Download lib_g11n
                    </a>
                </h3>
            </div>
            <?php 
            } else {
                g11n::loadLanguage('com_easycreator');
            }
            //$xml = simplexml_load_file(ECR_XML_LOCATION);
            $xml = simplexml_load_file($parent->getParent()->getPath('manifest'));
            if (false == $xml) {
                JFactory::getApplication()->enqueueMessage(jgettext('Install manifest not found'), 'error');
                return false;
            }
        } catch (Exception $e) {
            JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
            return false;
        }
        define('ECR_VERSION', $xml->version);
        require_once JPATH_ADMINISTRATOR . '/components/com_easycreator/helpers/html.php';
        JFactory::getDocument()->addStyleSheet(JURI::root() . 'media/com_easycreator/admin/css/default.css');
        JFactory::getDocument()->addStyleSheet(JURI::root() . 'media/com_easycreator/admin/css/icon.css');
        ?>

    <div>

        <div style="float: right">
            <img
                    src="<?php 
        echo $logo;
        ?>
"
                    alt="EasyCreator Logo" title="EasyCreator Logo"/>
        </div>

        <h1>EasyCreator</h1>
        <?php 
        echo jgettext('EasyCreator is a developer tool.');
        ?>
<br/>
        <?php 
        echo jgettext('It tries to speed up the developing process of custom Joomla! extensions.');
        ?>
<br/>
        <?php 
        echo jgettext('You can create a "frame" for your extension and an installable zip package with just a few "clicks"');
        ?>

        <p>Happy coding,<br/>
            <?php 
        echo sprintf(jgettext('The %s Team.'), '<a href="https://github.com/elkuku/EasyCreator">EasyCreator</a>');
        ?>
        </p>

    </div>

    <h3 style="color: orange;">
        <?php 
        echo jgettext('Please use this extension only in local development environments.');
        ?>
    </h3>
    <p>
        <?php 
        echo sprintf(jgettext('See: <a %s>docs.joomla.org/Setting up your workstation for Joomla! development</a>'), 'href="http://docs.joomla.org/Setting_up_your_workstation_for_Joomla!_development"');
        ?>
    </p>

    <?php 
        ##ECR_MD5CHECK##
        EcrHtml::footer();
    }
コード例 #5
0
JFactory::getDocument()->addScriptDeclaration("var ECR_JVERSION = '" . ECR_JVERSION . "';" . NL);
$prevErrorReporting = error_reporting(-1);
try {
    $controller = EcrEasycreator::getController();
    $input = JFactory::getApplication()->input;
    if ('component' == $input->get('tmpl')) {
        // Perform the Request task only - raw view
        $controller->execute($input->get('task'));
    } else {
        // Display the menu
        EcrHtmlMenu::main();
        // Perform the Request task
        $controller->execute($input->get('task'));
        if (ECR_DEV_MODE && ECR_DEBUG_LANG && class_exists('g11n')) {
            g11n::debugPrintTranslateds(true);
            g11n::debugPrintTranslateds();
        }
        // Display the footer
        EcrHtml::footer();
        JDEBUG ? JProfiler::getInstance('Application')->mark('com_easycreator finished') : null;
    }
    // Restore error_reporting
    error_reporting($prevErrorReporting);
    // Redirect if set by the controller
    // We don't do this very often =;)
    $controller->redirect();
} catch (Exception $e) {
    EcrHtml::message($e);
    JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
    if (ECR_DEBUG) {
        echo '<pre>' . $e->getTraceAsString() . '</pre>';
コード例 #6
0
ファイル: g11nhelper.php プロジェクト: cuongnd/etravelservice
 /**
  * Create a language template file.
  *
  * @static
  *
  * @param string $extension Extension name
  * @param string $scope Scope mus be "admin" or "site"
  *
  * @param string $version Version string
  * @param string $fileName Process only a single file
  *
  * @return bool
  * @throws Exception
  */
 public static function createTemplate($extension, $scope, $version = '1.0', $fileName = null)
 {
     if ($scope != 'admin' && $scope != 'site') {
         throw new Exception('Scope must be "admin" or "site"');
     }
     $base = g11nExtensionHelper::getScopePath($scope);
     $templatePath = g11nStorage::getTemplatePath($extension, $scope);
     $extensionDir = g11nExtensionHelper::getExtensionPath($extension);
     if (!JFolder::exists($base . DS . $extensionDir)) {
         throw new Exception('Invalid extension');
     }
     $dirName = dirname($templatePath);
     if (!JFolder::exists($dirName) && !JFolder::create($dirName)) {
         throw new Exception(jgettext('Can not create the language template folder'));
     }
     $headerData = '';
     $headerData .= ' --copyright-holder="Nikolai Plath - elkuku"';
     $headerData .= ' --package-name="' . $extension . '"';
     $headerData .= ' --package-version="' . $version . '"';
     $headerData .= ' --msgid-bugs-address="*****@*****.**"';
     $comments = ' --add-comments=TRANSLATORS:';
     $keywords = ' -k --keyword=jgettext --keyword=jngettext:1,2';
     $forcePo = ' --force-po --no-wrap';
     $subType = strpos($extension, '.') ? substr($extension, strpos($extension, '.') + 1) : '';
     $buildOpts = '';
     $excludes = array('/editarea_0_8_1_1/', '/highcharts-2.0.5/', '/php2js.js', 'krumo_0_2');
     $title = $extension . ' - ' . $scope;
     $search = 'php';
     $path = $base . DS . $extensionDir;
     switch ($subType) {
         case '':
             $search = 'php';
             $title .= ' - The main language file.';
             break;
         case 'js':
             $search = 'js';
             $buildOpts .= ' -L python';
             $title .= ' - The javascript language file.';
             $parts = g11nExtensionHelper::split($extension);
             $p = JPATH_ROOT . '/media/' . $parts[0] . '/' . $scope;
             if (JFolder::exists($p)) {
                 //-- Change the path to the media folder
                 $path = $p;
             }
             $excludes[] = '/templates/';
             $excludes[] = '.min.';
             break;
         case 'config':
             $search = 'xml';
             $buildOpts .= ' -L Glade';
             $keywords = ' -k --keyword=description --keyword=label';
             $excludes[] = '/templates/';
             $excludes[] = '/scripts/';
             $excludes[] = '/data/';
             $title .= ' - The configuration language file.';
             break;
         default:
             break;
     }
     $files = JFolder::files($path, '.' . $search . '$', true, true);
     if (!$files) {
         throw new Exception(jgettext('No files found'));
     }
     $cleanFiles = array();
     foreach ($files as $file) {
         $found = false;
         foreach ($excludes as $exclude) {
             if (strpos($file, $exclude)) {
                 $found = true;
             }
         }
         if (!$found) {
             $cleanFiles[] = $file;
         }
     }
     if ('config' == $subType) {
         defined('NL') || define('NL', "\n");
         $parser = g11n::getParser('code', 'xml');
         $potParser = g11n::getParser('language', 'pot');
         $options = new JObject();
         $outFile = new g11nFileInfo();
         foreach ($cleanFiles as $fileName) {
             $fileInfo = $parser->parse($fileName);
             if (!count($fileInfo->strings)) {
                 continue;
             }
             $relPath = str_replace(JPATH_ROOT . DS, '', $fileName);
             foreach ($fileInfo->strings as $key => $strings) {
                 foreach ($strings as $string) {
                     if (array_key_exists($string, $outFile->strings)) {
                         if (strpos($outFile->strings[$string]->info, $relPath . ':' . $key) !== false) {
                             continue;
                         }
                         $outFile->strings[$string]->info .= '#: ' . $relPath . ':' . $key . NL;
                         continue;
                     }
                     $t = new g11nTransInfo();
                     $t->info .= '#: ' . $relPath . ':' . $key . NL;
                     $outFile->strings[$string] = $t;
                 }
                 //foreach
             }
             //foreach
         }
         //foreach
         $buffer = $potParser->generate($outFile, $options);
         if (!JFile::write($templatePath, $buffer)) {
             throw new Exception('Unable to write the output file');
         }
     } else {
         $fileList = implode("\n", $cleanFiles);
         $command = $keywords . $buildOpts . ' -o ' . $templatePath . $forcePo . $comments . $headerData;
         echo '<h3>FILELIST | xgettext ' . $command . ' -f - 2>&1</h3>';
         ob_start();
         system('echo "' . $fileList . '" | xgettext ' . $command . ' -f - 2>&1');
         $result = ob_get_clean();
         echo '<pre>' . $result . '</pre>';
     }
     if (!JFile::exists($templatePath)) {
         throw new Exception('Could not create the template');
     }
     //-- Manually strip the JROOT path
     $contents = JFile::read($templatePath);
     $contents = str_replace(JPATH_ROOT . DS, '', $contents);
     //-- Replace the title
     $contents = str_replace('# SOME DESCRIPTIVE TITLE.', '# ' . $title, $contents);
     if (!JFile::write($templatePath, $contents)) {
         throw new Exception(sprintf('Unable to write to path: %s', $templatePath));
     }
     return true;
 }