Example #1
0
 /**
  * @param  array  $params   plugin parameters for the current action
  * @return null or jSelectorAct  if action should change
  */
 public function beforeAction($params)
 {
     $selector = null;
     $aclok = true;
     if (isset($params['jacl.right'])) {
         $aclok = jAcl::check($params['jacl.right'][0], $params['jacl.right'][1]);
     } elseif (isset($params['jacl.rights.and'])) {
         $aclok = true;
         foreach ($params['jacl.rights.and'] as $right) {
             if (!jAcl::check($right[0], $right[1])) {
                 $aclok = false;
                 break;
             }
         }
     } elseif (isset($params['jacl.rights.or'])) {
         $aclok = false;
         foreach ($params['jacl.rights.or'] as $right) {
             if (jAcl::check($right[0], $right[1])) {
                 $aclok = true;
                 break;
             }
         }
     }
     if (!$aclok) {
         if (jApp::coord()->request->isAjax() || $this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) {
             throw new jException($this->config['error_message']);
         } else {
             $selector = new jSelectorAct($this->config['on_error_action']);
         }
     }
     return $selector;
 }
/**
 * @package     jelix
 * @subpackage  jtpl_plugin
 * @author      Lepeltier kévin
 * @contributor Dominique Papin
 * @copyright   2008 Lepeltier kévin, 2008 Dominique Papin
 * @link        http://www.jelix.org
 * @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
 */
function jtpl_function_html_breadcrumb($tpl, $nb = null, $separator = '')
{
    $plugin = jApp::coord()->getPlugin('history', true);
    if ($plugin === null) {
        return;
    }
    $config =& $plugin->config;
    if (!isset($config['session_name']) || $config['session_name'] == '') {
        $config['session_name'] = 'HISTORY';
    }
    if (!isset($_SESSION[$config['session_name']])) {
        return;
    }
    echo '<ol class="history">';
    $leng = count($_SESSION[$config['session_name']]);
    $nb = $nb !== null ? count($_SESSION[$config['session_name']]) - $nb : 0;
    $nb = $nb < 0 ? 0 : $nb;
    for ($i = $nb; $i < $leng; $i++) {
        $page = $_SESSION[$config['session_name']][$i];
        echo '<li' . ($i == $nb ? ' class="first"' : ($i == $leng - 1 ? ' class="end"' : '')) . '>';
        if ($i != $leng - 1) {
            echo '<a href="' . jUrl::get($page['action'], $page['params'], jUrl::XMLSTRING) . '" ' . ($page['title'] != '' ? 'title="' . $page['title'] . '"' : '') . '>';
        }
        echo $_SESSION[$config['session_name']][$i]['label'];
        if ($i != $leng - 1) {
            echo '</a>';
        }
        echo ($i == $leng - 1 ? '' : $separator) . '</li>';
    }
    echo '</ol>';
}
 /**
  * Displays a list of project for a given repository.
  *
  * @param string $repository. Name of the repository.
  * @return Html page with a list of projects.
  */
 function index()
 {
     if ($this->param('theme')) {
         jApp::config()->theme = $this->param('theme');
     }
     $rep = $this->getResponse('html');
     // Get lizmap services
     $services = lizmap::getServices();
     // only maps
     if ($services->onlyMaps) {
         $repository = lizmap::getRepository($services->defaultRepository);
         if ($repository && jAcl2::check('lizmap.repositories.view', $repository->getKey())) {
             $project = lizmap::getProject($repository->getKey() . '~' . $services->defaultProject);
             if ($project) {
                 // test redirection to an other controller
                 $items = jEvent::notify('mainviewGetMaps')->getResponse();
                 foreach ($items as $item) {
                     if ($item->parentId == $repository->getKey() && $item->id == $services->defaultProject) {
                         $rep = $this->getResponse('redirectUrl');
                         $rep->url = $item->url;
                         return $rep;
                     }
                 }
                 // redirection to default controller
                 $rep = $this->getResponse('redirect');
                 $rep->action = 'view~map:index';
                 return $rep;
             }
         }
     }
     // Get repository data
     $repository = $this->param('repository');
     $repositoryList = array();
     if ($repository) {
         if (!jAcl2::check('lizmap.repositories.view', $repository)) {
             $rep = $this->getResponse('redirect');
             $rep->action = 'view~default:index';
             jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error');
             return $rep;
         }
     }
     $title = jLocale::get("view~default.repository.list.title");
     $rep->body->assign('repositoryLabel', $title);
     $rep->body->assign('isConnected', jAuth::isConnected());
     $rep->body->assign('user', jAuth::getUserSession());
     if ($services->allowUserAccountRequests) {
         $rep->body->assign('allowUserAccountRequests', True);
     }
     if ($repository) {
         $lrep = lizmap::getRepository($repository);
         $title .= ' - ' . $lrep->getData('label');
     }
     $rep->title = $title;
     $rep->body->assignZone('MAIN', 'main_view', array('repository' => $repository));
     $rep->addJSCode("\n      \$(window).load(function() {\n        \$('.liz-project-img').parent().mouseenter(function(){\n          var self = \$(this);\n          self.find('.liz-project-desc').slideDown();\n          self.css('cursor','pointer');\n        }).mouseleave(function(){\n          var self = \$(this);\n          self.find('.liz-project-desc').hide();\n        }).click(function(){\n          var self = \$(this);\n          window.location = self.parent().find('a.liz-project-view').attr('href');\n          return false;\n        });\n      });\n      ");
     // Js hack to normalize the height of the project thumbnails to avoid line breaks with long project titles
     $bp = jApp::config()->urlengine['basePath'];
     $rep->addJSLink($bp . 'js/view.js');
     return $rep;
 }
 protected function _initParams()
 {
     $argv = $_SERVER['argv'];
     $scriptName = array_shift($argv);
     $mod = jApp::config()->startModule;
     $act = jApp::config()->startAction;
     if ($this->onlyDefaultAction) {
         if ($_SERVER['argc'] > 1 && $argv[0] == 'help') {
             $argv[0] = $mod . '~' . $act;
             $mod = 'jelix';
             $act = 'help:index';
         }
     } else {
         if ($_SERVER['argc'] != 1) {
             $argsel = array_shift($argv);
             if ($argsel == 'help') {
                 $mod = 'jelix';
                 $act = 'help:index';
             } else {
                 if (($pos = strpos($argsel, '~')) !== false) {
                     $mod = substr($argsel, 0, $pos);
                     $act = substr($argsel, $pos + 1);
                 } else {
                     $act = $argsel;
                 }
             }
         }
     }
     $this->params = $argv;
     $this->params['module'] = $mod;
     $this->params['action'] = $act;
 }
