Location: PHPKode > projects > Moc10 PHP Library > docs/manual.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Header //-->
<html>

<head>

    <title>
        Moc10 Library v1.9.7 | A Lightweight PHP Library
    </title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="Nick Sagona"/>
    <meta name="keywords" content="php, php library, php framework, php code library, moc10 library, moc10media, moc 10 media, moc 10, object oriented programming, oop" />
    <meta name="description" content="Moc10 Library is a lightweight, easily deployable PHP library that integrates a handful of some of the 'basics' that go into many websites, projects and applications." />
    <meta name="robots" content="all" />

    <link rel="stylesheet" type="text/css" href="styles.css" />
    <link rel="shortcut icon" href="moc10media.ico" type="image/ico" />

</head>

<body>
<!-- Content //-->
<div id="content">
    <a name="top"></a>
    <h1>Moc10 Library v1.9.7 | A Lightweight PHP Library</h1>
    <ul id="mainNav">
        <li><a href="./index.html">Overview</a></li>
        <li><a href="./features.html">Features</a></li>
        <li>Manual</li>
        <li><a href="./api-glossary.html">API Glossary</a></li>
        <li><a href="./api-docs/index.html">API Docs</a></li>
        <li><a href="./faqs.html">FAQs</a></li>
        <li><a href="./development.html">Development</a></li>
        <li><a href="./download.html">Download</a></li>
    </ul>
    <h3>Manual</h3>
    <ul>
        <li><a href="./manual.html#autoloader">The Autoloader Component</a></li>
        <li><a href="./manual.html#cookie">The Cookie Component</a></li>
        <li><a href="./manual.html#curl">The Curl Component</a></li>
        <li><a href="./manual.html#db">The DB Connection Component</a></li>
        <li><a href="./manual.html#dom">The DOM Component</a></li>
        <li><a href="./manual.html#feed">The Feed Component</a></li>
        <li><a href="./manual.html#file">The File Component</a></li>
        <li><a href="./manual.html#form">The Form Component</a></li>
        <li><a href="./manual.html#ftp">The FTP Component</a></li>
        <li><a href="./manual.html#image">The Image Component</a></li>
        <li><a href="./manual.html#lang">The Language Component</a></li>
        <li><a href="./manual.html#mail">The Mail Component</a></li>
        <li><a href="./manual.html#pdf">The PDF Component</a></li>
        <li><a href="./manual.html#record">The Record Component</a></li>
        <li><a href="./manual.html#session">The Session Component</a></li>
        <li><a href="./manual.html#string">The String Component</a></li>
    </ul>
    <p>
        Below is a detailed manual of the Moc10 Library. At the end of each section, there is a separated gray area that highlights a few example uses of that component. Most of these examples can be found in the /public/examples/ folder for further review. Also, you can review the class files under the /library/Moc10/ folder to dive deeper into the inner workings of the library and its classes, methods and properties.
    </p>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="autoloader"></a>
    <h4>The Autoloader Component</h4>
    <p>
        This component can work in tandem with a "bootstrap" file. In the autoloader class, the Moc10 Library path is set and in your "bootstrap" file you can set the path of your application code using the <strong>set_include_path</strong> function.
    </p>
    <p>
        An application code example has been included here: <strong>/public/bootstrap.php</strong>. In this example, the autoloader is included, the application path is set and the autoloader is executed. The result of this bootstrap script is that any class that exists within the library or application folders will be found and accessed. However, in order to work properly, the naming convention needs to be as follows:
    </p>
    <pre>
/application/
  |--/YourApp/
       |--/SomeClass.php
       |--/SomeClass/AnotherClass.php
    </pre>
    <p>
        And, the class names and access to those classes are as follows:
    </p>
    <pre>
$obj = new YourApp_SomeClass();
$obj = new YourApp_SomeClass_AnotherClass();
    </pre>
    <p>
        As you can see, the Moc10 Library follows this same naming convention:
    </p>
    <pre>
/library/
  |--/Moc10/
       |--/File.php
       |--/File/Upload.php
    </pre>
    <p>
        Where the class names and access to those classes are as follows:
    </p>
    <pre>
$file = new Moc10_File();
$file = new Moc10_File_Upload();
    </pre>
    <p>
        So, by following this naming convention for your application code, all you have to do is add the application path to your bootstrap file, and you'll have access to your application code and classes, as well as the Moc10 Library.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Autoloader</li>
    </ul>
    <h5 class="underline">Methods:</h5>
    <ul>
        <li>public static function autoload($class)</li>
        <li>public static function registerAutoloader()</li>
        <li>public static function setupIncludePath()</li>
        <li>public static function bootstrap()</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call:</h5>
    <pre>

Moc10_Autoloader::bootstrap();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="cookie"></a>
    <h4>The Cookie Component</h4>
    <p>
        This class allows for the creation, manipulation and destruction of cookies via PHP.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Cookie</li>
    </ul>
    <h5 class="underline">Moc10_Cookie Methods:</h5>
    <ul>
        <li>public static function getInstance()</li>
        <li>public function set($name, $value, $exp = 0)</li>
        <li>public function __get($name)</li>
        <li>public function __isset($name)</li>
        <li>public function __unset($name)</li>
    </ul>
    <h5 class="underline">Moc10_Cookie Properties:</h5>
    <ul>
        <li>static private $_instance</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Creation of a Cookie:</h5>
    <pre>

$cookie = Moc10_Cookie::getInstance();
$cookie-&gt;set('username', 'Your Name', (time() + 3600));
    </pre>
    <h5 class="underline">Access a Cookie:</h5>
    <pre>

$cookie = Moc10_Cookie::getInstance();
$username = $cookie-&gt;username;
    </pre>
    <h5 class="underline">Destory a Cookie:</h5>
    <pre>

$cookie = Moc10_Cookie::getInstance();
unset($cookie-&gt;username);
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="curl"></a>
    <h4>The Curl Component</h4>
    <p>
        This class allows the simple execution and management of cURL session transactions.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Curl</li>
    </ul>
    <h5 class="underline">Moc10_Curl Methods:</h5>
    <ul>
        <li>public function __construct($opts, $val = null)</li>
        <li>public function setOption($opt, $vl = null)</li>
        <li>public function getOption($opt)</li>
        <li>public function execute()</li>
        <li>public function processData($ch, $dt)</li>
        <li>public function getinfo($opt = null)</li>
        <li>public function version()</li>
        <li>public function __destruct()</li>
        <li>protected function _showError()</li>
    </ul>
    <h5 class="underline">Moc10_Curl Properties:</h5>
    <ul>
        <li>public $data</li>
        <li>protected $_curl</li>
        <li>protected $_options</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic cURL Session Transaction:</h5>
    <pre>

$options = Array(CURLOPT_URL =&gt; 'http://www.moc10phplibrary.com/LICENSE.TXT',
                 CURLOPT_HEADER =&gt; FALSE);

header('Content-Type: text/plain; charset=utf-8');
$curl = new Moc10_Curl($options);
$curl-&gt;execute();
    </pre>
    <h5 class="underline">cURL Session Transaction Using POST:</h5>
    <pre>

$options = Array(CURLOPT_URL =&gt; 'http://www.domain.com/process.php',
                 CURLOPT_POST =&gt; TRUE,
                 CURLOPT_POSTFIELDS =&gt; Array('name' =&gt; 'Bub', 'email' =&gt; 'hide@address.com'),
                 CURLOPT_HEADER =&gt; FALSE,
                 CURLOPT_RETURNTRANSFER =&gt; TRUE);

header('Content-Type: text/html; charset=utf-8');
$curl = new Moc10_Curl($options);
$output = "&lt;html&gt;&lt;body&gt;&lt;h1&gt;cURL POST Test&lt;/h1&gt;";
$output .= $curl-&gt;execute();
$output .= "&lt;/body&gt;&lt;/html&gt;";

