/exchange/code/trunk/administrator/components/com_exchange/helper.php
PHP | 114 lines | 55 code | 8 blank | 51 comment | 4 complexity | 6f30e3a7e182006259e6314c2fbc8134 MD5 | raw file
- <?php
- /**
- * @version $Id: helper.php 280 2010-09-18 02:14:15Z eddieajau $
- * @package NewLifeInIT
- * @subpackage com_exchange
- * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License version 2 or later.
- * @link http://www.theartofjoomla.com
- */
- // no direct access
- defined('_JEXEC') or die;
- /**
- * @package NewLifeInIT
- * @subpackage com_exchange
- * @since 1.0
- */
- class ExchangeLog extends JObject
- {
- /**
- * The internal counter for the number of log messages
- * @var int
- */
- private $count;
- /**
- * An array of messages
- * @var array
- */
- private $logs;
- /**
- * Constructor
- */
- function __construct()
- {
- $this->logs = array();
- $this->count = 0;
- }
- /**
- * Singleton method
- *
- * @return ExchangeLog
- */
- function &getInstance()
- {
- static $instance = null;
- if ($instance == null) {
- $instance = new ExchangeLog;
- }
- return $instance;
- }
- /**
- * Adds a log message
- *
- * @param int A code
- * @param string A message
- * @param boolean True if you are appending to the last message added
- */
- function add($code, $text, $append = false)
- {
- $log = &ExchangeLog::getInstance();
- if ($append && $log->count > 0) {
- $i = $log->count - 1;
- $log->logs[$i]['code'] = $code;
- $log->logs[$i]['text'] .= $text;
- }
- else
- {
- $log->logs[] = array('code' => (int) $code, 'text' => $text);
- $log->count++;
- }
- }
- /**
- * Output the log as an HTML list
- *
- * @return string
- */
- function toHtml()
- {
- $log = &ExchangeLog::getInstance();
- $result = '<ol class="log">';
- foreach ($log->logs as $item)
- {
- $result .= '<li class="c'.$item['code'].'">'.nl2br($item['text']).'</li>';
- }
- $result .= '</ol>';
- return $result;
- }
- }
- /**
- * @package jXExchange
- */
- class XMLHelper
- {
- /**
- * Checks if a string value is boolean true
- *
- * @param mixed A string or integer value
- * @return boolean True is the value is a text or int representation of a boolean
- */
- function isBool($value)
- {
- static $bools = array('yes', '1', 'true', 'y');
- $needle = strtolower(trim($value));
- $result = in_array($needle, $bools);
- return $result;
- }
- }