Exemplo n.º 1
0
 function install()
 {
     // installer le CSS
     $cssFile = jApp::wwwPath('css/localiz.css');
     if (!file_exists($cssFile)) {
         $this->copyFile('css/localiz.css', $cssFile);
     }
     // installer le JS
     $jsFile = jApp::wwwPath('js/localiz.js');
     if (!file_exists($jsFile)) {
         $this->copyFile('js/localiz.js', $jsFile);
     }
     // conf DB
     $localConfFile = jApp::configPath('localconfig.ini.php');
     if (file_exists($localConfFile)) {
         $ini = new jIniFileModifier($localConfFile);
         $ini->setValue('db_driver', 'pgsql', 'localiz_plugin');
         $ini->setValue('db_host', 'pgpool', 'localiz_plugin');
         $ini->setValue('db_port', '5432', 'localiz_plugin');
         $ini->setValue('db_database', 'refgeo2', 'localiz_plugin');
         $ini->setValue('db_user', 'visu', 'localiz_plugin');
         $ini->setValue('db_password', 'visu', 'localiz_plugin');
         $ini->setValue('db_query', "select oid, geometrytype, value, label, longlabel, xmin, ymin, xmax, ymax from MYTABLE where label like '%s%%'", 'localiz_plugin');
         /* Ex with plain text search
            "select oid, typcode, geometrytype(geom) as geometrytype, code as value, lib || complement as label, 
            typ || ' ' || lib || complement || ' (' || code || ')' as longlabel, 
            st_xmin(st_transform(bbox, 4326)) xmin, st_ymin(st_transform(bbox, 4326)) ymin, st_xmax(st_transform(bbox, 4326)) xmax, st_ymax(st_transform(bbox, 4326)) ymax
            from services.ref_search
            where (v @@ to_tsquery('fr', regexp_replace('%1$s', '\\s+', '&', 'g')) )
            order by st_area(bbox) desc"            */
         $ini->save();
     }
 }
Exemplo n.º 2
0
 function testContext()
 {
     $appPath = jApp::appPath();
     $varPath = jApp::varPath();
     $logPath = jApp::logPath();
     $configPath = jApp::configPath();
     $wwwPath = jApp::wwwPath();
     $scriptsPath = jApp::scriptsPath();
     $tempPath = jApp::tempPath();
     // first save
     jApp::saveContext();
     // verify that we still have the current path
     $this->assertEquals($appPath, jApp::appPath());
     $this->assertEquals($varPath, jApp::varPath());
     $this->assertEquals($logPath, jApp::logPath());
     $this->assertEquals($configPath, jApp::configPath());
     $this->assertEquals($wwwPath, jApp::wwwPath());
     $this->assertEquals($scriptsPath, jApp::scriptsPath());
     $this->assertEquals($tempPath, jApp::tempPath());
     // change the path
     jApp::initPaths('/myapp/');
     $this->assertEquals('/myapp/', jApp::appPath());
     $this->assertEquals('/myapp/var/', jApp::varPath());
     $this->assertEquals('/myapp/var/log/', jApp::logPath());
     $this->assertEquals('/myapp/var/config/', jApp::configPath());
     $this->assertEquals('/myapp/www/', jApp::wwwPath());
     $this->assertEquals('/myapp/scripts/', jApp::scriptsPath());
     $this->assertEquals($tempPath, jApp::tempPath());
     // second save
     jApp::saveContext();
     jApp::initPaths('/myapp2/');
     $this->assertEquals('/myapp2/', jApp::appPath());
     $this->assertEquals('/myapp2/var/', jApp::varPath());
     $this->assertEquals('/myapp2/var/log/', jApp::logPath());
     $this->assertEquals('/myapp2/var/config/', jApp::configPath());
     $this->assertEquals('/myapp2/www/', jApp::wwwPath());
     $this->assertEquals('/myapp2/scripts/', jApp::scriptsPath());
     $this->assertEquals($tempPath, jApp::tempPath());
     // pop the second save, we should be with the first saved values
     jApp::restoreContext();
     $this->assertEquals('/myapp/', jApp::appPath());
     $this->assertEquals('/myapp/var/', jApp::varPath());
     $this->assertEquals('/myapp/var/log/', jApp::logPath());
     $this->assertEquals('/myapp/var/config/', jApp::configPath());
     $this->assertEquals('/myapp/www/', jApp::wwwPath());
     $this->assertEquals('/myapp/scripts/', jApp::scriptsPath());
     $this->assertEquals($tempPath, jApp::tempPath());
     // pop the first save, we should be with initial paths
     jApp::restoreContext();
     $this->assertEquals($appPath, jApp::appPath());
     $this->assertEquals($varPath, jApp::varPath());
     $this->assertEquals($logPath, jApp::logPath());
     $this->assertEquals($configPath, jApp::configPath());
     $this->assertEquals($wwwPath, jApp::wwwPath());
     $this->assertEquals($scriptsPath, jApp::scriptsPath());
     $this->assertEquals($tempPath, jApp::tempPath());
 }
Exemplo n.º 3
0
 /**
  * initialize the application paths
  *
  * Warning: given paths should be ended by a directory separator.
  * @param string $appPath  application directory
  * @param string $wwwPath  www directory
  * @param string $varPath  var directory
  * @param string $logPath log directory
  * @param string $configPath config directory
  * @param string $scriptPath scripts directory
  */
 public static function initPaths($appPath, $wwwPath = null, $varPath = null, $logPath = null, $configPath = null, $scriptPath = null)
 {
     self::$appPath = $appPath;
     self::$wwwPath = is_null($wwwPath) ? $appPath . 'www/' : $wwwPath;
     self::$varPath = is_null($varPath) ? $appPath . 'var/' : $varPath;
     self::$logPath = is_null($logPath) ? self::$varPath . 'log/' : $logPath;
     self::$configPath = is_null($configPath) ? self::$varPath . 'config/' : $configPath;
     self::$scriptPath = is_null($scriptPath) ? $appPath . 'scripts/' : $scriptPath;
     self::$_isInit = true;
 }
 /**
  * initialize a full jelix environment with a coordinator, a request object etc.
  *
  * it initializes a coordinator, a classic request object. It sets jApp::coord(),
  * @param string $url the full requested URL (with http://, the domaine name etc.)
  * @param string $config the configuration file to use, as if you were inside an entry point
  * @param string $entryPoint the entrypoint name as indicated into project.xml
  */
 protected static function initClassicRequest($url, $config = 'index/config.ini.php', $entryPoint = 'index.php')
 {
     self::$fakeServer = new jelix\FakeServerConf\ApacheMod(jApp::wwwPath(), '/' . $entryPoint);
     self::$fakeServer->setHttpRequest($url);
     $config = jConfigCompiler::read($config, true, false, '/' . $entryPoint);
     $coord = new jCoordinatorForTest($config, false);
     jApp::setCoord($coord);
     $request = new jClassicRequest();
     $coord->testSetRequest($request);
 }