print($output);
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="db"></a>
    <h4>The DB Connection Component</h4>
    <p>
        This component allows basic database access to either MySQL (via MySQL or MySQLi), PostgreSQL or SQLite database. To gain access to the database, you have the option to either directly changing the database credential properties once within the database class, or passing them dynamically to the static <strong>getInstance( )</strong> method as needed in your application code.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Db</li>
        <li>Moc10_Db_MySQL</li>
        <li>Moc10_Db_MySQLi</li>
        <li>Moc10_Db_PostgreSQL</li>
        <li>Moc10_Db_SQLite</li>
    </ul>
    <h5 class="underline">Moc10_Db Methods:</h5>
    <ul>
        <li>private function __construct($type = null, $dbase = null, $host = null, $user = null, $pass = null)</li>
        <li>public static function getInstance($type = null, $dbase = null, $host = null, $user = null, $pass = null)</li>
    </ul>
    <h5 class="underline">Moc10_Db Properties:</h5>
    <ul>
        <li>public $interface</li>
        <li>static private $_instance</li>
        <li>static private $_type</li>
        <li>static private $_dbname</li>
        <li>static private $_hostname</li>
        <li>static private $_username</li>
        <li>static private $_password</li>
    </ul>
    <h5 class="underline">Moc10_Db_MySQL|MySQLi|PostgreSQL|SQLite Methods:</h5>
    <ul>
        <li>public function showError()</li>
        <li>public function query($sql)</li>
        <li>public function fetch()</li>
        <li>public function escape($value)</li>
        <li>public function lastId()</li>
        <li>public function numRows()</li>
        <li>public function numFields()</li>
        <li>public function getTables()</li>
        <li>public function version()</li>
        <li>public function __destruct()</li>
    </ul>
    <h5 class="underline">Moc10_Db_MySQL|MySQLi|PostgreSQL|SQLite Properties:</h5>
    <ul>
        <li>public $result</li>
        <li>public $connection</li>
        <li>public $last_result</li>
        <li>public $last_sql</li>
        <li>public $_tables</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call:</h5>
    <p>
        The first example requires that you set the database credential properties within the actual class. You can set this once, and not have to worry about maintaining it later in your application. Or, you can pass the database credentials dynamically, as needed, as in the second example.
    </p>
    <pre>

$db = Moc10_Db::getInstance();

&lt;OR&gt;

$db = Moc10_Db::getInstance($type, $dbase, $host, $user, $pass);
    </pre>
    <h5 class="underline">Execute Query and Fetch Results:</h5>
    <pre>

$db-&gt;interface-&gt;query("SELECT SQL STATEMENT");
while (($row = $db-&gt;fetch())) {
    $x = $row;
}
    </pre>
    <h5 class="underline">Return Last Insert ID:</h5>
    <pre>

$db-&gt;interface-&gt;query("INSERT SQL STATEMENT");
$id = $db-&gt;interface-&gt;lastId();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="dom"></a>
    <h4>The DOM Component</h4>
    <p>
        This class allows for the creation, manipulation and destruction of DOM elements and their children.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Dom</li>
        <li>Moc10_Dom_Child</li>
    </ul>
    <h5 class="underline">Moc10_Dom Methods:</h5>
    <ul>
        <li>public function __construct($type = null, $charset = 'utf-8', $childNode = null, $indent = null)</li>
        <li>public function getType()</li>
        <li>public function getCharset()</li>
        <li>public function getIndent()</li>
        <li>public function setType($type)</li>
        <li>public function setDTD($dtd)</li>
        <li>public function setCharset($chr)</li>
        <li>public function setIndent($ind)</li>
        <li>public function addChildren($c)</li>
        <li>public function getChildren()</li>
        <li>public function removeChildren()</li>
        <li>public function render($ret = false)</li>
    </ul>
    <h5 class="underline">Moc10_Dom Properties:</h5>
    <ul>
        <li>protected $_type</li>
        <li>protected $_contentType</li>
        <li>protected $_charset</li>
        <li>protected $_indent</li>
        <li>protected $_childNodes</li>
        <li>protected $_output</li>
        <li>protected $_doctypes</li>
    </ul>
    <h5 class="underline">Moc10_Dom_Child Methods:</h5>
    <ul>
        <li>public function __construct($name, $value = null, $childNode = null, $first = false)</li>
        <li>public function getName()</li>
        <li>public function getValue()</li>
        <li>public function getIndent()</li>
        <li>public function setName($name)</li>
        <li>public function setValue($value)</li>
        <li>public function setIndent($ind)</li>
        <li>public function setAttributes($a, $v = null)</li>
        <li>public function getAttributes()</li>
        <li>public function addChildren($c)</li>
        <li>public function getChildren()</li>
        <li>public function removeChildren()</li>
        <li>public function render($ret = false, $depth = 0, $indent = null)</li>
    </ul>
    <h5 class="underline">Moc10_Dom_Child Properties:</h5>
    <ul>
        <li>protected $_nodeName</li>
        <li>protected $_nodeValue</li>
        <li>protected $_childNodes</li>
        <li>protected $_childrenFirst</li>
        <li>protected $_indent</li>
        <li>protected $_attributes</li>
        <li>protected $_output</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Creation of a DOM element section:</h5>
    <pre>

$p = new Moc10_Dom_Child('p', 'This is a paragraph.');
$p-&gt;setAttributes('class', 'paraStyle');

$div = new Moc10_Dom_Child('div', 'Hello World!', null, true);
$div-&gt;setAttributes('class', 'contentDiv');
$div-&gt;addChildren($p);

$header = new Moc10_Dom_Child('h3', 'Header goes here.');
$p-&gt;addChildren($header);

$doc = new Moc10_Dom();
$doc-&gt;addChildren($div);
$doc-&gt;render();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="feed"></a>
    <h4>The Feed Component</h4>
    <p>
        This class allows for the creation, parsing and rendering of data from an RSS feed.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Feed_Reader</li>
        <li>Moc10_Feed_Writer (extends Moc10_Dom)</li>
    </ul>
    <h5 class="underline">Moc10_Feed_Reader Methods:</h5>
    <ul>
        <li>public function __construct($url, $limit = null)</li>
        <li>public function setItemTemplate($tmpl)</li>
        <li>public function getFeedType()</li>
        <li>public function render($dt = null, $ret = false)</li>
        <li>protected function _parseFeed()</li>
        <li>protected function _calcElapsedTime($dt)</li>
    </ul>
    <h5 class="underline">Moc10_Feed_Writer Methods:</h5>
    <ul>
        <li>public function __construct($hdrs, $itms, $type = 'RSS', $dt = 'D, j M Y H:i:s O')</li>
        <li>public function render($ret = false)</li>
        <li>protected function _init()</li>
    </ul>
    <h5 class="underline">Moc10_Feed_Reader Properties:</h5>
    <ul>
        <li>public $title</li>
        <li>public $url</li>
        <li>public $desc</li>
        <li>public $date</li>
        <li>public $generator</li>
        <li>public $editor</li>
        <li>public $items</li>
        <li>protected $_limit</li>
        <li>protected $_xml</li>
        <li>protected $_feed_type</li>
        <li>protected $_feed_src</li>
        <li>protected $_template</li>
    </ul>
    <h5 class="underline">Moc10_Feed_Writer Properties:</h5>
    <ul>
        <li>protected $_headers</li>
        <li>protected $_items</li>
        <li>protected $_feed_type</li>
        <li>protected $_date</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Parse and Render a Feed:</h5>
    <pre>

$feed = new Moc10_Feed_Reader('http://gdata.youtube.com/feeds/someuser/channel', 3);

$htmlTemplate = &lt;&lt;&lt;HTML
&lt;div&gt;
    &lt;a href="[{link}]"&gt;&lt;img src="[{image}]" alt="[{title}]" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;
    &lt;a href="[{link}]"&gt;[{title}]&lt;/a&gt;&lt;br /&gt;
    &lt;strong&gt;[{pubDate}]&lt;/strong&gt; ([{timeElapsed}])&lt;br /&gt;
    &lt;p&gt;[{description}]&lt;/p&gt;
&lt;/div&gt;

HTML;

$feed-&gt;setItemTemplate($htmlTemplate);
$feed-&gt;render('m/d/Y h:i a');
    </pre>
    <h5 class="underline">Output a Feed:</h5>
    <pre>

$feed_headers = Array('title' =&gt; 'Test Feed Title',
                      'link' =&gt; 'http://www.testfeed.com/',
                      'description' =&gt; 'Test Feed Description',
                      'language' =&gt; 'en',
                      'lastBuildDate' =&gt; '2010-01-12 13:01:32',
                      'generator' =&gt; 'http://www.phoenixcms.com/',
                      'managingEditor' =&gt; 'Some Editor');

