/**
  * Create a jurl object with the given action data
  * @param jUrlAction $url  information about the action
  * @return jUrl the url correspondant to the action
  */
 public function create($urlact)
 {
     $m = $urlact->getParam('module');
     $a = $urlact->getParam('action');
     $scriptName = $this->getBasePath($urlact->requestType, $m, $a);
     $script = $this->getScript($urlact->requestType, $m, $a);
     if (isset(jApp::config()->basic_significant_urlengine_entrypoints[$script]) && jApp::config()->basic_significant_urlengine_entrypoints[$script]) {
         if (!jApp::config()->urlengine['multiview']) {
             $script .= '.php';
         }
         $scriptName .= $script;
     }
     $url = new jUrl($scriptName, $urlact->params, '');
     // for some request types, parameters aren't in the url
     // so we remove them
     // it's a bit dirty to do that hardcoded here, but it would be a pain
     // to load the request class to check whether we can remove or not
     if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) {
         $url->clearParam();
     } else {
         $pi = '/' . $m . '/';
         if ($a != 'default:index') {
             list($c, $a) = explode(':', $a);
             $pi .= $c . '/';
             if ($a != 'index') {
                 $pi .= $a;
             }
         }
         $url->pathInfo = $pi;
         $url->delParam('module');
         $url->delParam('action');
     }
     return $url;
 }
Exemplo n.º 2
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);
 }
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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
 }
Exemplo n.º 7
0
 /**
  * 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);
     }
 }
/**
 * function plugin :  Ajax request
 *
 * it creates a javascript ajax function
 * example :
 * <pre>
 * {link_to_remote
 *  'Link',    <!-- link label -->
 *  'result',    <!-- id dom for ajax result -->
 *  'test~default:ajax', array('id'=>'34'),    <!-- jurl request -->
 *  array(
 *    'position'=>'html',    <!-- html or append or prepend (default html) -->
 *    'method'=>'GET',    <!-- GET or POST (default POST) -->
 *    'beforeSend'=>'alert("beforeSend")',    <!-- JS script before send (default null) -->
 *    'complete'=>'alert("complete")',    <!-- JS script after send  (default null)-->
 *    'error'=>'alert("error")',    <!-- JS if error  (default null) -->
 * )}
 * <div id="result"></div>
 * </pre>
 */