Example #5
0
 /**
  * @param jILogMessage $message the message to log
  */
 function logMessage($message)
 {
     global $gJConfig, $gJCoord;
     if (!is_writable(jApp::logPath())) {
         return;
     }
     $type = $message->getCategory();
     if ($gJCoord && $gJCoord->request) {
         $conf =& $gJConfig->fileLogger;
         if (!isset($conf[$type])) {
             return;
         }
         $f = $conf[$type];
         $ip = $gJCoord->request->getIP();
         $f = str_replace('%ip%', $ip, $f);
         $f = str_replace('%m%', date("m"), $f);
         $f = str_replace('%Y%', date("Y"), $f);
         $f = str_replace('%d%', date("d"), $f);
         $f = str_replace('%H%', date("H"), $f);
     } else {
         // if there isn't a request, so jLog is called for an error during the construction
         // of the coordinator
         $f = 'errors.log';
         $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     }
     try {
         $sel = new jSelectorLog($f);
         $file = $sel->getPath();
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\t{$type}\t" . $message->getFormatedMessage() . "\n", 3, $file);
     } catch (Exception $e) {
         $file = jApp::logPath('errors.log');
         @error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\terror\t" . $e->getMessage() . "\n", 3, $file);
     }
 }
 /**
  * Get JSON containing all translation for a given jelix property file.
  * @param string $property Name of the property file. Ex: map if searched file is map.UTF-8.properties
  * @param string $lang Language. Ex: fr_FR (optional)
  * @return binary object The image for this project.
  */
 function getDictionary()
 {
     $rep = $this->getResponse('json');
     // Get the property file
     $property = $this->param('property');
     $lang = $this->param('lang');
     if (!$lang) {
         $lang = jLocale::getCurrentLang() . '_' . jLocale::getCurrentCountry();
     }
     $data = array();
     $path = jApp::appPath() . 'modules/view/locales/' . $lang . '/' . $property . '.UTF-8.properties';
     if (file_exists($path)) {
         $lines = file($path);
         foreach ($lines as $lineNumber => $lineContent) {
             if (!empty($lineContent) and $lineContent != '\\n') {
                 $exp = explode('=', trim($lineContent));
                 if (!empty($exp[0])) {
                     $data[$exp[0]] = jLocale::get('view~dictionnary.' . $exp[0], null, $lang);
                 }
             }
         }
     }
     $rep->data = $data;
     return $rep;
 }
 /**
  * get the menus to be added inside the ohers menu item
  * @return $menus array of menus
  */
 public function getMenus()
 {
     $menus = array();
     if (file_exists(jApp::configPath() . '/havefnubb/hfnumenus.xml')) {
         $doc = new DOMDocument();
         $doc->load(realpath(jApp::configPath()) . '/havefnubb/hfnumenus.xml');
         $xpath = new DOMXPath($doc);
         $query = '/menus/menu';
         $entries = $xpath->query($query);
         $gJConfig = jApp::config();
         foreach ($entries as $idx => $menu) {
             $queryName = '//name[@lang="' . $gJConfig->locale . '"]';
             $items = $xpath->query($queryName);
             $name = $items->item($idx)->nodeValue;
             $queryItemName = '//menu/itemName';
             $items = $xpath->query($queryItemName);
             $itemName = $items->item($idx)->nodeValue;
             $queryUrl = '//menu/url';
             $items = $xpath->query($queryUrl);
             $url = $items->item($idx)->nodeValue;
             $queryOrder = '//menu/order';
             $items = $xpath->query($queryOrder);
             $order = $items->item($idx)->nodeValue;
             $menus[] = array('itemName' => $itemName, 'name' => $name, 'url' => $url, 'order' => $order);
         }
     }
     return $menus;
 }