Exemplo n.º 5
0
 /**
  * initialize the application paths
  *
  * Warning: given paths should be ended by a directory separator.
  * @param string $appPath  application directory
  * @param string $wwwPath  www directory
  * @param string $varPath  var directory
  * @param string $logPath log directory
  * @param string $configPath config directory
  * @param string $scriptPath scripts directory
  */
 public static function initPaths($appPath, $wwwPath = null, $varPath = null, $logPath = null, $configPath = null, $scriptPath = null)
 {
     self::$appPath = $appPath;
     self::$wwwPath = is_null($wwwPath) ? $appPath . 'www/' : $wwwPath;
     self::$varPath = is_null($varPath) ? $appPath . 'var/' : $varPath;
     self::$logPath = is_null($logPath) ? self::$varPath . 'log/' : $logPath;
     self::$configPath = is_null($configPath) ? self::$varPath . 'config/' : $configPath;
     self::$scriptPath = is_null($scriptPath) ? $appPath . 'scripts/' : $scriptPath;
     self::$_isInit = true;
     self::$_coord = null;
     self::$_config = null;
     self::$configAutoloader = null;
     self::$_mainConfigFile = null;
 }
Exemplo n.º 6
0
 protected function _prepareTpl()
 {
     $lang = jApp::config()->locale;
     if (!$this->param('no_lang_check')) {
         $locale = jLocale::getPreferedLocaleFromRequest();
         if (!$locale) {
             $locale = 'en_US';
         }
         jApp::config()->locale = $locale;
     }
     $messages = new \Jelix\Installer\Checker\Messages($lang);
     $reporter = new \Jelix\Installer\Reporter\HtmlBuffer($messages);
     $check = new \Jelix\Installer\Checker\Checker($reporter, $messages);
     $check->run();
     $this->_tpl->assign('wwwpath', jApp::wwwPath());
     $this->_tpl->assign('configpath', jApp::configPath());
     $this->_tpl->assign('check', $reporter->trace);
 }
Exemplo n.º 7
0
 protected function _prepareTpl()
 {
     $lang = jApp::config()->locale;
     if (!$this->getParam('no_lang_check')) {
         $locale = jLocale::getPreferedLocaleFromRequest();
         if (!$locale) {
             $locale = 'en_US';
         }
         jApp::config()->locale = $locale;
     }
     $reporter = new checkZoneInstallReporter();
     $check = new jInstallCheck($reporter, $lang);
     $reporter->messageProvider = $check->messages;
     $check->run();
     $this->_tpl->assign('wwwpath', jApp::wwwPath());
     $this->_tpl->assign('configpath', jApp::configPath());
     $this->_tpl->assign('check', $reporter->trace);
 }
Exemplo n.º 8
0
 function install()
 {
     // configure the entry point
     $entrypoint = $this->getParameter('entrypoint');
     if (!$entrypoint) {
         $entrypoint = 'soap';
     }
     if (!file_exists(jApp::wwwPath($entrypoint . '.php'))) {
         $this->copyFile('files/soap.php', jApp::wwwPath($entrypoint . '.php'));
     }
     // setup the configuration
     if (!file_exists(jApp::appConfigPath($entrypoint . '/config.ini.php'))) {
         $this->copyFile('files/config.ini.php', jApp::appConfigPath($entrypoint . '/config.ini.php'));
     }
     if ($this->entryPoint->getMainConfigIni()->getValue('soap', 'responses') === null) {
         $this->entryPoint->getMainConfigIni()->setValue('soap', "jsoap~jResponseSoap", "responses");
     }
     $this->declareNewEntryPoint($entrypoint, 'soap', $entrypoint . '/config.ini.php');
 }
 function __construct($id)
 {
     $dir = jApp::wwwPath('themes');
     $data = array();
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if ($file != "." && $file != ".." && $file != ".svn" && $file != '.cvs') {
                     if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
                         $data[$file] = $file;
                     }
                 }
             }
             closedir($dh);
         }
     }
     $this->formId = $id;
     $this->data = $data;
 }
 function testGetOmo2()
 {
     $cacheName = 'cache/images/' . md5('imagemodifier/logo_test.pngwidth50height30omo1') . '.png';
     $cacheFile = jApp::wwwPath($cacheName);
     if (file_exists($cacheFile)) {
         unlink($cacheFile);
     }
     $attributes = jImageModifier::get('imagemodifier/logo_test.png', array('width' => 50, 'height' => 30, 'omo' => true));
     $this->assertEqual($GLOBALS['gJCoord']->request->getServerURI() . $GLOBALS['gJConfig']->urlengine['basePath'] . $cacheName, $attributes['src']);
     $this->assertEqual('50', $attributes['width']);
     $this->assertEqual('30', $attributes['height']);
     $this->assertTrue(file_exists($cacheFile));
     $image = imagecreatefrompng($cacheFile);
     $this->assertEqual(50, imagesx($image));
     $this->assertEqual(30, imagesy($image));
     @imagedestroy($image);
     if (file_exists($cacheFile)) {
         unlink($cacheFile);
     }
 }
Exemplo n.º 11
0
 function install()
 {
     if (!$this->firstExec('config')) {
         return;
     }
     $config = $this->entryPoint->getMainConfigIni();
     $plugins = $config->getValue('plugins', 'jResponseHtml');
     if (strpos($plugins, 'minify') === false) {
         $plugins .= ',minify';
         $config->setValue('plugins', $plugins, 'jResponseHtml', null, true);
     }
     if (null == $config->getValue('minifyCSS', 'jResponseHtml', null, true)) {
         $config->setValue('minifyCSS', 'off', 'jResponseHtml', null, true);
     }
     if (null == $config->getValue('minifyJS', 'jResponseHtml', null, true)) {
         $config->setValue('minifyJS', 'on', 'jResponseHtml', null, true);
     }
     if (null == $config->getValue('minifyExcludeCSS', 'jResponseHtml', null, true)) {
         $config->setValue('minifyExcludeCSS', '', 'jResponseHtml', null, true);
     }
     if (null == $config->getValue('minifyExcludeJS', 'jResponseHtml', null, true)) {
         $config->setValue('minifyExcludeJS', 'jelix/wymeditor/jquery.wymeditor.js', 'jResponseHtml', null, true);
     }
     $entrypoint = $config->getValue('minifyEntryPoint', 'jResponseHtml', null, true);
     if ($entrypoint === null) {
         $config->setValue('minifyEntryPoint', 'minify.php', 'jResponseHtml', null, true);
         $entrypoint = 'minify.php';
     }
     if (!file_exists(jApp::wwwPath($entrypoint))) {
         $this->copyFile('files/minify.php', jApp::wwwPath($entrypoint));
     }
     if (!file_exists(jApp::appConfigPath('minifyConfig.php'))) {
         $this->copyFile('files/minifyConfig.php', jApp::appConfigPath('minifyConfig.php'));
     }
     if (!file_exists(jApp::appConfigPath('minifyGroupsConfig.php'))) {
         $this->copyFile('files/minifyGroupsConfig.php', jApp::appConfigPath('minifyGroupsConfig.php'));
     }
 }