$item1 = Array('title' =&gt; 'Item Title 1',
               'link' =&gt; 'http://www.testfeed.com/item1',
               'comments' =&gt; 'http://www.testfeed.com/item1#comments',
               'author' =&gt; 'Item Author 1',
               'pubDate' =&gt; '2010-01-13 14:12:24',
               'description' =&gt; 'Item Desc 1');

$item2 = Array('title' =&gt; 'Item Title 2',
               'link' =&gt; 'http://www.testfeed.com/item2',
               'comments' =&gt; 'http://www.testfeed.com/item2#comments',
               'author' =&gt; 'Item Author 2',
               'pubDate' =&gt; '2010-01-12 14:12:24',
               'description' =&gt; 'Item Desc 2');

$feed_items = Array($item1, $item2);

$feed = new Moc10_Feed_Writer($feed_headers, $feed_items);
$feed-&gt;render();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="file"></a>
    <h4>The File Component</h4>
    <p>
        This component allows you to have basic control over files and file parameters. You can adjust the <strong>$_allowed</strong> array property to allow for more or less specific file types, either via the __construct() method or the setAllowedTypes() method. This is recommended if you only want to allow certain file types to interact with your application (i.e., Microsoft Office Documents or PDF files.)
    </p>
    <p>
        You can also statically adjust the <strong>$_max</strong> property in Moc10_File_Upload class or set it dynamically via the __construct() method to allow for a certain maximum file size (or null for no limit.) It is recommended that this be set for optimal server performance. Larger files that are uploaded and processed via PHP will tax the server's resources. Additionally, if any issues do arise regarding the uploading of files, check the upload_max_filesize and the memory_limit settings in the php.ini file.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>
            Moc10_File
            <ul class="subList">
                <li>Moc10_File_Upload</li>
            </ul>
        </li>
        <li>Moc10_File_Dir</li>
    </ul>
    <h5 class="underline">Moc10_File Methods:</h5>
    <ul>
        <li>public function __construct($fl = null, $up = false, $typ = null)</li>
        <li>public function setFile($file, $upload = false)</li>
        <li>public function setAllowedTypes($types)</li>
        <li>public function getAllowedTypes()</li>
        <li>public function getMode($dir = false)</li>
        <li>public function setMode($mode, $dir = false)</li>
        <li>public function read($off = null, $len = null)</li>
        <li>public function write($data, $append = null, $save = true)</li>
        <li>public function copy($new)</li>
        <li>public function move($new)</li>
        <li>public function output($action = null)</li>
        <li>public function export($ary, $omit = null, $delim = ',', $esc = '"', $dt = null, $dload = true, $save = false)</li>
        <li>public function import($delim = ',', $esc = '"')</li>
        <li>public function delete()</li>
        <li>protected function _checkPermissions($file)</li>
    </ul>
    <h5 class="underline">Moc10_File_Dir Methods:</h5>
    <ul>
        <li>public function __construct($dir, $full = false, $rec = false)</li>
        <li>public function getMode()</li>
        <li>public function setMode($mode)</li>
        <li>public function emptyDir($path, $del = false)</li>
    </ul>
    <h5 class="underline">Moc10_File_Upload Methods:</h5>
    <ul>
        <li>public function __construct($upload, $file, $size = null, $types = null)</li>
    </ul>
    <h5 class="underline">Moc10_File Properties:</h5>
    <ul>
        <li>public $fullpath</li>
        <li>public $dir</li>
        <li>public $basename</li>
        <li>public $filename</li>
        <li>public $ext</li>
        <li>public $size</li>
        <li>public $mime</li>
        <li>protected $_output</li>
        <li>protected $_perm</li>
        <li>
            protected $_allowed
            <ul class="subList">
                <li>'ai'   =&gt; 'application/postscript'</li>
                <li>'aif'  =&gt; 'audio/x-aiff'</li>
                <li>'aiff' =&gt; 'audio/x-aiff'</li>
                <li>'avi'  =&gt; 'video/x-msvideo'</li>
                <li>'bmp'  =&gt; 'image/x-ms-bmp'</li>
                <li>'css'  =&gt; 'text/css'</li>
                <li>'csv'  =&gt; 'text/csv'</li>
                <li>'doc'  =&gt; 'application/msword'</li>
                <li>'docx' =&gt; 'application/msword'</li>
                <li>'eps'  =&gt; 'application/octet-stream'</li>
                <li>'fla'  =&gt; 'application/octet-stream'</li>
                <li>'flv'  =&gt; 'application/octet-stream'</li>
                <li>'gif'  =&gt; 'image/gif'</li>
                <li>'gz'   =&gt; 'application/x-gzip'</li>
                <li>'html' =&gt; 'text/html'</li>
                <li>'htm'  =&gt; 'text/html'</li>
                <li>'jpe'  =&gt; 'image/jpeg'</li>
                <li>'jpg'  =&gt; 'image/jpeg'</li>
                <li>'jpeg' =&gt; 'image/jpeg'</li>
                <li>'js'   =&gt; 'text/plain'</li>
                <li>'mov'  =&gt; 'video/quicktime'</li>
                <li>'mp2'  =&gt; 'audio/mpeg'</li>
                <li>'mp3'  =&gt; 'audio/mpeg'</li>
                <li>'mp4'  =&gt; 'video/mp4'</li>
                <li>'mpg'  =&gt; 'video/mpeg'</li>
                <li>'mpeg' =&gt; 'video/mpeg'</li>
                <li>'otf'  =&gt; 'application/x-font-otf'</li>
                <li>'pdf'  =&gt; 'application/pdf'</li>
                <li>'php'  =&gt; 'text/plain'</li>
                <li>'png'  =&gt; 'image/png'</li>
                <li>'ppt'  =&gt; 'application/msword'</li>
                <li>'pptx' =&gt; 'application/msword'</li>
                <li>'psd'  =&gt; 'image/x-photoshop'</li>
                <li>'sit'  =&gt; 'application/x-stuffit'</li>
                <li>'sitx' =&gt; 'application/x-stuffit'</li>
                <li>'sql'  =&gt; 'text/plain'</li>
                <li>'swf'  =&gt; 'application/x-shockwave-flash'</li>
                <li>'tar'  =&gt; 'application/x-tar'</li>
                <li>'tif'  =&gt; 'image/tiff'</li>
                <li>'tiff' =&gt; 'image/tiff'</li>
                <li>'tsv'  =&gt; 'text/tsv'</li>
                <li>'ttf'  =&gt; 'application/x-font-ttf'</li>
                <li>'txt'  =&gt; 'text/plain'</li>
                <li>'wav'  =&gt; 'audio/x-wav'</li>
                <li>'wma'  =&gt; 'audio/x-ms-wma'</li>
                <li>'wmv'  =&gt; 'audio/x-ms-wmv'</li>
                <li>'xls'  =&gt; 'application/msword'</li>
                <li>'xlsx' =&gt; 'application/msword'</li>
                <li>'xhtml'=&gt; 'application/xhtml+xml'</li>
                <li>'xml'  =&gt; 'application/xml'</li>
                <li>'zip'  =&gt; 'application/x-zip</li>
            </ul>
        </li>
    </ul>
    <h5 class="underline">Moc10_File_Dir Properties:</h5>
    <ul>
        <li>public $path</li>
        <li>public $files</li>
        <li>protected $_full</li>
        <li>protected $_rec</li>
    </ul>
    <h5 class="underline">Moc10_File_Upload Properties:</h5>
    <ul>
        <li>
            protected $_max
            <ul class="subList">
                <li>5000000</li>
            </ul>
        </li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call:</h5>
    <p>
        The first example creates either a new, blank file object or a file object from a file on disk. The second example creates a new file object from the uploaded file.
    </p>
    <pre>

$file = new Moc10_File('files/test.txt');

&lt;OR&gt;

$file = new Moc10_File_Upload($_FILES['up_file']['tmp_name'], '../files/upload.txt');
    </pre>
    <h5 class="underline">Read from a File:</h5>
    <pre>

$file = new Moc10_File('files/test.txt');
$data = $file-&gt;read();
    </pre>
    <h5 class="underline">Append Data to a File:</h5>
    <pre>

$file = new Moc10_File('files/test.txt');
$file-&gt;write('New data', true);
    </pre>
    <h5 class="underline">Copy a File:</h5>
    <pre>