Example #8
0
 public function _connect()
 {
     if (isset($this->_profile['storage_dir']) && $this->_profile['storage_dir'] != '') {
         $this->_storage_dir = str_replace(array('var:', 'temp:'), array(jApp::varPath(), jApp::tempPath()), $this->_profile['storage_dir']);
         $this->_storage_dir = rtrim($this->_storage_dir, '\\/') . DIRECTORY_SEPARATOR;
     } else {
         $this->_storage_dir = jApp::varPath('kvfiles/');
     }
     jFile::createDir($this->_storage_dir);
     if (isset($this->_profile['file_locking'])) {
         $this->_file_locking = $this->_profile['file_locking'] ? true : false;
     }
     if (isset($this->_profile['automatic_cleaning_factor'])) {
         $this->automatic_cleaning_factor = $this->_profile['automatic_cleaning_factor'];
     }
     if (isset($this->_profile['directory_level']) && $this->_profile['directory_level'] > 0) {
         $this->_directory_level = $this->_profile['directory_level'];
         if ($this->_directory_level > 16) {
             $this->_directory_level = 16;
         }
     }
     if (isset($this->_profile['directory_umask']) && is_string($this->_profile['directory_umask']) && $this->_profile['directory_umask'] != '') {
         $this->_directory_umask = octdec($this->_profile['directory_umask']);
     }
     if (isset($this->_profile['file_umask']) && is_string($this->_profile['file_umask']) && $this->_profile['file_umask'] != '') {
         $this->file_umask = octdec($this->_profile['file_umask']);
     }
 }
Example #9
0
 /**
  * handle the search of specific member
  */
 function index()
 {
     $title = stripslashes(jApp::config()->havefnubb['title']);
     $rep = $this->getResponse('html');
     $letter = $this->param('letter');
     $id_rank = (int) $this->param('id_rank');
     $memberSearch = (string) $this->param('member_search');
     $page = 0;
     $page = (int) $this->param('page');
     // get the group name of the group id we request
     $grpid = $this->param('grpid');
     $groupname = jLocale::get('havefnubb~member.memberlist.allgroups');
     if ($grpid != '__anonymous') {
         $dao = jDao::get('jacl2db~jacl2group');
         $grpname = $dao->get($grpid);
         $groupname = $grpname->name;
     }
     $beginningBy = '';
     if (strlen($letter) == 1) {
         $beginningBy = ' - ' . jLocale::get('havefnubb~member.memberlist.members.beginning.by', array($letter));
     }
     // change the label of the breadcrumb
     if ($page == 0) {
         jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list'));
         $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy;
     } else {
         jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list') . ' ' . ($page + 1));
         $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy . ' ' . ($page + 1);
     }
     $rep->body->assignZone('MAIN', 'memberlist', array('page' => $page, 'grpid' => $grpid, 'letter' => $letter, 'memberSearch' => $memberSearch));
     return $rep;
 }
Example #10
0
 public static function write($file, $data)
 {
     $_dirname = dirname($file);
     self::createDir($_dirname);
     if (!@is_writable($_dirname)) {
         if (!@is_dir($_dirname)) {
             throw new jException('jelix~errors.file.directory.notexists', array($_dirname));
         }
         throw new jException('jelix~errors.file.directory.notwritable', array($file, $_dirname));
     }
     $_tmp_file = tempnam($_dirname, 'wrt');
     if (!($fd = @fopen($_tmp_file, 'wb'))) {
         $_tmp_file = $_dirname . '/' . uniqid('wrt');
         if (!($fd = @fopen($_tmp_file, 'wb'))) {
             throw new jException('jelix~errors.file.write.error', array($file, $_tmp_file));
         }
     }
     fwrite($fd, $data);
     fclose($fd);
     if (jApp::config()->isWindows && file_exists($file)) {
         unlink($file);
     }
     rename($_tmp_file, $file);
     @chmod($file, 0664);
     return true;
 }
