summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/libraries')
-rw-r--r--user_guide_src/source/libraries/calendar.rst4
-rw-r--r--user_guide_src/source/libraries/cart.rst170
-rw-r--r--user_guide_src/source/libraries/pagination.rst8
-rw-r--r--user_guide_src/source/libraries/table.rst2
-rw-r--r--user_guide_src/source/libraries/xmlrpc.rst131
5 files changed, 175 insertions, 140 deletions
diff --git a/user_guide_src/source/libraries/calendar.rst b/user_guide_src/source/libraries/calendar.rst
index 65a447a3d..2263aa404 100644
--- a/user_guide_src/source/libraries/calendar.rst
+++ b/user_guide_src/source/libraries/calendar.rst
@@ -248,14 +248,14 @@ Class Reference
you submit 13 as the month, the year will increment and the month will
become January::
- print_r($this->calendar->adjust_date(13, 2013));
+ print_r($this->calendar->adjust_date(13, 2014));
outputs::
Array
(    
[month] => '01'
- [year] => '2014'
+ [year] => '2015'
)
.. method:: get_total_days($month, $year)
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index fb92c280a..d7d495967 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -33,7 +33,7 @@ Initializing the Shopping Cart Class
utilize a database.
To initialize the Shopping Cart Class in your controller constructor,
-use the $this->load->library function::
+use the ``$this->load->library()`` method::
$this->load->library('cart');
@@ -49,16 +49,16 @@ Adding an Item to The Cart
==========================
To add an item to the shopping cart, simply pass an array with the
-product information to the $this->cart->insert() function, as shown
+product information to the ``$this->cart->insert()`` method, as shown
below::
$data = array(
- 'id' => 'sku_123ABC',
- 'qty' => 1,
- 'price' => 39.95,
- 'name' => 'T-Shirt',
- 'options' => array('Size' => 'L', 'Color' => 'Red')
- );
+ 'id' => 'sku_123ABC',
+ 'qty' => 1,
+ 'price' => 39.95,
+ 'name' => 'T-Shirt',
+ 'options' => array('Size' => 'L', 'Color' => 'Red')
+ );
$this->cart->insert($data);
@@ -88,7 +88,19 @@ array will be stored in the session. However, it is best to standardize
your data among all your products in order to make displaying the
information in a table easier.
-The insert() method will return the $rowid if you successfully insert a
+::
+
+ $data = array(
+ 'id' => 'sku_123ABC',
+ 'qty' => 1,
+ 'price' => 39.95,
+ 'name' => 'T-Shirt',
+ 'coupon' => 'XMAS-50OFF'
+ );
+
+ $this->cart->insert($data);
+
+The ``insert()`` method will return the $rowid if you successfully insert a
single item.
Adding Multiple Items to The Cart
@@ -102,26 +114,26 @@ same page.
::
$data = array(
- array(
- 'id' => 'sku_123ABC',
- 'qty' => 1,
- 'price' => 39.95,
- 'name' => 'T-Shirt',
- 'options' => array('Size' => 'L', 'Color' => 'Red')
- ),
- array(
- 'id' => 'sku_567ZYX',
- 'qty' => 1,
- 'price' => 9.95,
- 'name' => 'Coffee Mug'
- ),
- array(
- 'id' => 'sku_965QRS',
- 'qty' => 1,
- 'price' => 29.95,
- 'name' => 'Shot Glass'
- )
- );
+ array(
+ 'id' => 'sku_123ABC',
+ 'qty' => 1,
+ 'price' => 39.95,
+ 'name' => 'T-Shirt',
+ 'options' => array('Size' => 'L', 'Color' => 'Red')
+ ),
+ array(
+ 'id' => 'sku_567ZYX',
+ 'qty' => 1,
+ 'price' => 9.95,
+ 'name' => 'Coffee Mug'
+ ),
+ array(
+ 'id' => 'sku_965QRS',
+ 'qty' => 1,
+ 'price' => 29.95,
+ 'name' => 'Shot Glass'
+ )
+ );
$this->cart->insert($data);
@@ -136,15 +148,15 @@ helper </helpers/form_helper>`.
::
- <?php echo form_open('path/to/controller/update/function'); ?>
+ <?php echo form_open('path/to/controller/update/method'); ?>
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
- <th>QTY</th>
- <th>Item Description</th>
- <th style="text-align:right">Item Price</th>
- <th style="text-align:right">Sub-Total</th>
+ <th>QTY</th>
+ <th>Item Description</th>
+ <th style="text-align:right">Item Price</th>
+ <th style="text-align:right">Sub-Total</th>
</tr>
<?php $i = 1; ?>
@@ -154,9 +166,9 @@ helper </helpers/form_helper>`.
<?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
<tr>
- <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
- <td>
- <?php echo $items['name']; ?>
+ <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
+ <td>
+ <?php echo $items['name']; ?>
<?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
@@ -170,9 +182,9 @@ helper </helpers/form_helper>`.
<?php endif; ?>
- </td>
- <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
- <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
+ </td>
+ <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
+ <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
</tr>
<?php $i++; ?>
@@ -180,9 +192,9 @@ helper </helpers/form_helper>`.
<?php endforeach; ?>
<tr>
- <td colspan="2"> </td>
- <td class="right"><strong>Total</strong></td>
- <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
+ <td colspan="2"> </td>
+ <td class="right"><strong>Total</strong></td>
+ <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>
</table>
@@ -193,8 +205,8 @@ Updating The Cart
=================
To update the information in your cart, you must pass an array
-containing the Row ID and quantity to the $this->cart->update()
-function:
+containing the Row ID and quantity to the ``$this->cart->update()``
+method.
.. note:: If the quantity is set to zero, the item will be removed from
the cart.
@@ -202,38 +214,52 @@ function:
::
$data = array(
- 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
- 'qty' => 3
- );
+ 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
+ 'qty' => 3
+ );
$this->cart->update($data);
// Or a multi-dimensional array
$data = array(
- array(
- 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
- 'qty' => 3
- ),
- array(
- 'rowid' => 'xw82g9q3r495893iajdh473990rikw23',
- 'qty' => 4
- ),
- array(
- 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
- 'qty' => 2
- )
- );
+ array(
+ 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
+ 'qty' => 3
+ ),
+ array(
+ 'rowid' => 'xw82g9q3r495893iajdh473990rikw23',
+ 'qty' => 4
+ ),
+ array(
+ 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
+ 'qty' => 2
+ )
+ );
+
+ $this->cart->update($data);
+
+You may also update any property you have previously defined when
+inserting the item such as options, price or other custom fields.
+
+::
+
+ $data = array(
+ 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
+ 'qty' => 1,
+ 'price' => 49.95,
+ 'coupon' => NULL
+ );
$this->cart->update($data);
What is a Row ID?
*****************
-The row ID is a unique identifier that is
-generated by the cart code when an item is added to the cart. The reason
-a unique ID is created is so that identical products with different
-options can be managed by the cart.
+The row ID is a unique identifier that is generated by the cart code
+when an item is added to the cart. The reason a unique ID is created
+is so that identical products with different options can be managed
+by the cart.
For example, let's say someone buys two identical t-shirts (same product
ID), but in different sizes. The product ID (and other attributes) will
@@ -247,9 +273,9 @@ In nearly all cases, updating the cart will be something the user does
via the "view cart" page, so as a developer, it is unlikely that you
will ever have to concern yourself with the "row ID", other than making
sure your "view cart" page contains this information in a hidden form
-field, and making sure it gets passed to the update function when the
-update form is submitted. Please examine the construction of the "view
-cart" page above for more information.
+field, and making sure it gets passed to the ``update()`` method when
+the update form is submitted. Please examine the construction of the
+"view cart" page above for more information.
***************
@@ -289,10 +315,10 @@ Class Reference
:returns: TRUE on success, FALSE on failure
:rtype: bool
- This method permits the quantity of a given item to be changed.
+ This method permits changing the properties of a given item.
Typically it is called from the "view cart" page if a user makes changes
- to the quantity before checkout. That array must contain the product ID
- and quantity for each item.
+ to the quantity before checkout. That array must contain the rowid
+ and qty for each item.
.. method:: remove($rowid)
@@ -347,7 +373,7 @@ Class Reference
Returns TRUE (boolean) if a particular row in the cart contains options.
This method is designed to be used in a loop with ``contents()``, since
- you must pass the rowid to this function, as shown in the Displaying
+ you must pass the rowid to this method, as shown in the Displaying
the Cart example above.
.. method:: product_options([$row_id = ''])
diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst
index ee12d9e6f..d8d31f8c5 100644
--- a/user_guide_src/source/libraries/pagination.rst
+++ b/user_guide_src/source/libraries/pagination.rst
@@ -165,6 +165,8 @@ $config['first_link'] = 'First';
The text you would like shown in the "first" link on the left. If you do
not want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['first_tag_open'] = '<div>';
====================================
@@ -185,6 +187,8 @@ $config['last_link'] = 'Last';
The text you would like shown in the "last" link on the right. If you do
not want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['last_tag_open'] = '<div>';
===================================
@@ -205,6 +209,8 @@ $config['next_link'] = '&gt;';
The text you would like shown in the "next" page link. If you do not
want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['next_tag_open'] = '<div>';
===================================
@@ -225,6 +231,8 @@ $config['prev_link'] = '&lt;';
The text you would like shown in the "previous" page link. If you do not
want this link rendered, you can set its value to FALSE.
+.. note:: This value can also be translated via a language file.
+
$config['prev_tag_open'] = '<div>';
===================================
diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst
index 6e011083e..9d95eddfc 100644
--- a/user_guide_src/source/libraries/table.rst
+++ b/user_guide_src/source/libraries/table.rst
@@ -139,7 +139,7 @@ Class Reference
.. class:: CI_Table
- .. attribute:: $function = FALSE
+ .. attribute:: $function = NULL
Allows you to specify a native PHP function or a valid function array object to be applied to all cell data.
::
diff --git a/user_guide_src/source/libraries/xmlrpc.rst b/user_guide_src/source/libraries/xmlrpc.rst
index 2cf548750..c2e9a1113 100644
--- a/user_guide_src/source/libraries/xmlrpc.rst
+++ b/user_guide_src/source/libraries/xmlrpc.rst
@@ -123,12 +123,12 @@ If you use data types other than strings, or if you have several
different data types, you will place each parameter into its own array,
with the data type in the second position::
- $request = array (
- array('John', 'string'),
- array('Doe', 'string'),
- array(FALSE, 'boolean'),
- array(12345, 'int')
- );
+ $request = array(
+ array('John', 'string'),
+ array('Doe', 'string'),
+ array(FALSE, 'boolean'),
+ array(12345, 'int')
+ );
$this->xmlrpc->request($request);
The `Data Types <#datatypes>`_ section below has a full list of data
@@ -171,7 +171,7 @@ not part of the CodeIgniter super object.
In other words, if an XML-RPC Client sends a request for the new_post
method, your server will load the My_blog class and call the new_entry
function. If the request is for the update_post method, your server
-will load the My_blog class and call the update_entry function.
+will load the My_blog class and call the ``update_entry()`` method.
The function names in the above example are arbitrary. You'll decide
what they should be called on your server, or if you are using
@@ -181,7 +181,7 @@ function names.
There are two additional configuration keys you may make use of when
initializing the server class: debug can be set to TRUE in order to
enable debugging, and xss_clean may be set to FALSE to prevent sending
-data through the Security library's xss_clean function.
+data through the Security library's ``xss_clean()`` method.
Processing Server Requests
==========================
@@ -207,49 +207,52 @@ have access to the *request parameters* enabling you to process the
request. When you are done you will send a Response back to the Client.
Below is a real-world example, using the Blogger API. One of the methods
-in the Blogger API is getUserInfo(). Using this method, an XML-RPC
+in the Blogger API is ``getUserInfo()``. Using this method, an XML-RPC
Client can send the Server a username and password, in return the Server
sends back information about that particular user (nickname, user ID,
email address, etc.). Here is how the processing function might look::
class My_blog extends CI_Controller {
- function getUserInfo($request)
- {
- $username = 'smitty';
- $password = 'secretsmittypass';
+ public function getUserInfo($request)
+ {
+ $username = 'smitty';
+ $password = 'secretsmittypass';
- $this->load->library('xmlrpc');
+ $this->load->library('xmlrpc');
- $parameters = $request->output_parameters();
+ $parameters = $request->output_parameters();
- if ($parameters['1'] != $username AND $parameters['2'] != $password)
- {
- return $this->xmlrpc->send_error_message('100', 'Invalid Access');
- }
+ if ($parameters[1] != $username && $parameters[2] != $password)
+ {
+ return $this->xmlrpc->send_error_message('100', 'Invalid Access');
+ }
- $response = array(array('nickname' => array('Smitty','string'),
- 'userid' => array('99','string'),
- 'url' => array('http://yoursite.com','string'),
- 'email' => array('jsmith@yoursite.com','string'),
- 'lastname' => array('Smith','string'),
- 'firstname' => array('John','string')
- ),
- 'struct');
+ $response = array(
+ array(
+ 'nickname' => array('Smitty', 'string'),
+ 'userid' => array('99', 'string'),
+ 'url' => array('http://yoursite.com', 'string'),
+ 'email' => array('jsmith@yoursite.com', 'string'),
+ 'lastname' => array('Smith', 'string'),
+ 'firstname' => array('John', 'string')
+ ),
+ 'struct'
+ );
- return $this->xmlrpc->send_response($response);
- }
+ return $this->xmlrpc->send_response($response);
+ }
}
Notes:
------
-The output_parameters() function retrieves an indexed array
+The ``output_parameters()`` method retrieves an indexed array
corresponding to the request parameters sent by the client. In the above
example, the output parameters will be the username and password.
If the username and password sent by the client were not valid, and
-error message is returned using send_error_message().
+error message is returned using ``send_error_message()``.
If the operation was successful, the client will be sent back a response
array containing the user's info.
@@ -263,22 +266,22 @@ single item**. This item can be an array with several additional arrays,
but there can be only one primary array index. In other words, the basic
prototype is this::
- $response = array('Response data', 'array');
+ $response = array('Response data', 'array');
Responses, however, usually contain multiple pieces of information. In
order to accomplish this we must put the response into its own array so
that the primary array continues to contain a single piece of data.
Here's an example showing how this might be accomplished::
- $response = array (
- array(
- 'first_name' => array('John', 'string'),
- 'last_name' => array('Doe', 'string'),
- 'member_id' => array(123435, 'int'),
- 'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),
- ),
- 'struct'
- );
+ $response = array(
+ array(
+ 'first_name' => array('John', 'string'),
+ 'last_name' => array('Doe', 'string'),
+ 'member_id' => array(123435, 'int'),
+ 'todo_list' => array(array('clean house', 'call mom', 'water plants'), 'array'),
+ ),
+ 'struct'
+ );
Notice that the above array is formatted as a struct. This is the most
common data type for responses.
@@ -373,17 +376,16 @@ folder::
$parameters = $request->output_parameters();
$response = array(
- array(
- 'you_said' => $parameters[0],
- 'i_respond' => 'Not bad at all.'
- ),
- 'struct'
- );
+ array(
+ 'you_said' => $parameters[0],
+ 'i_respond' => 'Not bad at all.'
+ ),
+ 'struct'
+ );
return $this->xmlrpc->send_response($response);
}
}
- ?>
Try it!
@@ -398,7 +400,7 @@ back to you.
The client you created sends a message ("How's is going?") to the
server, along with a request for the "Greetings" method. The Server
-receives the request and maps it to the "process" function, where a
+receives the request and maps it to the ``process()`` method, where a
response is sent back.
Using Associative Arrays In a Request Parameter
@@ -408,22 +410,21 @@ If you wish to use an associative array in your method parameters you
will need to use a struct datatype::
$request = array(
- array(
- // Param 0
- array(
- 'name'=>'John'
- ),
- 'struct'
- ),
- array(
- // Param 1
- array(
- 'size'=>'large',
- 'shape'=>'round'
- ),
- 'struct'
- )
- );
+ array(
+ // Param 0
+ array('name' => 'John'),
+ 'struct'
+ ),
+ array(
+ // Param 1
+ array(
+ 'size' => 'large',
+ 'shape'=>'round'
+ ),
+ 'struct'
+ )
+ );
+
$this->xmlrpc->request($request);
You can retrieve the associative array when processing the request in