Exemplo n.º 12
0
 /**
  * to answer to jcommunity_save_account event
  * @param object $event the given event to answer to
  */
 function onjcommunity_save_account($event)
 {
     $gJConfig = jApp::config();
     $form = $event->getParam('form');
     $form->check();
     if ($form->getData('member_language') != '') {
         $_SESSION['JX_LANG'] = $form->getData('member_language');
         $gJConfig->locale = $form->getData('member_language');
     }
     $ext = '';
     $id = jAuth::getUserSession()->id;
     if ($form->getData('member_avatar') != '') {
         $max_width = $gJConfig->havefnubb['avatar_max_width'];
         $max_height = $gJConfig->havefnubb['avatar_max_height'];
         @unlink(jApp::wwwPath() . 'images/avatars/' . $id . '.png');
         @unlink(jApp::wwwPath() . 'images/avatars/' . $id . '.jpg');
         @unlink(jApp::wwwPath() . 'images/avatars/' . $id . '.jpeg');
         @unlink(jApp::wwwPath() . 'images/avatars/' . $id . '.gif');
         $avatar = $form->getData('member_avatar');
         if (strpos($avatar, '.png') > 0) {
             $ext = '.png';
         } elseif (strpos($avatar, '.jpg') > 0) {
             $ext = '.jpg';
         } elseif (strpos($avatar, '.jpeg') > 0) {
             $ext = '.jpeg';
         } elseif (strpos($avatar, '.gif') > 0) {
             $ext = '.gif';
         }
         $form->saveFile('member_avatar', jApp::wwwPath() . 'hfnu/images/avatars/', $id . $ext);
         list($width, $height) = getimagesize(jApp::wwwPath() . 'hfnu/images/avatars/' . $id . $ext);
         if (empty($width) || empty($height) || $width > $max_width || $height > $max_height) {
             @unlink(jApp::wwwPath() . 'images/avatars/' . $id . $ext);
             jMessage::add(jLocale::get('havefnubb~member.profile.avatar.too.wide', array($max_width . ' x ' . $max_height)), 'error');
             return;
         }
     }
     jMessage::add(jLocale::get('havefnubb~member.profile.updated'), 'ok');
 }
Exemplo n.º 13
0
function getDocumentRoot()
{
    if (isset($_SERVER['DOCUMENT_ROOT'])) {
        return $_SERVER['DOCUMENT_ROOT'];
    }
    require_once JELIX_LIB_PATH . "core/jConfigCompiler.class.php";
    $config = parse_ini_file(jApp::configPath('defaultconfig.ini.php'));
    $urlengine = $config['urlengine'];
    if ($urlengine['scriptNameServerVariable'] == '') {
        $urlengine['scriptNameServerVariable'] = jConfigCompiler::findServerName('.php');
    }
    $urlScript = $_SERVER[$urlengine['scriptNameServerVariable']];
    $lastslash = strrpos($urlScript, '/');
    $urlScriptPath = substr($urlScript, 0, $lastslash) . '/';
    $basepath = $urlengine['basePath'];
    if ($basepath == '') {
        // for beginners or simple site, we "guess" the base path
        $basepath = $urlScriptPath;
    } elseif ($basepath != '/') {
        if ($basepath[0] != '/') {
            $basepath = '/' . $basepath;
        }
        if (substr($basepath, -1) != '/') {
            $basepath .= '/';
        }
        if (strpos($urlScriptPath, $basepath) !== 0) {
            throw new Exception('Jelix Error: basePath (' . $basepath . ') in config file doesn\'t correspond to current base path. You should setup it to ' . $urlengine['urlScriptPath']);
        }
    }
    if ($basepath == '/') {
        return jApp::wwwPath();
    }
    if (strpos(jApp::wwwPath(), $basepath) === false) {
        return jApp::wwwPath();
    }
    return substr(jApp::wwwPath(), 0, -strlen($basepath));
}
Exemplo n.º 14
0
 /**
  * calculate miscelaneous path, depending of the server configuration and other informations
  * in the given array : script path, script name, documentRoot ..
  * @param array $urlconf  urlengine configuration. scriptNameServerVariable, basePath,
  * jelixWWWPath, jqueryPath and entrypointExtension should be present
  */
 public static function getPaths(&$urlconf, $pseudoScriptName = '', $isCli = false)
 {
     // retrieve the script path+name.
     // for cli, it will be the path from the directory were we execute the script (given to the php exec).
     // for web, it is the path from the root of the url
     if ($pseudoScriptName) {
         $urlconf['urlScript'] = $pseudoScriptName;
     } else {
         if ($urlconf['scriptNameServerVariable'] == '') {
             $urlconf['scriptNameServerVariable'] = self::findServerName($urlconf['entrypointExtension'], $isCli);
         }
         $urlconf['urlScript'] = $_SERVER[$urlconf['scriptNameServerVariable']];
     }
     $lastslash = strrpos($urlconf['urlScript'], '/');
     // now we separate the path and the name of the script, and then the basePath
     if ($isCli) {
         if ($lastslash === false) {
             $urlconf['urlScriptPath'] = $pseudoScriptName ? jApp::appPath('/scripts/') : getcwd() . '/';
             $urlconf['urlScriptName'] = $urlconf['urlScript'];
         } else {
             $urlconf['urlScriptPath'] = getcwd() . '/' . substr($urlconf['urlScript'], 0, $lastslash) . '/';
             $urlconf['urlScriptName'] = substr($urlconf['urlScript'], $lastslash + 1);
         }
         $basepath = $urlconf['urlScriptPath'];
         $snp = $urlconf['urlScriptName'];
         $urlconf['urlScript'] = $basepath . $snp;
     } else {
         $urlconf['urlScriptPath'] = substr($urlconf['urlScript'], 0, $lastslash) . '/';
         $urlconf['urlScriptName'] = substr($urlconf['urlScript'], $lastslash + 1);
         $basepath = $urlconf['basePath'];
         if ($basepath == '') {
             // for beginners or simple site, we "guess" the base path
             $basepath = $localBasePath = $urlconf['urlScriptPath'];
         } else {
             if ($basepath != '/') {
                 if ($basepath[0] != '/') {
                     $basepath = '/' . $basepath;
                 }
                 if (substr($basepath, -1) != '/') {
                     $basepath .= '/';
                 }
             }
             if ($pseudoScriptName) {
                 // with pseudoScriptName, we aren't in a true context, we could be in a cli context
                 // (the installer), and we want the path like when we are in a web context.
                 // $pseudoScriptName is supposed to be relative to the basePath
                 $urlconf['urlScriptPath'] = substr($basepath, 0, -1) . $urlconf['urlScriptPath'];
                 $urlconf['urlScript'] = $urlconf['urlScriptPath'] . $urlconf['urlScriptName'];
             }
             $localBasePath = $basepath;
             if ($urlconf['backendBasePath']) {
                 $localBasePath = $urlconf['backendBasePath'];
                 // we have to change urlScriptPath. it may contains the base path of the backend server
                 // we should replace this base path by the basePath of the frontend server
                 if (strpos($urlconf['urlScriptPath'], $urlconf['backendBasePath']) === 0) {
                     $urlconf['urlScriptPath'] = $basepath . substr($urlconf['urlScriptPath'], strlen($urlconf['backendBasePath']));
                 } else {
                     $urlconf['urlScriptPath'] = $basepath . substr($urlconf['urlScriptPath'], 1);
                 }
             } elseif (strpos($urlconf['urlScriptPath'], $basepath) !== 0) {
                 throw new Exception('Jelix Error: basePath (' . $basepath . ') in config file doesn\'t correspond to current base path. You should setup it to ' . $urlconf['urlScriptPath']);
             }
         }
         $urlconf['basePath'] = $basepath;
         if ($urlconf['jelixWWWPath'][0] != '/') {
             $urlconf['jelixWWWPath'] = $basepath . $urlconf['jelixWWWPath'];
         }
         if ($urlconf['jqueryPath'][0] != '/') {
             $urlconf['jqueryPath'] = $basepath . $urlconf['jqueryPath'];
         }
         $snp = substr($urlconf['urlScript'], strlen($localBasePath));
         if ($localBasePath == '/') {
             $urlconf['documentRoot'] = jApp::wwwPath();
         } else {
             if (strpos(jApp::wwwPath(), $localBasePath) === false) {
                 if (isset($_SERVER['DOCUMENT_ROOT'])) {
                     $urlconf['documentRoot'] = $_SERVER['DOCUMENT_ROOT'];
                 } else {
                     $urlconf['documentRoot'] = jApp::wwwPath();
                 }
             } else {
                 $urlconf['documentRoot'] = substr(jApp::wwwPath(), 0, -strlen($localBasePath));
             }
         }
     }
     $pos = strrpos($snp, $urlconf['entrypointExtension']);
     if ($pos !== false) {
         $snp = substr($snp, 0, $pos);
     }
     $urlconf['urlScriptId'] = $snp;
     $urlconf['urlScriptIdenc'] = rawurlencode($snp);
 }