/**
* @package      jelix
* @subpackage   jtpl_plugin
* @author       Laurent Jouanneau
* @contributor  Dominique Papin, Julien Issler, Bastien Jaillot
* @copyright    2007-2012 Laurent Jouanneau, 2007 Dominique Papin
* @copyright    2008 Julien Issler, 2008 Bastien Jaillot
* @link         http://www.jelix.org
* @licence      GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
function jtpl_cfunction_html_formfull($compiler, $params = array())
{
    if (count($params) < 2 || count($params) > 5) {
        $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number', 'formfull', '2-5');
    }
    if (isset($params[3]) && trim($params[3]) != '""' && trim($params[3]) != "''") {
        $builder = $params[3];
    } else {
        $builder = "'" . jApp::config()->tplplugins['defaultJformsBuilder'] . "'";
    }
    $compiler->addMetaContent('if(isset(' . $params[0] . ')) { ' . $params[0] . '->getBuilder(' . $builder . ')->outputMetaContent($t);}');
    if (count($params) == 2) {
        $params[2] = 'array()';
    }
    if (isset($params[4])) {
        $options = $params[4];
    } else {
        $options = "array()";
    }
    $content = ' $formfull = ' . $params[0] . ';
    $formfullBuilder = $formfull->getBuilder(' . $builder . ');
    $formfullBuilder->setAction(' . $params[1] . ',' . $params[2] . ');
    $formfullBuilder->outputHeader(' . $options . ');
    $formfullBuilder->outputAllControls();
    $formfullBuilder->outputFooter();';
    return $content;
}
Example #12
0
 function install()
 {
     if (!$this->firstDbExec()) {
         return;
     }
     // ---  install table for session storage if needed
     $sessionStorage = $this->config->getValue("storage", "sessions");
     $sessionDao = $this->config->getValue("dao_selector", "sessions");
     $sessionProfile = $this->config->getValue("dao_db_profile", "sessions");
     if ($sessionStorage == "dao" && $sessionDao == "jelix~jsession") {
         $this->execSQLScript('sql/install_jsession.schema');
     }
     // --- install table for jCache if needed
     $cachefile = jApp::configPath('profiles.ini.php');
     if (file_exists($cachefile)) {
         $ini = new \Jelix\IniFile\IniModifier($cachefile);
         foreach ($ini->getSectionList() as $section) {
             if (substr($section, 0, 7) != 'jcache:') {
                 continue;
             }
             $driver = $ini->getValue('driver', $section);
             $dao = $ini->getValue('dao', $section);
             $this->useDbProfile($ini->getValue('dbprofile', $section));
             if ($driver == 'db' && $dao == 'jelix~jcache' && $this->firstExec('cachedb:' . $this->dbProfile)) {
                 $this->execSQLScript('sql/install_jcache.schema');
             }
         }
     }
 }
 function __construct($config = null)
 {
     if (is_string($config)) {
         $f = WIKIRENDERER_PATH . 'rules/' . basename($config) . '.php';
         if (file_exists($f)) {
             require_once $f;
             $this->config = new $config();
         } else {
             $this->config = jApp::loadPlugin($config, 'wr_rules', '.rule.php', $config);
             if (is_null($this->config)) {
                 throw new Exception('Rules "' . $config . '" not found for jWiki');
             }
         }
         $this->config->charset = jApp::config()->charset;
     } elseif (is_object($config)) {
         $this->config = $config;
     } else {
         require_once WIKIRENDERER_PATH . 'rules/wr3_to_xhtml.php';
         $this->config = new wr3_to_xhtml();
         $this->config->charset = jApp::config()->charset;
     }
     $this->inlineParser = new WikiInlineParser($this->config);
     foreach ($this->config->bloctags as $name) {
         $this->_blocList[] = new $name($this);
     }
     if ($this->config->defaultBlock) {
         $name = $this->config->defaultBlock;
         $this->_defaultBlock = new $name($this);
     }
 }
 public function run()
 {
     try {
         $tempPath = jApp::tempBasePath();
         if ($tempPath == DIRECTORY_SEPARATOR || $tempPath == '' || $tempPath == '/') {
             echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . $tempPath . "' !!\n";
             echo "       Jelix cannot clear the content of the temp directory.\n";
             echo "       Correct the path in your application.init.php or create the corresponding directory\n";
             exit(1);
         }
         if (!jFile::removeDir($tempPath, false, array('.svn', '.dummy'))) {
             echo "Some temp files were not removed\n";
         } else {
             if ($this->verbose()) {
                 echo "All temp files have been removed\n";
             }
         }
     } catch (Exception $e) {
         if ($this->config->helpLang == 'fr') {
             echo "Un ou plusieurs répertoires n'ont pas pu être supprimés.\n" . "Message d'erreur : " . $e->getMessage() . "\n";
         } else {
             echo "One or more directories couldn't be deleted.\n" . "Error: " . $e->getMessage() . "\n";
         }
     }
 }
Example #15
0
 /**
  *
  */
 function out()
 {
     $rep = $this->getResponse('redirectUrl');
     jAuth::logout();
     $conf = jApp::coord()->getPlugin('auth')->config;
     if ($conf['after_logout'] == '') {
         throw new jException('jcommunity~login.error.no.auth_logout');
     }
     if (jApp::coord()->execOriginalAction()) {
         if ($conf['enable_after_logout_override']) {
             $url_return = $this->param('auth_url_return');
             if ($url_return) {
                 $rep->url = $url_return;
             } else {
                 $rep->url = jUrl::get($conf['after_logout']);
             }
         }
     } else {
         // we are here because of an internal redirection (authentication missing)
         // if we can indicate the url to go after the login, let's pass this url
         // to the next action (which is in most of case a login form)
         if ($conf['enable_after_login_override']) {
             $rep->url = jUrl::get($conf['after_logout'], array('auth_url_return' => jUrl::getCurrentUrl()));
         } else {
             $rep->url = jUrl::get($conf['after_logout']);
         }
     }
     return $rep;
 }