function jtpl_function_html_link_to_remote($tpl, $label, $element_id, $action_selector, $action_parameters, $option)
{
    $resp = jApp::coord()->response;
    static $id_link_to_remote = 0;
    if ($resp && $resp->getFormatType() == 'html') {
        // Add js link
        $resp->addJSLink(jApp::config()->urlengine['jqueryPath'] . 'jquery.js');
    }
    $id_link_to_remote++;
    $url = jUrl::get($action_selector, $action_parameters);
    $position = array_key_exists("position", $option) ? $option['position'] : 'html';
    $method = array_key_exists("method", $option) ? $option['method'] : 'GET';
    $beforeSend = array_key_exists("beforeSend", $option) ? $option['beforeSend'] : '';
    $complete = array_key_exists("complete", $option) ? $option['complete'] : '';
    $error = array_key_exists("error", $option) ? $option['error'] : '';
    // Link
    echo '<a href="#" onclick="link_to_remote_' . $id_link_to_remote . '();">' . $label . "</a>\n";
    // Script
    echo '
    <script type="text/javascript">//<![CDATA[
      function link_to_remote_' . $id_link_to_remote . '() {
        $.ajax({
          type: \'' . $method . "',\n          url: '" . $url . "',\n          beforeSend: function(){" . $beforeSend . ";},\n          complete: function(){" . $complete . ";},\n          error: function(){" . $error . ';},
          success: function(msg){
            $(\'#' . $element_id . "')." . $position . "(msg);\n          }\n        });\n      }; //]]>\n    </script>";
}
Exemplo n.º 9
0
 /**
  * display the RSS of the forum
  */
 public function read_rss()
 {
     $ftitle = jUrl::escape($this->param('ftitle'), true);
     $id_forum = (int) $this->param('id_forum');
     if (!jAcl2::check('hfnu.posts.list', 'forum' . $id_forum)) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'default:index';
         return $rep;
     }
     if ($id_forum == 0) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'default:index';
         return $rep;
     }
     $forum = jClasses::getService('havefnubb~hfnuforum')->getForum($id_forum);
     if (jUrl::escape($forum->forum_name, true) != $ftitle) {
         $rep = $this->getResponse('redirect');
         $rep->action = jApp::config()->urlengine['notfoundAct'];
         return $rep;
     }
     jApp::coord()->getPlugin('history')->change('label', htmlentities($forum->forum_name, ENT_COMPAT, 'UTF-8'));
     $feed_reader = new jFeedReader();
     $feed_reader->setCacheDir(jApp::varPath('feeds'));
     $feed_reader->setTimeout(2);
     $feed_reader->setUserAgent('HaveFnuBB - http://www.havefnubb.org/');
     $feed = $feed_reader->parse($forum->forum_url);
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('feed', $feed);
     $tpl->assign('forum', $forum);
     $rep->title = $forum->forum_name;
     $rep->body->assign('MAIN', $tpl->fetch('havefnubb~forum_rss.view'));
     return $rep;
 }
Exemplo n.º 10
0
 /**
  * constructor
  */
 function __construct()
 {
     if (jApp::config()->httpVersion != "") {
         $this->httpVersion = jApp::config()->httpVersion;
         $this->forcedHttpVersion = true;
     }
 }
Exemplo n.º 11
0
 protected function _execute(InputInterface $input, OutputInterface $output)
 {
     $group = $input->getArgument('group');
     $labelkey = $input->getArgument('labelkey');
     $label = $input->getArgument('label');
     $cnx = \jDb::getConnection('jacl2_profile');
     $sql = "SELECT id_aclsbjgrp FROM " . $cnx->prefixTable('jacl2_subject_group') . " WHERE id_aclsbjgrp=" . $cnx->quote($group);
     $rs = $cnx->query($sql);
     if ($rs->fetch()) {
         throw new \Exception("This subject group already exists");
     }
     $sql = "INSERT into " . $cnx->prefixTable('jacl2_subject_group') . " (id_aclsbjgrp, label_key) VALUES (";
     $sql .= $cnx->quote($group) . ',';
     $sql .= $cnx->quote($labelkey);
     $sql .= ')';
     $cnx->exec($sql);
     if ($this->verbose()) {
         $ouput->writeln("Rights: group of subjects '" . $group . "' is created");
     }
     if ($label && preg_match("/^([a-zA-Z0-9_\\.]+)~([a-zA-Z0-9_]+)\\.([a-zA-Z0-9_\\.]+)\$/", $labelkey, $m)) {
         $localestring = "\n" . $m[3] . '=' . $label;
         $path = $this->getModulePath($m[1]);
         $file = $path . 'locales/' . \jApp::config()->locale . '/' . $m[2] . '.' . \jApp::config()->charset . '.properties';
         if (file_exists($file)) {
             $localestring = file_get_contents($file) . $localestring;
         }
         file_put_contents($file, $localestring);
         if ($output->isVerbose()) {
             $output->writeln("locale string " . $m[3] . " is created into " . $file);
         }
     }
 }
 public function compileItem($sourceFile, $module)
 {
     if (is_readable($sourceFile)) {
         $xml = simplexml_load_file($sourceFile);
         $config = jApp::config()->disabledListeners;
         if (isset($xml->listener)) {
             foreach ($xml->listener as $listener) {
                 $listenerName = (string) $listener['name'];
                 $selector = $module . '~' . $listenerName;
                 foreach ($listener->event as $eventListened) {
                     $name = (string) $eventListened['name'];
                     if (isset($config[$name])) {
                         if (is_array($config[$name])) {
                             if (in_array($selector, $config[$name])) {
                                 continue;
                             }
                         } else {
                             if ($config[$name] == $selector) {
                                 continue;
                             }
                         }
                     }
                     // key = event name ,  value = list of file listener
                     $this->eventList[$name][] = array($module, $listenerName);
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 13
0
 function extensionsConfig()
 {
     $rep = $this->getResponse('js');
     $config = array();
     $dir = "modules/";
     //
     $iter = new DirectoryIterator($dir);
     foreach ($iter as $file) {
         if (!$file->isDot()) {
             if ($file->isDir() && file_exists($dir . $file->getFilename() . '/urls.json')) {
                 $doc = jFile::read($dir . $file->getFilename() . '/urls.json');
                 $urls = json_decode($doc);
                 foreach ($urls->config as $row) {
                     $config['config'][] = $row;
                 }
                 foreach ($urls->modules as $row) {
                     $config['modules'][] = $row;
                 }
             }
         }
     }
     $tpl = new jTpl();
     $tpl->assign('config', $config);
     $tpl->assign('rootUrl', jApp::config()->urlengine['basePath']);
     $content = $tpl->fetch('bos~init');
     $rep->data = $content;
     return $rep;
 }
Exemplo n.º 14
0
 public static function loadClass($class)
 {
     if (strpos($class, 'jelix\\') === 0) {
         $f = LIB_PATH . 'jelix-legacy/' . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 6)) . '.php';
     } elseif (preg_match('/^j(Dao|Tpl|Event|Db|Controller|Forms|Auth|Installer|KV).*/i', $class, $m)) {
         $f = self::$libPath[$m[1]] . $class . '.class.php';
     } elseif (preg_match('/^cDao(?:Record)?_(.+)_Jx_(.+)_Jx_(.+)$/', $class, $m)) {
         // for DAO which are stored in sessions for example
         if (!isset(jApp::config()->_modulesPathList[$m[1]])) {
             //this may happen if we have several entry points, but the current one does not have this module accessible
             return;
         }
         $s = new jSelectorDaoDb($m[1] . '~' . $m[2], '', $m[3]);
         if (jApp::config()->compilation['checkCacheFiletime']) {
             // if it is needed to check the filetime, then we use jIncluder
             // because perhaps we will have to recompile the dao before the include
             jIncluder::inc($s);
         } else {
             $f = $s->getCompiledFilePath();
             // we should verify that the file is here and if not, we recompile
             // (case where the temp has been cleaned, see bug #6062 on berlios.de)
             if (!file_exists($f)) {
                 jIncluder::inc($s);
             } else {
                 require $f;
             }
         }
         return;
     } else {
         $f = JELIX_LIB_UTILS_PATH . $class . '.class.php';
     }
     if (file_exists($f)) {
         require $f;
     }
 }
Exemplo n.º 15
0
 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);
         }
     }
 }
Exemplo n.º 16
0
 /**
  * initialize some member
  */
 function __construct()
 {
     $config = jApp::config();
     $this->defaultLang = $config->locale;
     $this->CharSet = $config->charset;
     $this->Mailer = $config->mailer['mailerType'];
     if ($config->mailer['mailerType']) {
         $this->Mailer = $config->mailer['mailerType'];
     }
     $this->Hostname = $config->mailer['hostname'];
     $this->Sendmail = $config->mailer['sendmailPath'];
     $this->Host = $config->mailer['smtpHost'];
     $this->Port = $config->mailer['smtpPort'];
     $this->Helo = $config->mailer['smtpHelo'];
     $this->SMTPAuth = $config->mailer['smtpAuth'];
     $this->SMTPSecure = $config->mailer['smtpSecure'];
     $this->Username = $config->mailer['smtpUsername'];
     $this->Password = $config->mailer['smtpPassword'];
     $this->Timeout = $config->mailer['smtpTimeout'];
     if ($config->mailer['webmasterEmail'] != '') {
         $this->From = $config->mailer['webmasterEmail'];
     }
     $this->FromName = $config->mailer['webmasterName'];
     $this->filePath = jApp::varPath($config->mailer['filesDir']);
     $this->copyToFiles = $config->mailer['copyToFiles'];
     parent::__construct(true);
 }
Exemplo n.º 17
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);
}
Exemplo n.º 18
0
 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);
     }
 }