Exemplo n.º 15
0
 public static function getPaths(&$urlconf, $pseudoScriptName = '', $isCli = false)
 {
     if ($pseudoScriptName) {
         $urlconf['urlScript'] = $pseudoScriptName;
     } else {
         if ($urlconf['scriptNameServerVariable'] == '') {
             $urlconf['scriptNameServerVariable'] = self::findServerName($urlconf['entrypointExtension'], $isCli);
         }
         $urlconf['urlScript'] = $_SERVER[$urlconf['scriptNameServerVariable']];
     }
     $lastslash = strrpos($urlconf['urlScript'], '/');
     if ($isCli) {
         if ($lastslash === false) {
             $urlconf['urlScriptPath'] = $pseudoScriptName ? jApp::appPath('/scripts/') : getcwd() . '/';
             $urlconf['urlScriptName'] = $urlconf['urlScript'];
         } else {
             $urlconf['urlScriptPath'] = getcwd() . '/' . substr($urlconf['urlScript'], 0, $lastslash) . '/';
             $urlconf['urlScriptName'] = substr($urlconf['urlScript'], $lastslash + 1);
         }
         $basepath = $urlconf['urlScriptPath'];
         $snp = $urlconf['urlScriptName'];
         $urlconf['urlScript'] = $basepath . $snp;
     } else {
         $urlconf['urlScriptPath'] = substr($urlconf['urlScript'], 0, $lastslash) . '/';
         $urlconf['urlScriptName'] = substr($urlconf['urlScript'], $lastslash + 1);
         $basepath = $urlconf['basePath'];
         if ($basepath == '') {
             $basepath = $localBasePath = $urlconf['urlScriptPath'];
         } else {
             if ($basepath != '/') {
                 if ($basepath[0] != '/') {
                     $basepath = '/' . $basepath;
                 }
                 if (substr($basepath, -1) != '/') {
                     $basepath .= '/';
                 }
             }
             if ($pseudoScriptName) {
                 $urlconf['urlScriptPath'] = substr($basepath, 0, -1) . $urlconf['urlScriptPath'];
                 $urlconf['urlScript'] = $urlconf['urlScriptPath'] . $urlconf['urlScriptName'];
             }
             $localBasePath = $basepath;
             if ($urlconf['backendBasePath']) {
                 $localBasePath = $urlconf['backendBasePath'];
                 if (strpos($urlconf['urlScriptPath'], $urlconf['backendBasePath']) === 0) {
                     $urlconf['urlScriptPath'] = $basepath . substr($urlconf['urlScriptPath'], strlen($urlconf['backendBasePath']));
                 } else {
                     $urlconf['urlScriptPath'] = $basepath . substr($urlconf['urlScriptPath'], 1);
                 }
             } elseif (strpos($urlconf['urlScriptPath'], $basepath) !== 0) {
                 throw new Exception('Error in main configuration on basePath -- basePath (' . $basepath . ') in config file doesn\'t correspond to current base path. You should setup it to ' . $urlconf['urlScriptPath']);
             }
         }
         $urlconf['basePath'] = $basepath;
         if ($urlconf['jelixWWWPath'][0] != '/') {
             $urlconf['jelixWWWPath'] = $basepath . $urlconf['jelixWWWPath'];
         }
         if ($urlconf['jqueryPath'][0] != '/') {
             $urlconf['jqueryPath'] = $basepath . $urlconf['jqueryPath'];
         }
         $snp = substr($urlconf['urlScript'], strlen($localBasePath));
         if ($localBasePath == '/') {
             $urlconf['documentRoot'] = jApp::wwwPath();
         } else {
             if (strpos(jApp::wwwPath(), $localBasePath) === false) {
                 if (isset($_SERVER['DOCUMENT_ROOT'])) {
                     $urlconf['documentRoot'] = $_SERVER['DOCUMENT_ROOT'];
                 } else {
                     $urlconf['documentRoot'] = jApp::wwwPath();
                 }
             } else {
                 $urlconf['documentRoot'] = substr(jApp::wwwPath(), 0, -strlen($localBasePath));
             }
         }
     }
     $pos = strrpos($snp, $urlconf['entrypointExtension']);
     if ($pos !== false) {
         $snp = substr($snp, 0, $pos);
     }
     $urlconf['urlScriptId'] = $snp;
     $urlconf['urlScriptIdenc'] = rawurlencode($snp);
 }
 protected function expandPath($path)
 {
     if (strpos($path, 'www:') === 0) {
         $path = str_replace('www:', jApp::wwwPath(), $path);
     } elseif (strpos($path, 'jelixwww:') === 0) {
         $p = $this->config->getValue('jelixWWWPath', 'urlengine');
         if (substr($p, -1) != '/') {
             $p .= '/';
         }
         $path = str_replace('jelixwww:', jApp::wwwPath($p), $path);
     } elseif (strpos($path, 'config:') === 0) {
         $path = str_replace('config:', jApp::configPath(), $path);
     } elseif (strpos($path, 'epconfig:') === 0) {
         $p = dirname(jApp::configPath($this->entryPoint->configFile));
         $path = str_replace('epconfig:', $p . '/', $path);
     }
     return $path;
 }
Exemplo n.º 17
0
 public static function computeUrlFilePath($config = null)
 {
     $basePath = jApp::config()->urlengine['basePath'];
     if (!$config) {
         $config =& jApp::config()->imagemodifier;
     }
     if ($config['src_url'] && $config['src_path']) {
         $srcUri = $config['src_url'];
         if ($srcUri[0] != '/' && strpos($srcUri, 'http:') !== 0) {
             $srcUri = $basePath . $srcUri;
         }
         $srcPath = str_replace(array('www:', 'app:'), array(jApp::wwwPath(), jApp::appPath()), $config['src_path']);
     } else {
         $srcUri = jApp::coord()->request->getServerURI() . $basePath;
         $srcPath = jApp::wwwPath();
     }
     if ($config['cache_path'] && $config['cache_url']) {
         $cacheUri = $config['cache_url'];
         if ($cacheUri[0] != '/' && strpos($cacheUri, 'http:') !== 0) {
             $cacheUri = $basePath . $cacheUri;
         }
         $cachePath = str_replace(array('www:', 'app:'), array(jApp::wwwPath(), jApp::appPath()), $config['cache_path']);
     } else {
         $cachePath = jApp::wwwPath('cache/images/');
         $cacheUri = jApp::coord()->request->getServerURI() . $basePath . 'cache/images/';
     }
     return array($srcPath, $srcUri, $cachePath, $cacheUri);
 }