Example #16
0
 function testEntryPointsList()
 {
     jApp::saveContext();
     jApp::initPaths(dirname(__FILE__) . '/app1/');
     $app = new testInstallApp('project_empty.xml');
     $this->assertEquals(array(), $app->getEntryPointsList());
     $app = new testInstallApp('project_empty2.xml');
     $this->assertEquals(array(), $app->getEntryPointsList());
     $app = new testInstallApp('project.xml');
     $list = $app->getEntryPointsList();
     $this->assertEquals(2, count($list));
     $ep = $app->getEntryPointInfo('index');
     $this->assertFalse($ep->isCliScript);
     $this->assertEquals('/index.php', $ep->scriptName);
     $this->assertEquals('index.php', $ep->file);
     $this->assertEquals('', $ep->type);
     $this->assertEquals('aaa', $ep->config->startModule);
     $ep = $app->getEntryPointInfo('foo');
     $this->assertFalse($ep->isCliScript);
     $this->assertEquals('/foo.php', $ep->scriptName);
     $this->assertEquals('foo.php', $ep->file);
     $this->assertEquals('', $ep->type);
     $this->assertEquals('foo', $ep->config->startModule);
     jApp::restoreContext();
 }
 /**
  * Loads the resources for a given locale/charset.
  * @param string $locale     the locale
  * @param string $charset    the charset
  */
 protected function _loadLocales($locale, $charset)
 {
     $this->_loadedCharset[] = $charset;
     $source = $this->fic->getPath();
     $cache = $this->fic->getCompiledFilePath();
     // check if we have a compiled version of the ressources
     if (is_readable($cache)) {
         $okcompile = true;
         if (jApp::config()->compilation['force']) {
             $okcompile = false;
         } else {
             if (jApp::config()->compilation['checkCacheFiletime']) {
                 if (is_readable($source) && filemtime($source) > filemtime($cache)) {
                     $okcompile = false;
                 }
             }
         }
         if ($okcompile) {
             include $cache;
             $this->_strings[$charset] = $_loaded;
             return;
         }
     }
     $this->_loadResources($source, $charset);
     if (isset($this->_strings[$charset])) {
         $content = '<?php $_loaded= ' . var_export($this->_strings[$charset], true) . ' ?>';
         jFile::write($cache, $content);
     }
 }
Example #18
0
 function install()
 {
     if (self::$key === null) {
         $cryptokey = \Defuse\Crypto\Key::createNewRandomKey();
         self::$key = $cryptokey->saveToAsciiSafeString();
     }
     $authconfig = $this->getConfigIni()->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->getLocalConfigIni()->getValue('auth', 'coordplugins');
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->getConfigFile()) . '/' . $pluginIni;
         if ($this->firstExec('auth:' . $authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($authconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
             }
         }
     }
     $this->getLocalConfigIni()->setValue('persistant_encryption_key', self::$key, 'coordplugin_auth');
 }
