Changeset 217
- Timestamp:
- 04/26/07 17:55:27 (2 years ago)
- Files:
-
- trunk/config/boot.php (modified) (1 diff)
- trunk/lib/Ak.php (modified) (7 diffs)
- trunk/lib/AkActiveRecord.php (modified) (11 diffs)
- trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php (modified) (2 diffs)
- trunk/lib/AkBaseModel.php (modified) (2 diffs)
- trunk/lib/AkLogger.php (modified) (7 diffs)
- trunk/lib/AkRouter.php (modified) (1 diff)
- trunk/script/generators/controller/templates/functional_test.tpl (modified) (1 diff)
- trunk/script/generators/model/templates/unit_test.tpl (modified) (1 diff)
- trunk/script/generators/scaffold/templates/model_unit_test.tpl (modified) (1 diff)
- trunk/test/unit/lib/AkActionController/_AkActionController_filters.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionController/_AkActionController_locale_detection.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionController/_AkActionController_partials.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/AkActionViewHelper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/TemplateEngines/AkSintags.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/active_record_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/asset_tag_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/capture_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/date_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/file_upload_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/form_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/form_options_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/form_tag_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/javascript_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/javascript_macros_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/menu_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/number_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/pagination_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/prototype_helper.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActionView/helpers/scriptaculous_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/tag_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/text_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionView/helpers/url_helper.php (modified) (1 diff)
- trunk/test/unit/lib/AkActionWebService/AkActionWebServiceApi.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkActsAsList.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkActsAsNestedSet.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkActsAsTree.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkBelongsTo.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkHasAndBelongsToMany.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkHasMany.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkHasOne.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkObserver.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/AkValidation.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_1.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_2.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_3.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_accessible_attributes.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_associated_inclusion.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_calculations.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_i18n.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_locking.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_multiple_inclussion.php (modified) (1 diff)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_table_inheritance.php (modified) (1 diff)
- trunk/test/unit/lib/AkCache.php (modified) (1 diff)
- trunk/test/unit/lib/AkDbSession.php (modified) (1 diff)
- trunk/test/unit/lib/AkImage.php (modified) (1 diff)
- trunk/test/unit/lib/AkInflector.php (modified) (1 diff)
- trunk/test/unit/lib/AkInstaller.php (modified) (1 diff)
- trunk/test/unit/lib/AkLocaleManager.php (modified) (1 diff)
- trunk/test/unit/lib/AkRequest.php (modified) (1 diff)
- trunk/test/unit/lib/AkRouter.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_convert.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_file_functions.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_file_functions_over_ftp.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_object_inspection.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_support_functions.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_var_manipulation.php (modified) (1 diff)
- trunk/vendor/simpletest/mock_objects.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/config/boot.php
r172 r217 196 196 ak_define('MODE_DIE', 16); 197 197 198 ak_define('LOG_EVENTS', false); 198 199 199 200 ak_define('ROUTES_MAPPING_FILE', AK_CONFIG_DIR.DS.'routes.php'); trunk/lib/Ak.php
r204 r217 499 499 function url_get_contents($url, $options = array()) 500 500 { 501 Ak::compat('http_build_query');501 ak_compat('http_build_query'); 502 502 503 503 $default_options = array( … … 733 733 734 734 735 736 /** 737 * Log a system message into the database. 738 * 739 * @param $type The category to which this message belongs. Usually a model or a controller. 740 * @param $message The message to store in the log. 741 * @param $severity The severity of the message. One of the following values: 742 * - AK_LOG_NOTICE 743 * - AK_LOG_WARNING 744 * - AK_LOG_ERROR 745 * @param $link A link to associate with the message. 746 */ 747 function log($type, $message, $severity = AK_LOG_NOTICE, $link = NULL) 748 { 749 $DB =& Ak::db(); 750 $DB->debug=true; 751 752 /** 753 * @todo use a function like Ak::get_user_id() to fetch user id and insert it into the log. 754 * meanwhile we will use user 0; 755 */ 756 $user_id = 0; 757 758 $sql = "INSERT INTO log ( user_id, type, message, severity, link, location, hostname, created ) 759 VALUES (". 760 $user_id.', '. 761 $DB->qstr($type).', '. 762 $DB->qstr($message).', '. 763 $severity.', '. 764 $DB->qstr($link).', '. 765 $DB->qstr(AK_REQUEST_URI).', '. 766 $DB->qstr($_SERVER['REMOTE_ADDR']).', '. 767 $DB->DBTimeStamp(Ak::time()). 768 ');'; 769 if ($DB->Execute($sql) === false) { 770 trigger_error('Error inserting: '.$DB->ErrorMsg(),E_USER_WARNING); 771 } 772 } 773 774 735 function &getLogger() 736 { 737 static $Logger; 738 if(empty($Logger)){ 739 require_once(AK_LIB_DIR.DS.'AkLogger.php'); 740 $Logger =& new AkLogger(); 741 } 742 return $Logger; 743 } 775 744 776 745 … … 1099 1068 switch ($xml_elem['type']) { 1100 1069 case 'open': 1101 $tag_or_id = (array_key_exists ('attributes', $xml_elem)) ? @$xml_elem['attributes']['ID'] : $xml_elem['tag'];1102 $ptrs[$level][$tag_or_id][] = array ();1103 $ptrs[$level+1] = & $ptrs[$level][$tag_or_id][count($ptrs[$level][$tag_or_id])-1];1104 break;1070 $tag_or_id = (array_key_exists ('attributes', $xml_elem)) ? @$xml_elem['attributes']['ID'] : $xml_elem['tag']; 1071 $ptrs[$level][$tag_or_id][] = array (); 1072 $ptrs[$level+1] = & $ptrs[$level][$tag_or_id][count($ptrs[$level][$tag_or_id])-1]; 1073 break; 1105 1074 case 'complete': 1106 $ptrs[$level][$xml_elem['tag']] = (isset ($xml_elem['value'])) ? $xml_elem['value'] : '';1107 break;1075 $ptrs[$level][$xml_elem['tag']] = (isset ($xml_elem['value'])) ? $xml_elem['value'] : ''; 1076 break; 1108 1077 } 1109 1078 } … … 1332 1301 function compat($function_name) 1333 1302 { 1334 if(!function_exists($function_name)){ 1335 require_once(AK_VENDOR_DIR.DS.'pear'.DS.'PHP'.DS.'Compat'.DS.'Function'.DS.$function_name.'.php'); 1336 } 1303 ak_compat($function_name); 1337 1304 } 1338 1305 … … 1608 1575 { 1609 1576 static $mime_types; 1610 Ak::compat('mime_content_type');1577 ak_compat('mime_content_type'); 1611 1578 1612 1579 $mime = mime_content_type($file); … … 1714 1681 function test($test_case_name, $use_sessions = false) 1715 1682 { 1716 if(!defined('ALL_TESTS_CALL')){ 1717 $use_sessions ? @session_start() : null; 1718 $test = &new $test_case_name(); 1719 if (defined('AK_CLI') && AK_CLI || TextReporter::inCli() || (defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE) || (defined('AK_WEB_REQUEST') && !AK_WEB_REQUEST)) { 1720 $test->run(new TextReporter()); 1721 }else{ 1722 $test->run(new HtmlReporter()); 1723 } 1724 } 1683 ak_test($test_case_name, $use_sessions); 1725 1684 } 1726 1685 … … 1785 1744 1786 1745 1746 function ak_test($test_case_name, $use_sessions = false) 1747 { 1748 if(!defined('ALL_TESTS_CALL')){ 1749 $use_sessions ? @session_start() : null; 1750 $test = &new $test_case_name(); 1751 if (defined('AK_CLI') && AK_CLI || TextReporter::inCli() || (defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE) || (defined('AK_WEB_REQUEST') && !AK_WEB_REQUEST)) { 1752 $test->run(new TextReporter()); 1753 }else{ 1754 $test->run(new HtmlReporter()); 1755 } 1756 } 1757 } 1758 1759 function ak_compat($function_name) 1760 { 1761 if(!function_exists($function_name)){ 1762 require_once(AK_VENDOR_DIR.DS.'pear'.DS.'PHP'.DS.'Compat'.DS.'Function'.DS.$function_name.'.php'); 1763 } 1764 } 1765 1766 function ak_generate_mock($name) 1767 { 1768 static $Mock; 1769 if(empty($Mock)){ 1770 $Mock = new Mock(); 1771 } 1772 $Mock->generate($name); 1773 } 1774 1775 1787 1776 AK_PHP5 ? null : eval('function clone($object){return $object;}'); 1788 1777 trunk/lib/AkActiveRecord.php
r214 r217 31 31 ak_define('POST_CODE_REGULAR_EXPRESSION',"/^[0-9A-Za-z -]{2,9}$/"); 32 32 33 Ak::compat('array_combine');33 ak_compat('array_combine'); 34 34 35 35 /** … … 228 228 function init($attributes = array()) 229 229 { 230 AK_LOG_EVENTS ? ($this->Logger =& Ak::getLogger()) : null; 231 230 232 $this->_internationalize = is_null($this->_internationalize) ? count($this->getAvaliableLocales()) > 1 : $this->_internationalize; 231 233 … … 408 410 $this->setConnection(); 409 411 } 412 413 AK_LOG_EVENTS ? ($this->Logger->message($this->getModelName().' executing SQL: '.$sql)) : null; 410 414 $rs = $this->_db->Execute($sql); 411 415 … … 510 514 $sql = 'UPDATE '.$this->getTableName().' SET '.$updates; 511 515 $sql .= isset($conditions) ? ' WHERE '.$conditions : ''; 512 if(!$this->_db->Execute($sql) && AK_DEBUG){ 513 trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE); 514 } 516 $this->_executeSql($sql); 515 517 return $this->_db->Affected_Rows(); 516 518 } … … 577 579 578 580 $sql .= isset($conditions) ? ' WHERE '.$conditions : ($this->_getDatabaseType() == 'sqlite' ? ' WHERE 1' : ''); // (HACK) If where clause is not included sqlite_changes will not get the right result 579 if(!$this->_db->Execute($sql) && AK_DEBUG){ 580 trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE); 581 } 581 $this->_executeSql($sql); 582 582 return $this->_db->Affected_Rows() > 0; 583 583 } … … 621 621 622 622 $sql = 'DELETE FROM '.$this->getTableName().' WHERE '.$this->getPrimaryKey().' = '.$this->_db->qstr($this->getId()); 623 624 if(!$this->_db->Execute($sql) && AK_DEBUG){ 625 trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE); 626 } 623 $this->_executeSql($sql); 627 624 $had_success = ($this->_db->Affected_Rows() > 0); 628 625 if(!$had_success || ($had_success && !$this->afterDestroy())){ … … 1075 1072 } 1076 1073 $this->setConnection(); 1074 1075 AK_LOG_EVENTS ? $this->_startSqlBlockLog() : null; 1076 1077 1077 $objects = array(); 1078 1078 if(is_integer($limit)){ … … 1085 1085 $results = !empty($bindings) ? $this->_db->Execute($sql, $bindings) : $this->_db->Execute($sql); 1086 1086 } 1087 1088 AK_LOG_EVENTS ? $this->_endSqlBlockLog() : null; 1087 1089 1088 1090 if(!$results){ … … 3082 3084 } 3083 3085 3084 if(!$this->_ db->Execute($sql)){3086 if(!$this->_executeSql($sql, false)){ 3085 3087 $this->transactionFail(); 3086 3088 AK_DEBUG ? trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE) : null; … … 3209 3211 'VALUES ('.join(',',array_values($attributes)).')'; 3210 3212 3211 if(!$this->_ db->Execute($sql)){3213 if(!$this->_executeSql($sql, false)){ 3212 3214 AK_DEBUG ? trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE) : null; 3213 3215 } … … 4935 4937 } 4936 4938 } 4939 4937 4940 } 4938 4941 trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php
r173 r217 344 344 } 345 345 $this->setConnection(); 346 347 AK_LOG_EVENTS ? $this->_startSqlBlockLog() : null; 348 346 349 $objects = array(); 347 350 $_included_results = array(); // Used only in conjuntion with virtual limits for doing find('first',...include'=>... … … 362 365 } 363 366 367 AK_LOG_EVENTS ? $this->_endSqlBlockLog() : null; 368 364 369 if(!$results && AK_DEBUG){ 365 370 trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE); trunk/lib/AkBaseModel.php
r111 r217 16 16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html> 17 17 */ 18 19 ak_define('LOG_EVENTS', false); 18 20 19 21 require_once(AK_LIB_DIR.DS.'Ak.php'); … … 144 146 return $models; 145 147 } 148 149 function _executeSql($sql, $trigger_error = true) 150 { 151 AK_LOG_EVENTS ? ($this->Logger->message($this->getModelName().' executing SQL: '.$sql)) : null; 152 if(!$result = $this->_db->Execute($sql) && AK_DEBUG){ 153 AK_LOG_EVENTS ? ($this->Logger->error($this->getModelName().': '.$this->_db->ErrorMsg())) : null; 154 $trigger_error ? trigger_error($this->_db->ErrorMsg(), E_USER_NOTICE) : false; 155 } 156 return $result; 157 } 158 159 function _startSqlBlockLog() 160 { 161 $this->__original_dbug = $this->_db->debug; 162 $this->_db->debug = true; 163 ob_start(); 164 } 165 166 function _endSqlBlockLog() 167 { 168 $sql_debug = ob_get_clean(); 169 $this->Logger->message($this->getModelName().' executing SQL: '.preg_replace('/^\([a-z]+\): /','',trim(Ak::html_entity_decode(strip_tags($sql_debug)),"\n- "))); 170 if($this->__original_dbug){ 171 echo $sql_debug; 172 } 173 $this->_db->debug = $this->__original_dbug; 174 } 146 175 } 147 176 trunk/lib/AkLogger.php
r2 r217 35 35 defined('AK_LOGGER_DEBUG') ? null : define('AK_LOGGER_DEBUG', AK_MODE_FILE | AK_MODE_DISPLAY); 36 36 defined('AK_LOGGER_INFO') ? null : define('AK_LOGGER_INFO', AK_MODE_DISPLAY); 37 defined('AK_LOGGER_MESSAGE') ? null : define('AK_LOGGER_MESSAGE', AK_MODE_ DISPLAY | AK_MODE_FILE);37 defined('AK_LOGGER_MESSAGE') ? null : define('AK_LOGGER_MESSAGE', AK_MODE_FILE); 38 38 defined('AK_LOGGER_NOTICE') ? null : define('AK_LOGGER_NOTICE', AK_MODE_DISPLAY | AK_MODE_FILE | AK_MODE_DIE); 39 39 defined('AK_LOGGER_WARNING') ? null : define('AK_LOGGER_WARNING', AK_MODE_DISPLAY | AK_MODE_FILE | AK_MODE_DIE); … … 53 53 var $_log_params = array(); 54 54 var $print_display_message = true; 55 var $extended_details = true;55 var $extended_details = false; 56 56 var $default_mail_destination = AK_LOGER_DEFAULT_MAIL_DESTINATION; 57 57 var $default_mail_sender = AK_LOGER_DEFAULT_MAIL_SENDER; … … 69 69 $type = strtoupper($type); 70 70 $event_code = empty ($event_code) ? (defined('AK_LOGGER_'.$type) ? 'AK_LOGGER_'.$type : AK_LOGGER_INFO) : $event_code; 71 72 73 $this->_log($message, $error_message, $filename, $line_number, $vars); 71 $this->_log($type, $message, $vars, $event_code); 74 72 } 75 73 … … 109 107 } 110 108 111 function _log($error_ number, $error_message, $filename, $line_number, $vars=array())109 function _log($error_mode, $error_message, $vars=array(), $event_code = null) 112 110 { 113 111 $this->setLogParams($vars); 114 $this->mode = defined('AK_LOG_'.$error_ number) ? constant('AK_LOG_'.$error_number) : $this->default_log_settings;112 $this->mode = defined('AK_LOG_'.$error_mode) ? constant('AK_LOG_'.$error_mode) : $this->default_log_settings; 115 113 $type = $this->log_type; 116 $this->mode & AK_MODE_DISPLAY ? $this->_displayLog($type, $error_ number, $error_message, $filename, $line_number) : null;117 $this->mode & AK_MODE_ MAIL ? $this->_mailLog($type, $error_number, $error_message, $filename, $line_number) : null;118 $this->mode & AK_MODE_ FILE ? $this->_appendLogToFile($type, $error_number, $error_message, $filename, $line_number) : null;119 $this->mode & AK_MODE_ DATABASE ? $this->_saveLogInDatabase($type, $error_number, $error_message, $filename, $line_number) : null;114 $this->mode & AK_MODE_DISPLAY ? $this->_displayLog($type, $error_mode, $error_message) : null; 115 $this->mode & AK_MODE_FILE ? $this->_appendLogToFile($type, $error_mode, $error_message) : null; 116 $this->mode & AK_MODE_DATABASE ? $this->_saveLogInDatabase($type, $error_mode, $error_message) : null; 117 $this->mode & AK_MODE_MAIL ? $this->_mailLog($type, $error_mode, $error_message) : null; 120 118 $this->mode & AK_MODE_DIE ? exit : null; 121 119 } 122 120 123 function _displayLog($type, $error_ number, $error_message, $filename, $line_number)124 { 125 $message = $this->_getLogFormatedAsHtml($type, $error_ number, $error_message, $filename, $line_number);121 function _displayLog($type, $error_mode, $error_message) 122 { 123 $message = $this->_getLogFormatedAsHtml($type, $error_mode, $error_message); 126 124 if($this->print_display_message){ 127 echo $result;125 Ak::trace($message); 128 126 } 129 127 return $message; 130 128 } 131 function _mailLog($type, $error_ number, $error_message, $filename, $line_number)129 function _mailLog($type, $error_mode, $error_message) 132 130 { 133 131 if(!empty($this->default_mail_destination)){ 134 $message = $this->_getLogFormatedAsString($type, $error_ number, $error_message, $filename, $line_number);132 $message = $this->_getLogFormatedAsString($type, $error_mode, $error_message); 135 133 $message = strip_tags(str_replace('<li>',' - ',$message)); 136 134 Ak::mail($this->default_mail_sender, $this->default_mail_destination, $this->default_mail_subject, $message); 137 135 } 138 136 } 139 function _appendLogToFile($type, $error_ number, $error_message, $filename, $line_number)137 function _appendLogToFile($type, $error_mode, $error_message) 140 138 { 141 139 $filename = $this->error_file; 142 143 if (is_writable($filename) || (Ak::file_put_contents(AK_MODE_DIR.DS.$filename.'.log','') && (clearstatcache() && is_writable($filename)))){ 144 $message = $this->_getLogFormatedAsString($type, $error_number, $error_message, $filename, $line_number); 145 if(!$fp = fopen($filename, 'a')) { 146 die($this->internalError($this->t('Cannot open file (%file)', array('%file'=>$filename)),__FILE__,__LINE__)); 140 if(!is_writable($filename)){ 141 clearstatcache(); 142 Ak::file_put_contents($filename,''); 143 if(!is_writable($filename)){ 144 trigger_error($this->internalError($this->t('Error writing file: %filename Description:',array('%filename'=>$filename)).$error_message,__FILE__,__LINE__), E_USER_NOTICE); 145 return ; 147 146 } 148 @flock($fp, LOCK_EX); 149 if (@fwrite($fp, "\r\n".$message) === FALSE) { 150 @flock ($fp, LOCK_UN); 151 die($this->internalError($this->t('Error writing file: %filename Description:',array('%filename'=>$filename)).$error_message,__FILE__,__LINE__)); 152 } 147 } 148 149 $message = $this->_getLogFormatedAsString($type, $error_mode, $error_message); 150 if(!$fp = fopen($filename, 'a')) { 151 die($this->internalError($this->t('Cannot open file (%file)', array('%file'=>$filename)),__FILE__,__LINE__)); 152 } 153 @flock($fp, LOCK_EX); 154 if (@fwrite($fp, $message) === FALSE) { 153 155 @flock ($fp, LOCK_UN); 154 @fclose($fp);155 } else {156 156 die($this->internalError($this->t('Error writing file: %filename Description:',array('%filename'=>$filename)).$error_message,__FILE__,__LINE__)); 157 157 } 158 } 159 160 function _saveLogInDatabase($type, $error_number, $error_message, $filename, $line_number) 158 @flock ($fp, LOCK_UN); 159 @fclose($fp); 160 } 161 162 function _saveLogInDatabase($type, $error_mode, $error_message) 161 163 { 162 164 $db =& Ak::db(); 163 $message = $this->_getLogFormatedAsRawText($type, $error_ number, $error_message, $filename, $line_number);165 $message = $this->_getLogFormatedAsRawText($type, $error_mode, $error_message); 164 166 $sql = 'INSERT INTO log (user_id, type, message, severity, location, hostname, created) '. 165 167 " VALUES (0, ".$db->qstr($type).", ".$db->qstr($message).', '.($this->mode & AK_MODE_DIE ? 100 : 0).', '. … … 170 172 } 171 173 172 function _getLogFormatedAsHtml($type, $error_ number, $error_message, $filename, $line_number)173 { 174 $error_type = $error_ number? 'error' : 'info';175 $message = "\n<div id='logger_$error_type'>\n<p>".$this->t(ucfirst($error_type)).": [$error_ number] - $error_message</p>\n";176 $params = array_merge($this->_log_params, ($this->extended_details ? array(' file'=>$filename, 'line_number'=>$line_number, 'remote_address'=>$_SERVER['REMOTE_ADDR'], 'browser'=>$_SERVER['HTTP_USER_AGENT']) : array() ));174 function _getLogFormatedAsHtml($type, $error_mode, $error_message) 175 { 176 $error_type = $error_mode ? 'error' : 'info'; 177 $message = "\n<div id='logger_$error_type'>\n<p>".$this->t(ucfirst($error_type)).": [$error_mode] - $error_message</p>\n"; 178 $params = array_merge($this->_log_params, ($this->extended_details ? array('remote_address'=>$_SERVER['REMOTE_ADDR'], 'browser'=>$_SERVER['HTTP_USER_AGENT']) : array() )); 177 179 $details = ''; 178 180 foreach ($params as $k=>$v){ … … 182 184 } 183 185 184 function _getLogFormatedAsString($type, $error_ number, $error_message, $filename, $line_number, $serialized = false)185 { 186 $message = Ak::getTimestamp()."\t[$error_number]\t$error_message";187 $params = array_merge($this->_log_params, ($this->extended_details ? array(' file'=>$filename, 'line_number'=>$line_number, 'remote_address'=>$_SERVER['REMOTE_ADDR'], 'browser'=>$_SERVER['HTTP_USER_AGENT']) : array() ));186 function _getLogFormatedAsString($type, $error_mode, $error_message, $serialized = false) 187 { 188 $message = date('r')."\t[$error_mode]\t$error_message"; 189 $params = array_merge($this->_log_params, ($this->extended_details ? array('remote_address'=>$_SERVER['REMOTE_ADDR'], 'browser'=>$_SERVER['HTTP_USER_AGENT']) : array() )); 188 190 189 191 if($serialized){ … … 199 201 } 200 202 201 function _getLogFormatedAsRawText($type, $error_ number, $error_message, $filename, $line_number)202 { 203 return $this->_getLogFormatedAsString($type, $error_ number, $error_message, $filename, $line_number, true);203 function _getLogFormatedAsRawText($type, $error_mode, $error_message) 204 { 205 return $this->_getLogFormatedAsString($type, $error_mode, $error_message, $filename, $line_number, true); 204 206 } 205 207 trunk/lib/AkRouter.php
r154 r217 9 9 // +----------------------------------------------------------------------+ 10 10 11 Ak::compat('http_build_query');11 ak_compat('http_build_query'); 12 12 13 13 /** trunk/script/generators/controller/templates/functional_test.tpl
r155 r217 14 14 15 15 16 Ak::test('<?php echo $class_name?>ControllerTest',true);16 ak_test('<?php echo $class_name?>ControllerTest',true); 17 17 18 18 ?> trunk/script/generators/model/templates/unit_test.tpl
r155 r217 24 24 25 25 26 Ak::test('<?php echo $class_name?>Test',true);26 ak_test('<?php echo $class_name?>Test',true); 27 27 28 28 ?> trunk/script/generators/scaffold/templates/model_unit_test.tpl
r155 r217 24 24 25 25 26 Ak::test('<?php echo $model_name?>Test',true);26 ak_test('<?php echo $model_name?>Test',true); 27 27 28 28 ?> trunk/test/unit/lib/AkActionController/_AkActionController_filters.php
r126 r217 334 334 if(!defined('ALL_TESTS_CALL')){ 335 335 ob_start(); 336 Ak::test('Test_of_AkActionControllerFilters');336 ak_test('Test_of_AkActionControllerFilters'); 337 337 ob_end_flush(); 338 338 } trunk/test/unit/lib/AkActionController/_AkActionController_locale_detection.php
r126 r217 87 87 } 88 88 89 Ak::test('_AkActionController_locale_detection');89 ak_test('_AkActionController_locale_detection'); 90 90 91 91 ?> trunk/test/unit/lib/AkActionController/_AkActionController_partials.php
r126 r217 62 62 } 63 63 64 Ak::test('Test_of_AkActionController_partials');64 ak_test('Test_of_AkActionController_partials'); 65 65 66 66 trunk/test/unit/lib/AkActionView/AkActionViewHelper.php
r2 r217 10 10 11 11 12 Ak::test('test_AkActionViewHelper',true);12 ak_test('test_AkActionViewHelper',true); 13 13 14 14 ?> trunk/test/unit/lib/AkActionView/TemplateEngines/AkSintags.php
r149 r217 58 58 59 59 60 Ak::test('Test_of_AkSintags');60 ak_test('Test_of_AkSintags'); 61 61 62 62 ?> trunk/test/unit/lib/AkActionView/helpers/active_record_helper.php
r211 r217 11 11 require_once(AK_LIB_DIR.DS.'AkRequest.php'); 12 12 13 Mock::generate('AkRequest');13 ak_generate_mock('AkRequest'); 14 14 15 15 … … 110 110 111 111 112 Ak::test('ActiveRecordHelperTests');112 ak_test('ActiveRecordHelperTests'); 113 113 114 114 ?> trunk/test/unit/lib/AkActionView/helpers/asset_tag_helper.php
r205 r217 5 5 require_once(AK_LIB_DIR.DS.'AkRequest.php'); 6 6 7 Mock::generate('AkRequest');7 ak_generate_mock('AkRequest'); 8 8 9 9 class AssetTagHelperTests extends HelpersUnitTester … … 183 183 } 184 184 185 Ak::test('AssetTagHelperTests');185 ak_test('AssetTagHelperTests'); 186 186 187 187 ?> trunk/test/unit/lib/AkActionView/helpers/capture_helper.php
r206 r217 7 7 require_once(AK_LIB_DIR.DS.'AkRequest.php'); 8 8 9 Mock::generate('AkRequest');9 ak_generate_mock('AkRequest'); 10 10 11 11 … … 54 54 55 55 56 Ak::test('CaptureHelperTests');56 ak_test('CaptureHelperTests'); 57 57 58 58 ?> trunk/test/unit/lib/AkActionView/helpers/date_helper.php
r208 r217 119 119 } 120 120 121 Ak::test('DateHelperTests');121 ak_test('DateHelperTests'); 122 122 123 123 ?> trunk/test/unit/lib/AkActionView/helpers/file_upload_helper.php
r2 r217 18 18 19 19 20 Ak::test('FileUploadHelperTests');20 ak_test('FileUploadHelperTests'); 21 21 22 22 ?> trunk/test/unit/lib/AkActionView/helpers/form_helper.php
r208 r217 253 253 } 254 254 255 Ak::test('FormHelperTests', true);255 ak_test('FormHelperTests', true); 256 256 257 257 ?> trunk/test/unit/lib/AkActionView/helpers/form_options_helper.php
r212 r217 306 306 } 307 307 308 Ak::test('FormOptionsHelperTests', true);308 ak_test('FormOptionsHelperTests', true); 309 309 310 310 ?> trunk/test/unit/lib/AkActionView/helpers/form_tag_helper.php
r160 r217 43 43 } 44 44 45 Ak::test('FormTagHelperTests');45 ak_test('FormTagHelperTests'); 46 46 47 47 ?> trunk/test/unit/lib/AkActionView/helpers/javascript_helper.php
r200 r217 53 53 54 54 55 Ak::test('JavaScriptHelperTests');55 ak_test('JavaScriptHelperTests'); 56 56 57 57 ?> trunk/test/unit/lib/AkActionView/helpers/javascript_macros_helper.php
r208 r217 6 6 require_once(AK_LIB_DIR.DS.'AkRequest.php'); 7 7 8 Mock::generate('AkRequest');8 ak_generate_mock('AkRequest'); 9 9 10 10 … … 74 74 75 75 76 Ak::test('JavaScriptMacrosHelperTests');76 ak_test('JavaScriptMacrosHelperTests'); 77 77 78 78 ?> trunk/test/unit/lib/AkActionView/helpers/menu_helper.php
r210 r217 7 7 require_once(AK_CONTROLLERS_DIR.DS.'..'.DS.'application_controller.php'); 8 8 9 Mock::generate('AkRequest');9 ak_generate_mock('AkRequest'); 10 10 11 11 class MenuHelperTests extends HelpersUnitTester … … 73 73 } 74 74 75 Ak::test('MenuHelperTests');75 ak_test('MenuHelperTests'); 76 76 77 77 ?> trunk/test/unit/lib/AkActionView/helpers/number_helper.php
r2 r217 55 55 56 56 57 Ak::test('NumberHelperTests');57 ak_test('NumberHelperTests'); 58 58 59 59 ?> trunk/test/unit/lib/AkActionView/helpers/pagination_helper.php
r2 r217 18 18 19 19 20 Ak::test('PaginationHelperTests');20 ak_test('PaginationHelperTests'); 21 21 22 22 ?> trunk/test/unit/lib/AkActionView/helpers/prototype_helper.php
r199 r217 6 6 require_once(AK_LIB_DIR.DS.'AkRequest.php'); 7 7 8 Mock::generate('AkRequest');8 ak_generate_mock('AkRequest'); 9 9 10 10 class PrototypeHelperTests extends HelpersUnitTester … … 138 138 } 139 139 140 Ak::test('PrototypeHelperTests');