$file = new Moc10_File('files/test.txt');
$file-&gt;copy('files/test2.txt');
    </pre>
    <h5 class="underline">E-mail a File:</h5>
    <p>
        This method requires that the server be properly set up as an outgoing SMTP server, and that sendmail is set correctly within the php.ini file.
    </p>
    <pre>

$file = new Moc10_File('files/test.txt');
$file-&gt;mail(hide@address.com);
    </pre>
    <h5 class="underline">Delete a File:</h5>
    <pre>

$file = new Moc10_File('files/test.txt');
$file-&gt;delete();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="form"></a>
    <h4>The Form Component</h4>
    <p>
        This component allows you to create, render and validate HTML forms and form elements. The Moc10_Form_Element and its children are utilized to create specific form elements and handle any special rendering or validation needed for each type of form element. They are utilized by the form object. The Form Component inherits the methods and properties of the File Component.
    </p>
    <p>
        There are two ways to render a form object. The most direct way is to simply "print" the object, calling its <strong>__toString( )</strong> method. This will simply render the form using a 1:1 label to element template, using &lt;dl&gt;, &lt;dt&gt; and &lt;dd&gt; tags. If you desire more control over the output, then you can set a template for the form using the <strong>setTemplate($tmpl)</strong> method and then use the <strong>render( )</strong> method. This will execute a search and replace of labels and elements within the set template. The format within the template should be <strong>[{element_label}]</strong> and <strong>[{element}]</strong>, for example <strong>[{email_label}]</strong> and <strong>[{email}]</strong>.
    </p>
    <p>
        An application code example has been included here: <strong>/application/Test/Form/Contact.php</strong>. In this example, the class Test_Form_Contact extends Moc10_Form and contains the <strong>init( )</strong> method, which contains the code to create and initialize the example contact form. So, the contact form contains that which is pertinent to the form within the application, yet, it also inherits the complete functionality of the Moc10_Form class.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>
            Moc10_Form (extends Moc10_Dom)
            <ul class="subList">
                <li>Test_Form_Contact (Example)</li>
                <li>Test_Form_ContactAlt (Example)</li>
            </ul>
        </li>
        <li>
            Moc10_Form_Element (extends Moc10_Dom_Child)
            <ul class="subList">
                <li>Moc10_Form_Element_Checbox</li>
                <li>Moc10_Form_Element_Radio</li>
                <li>Moc10_Form_Element_Select</li>
                <li>Moc10_Form_Element_Textarea</li>
            </ul>
        </li>
    </ul>
    <h5 class="underline">Moc10_Form Methods:</h5>
    <ul>
        <li>public function __construct($action, $method, $indent = null)</li>
        <li>public function __toString()</li>
        <li>public function setInitValues($values)</li>
        <li>public function processInitValues()</li>
        <li>public function setPostValues($post, $filter = false)</li>
        <li>public function setTemplate($tmpl)</li>
        <li>public function getTemplate()</li>
        <li>public function setAttributes($a, $v = null)</li>
        <li>public function getAttributes()</li>
        <li>public function addElements($e)</li>
        <li>public function getElements()</li>
        <li>public function isValid()</li>
        <li>public function render($ret = false)</li>
    </ul>
    <h5 class="underline">Moc10_Form Properties:</h5>
    <ul>
        <li>protected $_form</li>
        <li>protected $_action</li>
        <li>protected $_method</li>
        <li>protected $_template</li>
    </ul>
    <h5 class="underline">Moc10_Form_Element Parent Methods:</h5>
    <ul>
        <li>public function __construct($type, $name, $value = null, $marked = null, $indent = null)</li>
        <li>public function setLabel($l)</li>
        <li>public function setRequired($r)</li>
        <li>public function addValidator($type, $condition = true, $value = null, $msg = null)</li>
        <li>public function validate()</li>
        <li>public function render()</li>
    </ul>
    <h5 class="underline">Moc10_Form_Element Parent Properties:</h5>
    <ul>
        <li>public $value</li>
        <li>public $marked</li>
        <li>public $label</li>
        <li>public $required</li>
        <li>public $validators</li>
        <li>public $errors</li>
        <li>
            protected $_allowed_types
            <ul class="subList">
                <li>button</li>
                <li>checkbox</li>
                <li>file</li>
                <li>hidden</li>
                <li>image</li>
                <li>password</li>
                <li>radio</li>
                <li>reset</li>
                <li>select</li>
                <li>submit</li>
                <li>text</li>
                <li>textarea</li>
            </ul>
        </li>
        <li>
            protected $_allowed_validators
            <ul class="subList">
                <li>AlphaNum</li>
                <li>Alpha</li>
                <li>Between</li>
                <li>Email</li>
                <li>Equal</li>
                <li>GreaterThan</li>
                <li>Length</li>
                <li>LengthBet</li>
                <li>LengthGT</li>
                <li>LengthLT</li>
                <li>LessThan</li>
                <li>NotEmpty</li>
                <li>NotEqual</li>
                <li>Num</li>
                <li>RegEx</li>
            </ul>
        </li>
    </ul>
    <h5 class="underline">Moc10_Form_Element Child Methods:</h5>
    <ul>
        <li>public function __construct($name, $value = null, $marked = null, $indent = null)</li>
        <li>public function setMarked($val) [For select, checkbox and radio elements only]</li>
    </ul>
    <h5 class="underline">Moc10_Form_Element Child Properties:</h5>
    <ul>
        <li>public $values [For select, checkbox and radio elements only]</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Form Call:</h5>
    <pre>

$form = new Test_Form_Contact($_SERVER['PHP_SELF'], 'post');
    </pre>
    <h5 class="underline">Basic Element Call and Set:</h5>
    <pre>

$name = new Moc10_Form_Element('text', 'name', 'My Name');
$name-&gt;setLabel('Name:');
$name-&gt;setAttributes('size', '40');
$name-&gt;setRequired(true);
    </pre>
    <h5 class="underline">Basic Select Element Call and Set:</h5>
    <pre>

$salute = new Moc10_Form_Element_Select('salute', Array('Salute-Mr' =&gt; 'Mr.',
                                                        'Salute-Ms' =&gt; 'Ms.'), $sal);
$salute-&gt;setLabel('Salutation:');

if (is_null($sal)) {
    $salute-&gt;setMarked('Salute-Mr');
}
    </pre>
    <h5 class="underline">Advanced Select Element Call and Set:</h5>
    <p><strong>NOTE:</strong> The select element has pre-defined array values to aide in the quick construction of standard select drop-down menus, i.e., date/time, states, countries, etc.</p>
    <pre>

$months = new Moc10_Form_Element_Select('months', 'MONTHS_LONG');
$months-&gt;setLabel('Months:');
    </pre>
    <h5 class="underline">Add Elements to the Form:</h5>
    <pre>

$form-&gt;addElements(Array($name, $email, $submit));
    </pre>
    <h5 class="underline">Set Form Template:</h5>
    <pre>

$form-&gt;setTemplate($tmpl);
    </pre>
    <h5 class="underline">Render the Form:</h5>
    <p>
        The first example renders the form simple by printing it out with the <strong>__toString( )</strong> method. The second example utilizes the <strong>render( )</strong> method.
    </p>
    <pre>

print($form);

&lt;OR&gt;

$form-&gt;render();
    </pre>
    <h5 class="underline">Validate the Form:</h5>
    <pre>

if ($form-&gt;isValid()) {
    print('The form submitted successfully!');
} else {
    include_once('includes/form_header.php');
    $form-&gt;render();
    include_once('includes/form_footer.php');
}
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="ftp"></a>
    <h4>The FTP Component</h4>
    <p>
        This class allows for basic FTP connectivity to an FTP server using FTP or FTPS (SSL) for the managing of files and directories.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Ftp</li>
    </ul>
    <h5 class="underline">Moc10_Ftp Methods:</h5>
    <ul>
        <li>public function __construct($ftp, $user, $pass, $ssl = false)</li>
        <li>public function pwd()</li>
        <li>public function chdir($dir)</li>
        <li>public function mkdir($dir)</li>
        <li>public function rmdir($dir)</li>
        <li>public function get($local, $remote, $mode = FTP_BINARY)</li>
        <li>public function put($remote, $local, $mode = FTP_BINARY)</li>
        <li>public function rename($old, $new)</li>
        <li>public function chmod($file, $mode)</li>
        <li>public function delete($file)</li>
        <li>public function pasv($flag = true)</li>
        <li>public function __destruct()</li>
    </ul>
    <h5 class="underline">Moc10_Ftp Properties:</h5>
    <ul>
        <li>static private $_conn</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Creation of an FTP connection and sending of a file:</h5>
    <pre>