Example #19
0
 /**
  */
 function __construct()
 {
     $config = isset(\jApp::config()->jcommunity) ? \jApp::config()->jcommunity : null;
     if ($config) {
         if (isset($config['loginResponse'])) {
             $this->responseType = $config['loginResponse'];
         }
     }
     if (class_exists('jPref')) {
         $pref = \jPref::get('jcommunity_registrationEnabled');
         if ($pref !== null) {
             $this->registrationEnabled = $pref;
         }
         $pref = \jPref::get('jcommunity_resetPasswordEnabled');
         if ($pref !== null) {
             $this->resetPasswordEnabled = $pref;
         }
     } else {
         if ($config) {
             if (isset($config['registrationEnabled'])) {
                 $this->registrationEnabled = !!$config['registrationEnabled'];
             }
             if (isset($config['resetPasswordEnabled'])) {
                 $this->resetPasswordEnabled = !!$config['resetPasswordEnabled'];
             }
         }
     }
 }
 public function outputMetaContent($t)
 {
     $resp = jApp::coord()->response;
     if ($resp === null || $resp->getType() != 'html') {
         return;
     }
     $confUrlEngine =& jApp::config()->urlengine;
     $www = $confUrlEngine['jelixWWWPath'];
     $jq = $confUrlEngine['jqueryPath'];
     $resp->addJSLink($jq . 'jquery.js');
     $resp->addJSLink($jq . 'include/jquery.include.js');
     $resp->addJSLink($www . 'js/jforms_jquery.js');
     $resp->addCSSLink($www . 'design/jform.css');
     //we loop on root control has they fill call the outputMetaContent recursively
     foreach ($this->_form->getRootControls() as $ctrlref => $ctrl) {
         if ($ctrl->type == 'hidden') {
             continue;
         }
         if (!$this->_form->isActivated($ctrlref)) {
             continue;
         }
         $widget = $this->getWidget($ctrl, $this->rootWidget);
         $widget->outputMetaContent($resp);
     }
 }
Example #21
0
 /**
  * Main page
  */
 public function index()
 {
     $submit = $this->param('validate');
     if ($submit == jLocale::get('hfnucontact~contact.form.saveBt')) {
         $form = jForms::fill('hfnucontact~admincontact');
         $rep = $this->getResponse('redirect');
         if (!$form->check()) {
             $rep->action = 'hfnucontact~admin:index';
             return $rep;
         }
         $HfnucontactConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
         $HfnucontactConfig->setValue('email_contact', $this->param('contact'), 'hfnucontact');
         $HfnucontactConfig->save();
         jMessage::add(jLocale::get('hfnucontact~contact.admin.form.email.saved'), 'ok');
         jForms::destroy('hfnucontact~admincontact');
         $rep->action = 'hfnucontact~admin:index';
         return $rep;
     } else {
         $form = jForms::create('hfnucontact~admincontact');
     }
     $form->setData('contact', jApp::config()->hfnucontact['email_contact']);
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('form', $form);
     $rep->body->assign('MAIN', $tpl->fetch('hfnucontact~admincontact'));
     $rep->body->assign('selectedMenuItem', 'contact');
     return $rep;
 }
 public function run()
 {
     $this->loadAppConfig();
     $config = jApp::config();
     $model_lang = $this->getParam('model_lang', $config->locale);
     $lang = $this->getParam('lang');
     foreach ($config->_modulesPathList as $module => $dir) {
         $source_dir = $dir . 'locales/' . $model_lang . '/';
         if (!file_exists($source_dir)) {
             continue;
         }
         $target_dir = jApp::varPath('overloads/' . $module . '/locales/' . $lang . '/');
         jFile::createDir($target_dir);
         if ($dir_r = opendir($source_dir)) {
             while (FALSE !== ($fich = readdir($dir_r))) {
                 if ($fich != "." && $fich != ".." && is_file($source_dir . $fich) && strpos($fich, '.' . $config->charset . '.properties') && !file_exists($target_dir . $fich)) {
                     copy($source_dir . $fich, $target_dir . $fich);
                     if ($this->verbose()) {
                         echo "Copy Locales file {$fich} from {$source_dir} to {$target_dir}.\n";
                     }
                 }
             }
             closedir($dir_r);
         }
     }
 }
 /**
  * @param    array  $params   plugin parameters for the current action
  * @return null or jSelectorAct  if action should change
  */
 public function beforeAction($params)
 {
     $langDetected = false;
     $lang = '';
     if ($this->config['enableUrlDetection']) {
         $l = jApp::coord()->request->getParam($this->config['urlParamNameLanguage']);
         if ($l !== null) {
             $lang = jLocale::getCorrespondingLocale($l);
             if ($lang != '') {
                 $langDetected = true;
             }
         }
     }
     if (!$langDetected) {
         if (isset($_SESSION['JX_LANG'])) {
             $lang = $_SESSION['JX_LANG'];
         } else {
             if ($this->config['useDefaultLanguageBrowser']) {
                 $lang = jLocale::getPreferedLocaleFromRequest();
             }
         }
     }
     if ($lang != '') {
         $_SESSION['JX_LANG'] = $lang;
         jApp::config()->locale = $lang;
     }
     return null;
 }
