summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Javascript.php2
-rw-r--r--system/libraries/Table.php138
-rw-r--r--system/libraries/Trackback.php9
-rw-r--r--system/libraries/Upload.php12
-rw-r--r--system/libraries/Xmlrpc.php12
-rw-r--r--system/libraries/Xmlrpcs.php6
-rw-r--r--system/libraries/javascript/Jquery.php (renamed from system/libraries/Jquery.php)2
7 files changed, 141 insertions, 40 deletions
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 3b7dcc6ff..af85e6509 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -23,7 +23,7 @@ class CI_Javascript {
$this->CI =& get_instance();
// load the requested js library
- $this->CI->load->library($js_library_driver, array('autoload' => $autoload));
+ $this->CI->load->library('javsacript/'.$js_library_driver, array('autoload' => $autoload));
// make js to refer to current library
$this->js =& $this->CI->$js_library_driver;
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 6d36121f2..1f920ea9e 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -35,7 +35,7 @@ class CI_Table {
var $template = NULL;
var $newline = "\n";
var $empty_cells = "";
-
+ var $function = FALSE;
function CI_Table()
{
@@ -75,7 +75,7 @@ class CI_Table {
function set_heading()
{
$args = func_get_args();
- $this->heading = (is_array($args[0])) ? $args[0] : $args;
+ $this->heading = $this->_prep_args($args);
}
// --------------------------------------------------------------------
@@ -110,7 +110,7 @@ class CI_Table {
$new = array();
while(count($array) > 0)
{
- $temp = array_splice($array, 0, $col_limit);
+ $temp = array_splice($array, 0, $col_limit);
if (count($temp) < $col_limit)
{
@@ -156,11 +156,59 @@ class CI_Table {
function add_row()
{
$args = func_get_args();
- $this->rows[] = (is_array($args[0])) ? $args[0] : $args;
+ $this->rows[] = $this->_prep_args($args);
}
// --------------------------------------------------------------------
+
+ /**
+ * Prep Args
+ *
+ * Ensures a standard associative array format for all cell data
+ *
+ * @access public
+ * @param type
+ * @return type
+ */
+ function _prep_args($args)
+ {
+ // If there is no $args[0], skip this and treat as an associative array
+ // This can happen if there is only a single key, for example this is passed to table->generate
+ // array(array('foo'=>'bar'))
+ if (isset($args[0]) AND (count($args) == 1 && is_array($args[0])))
+ {
+ // args sent as indexed array
+ if ( ! isset($args[0]['data']))
+ {
+ foreach ($args[0] as $key => $val)
+ {
+ if (is_array($val) && isset($val['data']))
+ {
+ $args[$key] = $val;
+ }
+ else
+ {
+ $args[$key] = array('data' => $val);
+ }
+ }
+ }
+ }
+ else
+ {
+ foreach ($args as $key => $val)
+ {
+ if ( ! is_array($val))
+ {
+ $args[$key] = array('data' => $val);
+ }
+ }
+ }
+
+ return $args;
+ }
+ // --------------------------------------------------------------------
+
/**
* Add a table caption
*
@@ -208,7 +256,9 @@ class CI_Table {
// Compile and validate the template date
$this->_compile_template();
-
+ // set a custom cell manipulation function to a locally scoped variable so its callable
+ $function = $this->function;
+
// Build the table!
$out = $this->template['table_open'];
@@ -225,23 +275,40 @@ class CI_Table {
// Is there a table heading to display?
if (count($this->heading) > 0)
{
+ $out .= $this->template['thead_open'];
+ $out .= $this->newline;
$out .= $this->template['heading_row_start'];
- $out .= $this->newline;
+ $out .= $this->newline;
foreach($this->heading as $heading)
{
- $out .= $this->template['heading_cell_start'];
- $out .= $heading;
+ $temp = $this->template['heading_cell_start'];
+
+ foreach ($heading as $key => $val)
+ {
+ if ($key != 'data')
+ {
+ $temp = str_replace('<th', "<th $key='$val'", $temp);
+ }
+ }
+
+ $out .= $temp;
+ $out .= isset($heading['data']) ? $heading['data'] : '';
$out .= $this->template['heading_cell_end'];
}
$out .= $this->template['heading_row_end'];
- $out .= $this->newline;
+ $out .= $this->newline;
+ $out .= $this->template['thead_close'];
+ $out .= $this->newline;
}
-
+
// Build the table rows
if (count($this->rows) > 0)
{
+ $out .= $this->template['tbody_open'];
+ $out .= $this->newline;
+
$i = 1;
foreach($this->rows as $row)
{
@@ -258,15 +325,33 @@ class CI_Table {
foreach($row as $cell)
{
- $out .= $this->template['cell_'.$name.'start'];
+ $temp = $this->template['cell_'.$name.'start'];
+
+ foreach ($cell as $key => $val)
+ {
+ if ($key != 'data')
+ {
+ $temp = str_replace('<td', "<td $key='$val'", $temp);
+ }
+ }
+ $cell = isset($cell['data']) ? $cell['data'] : '';
+ $out .= $temp;
+
if ($cell === "" OR $cell === NULL)
{
$out .= $this->empty_cells;
}
else
{
- $out .= $cell;
+ if ($function !== FALSE && is_callable($function))
+ {
+ $out .= $function($cell);
+ }
+ else
+ {
+ $out .= $cell;
+ }
}
$out .= $this->template['cell_'.$name.'end'];
@@ -275,6 +360,9 @@ class CI_Table {
$out .= $this->template['row_'.$name.'end'];
$out .= $this->newline;
}
+
+ $out .= $this->template['tbody_close'];
+ $out .= $this->newline;
}
$out .= $this->template['table_close'];
@@ -321,7 +409,7 @@ class CI_Table {
return FALSE;
}
- $this->heading = $query->list_fields();
+ $this->heading = $this->_prep_args($query->list_fields());
}
// Next blast through the result array and build out the rows
@@ -330,7 +418,7 @@ class CI_Table {
{
foreach ($query->result_array() as $row)
{
- $this->rows[] = $row;
+ $this->rows[] = $this->_prep_args($row);
}
}
}
@@ -353,21 +441,15 @@ class CI_Table {
$i = 0;
foreach ($data as $row)
- {
- if ( ! is_array($row))
- {
- $this->rows[] = $data;
- break;
- }
-
+ {
// If a heading hasn't already been set we'll use the first row of the array as the heading
if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE)
{
- $this->heading = $row;
+ $this->heading = $this->_prep_args($row);
}
else
{
- $this->rows[] = $row;
+ $this->rows[] = $this->_prep_args($row);
}
$i++;
@@ -391,7 +473,7 @@ class CI_Table {
}
$this->temp = $this->_default_template();
- foreach (array('table_open','heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
+ foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
{
if ( ! isset($this->template[$val]))
{
@@ -412,12 +494,18 @@ class CI_Table {
{
return array (
'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
-
+
+ 'thead_open' => '<thead>',
+ 'thead_close' => '</thead>',
+
'heading_row_start' => '<tr>',
'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
+ 'tbody_open' => '<tbody>',
+ 'tbody_close' => '</tbody>',
+
'row_start' => '<tr>',
'row_end' => '</tr>',
'cell_start' => '<td>',
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 9b1737c5f..a604c0b2d 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -128,7 +128,7 @@ class CI_Trackback {
* Receive Trackback Data
*
* This function simply validates the incoming TB data.
- * It returns false on failure and true on success.
+ * It returns FALSE on failure and TRUE on success.
* If the data is valid it is set to the $this->data array
* so that it can be inserted into a database.
*
@@ -221,7 +221,7 @@ class CI_Trackback {
* Process Trackback
*
* Opens a socket connection and passes the data to
- * the server. Returns true on success, false on failure
+ * the server. Returns TRUE on success, FALSE on failure
*
* @access public
* @param string
@@ -267,6 +267,7 @@ class CI_Trackback {
}
@fclose($fp);
+
if (stristr($this->response, '<error>0</error>') === FALSE)
{
$message = 'An unknown error was encountered';
@@ -383,7 +384,7 @@ class CI_Trackback {
if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
{
- return false;
+ return FALSE;
}
else
{
@@ -436,7 +437,7 @@ class CI_Trackback {
{
return $str;
}
-
+
$str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
if (strlen($str) <= $n)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 5ff478269..ac9323c08 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -454,6 +454,11 @@ class CI_Upload {
*/
function set_allowed_types($types)
{
+ if ( ! is_array($types) && $types == '*')
+ {
+ $this->allowed_types = '*';
+ return;
+ }
$this->allowed_types = explode('|', $types);
}
@@ -551,6 +556,11 @@ class CI_Upload {
*/
function is_allowed_filetype()
{
+ if ($this->allowed_types == '*')
+ {
+ return TRUE;
+ }
+
if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types');
@@ -805,7 +815,7 @@ class CI_Upload {
}
$CI =& get_instance();
- $data = $CI->input->xss_clean($data);
+ $data = $CI->security->xss_clean($data);
flock($fp, LOCK_EX);
fwrite($fp, $data);
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 5a82391dd..c46d52cdb 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -513,7 +513,7 @@ class XML_RPC_Response
}
else
{
- $array[$key] = $CI->input->xss_clean($array[$key]);
+ $array[$key] = $CI->security->xss_clean($array[$key]);
}
}
@@ -529,7 +529,7 @@ class XML_RPC_Response
}
else
{
- $result = $CI->input->xss_clean($result);
+ $result = $CI->security->xss_clean($result);
}
}
@@ -1127,7 +1127,9 @@ class XML_RPC_Message extends CI_Xmlrpc
}
else
{
- $array[$key] = $CI->input->xss_clean($array[$key]);
+ // 'bits' is for the MetaWeblog API image bits
+ // @todo - this needs to be made more general purpose
+ $array[$key] = ($key == 'bits') ? $array[$key] : $CI->security->xss_clean($array[$key]);
}
}
@@ -1147,7 +1149,7 @@ class XML_RPC_Message extends CI_Xmlrpc
}
else
{
- $parameters[] = $CI->input->xss_clean($a_param);
+ $parameters[] = $CI->security->xss_clean($a_param);
}
}
}
@@ -1322,7 +1324,7 @@ class XML_RPC_Values extends CI_Xmlrpc
function serializedata($typ, $val)
{
$rs = '';
-
+
switch($this->xmlrpcTypes[$typ])
{
case 3:
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 429ab8472..fe1c99bf5 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -40,10 +40,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc
var $debug_msg = ''; // Debug Message
var $system_methods = array(); // XML RPC Server methods
var $controller_obj;
-
- var $object = FALSE;
-
+ var $object = FALSE;
+
+
//-------------------------------------
// Constructor, more or less
//-------------------------------------
diff --git a/system/libraries/Jquery.php b/system/libraries/javascript/Jquery.php
index c63a74239..f6b8dce69 100644
--- a/system/libraries/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -24,7 +24,7 @@
* @link http://www.codeigniter.com/user_guide/libraries/jquery.html
*/
-class Jquery extends CI_Javascript {
+class CI_Jquery extends CI_Javascript {
var $_javascript_folder = 'js';
var $jquery_code_for_load = array();