Permalink
Browse files

replaced all $gJCoord by jApp::coord() in jelix components

  • Loading branch information...
laurentj committed Feb 18, 2012
1 parent e7048d2 commit 1fc5426124aa2246a4470df94cd05ef2f381a99f
Showing with 139 additions and 150 deletions.
  1. +0 −2 ext/jelix/TODO
  2. +1 −2 lib/jelix/auth/jAuth.class.php
  3. +2 −2 lib/jelix/controllers/jControllerDaoCrud.class.php
  4. +2 −2 lib/jelix/controllers/jControllerDaoCrudDfk.class.php
  5. +1 −2 lib/jelix/core/jErrorHandler.lib.php
  6. +2 −3 lib/jelix/core/jException.lib.php
  7. +8 −7 lib/jelix/core/jRequest.class.php
  8. +4 −5 lib/jelix/core/jUrl.class.php
  9. +4 −3 lib/jelix/core/log/jFileLogger.class.php
  10. +6 −4 lib/jelix/core/log/jLogErrorMessage.class.php
  11. +2 −2 lib/jelix/core/log/jMailLogger.class.php
  12. +3 −4 lib/jelix/core/log/jSyslogLogger.class.php
  13. +3 −3 lib/jelix/core/response/jResponseJson.class.php
  14. +8 −9 lib/jelix/core/response/jResponseJsonrpc.class.php
  15. +4 −4 lib/jelix/core/response/jResponseSitemap.class.php
  16. +5 −5 lib/jelix/core/response/jResponseSoap.class.php
  17. +2 −3 lib/jelix/core/response/jResponseXmlrpc.class.php
  18. +9 −9 lib/jelix/core/selector/jSelectorAct.class.php
  19. +1 −2 lib/jelix/forms/jFormsBuilderHtml.class.php
  20. +1 −3 lib/jelix/plugins/coord/autolocale/autolocale.coord.php
  21. +3 −3 lib/jelix/plugins/coord/history/history.coord.php
  22. +2 −2 lib/jelix/plugins/jforms/html/html.jformsbuilder.php
  23. +5 −5 lib/jelix/plugins/tpl/html/block.swfjs.php
  24. +1 −3 lib/jelix/plugins/tpl/html/function.breadcrumb.php
  25. +3 −3 lib/jelix/plugins/tpl/html/function.link_to_remote.php
  26. +29 −29 lib/jelix/plugins/tpl/html/meta.html.php
  27. +12 −12 lib/jelix/plugins/tpl/html/meta.htmlmodule.php
  28. +5 −5 lib/jelix/plugins/tpl/xml/meta.xml.php
  29. +8 −8 lib/jelix/plugins/tpl/xul/meta.xul.php
  30. +1 −3 lib/jelix/utils/jWSDL.class.php
  31. +2 −1 testapp/modules/jelix_tests/tests/core.urls_parsing.html_cli.php
