本文整理汇总了PHP中jApp类的典型用法代码示例。如果您正苦于以下问题:PHP jApp类的具体用法?PHP jApp怎么用?PHP jApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeAction
/**
* @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;
}
示例2: jtpl_function_html_breadcrumb
/**
* @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>';
}
示例3: index
/**
* 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;
}
示例4: _initParams
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;
}
示例5: logMessage
/**
* @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);
}
}
示例6: getDictionary
/**
* 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;
}
示例7: getMenus
/**
* 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;
}
示例8: _connect
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']);
}
}
示例9: index
/**
* 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;
}
示例10: write
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;
}
示例11: jtpl_cfunction_html_formfull
/**
* @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;
}
示例12: install
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');
}
}
}
}
示例13: __construct
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);
}
}
示例14: run
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";
}
}
}
示例15: out
/**
*
*/
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;
}