Example #24
0
/**
* @package    jelix
* @subpackage jtpl_plugin
* @author     Laurent Jouanneau
* @copyright  2011-2012 Laurent Jouanneau
* @link        http://www.jelix.org
* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
function jtpl_function_html_resurl($tpl, $module, $file, $intheme = false, $escape = true)
{
    if ($intheme) {
        $file = 'themes/' . jApp::config()->theme . '/' . $file;
    }
    echo jUrl::get("jelix~www:getfile", array('targetmodule' => $module, 'file' => $file), $escape ? 1 : 0);
}
 public function run()
 {
     require_once JELIX_LIB_PATH . 'installer/jInstaller.class.php';
     jAppManager::close();
     if ($this->verbose()) {
         $reporter = new textInstallReporter();
     } else {
         $reporter = new textInstallReporter('error');
     }
     $installer = new jInstaller($reporter);
     $installer->installApplication();
     try {
         jAppManager::clearTemp(jApp::tempBasePath());
     } catch (Exception $e) {
         if ($e->getCode() == 2) {
             echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . jApp::tempBasePath() . "' !!\n";
             echo "       Jelix cannot clear the content of the temp directory.\n";
             echo "       you must clear it your self.\n";
             echo "       Correct the path in the application.init.php or create the directory\n";
         } else {
             echo "Error: " . $e->getMessage();
         }
     }
     jAppManager::open();
 }
 function __construct()
 {
     parent::__construct();
     global $gJConfig;
     $config = jApp::config();
     $baseDirectory = $config->urlengine['basePath'];
     $this->addCSSLink($baseDirectory . "bootstrap/css/bootstrap.css");
     $this->addCSSLink($baseDirectory . "bootstrap/css/bootstrap.min.css");
     $this->addCSSLink($baseDirectory . "bootstrap/css/agency.css");
     //var_dump($baseDirectory);
     $this->addCSSLink($baseDirectory . "bootstrap/font-awesome/css/font-awesome.css");
     $this->addCSSLink($baseDirectory . "bootstrap/js/jquery.js");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     //$this->addCSSLink($baseDirectory."");
     $this->addJsLink($baseDirectory . "bootstrap/js/agency.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/bootstrap.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/bootstrap.min.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/cbpAnimatedHeader.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/classie.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/contact_me.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/jqBootstrapValidation.js");
     $this->addJsLink($baseDirectory . "bootstrap/js/jquery.js");
     //$this->addJsLink($baseDirectory."");
     //$this->addCSSLink(jApp::config()->urlengine['jelixWWWPath'].'design/jelix.css');
     //$this->addCSSLink($theme.'css/screen.css');
     // Include your common CSS and JS files here
 }
 protected function _getClassSelector()
 {
     $class_selector = null;
     if ($this->toSelector === null && $this->instance === null) {
         $str_selector = $this->fromSelector->toString();
         $str_selector_long = $this->fromSelector->toString(true);
         $config = jApp::config();
         if (isset($config->classbindings) && count($config->classbindings)) {
             $conf = $config->classbindings;
             $conf_selector = str_replace('~', '-', $str_selector);
             $conf_selector_long = str_replace('~', '-', $str_selector_long);
             $str_fromselector = null;
             if (isset($conf[$conf_selector])) {
                 $str_fromselector = $conf_selector;
             } elseif (isset($conf[$conf_selector_long])) {
                 $str_fromselector = $conf_selector_long;
             }
             if ($str_fromselector !== null) {
                 $this->fromSelector = jSelectorFactory::create($str_selector_long, 'iface');
                 return $this->toSelector = new jSelectorClass($conf[$str_fromselector]);
             }
         }
         $constname = $this->fromSelector->className . '::JBINDING_BINDED_IMPLEMENTATION';
         if (defined($constname)) {
             $class_selector = constant($constname);
             if ($class_selector !== null) {
                 return $this->toSelector = new jSelectorClass($class_selector);
             }
         }
         if (true === $this->fromSelector instanceof jSelectorClass) {
             return $this->toSelector = $this->fromSelector;
         }
         throw new jException('jelix~errors.bindings.nobinding', array($this->fromSelector->toString(true)));
     }
 }
 /**
  * write some data in an ini file
  * the data array should follow the same structure returned by
  * the read method (or parse_ini_file)
  * @param array $array the content of an ini file
  * @param string $filename the path and the name of the file use to store the content
  * @param string $header   some content to insert at the begining of the file
  * @param integer $chmod   
  */
 public static function write($array, $filename, $header = '', $chmod = null)
 {
     $result = '';
     foreach ($array as $k => $v) {
         if (is_array($v)) {
             $result .= '[' . $k . "]\n";
             foreach ($v as $k2 => $v2) {
                 $result .= self::_iniValue($k2, $v2);
             }
         } else {
             // we put simple values at the beginning of the file.
             $result = self::_iniValue($k, $v) . $result;
         }
     }
     if ($f = @fopen($filename, 'wb')) {
         fwrite($f, $header . $result);
         fclose($f);
         if ($chmod) {
             chmod($f, $chmod);
         }
     } else {
         // jIniFile is used by the configs compiler. There is no configuration
         // object in that case. we need to generate an error without using jLocale
         if (jApp::config()) {
             throw new jException('jelix~errors.inifile.write.error', array($filename));
         } else {
             throw new Exception('(24)Error while writing ini file ' . $filename);
         }
     }
 }