$ftp = new Moc10_Ftp('ftp.yourserver.com', 'user', 'pass');
$ftp-&gt;chdir('./httpdocs/');
$ftp-&gt;put('test.txt', '../assets/files/test.txt', FTP_ASCII);
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="image"></a>
    <h4>The Image Component</h4>
    <p>
        This component extends Moc10_File and allows you to have advanced control over images and image parameters. You can adjust the <strong>$_allowed</strong> array property to allow for more or less specific image file types. This is recommended if you only want to allow certain image types to interact with your application (i.e., only JPGs.) However, by default, and due to the dependency on the GD extension, the default allowed image types are JPG, GIF and PNG.
    </p>
    <p>
        You can also adjust the <strong>$_max</strong> property in Moc10_Image_Upload class to allow for a certain maximum image size (or null for no limit.) It is recommended that this be set for optimal server performance. Larger images that are uploaded and processed via PHP will tax the server's resources. Additionally, if any issues do arise regarding the uploading of images, check the upload_max_filesize and the memory_limit settings in the php.ini file.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>
            Moc10_Image (extends Moc10_File)
            <ul class="subList">
                <li>
                    Moc10_Image_Upload
                </li>
            </ul>
        </li>
    </ul>
    <h5 class="underline">Parent Methods:</h5>
    <ul>
        <li>public function __construct($img, $up = false, $typ = null, $w = null, $h = null, $r = null, $g = null, $b = null)</li>
        <li>public function resize($px, $q = null, $to = null)</li>
        <li>public function scale($scl, $q = null, $to = null)</li>
        <li>public function crop($px, $x = 0, $y = 0, $q = null, $to = null)</li>
        <li>public function text($str, $size, $x, $y, $rotate = null, $font = null, $r = null, $g = null, $b = null, $to = null)</li>
        <li>public function convert($type, $q = null)</li>
        <li>public function colorTotal()</li>
        <li>public function getColors($format = 'HEX')</li>
        <li>protected function _setQuality($q)</li>
        <li>protected function _createNew()</li>
        <li>protected function _createImage($new, $img, $q = null)</li>
        <li>protected function _save($w, $h, $q = null)</li>
    </ul>
    <h5 class="underline">Child Methods:</h5>
    <ul>
        <li>public function __construct($upload, $file, $size = null, $types = null)</li>
    </ul>
    <h5 class="underline">Parent Properties:</h5>
    <ul>
        <li>public $width</li>
        <li>public $height</li>
        <li>public $channels</li>
        <li>protected $_quality</li>
    </ul>
    <h5 class="underline">Child Properties:</h5>
    <ul>
        <li>protected $_max</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call:</h5>
    <p>
        The first example creates either a new, blank image object. The second example creates an image object from an image on disk. The third example creates a new image object from the uploaded image.
    </p>
    <pre>

$image = new Moc10_Image('images/new.jpg', false, '240', '120');

&lt;OR&gt;

$image = new Moc10_Image('images/test.jpg');

&lt;OR&gt;

$image = new Moc10_Image_Upload($_FILES['up_img']['tmp_name'], '../images/upload.jpg');
    </pre>
    <h5 class="underline">Resize an Image:</h5>
    <p>
        This will resize an image based on the parameter passed, using to the larger dimension.
    </p>
    <pre>

$image = new Moc10_Image('images/test.jpg');
$image-&gt;resize(120);
    </pre>
    <h5 class="underline">Crop an Image to a Square:</h5>
    <pre>

$image = new Moc10_Image('images/test.jpg');
$image-&gt;crop(50);
    </pre>
    <h5 class="underline">Output Text to an Image, Using a True-Type Font:</h5>
    <pre>

$image = new Moc10_Image('images/test.gif');
$image-&gt;text('Hello World', 32, 45, 70, null, 'fonts/times.ttf');
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="lang"></a>
    <h4>The Language Component</h4>
    <p>
        Allows for multiple language support for 12 languages, as well the extension of language support via the importing of custom XML language files.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>
            Moc10_Language
        </li>
    </ul>
    <h5 class="underline">Moc10_Language Methods:</h5>
    <ul>
        <li>public function __construct($lng = null)</li>
        <li>public function getLanguage()</li>
        <li>public function loadFile($langFile)</li>
        <li>public function __($str, $params = null)</li>
        <li>public function _e($str, $params = null)</li>
        <li>public function getLanguages($dir = null)</li>
        <li>public function generateLanguageFile($lang, $api, $dest = false, $src = 'en', $tmpl = null)</li>
        <li>protected function _translate($str, $params = null)</li>
        <li>protected function _loadCurrentLanguage()</li>
    </ul>
    <h5 class="underline">Moc10_Language Properties:</h5>
    <ul>
        <li>protected $_language</li>
        <li>protected $_content</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call:</h5>
    <p>
        The first example creates a language object set for French.
    </p>
    <pre>

$lang = new Moc10_Language('fr');
    </pre>
    <h5 class="underline">Return a Translated String:</h5>
    <p>
        This will return the translated string (if it exists in the XML language file.)
    </p>
    <pre>

$trans = $lang-&gt;__('Error:');
    </pre>
    <h5 class="underline">Echo a Translated String:</h5>
    <p>
        This will echo the translated string (if it exists in the XML language file.)
    </p>
    <pre>

$lang-&gt;_e('Error:');
    </pre>
    <h5 class="underline">Load an Additional Language File:</h5>
    <pre>

