[ghelda-devel] [11] Add the debugging logger and correct a bunch of 'notice' errors.

[ Thread Index | Date Index | More lists.tuxfamily.org/ghelda-devel Archives ]


Revision: 11
Author:   odyx
Date:     2009-03-04 17:27:40 +0100 (Wed, 04 Mar 2009)

Log Message:
-----------
Add the debugging logger and correct a bunch of 'notice' errors.

Modified Paths:
--------------
    trunk/inc/outputs/xHTML.class.php
    trunk/init/log.php
    trunk/plugins/People.php


Modified: trunk/inc/outputs/xHTML.class.php
===================================================================
--- trunk/inc/outputs/xHTML.class.php	2009-03-04 14:28:16 UTC (rev 10)
+++ trunk/inc/outputs/xHTML.class.php	2009-03-04 16:27:40 UTC (rev 11)
@@ -205,6 +205,7 @@
 	public function error_box($errors_array = array())
 	{
 		global $errorLevels;
+		$buffer = '';
 		foreach($errors_array as $error) {
 			$message = $error[0];
 			$priority = $errorLevels[$error[1]];
@@ -221,6 +222,8 @@
 	{	
 		// Get the global variables about locales
 		global $g_GT_supportedLocales,$g_GT_locale;
+
+		$localesBox = '';
 		// Go through the available locales
 		foreach($g_GT_supportedLocales as $locale) {
 			// Get the native language name (or the two first letters) : en_US.UTF-8 => "english" or "en"
@@ -297,6 +300,8 @@
 		// Ensure that the translation is correctly handled in the core.
 		$oldDomain = g_setDomain('g_core');
 
+		$formular = '';
+
 		//* $options = array( 
 		if(!array_key_exists('id',$options))		$options['id']		= 'NOID';
 		if(!array_key_exists('command',$options))	$options['command']	= 'Execute';
@@ -307,8 +312,8 @@
 			$formular = $this->tag('h2',$options['title']);
 
 		
-		$submit  = $this->stag('input',array('type'=>'submit',	'value'=>$options['command']));
-		$fields .= $this->mark('p',$submit);
+		$submit = $this->stag('input',array('type'=>'submit',	'value'=>$options['command']));
+		$fields = $this->mark('p',$submit);
 
 		// Initialise the $formKey
 		$formKey = array('name' => 'ERROR', 'value' => 'ERROR');
@@ -332,12 +337,12 @@
 				$fieldName = $pluginName.'_'.$fieldName_;
 
 				// Jump the complete 'id' fields
-				if($fieldProperties['restricted'] == 'key') {	/* == 'id' */
+				if(array_key_exists('restricted',$fieldProperties) && $fieldProperties['restricted'] == 'key') {	/* == 'id' */
 					$formKey = array('name' => $fieldName, 'value' => $fieldsContents[$fieldName_]);
 					continue;
 				}
 				// Jump the "no-show" fields
-				if($fieldProperties['noShow'] === true) continue;
+				if(array_key_exists('noShow',$fieldProperties) && $fieldProperties['noShow'] === true) continue;
 				// Initialize the parameters
 				$paramsArray = array();
 				// Get the maximum length
@@ -346,7 +351,7 @@
 
 				if(!empty($maxlength)) $paramsArray['maxlength'] = $maxlength;
 				// Treat the eventual error (TODO: rise a corresponding error).
-				if($fieldProperties['error']) $paramsArray['class'] = 'input_error';
+				if(array_key_exists('error',$fieldProperties) && $fieldProperties['error']) $paramsArray['class'] = 'input_error';
 	
 				if($fieldName_ == 'password') {
 					$label = $this->tag('label',$fieldProperties['name'][0],array('for'=>$fieldName));
@@ -394,10 +399,12 @@
 					$paramsArray['id']   = $fieldName;
 					$paramsArray['value']= !empty($fieldsContents[$fieldName_]) ? $fieldsContents[$fieldName_] : $fieldProperties['default'];
 	
-					// Additional parameters
-					if($fieldProperties['restricted'] == 'key')	$paramsArray['disabled'] = 'disabled'; 
-					if($fieldProperties['restricted'] == 'unique')	$paramsArray['disabled'] = 'disabled';
-					
+					if(array_key_exists('restricted',$fieldProperties)) {
+						// Additional parameters
+						if($fieldProperties['restricted'] == 'key')	$paramsArray['disabled'] = 'disabled'; 
+						if($fieldProperties['restricted'] == 'unique')	$paramsArray['disabled'] = 'disabled';
+					}
+
 					// Put the field
 					$field = $this->stag('input',$paramsArray);
 					// Add the "_old" hidden stag
@@ -507,6 +514,7 @@
 		$oldQS = $this->url->querystring;
 		// Use a pristine querystring
 		$this->url->querystring = '';
+		$modules = '';
 		// Go along all the plugins
 		foreach($targets as $plugin => $pluginMenu) {
 			$this->url->addQueryString('plugin',$plugin);
@@ -580,21 +588,23 @@
 	private function textarea($code,$attributes_array = array(),$do_break = false,$do_echo = false)
 	{
 		$mark = 'textarea';
+		$attributes = '';
 		foreach($attributes_array as $aa_key => $aa_value) {
 			$attributes .= ' '.$aa_key.'="'.htmlspecialchars($aa_value).'"';
 		}
-
+		$LB = '';
 		if($do_break) $LB = LB;
 
 		return $this->echo_("<$mark$attributes>".$code."</$mark>".$LB,0,$do_echo);
 	}
 
 	private function tag($mark,$code,$attributes_array = array(),$do_break = false,$do_echo = false)
-	{
+	{	
+		$attributes = '';
 		foreach($attributes_array as $aa_key => $aa_value) {
 			$attributes .= ' '.$aa_key.'="'.htmlspecialchars($aa_value).'"';
 		}
-
+		$LB = '';
 		if($do_break) $LB = LB;
 
 		return $this->echo_("<$mark$attributes>".$code."</$mark>".$LB,0,$do_echo);
@@ -602,6 +612,7 @@
 
 	private function stag($smark,$attributes_array = array(),$do_break = false,$do_echo = false)
 	{
+		$attributes = '';
 		foreach($attributes_array as $aa_key => $aa_value) {
 			$attributes .= ' '.$aa_key.'="'.htmlspecialchars($aa_value).'"';
 		}
@@ -614,6 +625,7 @@
 	
 	private function mark($tag,$code,$attributes_array = array(),$do_echo = false, $do_indent = true)
 	{
+		$attributes = '';
 		foreach($attributes_array as $aa_key => $aa_value) {
 			$attributes .= ' '.$aa_key.'="'.htmlspecialchars($aa_value).'"';
 		}
@@ -631,6 +643,7 @@
 		if(is_string($options_selected)) $options_selected = array($options_selected);
 
 		if( $optgroups === false ) {
+			$optionsTxt = '';
 			// Go through all the options and draw the correct section
 			foreach($options as $value => $name) {
 				// Set the value iff the value is different
@@ -643,12 +656,13 @@
 			}
 		} else {
 			// Go along all the optgroups
+			$optionsTxt = '';
 			foreach($options as $optgroup_id => $optgroup) {
 				$opt_name = $optgroup['name'];
 				$options = $optgroup['values'];
 
 				$opt_attributes['label'] = $opt_name;
-				unset($optionsInTxt);
+				$optionsInTxt = '';
 				// Go through all the options and draw the correct section
 				foreach($options as $value => $name) {
 					// Set the value iff the value is different
@@ -671,7 +685,7 @@
 		$label = $this->tag('label',$fieldProperties['name'],array('for'=>$fieldName.'_year'));
 		$formattedDate = T_('%YEAR%-%MONTH%-%DAY%');
 		preg_match("`([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})`", $fieldContent, $regs);
-		$dateOptions = $fieldProperties['error'] ? array("class" => "input_error") : array();
+		$dateOptions = array_key_exists('error',$fieldProperties) ? ($fieldProperties['error'] ? array("class" => "input_error") : array() ) : array();
 		// Get the global lists
 		global $DAYS,$MONTHS,$YEARS;
 		$year  = $this->select($YEARS,$regs[1],array_merge($paramsArray,array('name'=>$fieldName.'_year')));

Modified: trunk/init/log.php
===================================================================
--- trunk/init/log.php	2009-03-04 14:28:16 UTC (rev 10)
+++ trunk/init/log.php	2009-03-04 16:27:40 UTC (rev 11)
@@ -27,18 +27,27 @@
 define('G_E_DISPLAY',E_USER_ERROR);
 //! Standard error level for errors to be logged
 define('G_E_LOG',E_USER_WARNING);
+//! Standard error level for errors to be logged
+define('G_E_DEBUG',E_USER_NOTICE);
 
 //! Create a composite log handler 
 $Logger = &Log::singleton('composite');
 
-//! Add to it the file logger
-$g_H_FileLogger = &Log::singleton('file', 'log/'.date('Ymd').'.log', 'G', array('mode' => 0666, 'timeFormat' => '%T', 'lineFormat' => '%1$s %4$s'),PEAR_LOG_WARNING);
-$Logger->addChild($g_H_FileLogger);
-
+//! If the debug/ folder exists, add a singleton for logging
 //! Add to it the display logger
 $g_H_DisplayLogger = &Log::singleton('Display','DisplayLogger','Ghelda',array(),PEAR_LOG_ERR);
 $Logger->addChild($g_H_DisplayLogger);
 
+//! Add to it the file logger
+$g_H_FileLogger = &Log::singleton('file', 'log/'.date('Ymd').'.log', 'G', array('mode' => 0666, 'timeFormat' => '%T', 'lineFormat' => '%{message}'),PEAR_LOG_WARNING);
+$Logger->addChild($g_H_FileLogger);
+
+//! If the debug/ folder exists, add a singleton for logging
+if( is_dir('debug') ) {
+	$g_H_FileLogger = &Log::singleton('file', 'debug/'.date('Ymd').'.log', 'G', array('mode' => 0666, 'timeFormat' => '%T', 'lineFormat' => '%{priority} %{message}'),PEAR_LOG_NOTICE);
+	$Logger->addChild($g_H_FileLogger);
+}
+
 // Require both errors handlers
 require_once "inc/error_handlers.php";
 

Modified: trunk/plugins/People.php
===================================================================
--- trunk/plugins/People.php	2009-03-04 14:28:16 UTC (rev 10)
+++ trunk/plugins/People.php	2009-03-04 16:27:40 UTC (rev 11)
@@ -140,6 +140,7 @@
 			// Get the fields from the keyed array
 			$fields = array_keys($fieldsSpec);
 
+			$formattedFields = '';
 			// Go along the fields
 			foreach($fields as $fieldName_) {
 				$fieldName = $this->name.'_'.$fieldName_;
@@ -151,7 +152,7 @@
 				}
 				// Get the type of the field and store its value
 				$type = $fieldsSpec[$fieldName_]['type'];
-				$fieldValue = $_POST[$fieldName];
+				$fieldValue = array_key_exists($fieldName,$_POST) ? $_POST[$fieldName] : '';
 
 				// Jump id (No insert nor check)
 				if($fieldName_ == G_DB_PEOPLE_ID ) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/