Exemplo n.º 19
0
 /**
  * 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);
         }
     }
 }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
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'];
             }
         }
     }
 }
Exemplo n.º 22
0
/**
* @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;
}
Exemplo n.º 23
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;
 }
Exemplo n.º 24
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;
 }
Exemplo n.º 25
0
 /**
  * @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;
 }
Exemplo n.º 26
0
 protected function _createPath()
 {
     if (!isset(jApp::config()->_modulesPathList[$this->module])) {
         throw new jExceptionSelector('jelix~errors.selector.module.unknown', $this->toString(true));
     }
     // we see if the forms have been redefined in var/
     $overloadedPath = jApp::varPath('overloads/' . $this->module . '/' . $this->_dirname . $this->resource . $this->_suffix);
     if (is_readable($overloadedPath)) {
         $this->_path = $overloadedPath;
         $this->_where = 'var/';
         return;
     }
     // we see if the forms have been redefined in app/
     $overloadedPath = jApp::appPath('app/overloads/' . $this->module . '/' . $this->_dirname . $this->resource . $this->_suffix);
     if (is_readable($overloadedPath)) {
         $this->_path = $overloadedPath;
         $this->_where = 'app/';
         return;
     }
     $this->_path = jApp::config()->_modulesPathList[$this->module] . $this->_dirname . $this->resource . $this->_suffix;
     if (!is_readable($this->_path)) {
         throw new jExceptionSelector('jelix~errors.selector.invalid.target', array($this->toString(), $this->type));
     }
     $this->_where = 'modules/';
 }
Exemplo n.º 27
0
 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)));
     }
 }
Exemplo n.º 28
0
 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);
     }
 }
Exemplo n.º 29
0
/**
 * 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;
}
Exemplo n.º 30
0
 public function getfile()
 {
     $module = $this->param('targetmodule');
     if (!jApp::isModuleEnabled($module) || jApp::config()->modules[$module . '.access'] < 2) {
         throw new jException('jelix~errors.module.untrusted', $module);
     }
     $dir = jApp::getModulePath($module) . 'www/';
     $filename = realpath($dir . str_replace('..', '', $this->param('file')));
     if (!is_file($filename)) {
         $rep = $this->getResponse('html', true);
         $rep->bodyTpl = 'jelix~404.html';
         $rep->setHttpStatus('404', 'Not Found');
         return $rep;
     }
     $rep = $this->getResponse('binary');
     $dateModif = new DateTime();
     $dateModif->setTimestamp(filemtime($fileName));
     if ($rep->isValidCache($dateModif)) {
         return $rep;
     }
     $rep->doDownload = false;
     $rep->fileName = $filename;
     $rep->mimeType = \Jelix\FileUtilities\File::getMimeTypeFromFilename($rep->fileName);
     return $rep;
 }