$lang-&gt;loadFile('my_french.xml');
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="mail"></a>
    <h4>The Mail Component</h4>
    <p>
        This component allows you to send email messages and content to one or more email addresses in any combination of different ways - text, HTML and with or without file attachments. Multiple files may be attached, and there is support for individual "search and replace" customization per email message (i.e., each person's name, company, etc.)
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Mail</li>
    </ul>
    <h5 class="underline">Methods:</h5>
    <ul>
        <li>public function __construct($em, $nm = null, $subj = null)</li>
        <li>public function setSubject($subj)</li>
        <li>public function getSubject()</li>
        <li>public function setBoundary($bnd = null)</li>
        <li>public function getBoundary()</li>
        <li>public function setCharset($chr)</li>
        <li>public function getCharset()</li>
        <li>public function setText($txt)</li>
        <li>public function setHtml($html)</li>
        <li>public function attachFile($file)</li>
        <li>public function setHeaders($hdrs = null)</li>
        <li>public function init()</li>
        <li>public function send()</li>
        <li>protected function _getMessageType()</li>
    </ul>
    <h5 class="underline">Properties:</h5>
    <ul>
        <li>protected $_queue</li>
        <li>protected $_subject</li>
        <li>protected $_message</li>
        <li>protected $_text</li>
        <li>protected $_html</li>
        <li>protected $_headers</li>
        <li>protected $_charset</li>
        <li>protected $_mime_boundary</li>
        <li>protected $_attachments</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Send a Basic Text Email:</h5>
    <pre>

$mail = new Moc10_Mail('hide@address.com', 'Test Smith', 'Hello World!');

$mail-&gt;setHeaders(Array('From' =&gt; Array('Bob', 'hide@address.com'),
                        'Reply-To' =&gt; Array('Bob', 'hide@address.com')));

$mail-&gt;setText("I'm just trying out this new Moc10 Mail component.\n\nThanks,\nBob\n\n");
$mail-&gt;init();
$mail-&gt;send();
    </pre>
    <h5 class="underline">Attach Files:</h5>
    <pre>

$mail = new Moc10_Mail('hide@address.com', 'Test Smith', 'Hello World!');

$mail-&gt;setHeaders(Array('From' =&gt; Array('Bob', 'hide@address.com'),
                        'Reply-To' =&gt; Array('Bob', 'hide@address.com')));

$mail-&gt;setText("I'm just trying out this new Moc10 Mail component.\n\nThanks,\nBob\n\n");
$mail-&gt;attachFile('../assets/pdfs/hospital_template1.pdf');
$mail-&gt;attachFile('../assets/pdfs/pdf_shapes.pdf');
$mail-&gt;init();
$mail-&gt;send();
    </pre>
    <h5 class="underline">Send to Multiple Emails, with Customization:</h5>
    <pre>

$rcpts = Array(Array('name' =&gt; 'Test',
                     'email' =&gt; 'hide@address.com',
                     'company' =&gt; 'Test Company'),
               Array('name' =&gt; 'John',
                     'email' =&gt; 'hide@address.com',
                     'company' =&gt; 'Johns Company'));

$mail = new Moc10_Mail($rcpts, null, 'Hello [{name}]!');

$mail-&gt;setHeaders(Array('From' =&gt; Array('Bob', 'hide@address.com'),
                        'Reply-To' =&gt; Array('Bob', 'hide@address.com')));

$mail-&gt;setText("Dear [{name}],\n\n
                I'm emailing you at [{email}].
                I'm just trying out this new Moc10 Library component.
                I really like what you've done at [{company}]!\n\n
                Thanks,\n
                Bob\n\n");
$mail-&gt;init();
$mail-&gt;send();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="pdf"></a>
    <h4>The PDF Component</h4>
    <p>
        This component extends Moc10_File and utilizes Moc10_Image. It allows for basic text, graphic and image manipulation within the PDF format, as well as the importing and manipulation of existing PDFs. The following image formats and color types are supported (full PNG alpha channels are not supported):
    </p>
    <ul>
        <li>JPG RGB</li>
        <li>JPG CMYK</li>
        <li>JPG Grayscale</li>
        <li>GIF Indexed Color (w/ Transparency)</li>
        <li>PNG 8-bit Indexed Color (w/ Transparency)</li>
        <li>PNG 24-bit RGB Color</li>
    </ul>
    <img style="float: right;" src="pdf_coor.gif" width="100" height="180" alt="PDF coordinates" />
    <p>
        Many of the methods utilized to place content on a PDF page used a coordinate system that mirrors that of the PDF standard coordinate system. This means that the X,Y coordinates of (0,0) are located at the bottom left of the page. And, in the case of a 'Letter' sized page, the X,Y coordinates of (612, 792) are located at the top right.
    </p>
    <p>
        The Moc10_Pdf_Import class is utilized to import existing PDFs in their entirely, or by pre-defined pages. It is utilized by a Moc10_Pdf object. The classes Moc10_Pdf_Info, Moc10_Pdf_Object, Moc10_Pdf_Page, Moc10_Pdf_Parent and Moc10_Pdf_Root all create their respective PDF-based Postscript objects for the Moc10_Pdf object to utilize.
    </p>
    <p>
        Working with larger PDFs can tax the server's resources. If any issues do arise regarding the handling of PDFs, check the memory_limit settings in the php.ini file.
    </p>
    <p>
        <em><strong>NOTE:</strong> The Moc10_Pdf_Import class attempts to maintain the pertinent data from the imported PDF and its pages, while streamlining and striping away any data that may no longer be relevant as the structure or data of the PDF changes. In particular, any internal links or annotations within the imported PDF may cease to work as a result of changes to the PDF structure or data.</em>
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Pdf (extends Moc10_File)</li>
        <li>Moc10_Pdf_Root</li>
        <li>Moc10_Pdf_Parent</li>
        <li>Moc10_Pdf_Info</li>
        <li>Moc10_Pdf_Page</li>
        <li>Moc10_Pdf_Object</li>
        <li>Moc10_Pdf_Import</li>
    </ul>
    <h5 class="underline">Moc10_Pdf Methods:</h5>
    <span class="note"><strong>Note:</strong> All of the "set" methods return an instance of Moc10_Pdf so they can be easily chained together.</span>
    <ul>
        <li>public function __construct($pdf, $sz = null, $w = null, $h = null)</li>
        <li>public function importPdf($pdf, $pg = null)</li>
        <li>public function addPage($sz = null, $w = null, $h = null)</li>
        <li>public function copyPage($pg)</li>
        <li>public function deletePage($pg)</li>
        <li>public function orderPages($pgs)</li>
        <li>public function curPage()</li>
        <li>public function numPages()</li>
        <li>public function setPage($pg)</li>
        <li>public function setVersion($ver)</li>
        <li>public function setTitle($tle)</li>
        <li>public function setAuthor($auth)</li>
        <li>public function setSubject($subj)</li>
        <li>public function setCreateDate($dt)</li>
        <li>public function setModDate($dt)</li>
        <li>public function setFillColor($r, $g, $b)</li>
        <li>public function setStrokeColor($r, $g, $b)</li>
        <li>public function setStroke($w = null, $dash_len = null, $dash_gap = null)</li>
        <li>public function setTextParams($c = 0, $w = 0, $h = 100, $v = 100, $rot = 0, $rend = 0)</li>
        <li>public function addFont($font)</li>
        <li>public function addText($x, $y, $str, $font, $size)</li>
        <li>public function getStringSize($str, $font, $sz)</li>
        <li>public function addLine($x1, $y1, $x2, $y2)</li>
        <li>public function addRect($x, $y, $l, $w, $fill = true)</li>
        <li>public function addSquare($x, $y, $w, $fill = true)</li>
        <li>public function addEllipse($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $fill = true)</li>
        <li>public function addCircle($x, $y, $r, $fill = true)</li>
        <li>public function addURL($x, $y, $l, $w, $url)</li>
        <li>public function addLink($x, $y, $l, $w, $X, $Y, $Z, $dest = null)</li>
        <li>public function addImage($x, $y, $image, $scl = null)</li>
        <li>public function save($filename = null)</li>
        <li>public function output($action = null)</li>
        <li>public function finalize()</li>
        <li>protected function _getContentObject()</li>
        <li>protected function _calcTextMatrix()</li>
        <li>protected function _calcByteLength($str)</li>
        <li>protected function _formatByteLength($num)</li>
        <li>protected function _convertColor($color)</li>
        <li>protected function _lastIndex($arr)</li>
    </ul>
    <h5 class="underline">Moc10_Pdf Properties:</h5>
    <ul>
        <li>protected $_root</li>
        <li>protected $_parent</li>
        <li>protected $_info</li>
        <li>protected $_allowed</li>
        <li>protected $_pages</li>
        <li>protected $_objects</li>
        <li>protected $_trailer</li>
        <li>protected $_curPage</li>
        <li>protected $_textParams</li>
        <li>protected $_bytelength</li>
        <li>protected $_output</li>
        <li>protected $_standard_fonts</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Root Methods:</h5>
    <ul>
        <li>public function __construct($str = null)</li>
        <li>public function __toString()</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Root Properties:</h5>
    <ul>
        <li>public $version</li>
        <li>public $index</li>
        <li>public $parent</li>
        <li>public $metadata</li>
        <li>protected $_header</li>
        <li>protected $_data</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Parent Methods:</h5>
    <ul>
        <li>public function __construct($str = null)</li>
        <li>public function __toString()</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Parent Properties:</h5>
    <ul>
        <li>public $index</li>
        <li>public $count</li>
        <li>public $kids</li>
        <li>protected $_data</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Info Methods:</h5>
    <ul>
        <li>public function __construct($str = null)</li>
        <li>public function __toString()</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Info Properties:</h5>
    <ul>
        <li>public $index</li>
        <li>public $title</li>
        <li>public $author</li>
        <li>public $subject</li>
        <li>public $create_date</li>
        <li>public $mod_date</li>
        <li>protected $_data</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Page Methods:</h5>
    <ul>
        <li>public function __construct($str = null, $sz = null, $w = null, $h = null, $i = null)</li>
        <li>public function __toString()</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Page Properties:</h5>
    <ul>
        <li>public $index</li>
        <li>public $parent</li>
        <li>public $width</li>
        <li>public $height</li>
        <li>public $curContent</li>
        <li>public $annots</li>
        <li>public $content</li>
        <li>public $xobjs</li>
        <li>public $fonts</li>
        <li>public $thumb</li>
        <li>protected $_data</li>
        <li>protected $_sizes</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Object Methods:</h5>
    <ul>
        <li>public function __construct($i)</li>
        <li>public function __toString()</li>
        <li>public function define($str)</li>
        <li>public function getDef()</li>
        <li>public function setStream($str)</li>
        <li>public function getStream()</li>
        <li>public function getByteLength()</li>
        <li>protected function _calcByteLength($str)</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Object Properties:</h5>
    <ul>
        <li>public $index</li>
        <li>protected $_data</li>
        <li>protected $_def</li>
        <li>protected $_stream</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Import Methods:</h5>
    <ul>
        <li>public function __construct($pdf, $pgs = null)</li>
        <li>public function shiftObjects($ind, $si)</li>
        <li>public function returnObjects($par)</li>
        <li>protected function _getObjects($data)</li>
        <li>protected function _getRefs($data)</li>
        <li>protected function _lastIndex($arr)</li>
    </ul>
    <h5 class="underline">Moc10_Pdf_Import Properties:</h5>
    <ul>
        <li>public $objects</li>
        <li>public $pages</li>
        <li>protected $_data</li>
        <li>protected $_kids</li>
        <li>protected $_thumbs</li>
        <li>protected $_changed</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call, Adding of a Page, Adding of Text, and Output:</h5>
    <p>
        You can either add a page upon instantiation, or via the <strong>addPage( )</strong> method.
    </p>
    <pre>

$pdf = new Moc10_Pdf('new.pdf', 'Letter');

&lt;OR&gt;

$pdf = new Moc10_Pdf('new.pdf');
$pdf-&gt;addPage('Letter');

&lt;THEN&gt;

$pdf-&gt;addFont('Arial');
$pdf-&gt;addText(50, 620, 'Hello World!', 'Arial', 18);

$pdf-&gt;output();
    </pre>
    <h5 class="underline">Copy a Page:</h5>
    <pre>

$pdf-&gt;copyPage(1);
    </pre>
    <h5 class="underline">Set Page in Which to Append Content:</h5>
    <pre>

$pdf-&gt;setPage(2);
    </pre>
    <h5 class="underline">Order Pages:</h5>
    <pre>

$pdf-&gt;orderPages(Array(2, 1));
    </pre>
    <h5 class="underline">Add Graphics:</h5>
    <pre>

$pdf-&gt;setFillColor(12, 101, 215)-&gt;setStrokeColor(215, 101, 12)-&gt;setStroke(4, 10, 5);
$pdf-&gt;addRect(100, 550, 175, 50);
$pdf-&gt;addCircle(150, 700, 60);
    </pre>
    <h5 class="underline">Add an Internal Link and a URL:</h5>
    <pre>

$pdf-&gt;addLink(100, 550, 175, 50, 150, 550, 1, 2);
$pdf-&gt;addURL(50, 650, 380, 36, 'http://www.moc10media.com/');
    </pre>
    <h5 class="underline">Importing PDFs or Selected Pages from Another PDF:</h5>
    <p>
        You have a few options when importing PDFs or pages from a PDF. In the first example, if you declare a new instance of Moc10_PDF object using a PDF file that already exists, then that PDF file and all of its data will be automatically imported. Otherwise, in the second, third and fourth examples, you can declare a new, blank Moc10_PDF object and then import either an entire PDF, a page from a PDF or an array of pages from a PDF.
    </p>
    <pre>

$pdf = new Moc10_Pdf('pdfs/existing_pdf_file.pdf');

&lt;OR&gt;

$pdf = new Moc10_Pdf('new_pdf_file.pdf');
$pdf-&gt;importPdf('existing_pdf_file.pdf');

&lt;OR&gt;

$pdf = new Moc10_Pdf('new_pdf_file.pdf');
$pdf-&gt;importPdf('pdfs/existing_pdf_file.pdf', 2);

&lt;OR&gt;

$pdf = new Moc10_Pdf('new_pdf_file.pdf');
$pdf-&gt;importPdf('pdfs/existing_pdf_file.pdf', Array(1, 3));
    </pre>
    <h5 class="underline">E-mail a PDF:</h5>
    <p>
        You have two options when e-mailing a PDF. In the first example, you can use the inherited <strong>mail( )</strong> method, but it requires that you to save the file to the server, so that the file data can be read and encoded. This example obviously carries the expense of writing to the disk. In the second example, you can simply used the <strong>mailPdf( )</strong> method and it will finalize the PDF's output without writing it to the disk, and then internally utilize the inherited <strong>mail( )</strong> method with that output data.
    </p>
    <p>
        This method requires that the server be properly set up as an outgoing SMTP server, and that sendmail is set correctly within the php.ini file.
    </p>
    <pre>

$pdf-&gt;save('newfile.pdf');
$pdf-&gt;mail('hide@address.com');

&lt;OR&gt;

$pdf-&gt;mailPdf('hide@address.com');
    </pre>
    <h5 class="underline">Save to Server:</h5>
    <pre>

$pdf-&gt;save('newfile.pdf');
    </pre>
    <h5 class="underline">Force Output to Download:</h5>
    <pre>

$pdf-&gt;output(true);
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="record"></a>
    <h4>The Record Component</h4>
    <p>
        This component utilizes Moc10_Db. The Moc10_Record class is meant to be extended based on the name of the table in a database, in which the table name and the primary id properties are defined. Once the class is extended to the child class, the child class will inherit the useful methods to access and modify data in the table within the database.
    </p>
    <p>
        An application code example has been included here: <strong>/application/Test/Table/Users.php</strong>. In this example, the class Test_Table_Users extends Moc10_Record and defines the <strong>$_tableName</strong> and <strong>$_primaryId</strong> properties associated with the database table. This class becomes the main interface to the table in the database, and inherits all of the Moc10_Record class methods and properties to interact with that table and its records.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>
            Moc10_Record
            <ul class="subList">
                <li>Test_Table_Users (Example)</li>
            </ul>
        </li>
    </ul>
    <h5 class="underline">Moc10_Record Methods:</h5>
    <ul>
        <li>protected function __construct($fields = null, $type = null, $db = null, $host = null, $user = null, $pass = null)</li>
        <li>public function __set($name, $value)</li>
        <li>public function __get($name)</li>
        <li>public function __isset($name)</li>
        <li>public function __unset($name)</li>
        <li>public function setAll($fields = null)</li>
        <li>public function findById($id, $limit = 1)</li>
        <li>public function findBy($field, $value = null, $limit = 1)</li>
        <li>public function findAll($order = null, $field = null, $value = null, $limit = null)</li>
        <li>public function distinct($distinctFields, $order = null, $field = null, $value = null, $limit = null)</li>
        <li>public function search($likeFields, $conj = 'AND', $order = null, $limit = null)</li>
        <li>public function join($table, $tableid, $order = null, $field = null, $value = null, $limit = null)</li>
        <li>public function execute($sql)</li>
        <li>public function save($new = true)</li>
        <li>public function delete($field = null, $value = null)</li>
        <li>protected function _setResults()</li>
    </ul>
    <h5 class="underline">Moc10_Record Properties:</h5>
    <ul>
        <li>public $db</li>
        <li>public $rows</li>
        <li>protected $_type</li>
        <li>protected $_hostname</li>
        <li>protected $_dbname</li>
        <li>protected $_username</li>
        <li>protected $_password</li>
        <li>protected $_tableName</li>
        <li>protected $_primaryId</li>
        <li>protected $_fields</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call and Query:</h5>
    <p>
        Since this class utilizes Moc10_Db, the same options exist for handling the database credentials. You can either set the database credential properties within the actual Moc10_Db class once, or, you can pass the database credentials dynamically, as needed.
    </p>
    <pre>

$users = new Test_Table_Users();

&lt;OR&gt;

$users = new Test_Table_Users(null, $type, $db, $host, $user, $pass);

&lt;THEN&gt;

$users-&gt;findAll();

foreach($users-&gt;rows as $value) {
    print($value['username']);
}
    </pre>
    <h5 class="underline">A Note About Moc10_Record Return Results:</h5>
    <p>
        When performing a retrieval query, if only one row is returned, then the object takes on publicly accessible properties that mirror the fields in the record, as well as one ArrayObject added to the publicly accessible $rows property ($rows[0]), where the keys/properties of the ArrayObject mirror the fields in the row. If the retrieval query returns more than one row, then the publicly accessible array property $rows will store ArrayObjects whose keys/properties mirror the fields in each row.
    </p>
    <pre>

print('Username: ' . $user-&gt;username);
print('Email: ' . $user-&gt;email);

&lt;OR&gt;

foreach($users-&gt;rows as $user) {
    print('Username: ' . $user['username']);
    print('Email: ' . $user['email']);
}

&lt;OR&gt;

foreach($users-&gt;objs as $user) {
    print('Username: ' . $user-&gt;username);
    print('Email: ' . $user-&gt;email);
}
    </pre>
    <h5 class="underline">Retrieve and Update a Value:</h5>
    <pre>

$user = new Test_Table_Users();
$user-&gt;findById(15);
$user-&gt;username = 'New Name';
$user-&gt;save();
    </pre>
    <h5 class="underline">Create a New Record:</h5>
    <pre>

$userFields = Array('username' =&gt; 'My Name',
                    'email'    =&gt; 'hide@address.com');

&lt;THEN&gt;

$users = new Test_Table_Users($userFields);

&lt;OR&gt;

$users = new Test_Table_Users($userFields, $type, $db, $host, $user, $pass);

&lt;THEN&gt;

$user-&gt;save();
    </pre>
    <h5 class="underline">Delete a Record:</h5>
    <pre>

$user = new Test_Table_Users();
$user-&gt;findBy('email', 'hide@address.com');
$user-&gt;delete();
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="session"></a>
    <h4>The Session Component</h4>
    <p>
        This class allows for streamlined session management.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_Session</li>
        <li>Moc10_Session_Mobile</li>
        <li>Moc10_Session_Paginator</li>
    </ul>
    <h5 class="underline">Moc10_Session Methods:</h5>
    <ul>
        <li>private function __construct()</li>
        <li>public static function getInstance()</li>
        <li>public function __set($name, $value)</li>
        <li>public function __get($name)</li>
        <li>public function __isset($name)</li>
        <li>public function __unset($name)</li>
        <li>public function getId()</li>
        <li>public function regenId()</li>
        <li>public function kill()</li>
    </ul>
    <h5 class="underline">Moc10_Session Properties:</h5>
    <ul>
        <li>static private $_instance</li>
        <li>private $_session_id</li>
    </ul>
    <h5 class="underline">Moc10_Session_Browser Methods:</h5>
    <ul>
        <li>public function __construct()</li>
        <li>protected function _detect()</li>
    </ul>
    <h5 class="underline">Moc10_Session_Browser Properties:</h5>
    <ul>
        <li>public $ip</li>
        <li>public $subnet</li>
        <li>public $ua</li>
        <li>public $platform</li>
        <li>public $os</li>
        <li>public $browser</li>
        <li>public $version</li>
    </ul>
    <h5 class="underline">Moc10_Session_Mobile Methods:</h5>
    <ul>
        <li>public function __construct($mob = null, $full = null)</li>
        <li>public function goToMobile()</li>
        <li>public function goToStandard()</li>
        <li>public function goToURL($url)</li>
        <li>protected function _detect()</li>
    </ul>
    <h5 class="underline">Moc10_Session_Mobile Properties:</h5>
    <ul>
        <li>public $ua</li>
        <li>public $standard</li>
        <li>public $mobile</li>
        <li>public $isMobile</li>
        <li>public $bypass</li>
    </ul>
    <h5 class="underline">Moc10_Session_Paginator Methods:</h5>
    <ul>
        <li>public function __construct($content, $perpage = 10, $range = null, $total = null, $key = 'Arrows')</li>
        <li>public function setContent($content)</li>
        <li>public function getContent()</li>
        <li>public function setHeader($hdr)</li>
        <li>public function setRowTemplate($tmpl)</li>
        <li>public function setFooter($ftr)</li>
        <li>public function render($pg, $sep = ' | ', $clsLnk = null, $clsOff = null, $dt = null, $ret = false)</li>
        <li>protected function _calcItems($p)</li>
    </ul>
    <h5 class="underline">Moc10_Session_Paginator Properties:</h5>
    <ul>
        <li>protected $_header</li>
        <li>protected $_rowtmpl</li>
        <li>protected $_footer</li>
        <li>protected $_links</li>
        <li>protected $_content</li>
        <li>protected $_perpage</li>
        <li>protected $_numpages</li>
        <li>protected $_start</li>
        <li>protected $_end</li>
        <li>protected $_rem</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call and Session Variable Set:</h5>
    <pre>

$sess = Moc10_Session::getInstance();
$sess-&gt;username = 'yourname';
    </pre>
    <h5 class="underline">Session Verification:</h5>
    <pre>

$sess = Moc10_Session::getInstance();

if (isset($sess-&gt;username) &amp;&amp; ($sess-&gt;username == 'yourname')) {
    print("You are allowed here!");
} else {
    print("You ARE NOT allowed here!");
}
    </pre>
    <h5 class="underline">Session Destruction:</h5>
    <pre>

$sess = Moc10_Session::getInstance();
$sess-&gt;kill();
    </pre>
    <h5 class="underline">Mobile Session Detection:</h5>
    <pre>

$mob = new Moc10_Session_Mobile('./mobile.html', './standard.html');

if ($mob-&gt;isMobile !== false) {
    $mob-&gt;goToMobile();
} else {
    $mob-&gt;goToStandard();
}
    </pre>
    <h5 class="underline">Pagination:</h5>
    <pre>

$sess = Moc10_Session::getInstance();

$sess-&gt;pages = new Moc10_Session_Paginator($rows, 15);

$sess-&gt;pages-&gt;setHeader($header);
$sess-&gt;pages-&gt;setRowTemplate($template);
$sess-&gt;pages-&gt;setFooter($footer);
    </pre>
    </div>
    <div class="divide"></div>
    <span class="right"><a href="./manual.html#top">back to top ^</a></span>
    <a name="string"></a>
    <h4>The String Component</h4>
    <p>
        This class allows for easy manipulation of strings.
    </p>
    <h5 class="underline">Classes:</h5>
    <ul>
        <li>Moc10_String</li>
    </ul>
    <h5 class="underline">Moc10_String Methods:</h5>
    <span class="note"><strong>Note:</strong> The string manipulation methods (everything from <strong>glue( )</strong> and below) returns an instance of Moc10_String so they can be easily chained together.</span>
    <ul>
        <li>public function __construct($str = null)</li>
        <li>public function __toString()</li>
        <li>public static function setString($str)</li>
        <li>public function length()</li>
        <li>public function pos($char, $offset = 0)</li>
        <li>public function ipos($char, $offset = 0)</li>
        <li>public function split($delimiter)</li>
        <li>public function glue($ary, $delimiter)</li>
        <li>public function lower()</li>
        <li>public function upper()</li>
        <li>public function upperall()</li>
        <li>public function upperfirst()</li>
        <li>public function sub($start, $len = null)</li>
        <li>public function between($start, $end)</li>
        <li>public function replace($search, $replace)</li>
        <li>public function ireplace($search, $replace)</li>
        <li>public function preg($pattern, $replace)</li>
        <li>public function trim($chars = null)</li>
        <li>public function add()</li>
        <li>public function strip()</li>
        <li>public function striptags($allowed = null)</li>
        <li>public function escape($all = false)</li>
        <li>public function br()</li>
        <li>public function wrap($len, $delimiter = "\n", $cut = false)</li>
        <li>public function html()</li>
        <li>public function dehtml()</li>
        <li>public function slug($sep = null)</li>
        <li>public function links($tar = false)</li>
        <li>public function date($format = 'm/d/Y')</li>
        <li>public function random($len, $caps = false)</li>
    </ul>
    <h5 class="underline">Moc10_String Properties:</h5>
    <ul>
        <li>protected $_string</li>
    </ul>
    <div class="examples">
    <h5 class="underline">Basic Call and Preparation for a Database:</h5>
    <pre>

$str = new Moc10_String("Bob's Things &amp;amp; Stuff");
$str-&gt;dehtml()-&gt;add();
    </pre>
    <h5 class="underline">Convert Newlines to BR Tags:</h5>
    <pre>

$str = new Moc10_String($content);
$str-&gt;br();
    </pre>
    <h5 class="underline">Link Conversion:</h5>
    <pre>

$str = new Moc10_String("Visit the website at http://www.moc10media.com/");
$str-&gt;links();
    </pre>
    <h5 class="underline">SEO-Slug:</h5>
    <pre>

$str = new Moc10_String("Hello You 283 &amp;^%$ 'Dud\e798(*0:");
$str-&gt;slug();
    </pre>
    <h5 class="underline">Random Alphanumeric String:</h5>
    <pre>

$str = new Moc10_String();
$str-&gt;random(7);
    </pre>
    </div>
    <div class="divide"></div>
</div>
<!-- Footer //-->
<div id="footer">
    Copyright &copy; 2009-2011, Moc 10 Media, LLC. All rights reserved.
</div>
</body>

</html>
Return current item: Moc10 PHP Library