Exemplo n.º 18
0
 public function run()
 {
     // retrieve the type of entry point we want to create
     $type = $this->getOption('-type');
     if (!$type) {
         $type = 'classic';
     } else {
         if (!in_array($type, array('classic', 'jsonrpc', 'xmlrpc', 'rdf', 'soap', 'cmdline'))) {
             throw new Exception("invalid type");
         }
     }
     // retrieve the name of the entry point
     $name = $this->getParam('name');
     if (preg_match('/(.*)\\.php$/', $name, $m)) {
         $name = $m[1];
     }
     // the full path of the entry point
     if ($type == 'cmdline') {
         $entryPointFullPath = jApp::scriptsPath($name . '.php');
         $entryPointTemplate = 'scripts/cmdline.php.tpl';
     } else {
         $entryPointFullPath = jApp::wwwPath($name . '.php');
         $entryPointTemplate = 'www/' . ($type == 'classic' ? 'index' : $type) . '.php.tpl';
     }
     if (file_exists($entryPointFullPath)) {
         throw new Exception("the entry point already exists");
     }
     $entryPointDir = dirname($entryPointFullPath) . '/';
     $this->loadProjectXml();
     // retrieve the config file name
     $configFile = $this->getParam('config');
     if ($configFile == null) {
         if ($type == 'cmdline') {
             $configFile = 'cmdline/' . $name . '.ini.php';
         } else {
             $configFile = $name . '/config.ini.php';
         }
     }
     // let's create the config file if needed
     $configFilePath = jApp::configPath($configFile);
     if (!file_exists($configFilePath)) {
         $this->createDir(dirname($configFilePath));
         // the file doesn't exists
         // if there is a -copy-config parameter, we copy this file
         $originalConfig = $this->getOption('-copy-config');
         if ($originalConfig) {
             if (!file_exists(jApp::configPath($originalConfig))) {
                 throw new Exception("unknown original configuration file");
             }
             file_put_contents($configFilePath, file_get_contents(jApp::configPath($originalConfig)));
         } else {
             // else we create a new config file, with the startmodule of the default
             // config as a module name.
             $defaultConfig = parse_ini_file(jApp::configPath('defaultconfig.ini.php'), true);
             $param = array();
             if (isset($defaultConfig['startModule'])) {
                 $param['modulename'] = $defaultConfig['startModule'];
             } else {
                 $param['modulename'] = 'jelix';
             }
             $this->createFile($configFilePath, 'var/config/index/config.ini.php.tpl', $param);
         }
     }
     require_once JELIX_LIB_PATH . 'utils/jIniMultiFilesModifier.class.php';
     $inifile = new jIniMultiFilesModifier(jApp::configPath('defaultconfig.ini.php'), $configFilePath);
     $param = array();
     $param['modulename'] = $inifile->getValue('startModule');
     // creation of the entry point
     $this->createDir($entryPointDir);
     $param['rp_app'] = $this->getRelativePath($entryPointDir, jApp::appPath());
     $param['config_file'] = $configFile;
     $this->createFile($entryPointFullPath, $entryPointTemplate, $param);
     if ($type != 'cmdline') {
         if (null === $inifile->getValue($name, 'simple_urlengine_entrypoints', null, true)) {
             $inifile->setValue($name, '', 'simple_urlengine_entrypoints', null, true);
         }
         if (null === $inifile->getValue($name, 'basic_significant_urlengine_entrypoints', null, true)) {
             $inifile->setValue($name, '1', 'basic_significant_urlengine_entrypoints', null, true);
         }
         $inifile->save();
     }
     $this->updateProjectXml($name . ".php", $configFile, $type);
     require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php';
     $installer = new jInstaller(new textInstallReporter('warning'));
     $installer->installEntryPoint($name . ".php");
 }
 /**
  * compute path from the configuration or from
  * the given array. These paths will be used to read images and to save them
  * into a cache directory.
  * @return array. keys are
  *          src_url, src_path, cache_path, cache_url
  */
 public static function computeUrlFilePath($config = null)
 {
     // paths & uri
     $basePath = jApp::urlBasePath();
     if (!$config) {
         $config =& jApp::config()->imagemodifier;
     }
     // compute URL and file path of the source image
     if ($config['src_url'] && $config['src_path']) {
         $srcUri = $config['src_url'];
         if ($srcUri[0] != '/' && strpos($srcUri, 'http:') !== 0) {
             $srcUri = $basePath . $srcUri;
         }
         $srcPath = jFile::parseJelixPath($config['src_path']);
     } else {
         $srcUri = jApp::coord()->request->getServerURI() . $basePath;
         $srcPath = jApp::wwwPath();
     }
     if ($config['cache_path'] && $config['cache_url']) {
         $cacheUri = $config['cache_url'];
         if ($cacheUri[0] != '/' && strpos($cacheUri, 'http:') !== 0) {
             $cacheUri = $basePath . $cacheUri;
         }
         $cachePath = jFile::parseJelixPath($config['cache_path']);
     } else {
         $cachePath = jApp::wwwPath('cache/images/');
         $cacheUri = jApp::coord()->request->getServerURI() . $basePath . 'cache/images/';
     }
     return array($srcPath, $srcUri, $cachePath, $cacheUri);
 }
Exemplo n.º 20
0
 function checkAppPaths()
 {
     $ok = true;
     if (!defined('JELIX_LIB_PATH') || !jApp::isInit()) {
         throw new Exception($this->messages->get('path.core'));
     }
     if (!file_exists(jApp::tempBasePath()) || !is_writable(jApp::tempBasePath())) {
         $this->error('path.temp');
         $ok = false;
     }
     if (!file_exists(jApp::logPath()) || !is_writable(jApp::logPath())) {
         $this->error('path.log');
         $ok = false;
     }
     if (!file_exists(jApp::varPath())) {
         $this->error('path.var');
         $ok = false;
     }
     if (!file_exists(jApp::configPath())) {
         $this->error('path.config');
         $ok = false;
     } elseif ($this->checkForInstallation) {
         if (!is_writable(jApp::configPath())) {
             $this->error('path.config.writable');
             $ok = false;
         }
         if (file_exists(jApp::configPath('profiles.ini.php')) && !is_writable(jApp::configPath('profiles.ini.php'))) {
             $this->error('path.profiles.writable');
             $ok = false;
         }
         if (file_exists(jApp::configPath('defaultconfig.ini.php')) && !is_writable(jApp::configPath('defaultconfig.ini.php'))) {
             $this->error('path.defaultconfig.writable');
             $ok = false;
         }
         if (file_exists(jApp::configPath('installer.ini.php')) && !is_writable(jApp::configPath('installer.ini.php'))) {
             $this->error('path.installer.writable');
             $ok = false;
         }
     }
     if (!file_exists(jApp::wwwPath())) {
         $this->error('path.www');
         $ok = false;
     }
     foreach ($this->otherPaths as $path) {
         $realPath = str_replace(array('app:', 'lib:', 'var:', 'www:'), array(jApp::appPath(), LIB_PATH, jApp::varPath(), jApp::wwwPath()), $path);
         if (!file_exists($realPath)) {
             $this->error('path.custom.not.exists', array($path));
             $ok = false;
         } else {
             if (!is_writable($realPath)) {
                 $this->error('path.custom.writable', array($path));
                 $ok = false;
             } else {
                 $this->ok('path.custom.ok', array($path));
             }
         }
     }
     if ($ok) {
         $this->ok('paths.ok');
     } else {
         throw new Exception($this->messages->get('too.critical.error'));
     }
     return $ok;
 }