/**
 * a block to display only data of a form
 *
 * usage : {formdata $theformobject} here the form content {/formdata}
 *
 * @param jTplCompiler $compiler the template compiler
 * @param boolean $begin true if it is the begin of block, else false
 * @param array $param 0=>form object
 * @param array $param 0=>form object
 *                     2=>name of the builder : default is html
 *                     3=>array of options for the builder
 * @return string the php code corresponding to the begin or end of the block
 * @see jForms
 * @since 1.0.1
 */
function jtpl_block_html_formdata($compiler, $begin, $param = array())
{
    if (!$begin) {
        return '
unset($t->_privateVars[\'__form\']);
unset($t->_privateVars[\'__formbuilder\']);
unset($t->_privateVars[\'__formViewMode\']);
unset($t->_privateVars[\'__displayed_ctrl\']);';
    }
    if (count($param) < 1 || count($param) > 3) {
        $compiler->doError2('errors.tplplugin.block.bad.argument.number', 'formdata', '1-3');
        return '';
    }
    if (isset($param[1]) && trim($param[1]) != '""' && trim($param[1]) != "''") {
        $builder = $param[1];
    } else {
        $builder = "'" . jApp::config()->tplplugins['defaultJformsBuilder'] . "'";
    }
    if (isset($param[2])) {
        $options = $param[2];
    } else {
        $options = "array()";
    }
    $content = ' $t->_privateVars[\'__form\'] = ' . $param[0] . ';
    $t->_privateVars[\'__formViewMode\'] = 1;
    $t->_privateVars[\'__formbuilder\'] = $t->_privateVars[\'__form\']->getBuilder(' . $builder . ');
    $t->_privateVars[\'__formbuilder\']->setOptions(' . $options . ');
$t->_privateVars[\'__displayed_ctrl\'] = array();
';
    return $content;
}
Example #30
0
 protected function _prepareTpl()
 {
     $config = new \Jelix\JCommunity\Config();
     $this->_tpl->assign('canRegister', $config->isRegistrationEnabled());
     $this->_tpl->assign('canResetPassword', $config->isResetPasswordEnabled());
     if (jAuth::isConnected()) {
         $this->_tpl->assign('login', jAuth::getUserSession()->login);
     } else {
         $conf = jAuth::loadConfig();
         $this->_tpl->assign('persistance_ok', jAuth::isPersistant());
         $form = jForms::get("jcommunity~login");
         if (!$form) {
             $form = jForms::create("jcommunity~login");
         }
         $this->_tpl->assign('form', $form);
         $this->_tpl->assign('url_return', '');
         if ($conf['enable_after_login_override']) {
             $req = jApp::coord()->request;
             if ($req->getParam('auth_url_return')) {
                 $this->_tpl->assign('url_return', $req->getParam('auth_url_return'));
             } else {
                 if ($this->param('as_main_content')) {
                     if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] && $_SERVER['HTTP_REFERER'] != jUrl::getCurrentUrl(false, true)) {
                         $this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']);
                     }
                 } else {
                     if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') {
                         $this->_tpl->assign('url_return', jUrl::getCurrentUrl(false, true));
                     }
                 }
             }
         }
     }
 }