View
@@ -12,8 +12,6 @@ JX_URL_SCRIPT_PATH
JX_URL_SCRIPT_NAME
JX_URL_PATH_INFO
-$gJCoord = null;
-
Fonctions
=========
@@ -41,8 +41,7 @@ class jAuth {
protected static function _getConfig(){
static $config = null;
if($config == null){
- global $gJCoord;
- $plugin = $gJCoord->getPlugin('auth');
+ $plugin = jApp::coord()->getPlugin('auth');
if($plugin === null)
throw new jException('jelix~auth.error.plugin.missing');
$config = & $plugin->config;
@@ -152,8 +152,8 @@ protected function _getForm($formId = null) {
* @return string an action selector
*/
protected function _getAction($method){
- global $gJCoord;
- return $gJCoord->action->module.'~'.$gJCoord->action->controller.':'.$method;
+ $act = jApp::coord()->action;
+ return $act->module.'~'.$act->controller.':'.$method;
}
/**
@@ -138,8 +138,8 @@ protected function _getResponse(){
* @return string an action selector
*/
protected function _getAction($method){
- global $gJCoord;
- return $gJCoord->action->module.'~'.$gJCoord->action->controller.':'.$method;
+ $act = jApp::coord()->action;
+ return $act->module.'~'.$act->controller.':'.$method;
}
/**
@@ -26,7 +26,6 @@
* @param array $errcontext
*/
function jErrorHandler($errno, $errmsg, $filename, $linenum, $errcontext){
- global $gJCoord;
if (error_reporting() == 0)
return;
@@ -58,5 +57,5 @@ function jErrorHandler($errno, $errmsg, $filename, $linenum, $errcontext){
$trace = debug_backtrace();
array_shift($trace);
- $gJCoord->handleError($codestr, $errno, $errmsg, $filename, $linenum, $trace);
+ jApp::coord()->handleError($codestr, $errno, $errmsg, $filename, $linenum, $trace);
}
@@ -4,7 +4,7 @@
* @subpackage core
* @author Laurent Jouanneau
* @contributor Sylvain de Vathaire, Julien Issler
-* @copyright 2005-2010 laurent Jouanneau, 2007 Sylvain de Vathaire
+* @copyright 2005-2012 laurent Jouanneau, 2007 Sylvain de Vathaire
* @copyright 2008 Julien Issler
* @link http://www.jelix.org
* @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
@@ -16,9 +16,8 @@
* @param Exception $e the exception object
*/
function jExceptionHandler($e){
- global $gJCoord;
- $gJCoord->handleError('error', $e->getCode(), $e->getMessage(), $e->getFile(),
+ jApp::coord()->handleError('error', $e->getCode(), $e->getMessage(), $e->getFile(),
$e->getLine(), $e->getTrace());
}
@@ -161,7 +161,7 @@ public function isAllowedResponse($response){
* @return jResponse the response object
*/
public function getResponse($type='', $useOriginal = false){
- global $gJCoord;
+
if($type == ''){
$type = $this->defaultResponseType;
}
@@ -171,13 +171,14 @@ public function getResponse($type='', $useOriginal = false){
else
$responses = &jApp::config()->responses;
+ $coord = jApp::coord();
if(!isset($responses[$type])){
- if ($gJCoord->action) {
- $action = $gJCoord->action->resource;
- $path = $gJCoord->action->getPath();
+ if ($coord->action) {
+ $action = $coord->action->resource;
+ $path = $coord->action->getPath();
}
else {
- $action = $gJCoord->moduleName.'~'.$gJCoord->actionName;
+ $action = $coord->moduleName.'~'.$coord->actionName;
$path = '';
}
if ($type == $this->defaultResponseType)
@@ -194,10 +195,10 @@ public function getResponse($type='', $useOriginal = false){
$response = new $respclass();
if (!$this->isAllowedResponse($response)){
- throw new jException('jelix~errors.ad.response.type.notallowed',array($gJCoord->action->resource, $type, $gJCoord->action->getPath()));
+ throw new jException('jelix~errors.ad.response.type.notallowed',array($coord->action->resource, $type, $coord->action->getPath()));
}
- $gJCoord->response = $response;
+ $coord->response = $response;
return $response;
}
@@ -182,27 +182,26 @@ static function get ($actSel, $params = array (), $what=0) {
* @return string the url string
*/
static function getFull ($actSel, $params = array (), $what=0, $domainName = null) {
- global $gJCoord;
$domain = '';
-
+ $req = jApp::coord()->request;
$url = self::get($actSel, $params, ($what != self::XMLSTRING?self::STRING:$what));
if (!preg_match('/^http/', $url)) {
if ($domainName) {
$domain = $domainName;
if (!preg_match('/^http/', $domainName))
- $domain = $gJCoord->request->getProtocol() . $domain;
+ $domain = $req->getProtocol() . $domain;
}
else {
- $domain = $gJCoord->request->getServerURI();
+ $domain = $req->getServerURI();
}
if ($domain == '') {
throw new jException('jelix~errors.urls.domain.void');
}
}
else if ($domainName != '') {
- $url = str_replace($gJCoord->request->getDomainName(), $domainName, $url);
+ $url = str_replace($req->getDomainName(), $domainName, $url);
}
return $domain.$url;
@@ -16,17 +16,18 @@ class jFileLogger implements jILogger {
* @param jILogMessage $message the message to log
*/
function logMessage($message) {
- global $gJCoord;
+
if (!is_writable(jApp::logPath()))
return;
$type = $message->getCategory();
- if ($gJCoord && $gJCoord->request ) {
+ $coord = jApp::coord();
+ if ($coord && $coord->request ) {
$conf = & jApp::config()->fileLogger;
if (!isset($conf[$type]))
return;
$f = $conf[$type];
- $ip = $gJCoord->request->getIP();
+ $ip = $coord->request->getIP();
$f = str_replace('%ip%', $ip , $f);
$f = str_replace('%m%', date("m"), $f);
@@ -92,18 +92,20 @@ public function getTrace() {
* @return string formated error message
*/
public function getFormatedMessage() {
- global $gJCoord;
if (isset($_SERVER['REQUEST_URI']))
$url = $_SERVER['REQUEST_URI'];
elseif(isset($_SERVER['SCRIPT_NAME']))
$url = $_SERVER['SCRIPT_NAME'];
else
$url = 'Unknow request';
+
+ $req = jApp::coord()->request;
+
// url params including module and action
- if ($gJCoord->request) {
- $params = str_replace("\n", ' ', var_export($gJCoord->request->params, true));
- $remoteAddr = $gJCoord->request->getIP();
+ if ($req) {
+ $params = str_replace("\n", ' ', var_export($req->params, true));
+ $remoteAddr = $req->getIP();
}
else {
$params = isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'';
@@ -29,8 +29,8 @@ function logMessage($message) {
* @param jResponse $response
*/
function output($response) {
- global $gJCoord;
- if (!$gJCoord->request)
+
+ if (!jApp::coord()->request)
return;
$email = jApp::config()->mailLogger['email'];
@@ -3,7 +3,7 @@
* @package jelix
* @subpackage core
* @author Laurent Jouanneau
-* @copyright 2006-2010 Laurent Jouanneau
+* @copyright 2006-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
*/
@@ -18,9 +18,8 @@ class jSyslogLogger implements jILogger {
function logMessage($message) {
$type = $message->getCategory();
- global $gJCoord;
- if ($gJCoord->request)
- $ip = $gJCoord->request->getIP();
+ if (jApp::coord()->request)
+ $ip = jApp::coord()->request->getIP();
else
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
@@ -42,10 +42,10 @@ public function output(){
}
public function outputErrors(){
- global $gJCoord;
+
$message = array();
- $message['errorMessage'] = $gJCoord->getGenericErrorMessage();
- $e = $gJCoord->getErrorMessage();
+ $message['errorMessage'] = jApp::coord()->getGenericErrorMessage();
+ $e = jApp::coord()->getErrorMessage();
if($e){
$message['errorCode'] = $e->getCode();
}else{
@@ -38,11 +38,10 @@ public function output(){
return true;
}
- global $gJCoord;
-
$this->_httpHeaders['Content-Type'] = "application/json";
- if($gJCoord->request->jsonRequestId !== null){
- $content = jJsonRpc::encodeResponse($this->response, $gJCoord->request->jsonRequestId);
+ $req = jApp::coord()->request;
+ if($req->jsonRequestId !== null){
+ $content = jJsonRpc::encodeResponse($this->response, $req->jsonRequestId);
$this->_httpHeaders['Content-length'] = strlen($content);
$this->sendHttpHeaders();
echo $content;
@@ -55,24 +54,24 @@ public function output(){
}
public function outputErrors(){
- global $gJCoord;
- $e = $gJCoord->getErrorMessage();
+ $coord = jApp::coord();
+ $e = $coord->getErrorMessage();
if ($e) {
$errorCode = $e->getCode();
if ($errorCode > 5000)
$errorMessage = $e->getMessage();
else
- $errorMessage = $gJCoord->getGenericErrorMessage();
+ $errorMessage = $coord->getGenericErrorMessage();
}
else {
$errorCode = -1;
- $errorMessage = $gJCoord->getGenericErrorMessage();
+ $errorMessage = $coord->getGenericErrorMessage();
}
$this->clearHttpHeaders();
$this->_httpStatusCode ='500';
$this->_httpStatusMsg ='Internal Server Error';
$this->_httpHeaders['Content-Type'] = "application/json";
- $content = jJsonRpc::encodeFaultResponse($errorCode, $errorMessage, $gJCoord->request->jsonRequestId);
+ $content = jJsonRpc::encodeFaultResponse($errorCode, $errorMessage, $coord->request->jsonRequestId);
$this->_httpHeaders['Content-length'] = strlen($content);
$this->sendHttpHeaders();
echo $content;
@@ -129,9 +129,9 @@ public function addUrl($loc, $lastmod = null, $changefreq = null, $priority = nu
if (isset($loc[2048]) || count($this->urlList) >= $this->maxUrl) {
return false;
}
- global $gJCoord;
+
$url = new jSitemapUrl();
- $url->loc = $gJCoord->request->getServerURI() . $loc;
+ $url->loc = jApp::coord()->request->getServerURI() . $loc;
if (($timestamp = strtotime($lastmod))) {
$url->lastmod = date('c', $timestamp);
@@ -159,9 +159,9 @@ public function addSitemap($loc, $lastmod = null) {
if (isset($loc[2048]) || count($this->urlSitemap) >= $this->maxSitemap) {
return false;
}
- global $gJCoord;
+
$sitemap = new jSitemapIndex();
- $sitemap->loc = $gJCoord->request->getServerURI() . $loc;
+ $sitemap->loc = jApp::coord()->request->getServerURI() . $loc;
if (($timestamp = strtotime($lastmod))) {
$sitemap->lastmod = date('c', $timestamp);
@@ -33,27 +33,27 @@ public function output(){
}
public function outputErrors(){
- global $gJCoord;
+ $coord = jApp::coord();
- $e = $gJCoord->getErrorMessage();
+ $e = $coord->getErrorMessage();
if ($e) {
$errorCode = $e->getCode();
if ($errorCode > 5000)
$errorMessage = $e->getMessage();
else
- $errorMessage = $gJCoord->getGenericErrorMessage();
+ $errorMessage = $coord->getGenericErrorMessage();
}
else {
$errorCode = -1;
- $errorMessage = $gJCoord->getGenericErrorMessage();
+ $errorMessage = $coord->getGenericErrorMessage();
}
//soapFault param have to be UTF-8 encoded (soapFault seems to not use the encoding param of the SoapServer)
if(jApp::config()->charset != 'UTF-8'){
$errorCode = utf8_encode($errorCode);
$errorMessage = utf8_encode($errorMessage);
}
- $soapServer = $gJCoord->getSoapServer();
+ $soapServer = $coord->getSoapServer();
$soapServer->fault($errorCode, $errorMessage);
}
}
@@ -43,10 +43,9 @@ public function output(){
}
public function outputErrors(){
- global $gJCoord;
- $errorMessage = $gJCoord->getGenericErrorMessage();
- $e = $gJCoord->getErrorMessage();
+ $errorMessage = jApp::coord()->getGenericErrorMessage();
+ $e = jApp::coord()->getErrorMessage();
if ($e) {
$errorCode = $e->getCode();
}
Oops, something went wrong.

0 comments on commit 1fc5426

Please sign in to comment.