Exemplo n.º 21
0
 public function run()
 {
     require_once LIB_PATH . 'clearbricks/jelix.inc.php';
     require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php';
     $appPath = $this->getParam('path');
     $appPath = $this->getRealPath($appPath);
     $appName = basename($appPath);
     $appPath .= '/';
     if (file_exists($appPath)) {
         throw new Exception("this application is already created");
     }
     $this->config = JelixScript::loadConfig($appName);
     $this->config->infoIDSuffix = $this->config->newAppInfoIDSuffix;
     $this->config->infoWebsite = $this->config->newAppInfoWebsite;
     $this->config->infoLicence = $this->config->newAppInfoLicence;
     $this->config->infoLicenceUrl = $this->config->newAppInfoLicenceUrl;
     $this->config->infoLocale = $this->config->newAppInfoLocale;
     $this->config->infoCopyright = $this->config->newAppInfoCopyright;
     $this->config->initAppPaths($appPath);
     jApp::setEnv('jelix-scripts');
     jApp::initLegacy();
     JelixScript::checkTempPath();
     if ($p = $this->getOption('-wwwpath')) {
         $wwwpath = path::real($appPath . $p, false) . '/';
     } else {
         $wwwpath = jApp::wwwPath();
     }
     $this->createDir($appPath);
     $this->createDir(jApp::tempBasePath());
     $this->createDir($wwwpath);
     $varPath = jApp::varPath();
     $configPath = jApp::configPath();
     $this->createDir($varPath);
     $this->createDir(jApp::logPath());
     $this->createDir($configPath);
     $this->createDir($configPath . 'index/');
     $this->createDir($varPath . 'overloads/');
     $this->createDir($varPath . 'themes/');
     $this->createDir($varPath . 'themes/default/');
     $this->createDir($varPath . 'uploads/');
     $this->createDir($varPath . 'sessions/');
     $this->createDir($varPath . 'mails/');
     $this->createDir($appPath . 'install');
     $this->createDir($appPath . 'modules');
     $this->createDir($appPath . 'plugins');
     $this->createDir($appPath . 'plugins/coord/');
     $this->createDir($appPath . 'plugins/tpl/');
     $this->createDir($appPath . 'plugins/tpl/common');
     $this->createDir($appPath . 'plugins/tpl/html');
     $this->createDir($appPath . 'plugins/tpl/text');
     $this->createDir($appPath . 'plugins/db/');
     $this->createDir($appPath . 'plugins/auth/');
     $this->createDir($appPath . 'responses');
     $this->createDir($appPath . 'tests');
     $this->createDir(jApp::scriptsPath());
     $param = array();
     $param['default_id'] = $appName . $this->config->infoIDSuffix;
     if ($this->getOption('-nodefaultmodule')) {
         $param['tplname'] = 'jelix~defaultmain';
         $param['modulename'] = 'jelix';
     } else {
         // note: since module name are used for name of generated name,
         // only this characters are allowed
         $param['modulename'] = preg_replace('/([^a-zA-Z_0-9])/', '_', $appName);
         $param['tplname'] = $param['modulename'] . '~main';
     }
     $param['config_file'] = 'index/config.ini.php';
     $param['rp_temp'] = $this->getRelativePath($appPath, jApp::tempBasePath());
     $param['rp_var'] = $this->getRelativePath($appPath, jApp::varPath());
     $param['rp_log'] = $this->getRelativePath($appPath, jApp::logPath());
     $param['rp_conf'] = $this->getRelativePath($appPath, $configPath);
     $param['rp_www'] = $this->getRelativePath($appPath, $wwwpath);
     $param['rp_cmd'] = $this->getRelativePath($appPath, jApp::scriptsPath());
     $param['rp_jelix'] = $this->getRelativePath($appPath, JELIX_LIB_PATH);
     $param['rp_app'] = $this->getRelativePath($wwwpath, $appPath);
     $this->createFile(jApp::logPath() . '.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::varPath() . 'mails/.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::varPath() . 'sessions/.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::varPath() . 'overloads/.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::varPath() . 'themes/default/.dummy', 'dummy.tpl', array());
     $this->createFile($appPath . 'plugins/.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::scriptsPath() . '.dummy', 'dummy.tpl', array());
     $this->createFile(jApp::tempBasePath() . '.dummy', 'dummy.tpl', array());
     $this->createFile($appPath . '.htaccess', 'htaccess_deny', $param, "Configuration file for Apache");
     $this->createFile($appPath . 'project.xml', 'project.xml.tpl', $param, "Project description file");
     $this->createFile($appPath . 'cmd.php', 'cmd.php.tpl', $param, "Script for developer commands");
     $this->createFile($configPath . 'defaultconfig.ini.php', 'var/config/defaultconfig.ini.php.tpl', $param, "Main configuration file");
     $this->createFile($configPath . 'defaultconfig.ini.php.dist', 'var/config/defaultconfig.ini.php.tpl', $param, "Main configuration file for your repository");
     $this->createFile($configPath . 'profiles.ini.php', 'var/config/profiles.ini.php.tpl', $param, "Profiles file");
     $this->createFile($configPath . 'profiles.ini.php.dist', 'var/config/profiles.ini.php.tpl', $param, "Profiles file for your repository");
     $this->createFile($configPath . 'preferences.ini.php', 'var/config/preferences.ini.php.tpl', $param, "Preferences file");
     $this->createFile($configPath . 'urls.xml', 'var/config/urls.xml.tpl', $param, "URLs mapping file");
     //$this->createFile(JELIX_APP_CONFIG_PATH.'installer.ini.php', 'var/config/installer.ini.php.tpl', $param);
     $this->createFile($configPath . 'index/config.ini.php', 'var/config/index/config.ini.php.tpl', $param, "Entry point configuration file");
     $this->createFile($appPath . 'responses/myHtmlResponse.class.php', 'responses/myHtmlResponse.class.php.tpl', $param, "Main response class");
     $this->createFile($appPath . 'install/installer.php', 'installer/installer.php.tpl', $param, "Installer script");
     $this->createFile($appPath . 'tests/runtests.php', 'tests/runtests.php', $param, "Tests script");
     $temp = dirname(jApp::tempBasePath());
     if (file_exists($temp . '/.gitignore')) {
         $gitignore = file_get_contents($temp . '/.gitignore') . "\n" . $appName . "/*\n";
         file_put_contents($temp . '/.gitignore', $gitignore);
     } else {
         file_put_contents($temp . '/.gitignore', $appName . "/*\n");
     }
     $this->createFile($wwwpath . 'index.php', 'www/index.php.tpl', $param, "Main entry point");
     $this->createFile($wwwpath . '.htaccess', 'htaccess_allow', $param, "Configuration file for Apache");
     $param['php_rp_temp'] = $this->convertRp($param['rp_temp']);
     $param['php_rp_var'] = $this->convertRp($param['rp_var']);
     $param['php_rp_log'] = $this->convertRp($param['rp_log']);
     $param['php_rp_conf'] = $this->convertRp($param['rp_conf']);
     $param['php_rp_www'] = $this->convertRp($param['rp_www']);
     $param['php_rp_cmd'] = $this->convertRp($param['rp_cmd']);
     $param['php_rp_jelix'] = $this->convertRp($param['rp_jelix']);
     $this->createFile($appPath . 'application.init.php', 'application.init.php.tpl', $param, "Bootstrap file");
     $installer = new jInstaller(new textInstallReporter('warning'));
     $installer->installApplication();
     $moduleok = true;
     if (!$this->getOption('-nodefaultmodule')) {
         try {
             $cmd = JelixScript::getCommand('createmodule', $this->config);
             $options = $this->getCommonActiveOption();
             $options['-addinstallzone'] = true;
             $cmd->initOptParam($options, array('module' => $param['modulename']));
             $cmd->run();
             $this->createFile($appPath . 'modules/' . $param['modulename'] . '/templates/main.tpl', 'module/main.tpl.tpl', $param, "Main template");
         } catch (Exception $e) {
             $moduleok = false;
             echo "The module has not been created because of this error: " . $e->getMessage() . "\nHowever the application has been created\n";
         }
     }
     if ($this->getOption('-withcmdline')) {
         if (!$this->getOption('-nodefaultmodule') && $moduleok) {
             $agcommand = JelixScript::getCommand('createctrl', $this->config);
             $options = $this->getCommonActiveOption();
             $options['-cmdline'] = true;
             $agcommand->initOptParam($options, array('module' => $param['modulename'], 'name' => 'default', 'method' => 'index'));
             $agcommand->run();
         }
         $agcommand = JelixScript::getCommand('createentrypoint', $this->config);
         $options = $this->getCommonActiveOption();
         $options['-type'] = 'cmdline';
         $parameters = array('name' => $param['modulename']);
         $agcommand->initOptParam($options, $parameters);
         $agcommand->run();
     }
 }
Exemplo n.º 22
0
 /**
  * compute path from the configuration or from
  * the given array. These paths will be used to read images and to save them
  * into a cache directory.
  * @return array. keys are
  *          src_url, src_path, cache_path, cache_url
  */
 public static function computeUrlFilePath($config = null)
 {
     // paths & uri
     global $gJConfig;
     $basePath = $gJConfig->urlengine['basePath'];
     if (!$config) {
         $config =& $gJConfig->imagemodifier;
     }
     // compute URL and file path of the source image
     if ($config['src_url'] && $config['src_path']) {
         $srcUri = $config['src_url'];
         if ($srcUri[0] != '/' && strpos($srcUri, 'http:') !== 0) {
             $srcUri = $basePath . $srcUri;
         }
         $srcPath = str_replace(array('www:', 'app:'), array(jApp::wwwPath(), jApp::appPath()), $config['src_path']);
     } else {
         $srcUri = $GLOBALS['gJCoord']->request->getServerURI() . $basePath;
         $srcPath = jApp::wwwPath();
     }
     if ($config['cache_path'] && $config['cache_url']) {
         $cacheUri = $config['cache_url'];
         if ($cacheUri[0] != '/' && strpos($cacheUri, 'http:') !== 0) {
             $cacheUri = $basePath . $cacheUri;
         }
         $cachePath = str_replace(array('www:', 'app:'), array(jApp::wwwPath(), jApp::appPath()), $config['cache_path']);
     } else {
         $cachePath = jApp::wwwPath('cache/images/');
         $cacheUri = $GLOBALS['gJCoord']->request->getServerURI() . $basePath . 'cache/images/';
     }
     return array($srcPath, $srcUri, $cachePath, $cacheUri);
 }
 function checkAppPaths()
 {
     $ok = true;
     if (!defined('JELIX_LIB_PATH') || !jApp::isInit()) {
         throw new Exception($this->messages->get('path.core'));
     }
     if (!file_exists(jApp::tempBasePath()) || !is_writable(jApp::tempBasePath())) {
         $this->error('path.temp');
         $ok = false;
     }
     if (!file_exists(jApp::logPath()) || !is_writable(jApp::logPath())) {
         $this->error('path.log');
         $ok = false;
     }
     if (!file_exists(jApp::varPath())) {
         $this->error('path.var');
         $ok = false;
     }
     if (!file_exists(jApp::configPath())) {
         $this->error('path.config');
         $ok = false;
     } elseif ($this->checkForInstallation) {
         if (!is_writable(jApp::configPath())) {
             $this->error('path.config.writable');
             $ok = false;
         }
         if (file_exists(jApp::configPath('profiles.ini.php')) && !is_writable(jApp::configPath('profiles.ini.php'))) {
             $this->error('path.profiles.writable');
             $ok = false;
         }
         if (file_exists(jApp::mainConfigFile()) && !is_writable(jApp::mainConfigFile())) {
             $this->error('path.mainconfig.writable');
             $ok = false;
         } elseif (file_exists(jApp::configPath('defaultconfig.ini.php')) && !is_writable(jApp::configPath('defaultconfig.ini.php'))) {
             $this->error('path.mainconfig.writable');
             $ok = false;
         }
         if (file_exists(jApp::configPath('installer.ini.php')) && !is_writable(jApp::configPath('installer.ini.php'))) {
             $this->error('path.installer.writable');
             $ok = false;
         }
     }
     if (!file_exists(jApp::wwwPath())) {
         $this->error('path.www');
         $ok = false;
     }
     foreach ($this->otherPaths as $path) {
         $realPath = jFile::parseJelixPath($path);
         if (!file_exists($realPath)) {
             $this->error('path.custom.not.exists', array($path));
             $ok = false;
         } else {
             if (!is_writable($realPath)) {
                 $this->error('path.custom.writable', array($path));
                 $ok = false;
             } else {
                 $this->ok('path.custom.ok', array($path));
             }
         }
     }
     if ($ok) {
         $this->ok('paths.ok');
     } else {
         throw new Exception($this->messages->get('too.critical.error'));
     }
     /*if(!isset($GLOBALS['config_file']) ||
          empty($GLOBALS['config_file']) ||
          !file_exists(jApp::configPath($GLOBALS['config_file']))){
           throw new Exception($this->messages->get('config.file'));
       }*/
     return $ok;
 }
Exemplo n.º 24
0
 /**
  *
  */
 function seeding()
 {
     $fakeServer = new jelix\FakeServerConf\ApacheMod(jApp::wwwPath(), '/index.php');
     $forced = $this->option('-f');
     $verbose = $this->option('-v');
     $rep = $this->getResponse();
     // cmdline response by default
     $project = null;
     try {
         $project = lizmap::getProject($this->param('repository') . '~' . $this->param('project'));
         // Project not found
         if (!$project) {
             $rep->addContent("The project has not be found!\n");
             return $rep;
         }
     } catch (UnknownLizmapProjectException $e) {
         $rep->addContent("The project has not be found!\n");
         return $rep;
     }
     $repository = $project->getRepository();
     $cacheId = $repository->getKey() . '_' . $project->getKey() . '_WMTS';
     $tileMatrixSetList = jCache::get($cacheId . '_tileMatrixSetList');
     if (!$tileMatrixSetList) {
         $request = new lizmapWMTSRequest($project, array('service' => 'WMTS', 'request' => 'GetCapabilities'));
         $result = $request->process();
         $tileMatrixSetList = jCache::get($cacheId . '_tileMatrixSetList');
     }
     $layers = $tileMatrixSetList = jCache::get($cacheId . '_layers');
     $layerIds = explode(',', $this->param('layers'));
     $selectedLayers = array();
     foreach ($layers as $l) {
         if (in_array('*', $layerIds) || in_array($l->name, $layerIds)) {
             $selectedLayers[] = $l;
         }
     }
     // Layer not found
     if (count($selectedLayers) == 0) {
         $rep->addContent("The layers '" . implode(',', $layerIds) . "' have not be found!\n");
         return $rep;
     }
     foreach ($selectedLayers as $layer) {
         $TileMatrixSetId = $this->param('TileMatrixSet');
         $tileMatrixSetLink = null;
         foreach ($layer->tileMatrixSetLinkList as $tms) {
             if ($tms->ref == $TileMatrixSetId) {
                 $tileMatrixSetLink = $tms;
                 break;
             }
         }
         // TileMatrixSet not found
         if (!$tileMatrixSetLink) {
             $rep->addContent("The TileMatrixSet '" . $TileMatrixSetId . "' has not be found!\n");
             continue;
         }
         $TileMatrixMin = (int) $this->param('TileMatrixMin');
         $TileMatrixMax = (int) $this->param('TileMatrixMax');
         // count tiles
         $tileCount = 0;
         foreach ($tileMatrixSetLink->tileMatrixLimits as $tileMatrixLimit) {
             if ($tileMatrixLimit->id >= $TileMatrixMin && $tileMatrixLimit->id <= $TileMatrixMax) {
                 $tmCount = ($tileMatrixLimit->maxRow - $tileMatrixLimit->minRow + 1) * ($tileMatrixLimit->maxCol - $tileMatrixLimit->minCol + 1);
                 if ($verbose) {
                     $rep->addContent($tmCount . ' tiles to generate for "' . $layer->name . '" "' . $TileMatrixSetId . '" "' . $tileMatrixLimit->id . '"' . "\n");
                 }
                 $tileCount += $tmCount;
             }
         }
         if ($verbose) {
             $rep->addContent($tileCount . ' tiles to generate for "' . $layer->name . '" "' . $TileMatrixSetId . '" between "' . $TileMatrixMin . '" and "' . $TileMatrixMax . '"' . "\n");
         }
         // generate tiles
         $rep->addContent("Start generation\n");
         $rep->addContent("================\n");
         $tileProgress = 0;
         $tileStepHeight = max(5.0, floor(5 * 100 / $tileCount));
         $tileStep = $tileStepHeight;
         foreach ($tileMatrixSetLink->tileMatrixLimits as $tileMatrixLimit) {
             if ($tileMatrixLimit->id >= $TileMatrixMin && $tileMatrixLimit->id <= $TileMatrixMax) {
                 $row = (int) $tileMatrixLimit->minRow;
                 //$rep->addContent( $tileMatrixLimit->id.' '.$tileMatrixLimit->minRow.' '.$tileMatrixLimit->maxRow.' '.$tileMatrixLimit->minCol.' '.$tileMatrixLimit->maxCol."\n");
                 while ($row <= $tileMatrixLimit->maxRow) {
                     $col = (int) $tileMatrixLimit->minCol;
                     while ($col <= $tileMatrixLimit->maxCol) {
                         $request = new lizmapWMTSRequest($project, array('service' => 'WMTS', 'version' => '1.0.0', 'request' => 'GetTile', 'layer' => $layer->name, 'format' => $layer->imageFormat, 'TileMatrixSet' => $TileMatrixSetId, 'TileMatrix' => $tileMatrixLimit->id, 'TileRow' => $row, 'TileCol' => $col));
                         if ($forced) {
                             $request->setForceRequest(True);
                         }
                         $result = $request->process();
                         //$rep->addContent($layer->name.' '.$layer->imageFormat.' '.$TileMatrixSetId.' '.$tileMatrixLimit->id.' '.$row.' '.$col.' '.$result->code."\n");
                         $col += 1;
                         $tileProgress += 1;
                         if ($verbose && $tileProgress * 100 / $tileCount >= $tileStep) {
                             $tileStep = floor($tileProgress * 100 / $tileCount);
                             $rep->addContent('Progression: ' . $tileStep . '%, ' . $tileProgress . ' tiles generated on ' . $tileCount . ' tiles' . "\n");
                             $tileStep = $tileStep + $tileStepHeight;
                         }
                     }
                     $row += 1;
                 }
             }
         }
         $rep->addContent("================\n");
         $rep->addContent("End generation\n");
     }
     return $rep;
 }
Exemplo n.º 25
0
 /**
  * Get default Lizmap theme as a ZIP file.
  *
  * @return Zip file containing the default theme
  */
 function getDefaultTheme()
 {
     $rep = $this->getResponse('zip');
     $rep->zipFilename = 'lizmapWebClient_default_theme.zip';
     $rep->content->addDir(jApp::wwwPath() . '/themes/default/', 'default', true);
     return $rep;
 }
Exemplo n.º 26
0
 /**
  * replace a path with Jelix shortcuts parts (var:, temp:, www: app:, lib:)
  *
  * @param string $path the system valid path
  * @param string $beforeShortcut a string to be output before the Jelix shortcut
  * @param string $afterShortcut a string to be output after the Jelix shortcut
  * @return string the path with Jelix shortcuts parts
  */
 public static function unparseJelixPath($path, $beforeShortcut = '', $afterShortcut = '')
 {
     $shortcutPath = '';
     $shortcut = '';
     if (strpos($path, LIB_PATH) === 0) {
         $shortcutPath = LIB_PATH;
         $shortcut = 'lib:';
     } elseif (strpos($path, jApp::tempPath()) === 0) {
         $shortcutPath = jApp::tempPath();
         $shortcut = 'temp:';
     } elseif (strpos($path, jApp::wwwPath()) === 0) {
         $shortcutPath = jApp::wwwPath();
         $shortcut = 'www:';
     } elseif (strpos($path, jApp::varPath()) === 0) {
         $shortcutPath = jApp::varPath();
         $shortcut = 'var:';
     } elseif (strpos($path, jApp::appPath()) === 0) {
         $shortcutPath = jApp::appPath();
         $shortcut = 'app:';
     } else {
         $shortcutPath = dirname(jApp::appPath());
         $shortcut = 'app:';
         while ($shortcutPath != '.' && $shortcutPath != '') {
             $shortcut .= '../';
             if (strpos($path, $shortcutPath) === 0) {
                 break;
             }
             $shortcutPath = dirname($shortcutPath);
         }
         if ($shortcutPath == '.') {
             $shortcutPath = '';
         }
     }
     if ($shortcutPath != '') {
         $cut = $shortcutPath[0] == '/' ? 0 : 1;
         $path = $beforeShortcut . $shortcut . $afterShortcut . substr($path, strlen($path) + $cut);
     }
     return $path;
 }
Exemplo n.º 27
0
 protected function _prepareTpl()
 {
     $lang = $GLOBALS['gJConfig']->locale;
     if (!$this->getParam('no_lang_check')) {
         $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         foreach ($languages as $bl) {
             if (preg_match("/^([a-zA-Z]{2})(?:[-_]([a-zA-Z]{2}))?(;q=[0-9]\\.[0-9])?\$/", $bl, $match)) {
                 if (isset($match[2])) {
                     $lang = strtolower($match[1]) . '_' . strtoupper($match[2]);
                 } else {
                     $lang = strtolower($match[1]) . '_' . strtoupper($match[1]);
                 }
                 break;
             }
         }
         if ($lang != 'fr_FR' && $lang != 'en_EN' && $lang != 'en_US') {
             $lang = 'en_EN';
         }
         $GLOBALS['gJConfig']->locale = $lang;
     }
     $reporter = new checkZoneInstallReporter();
     $check = new jInstallCheck($reporter, $lang);
     $reporter->messageProvider = $check->messages;
     $check->run();
     $this->_tpl->assign('wwwpath', jApp::wwwPath());
     $this->_tpl->assign('configpath', jApp::configPath());
     $this->_tpl->assign('check', $reporter->trace);
 }