Located in File: /Ak.php
Ak contains all the Akelos Framework static functions. This class acts like a name space to avoid naming collisions when PHP gets new functions into its core. And also to provide additional functionality to existing PHP functions mantaining the same interface
Static Method db (line 64)
Whenever a database connection is required you can get a reference to the default database connection by doing:
$db =& Ak::db(); // get an adodb instance
AdoDB manual can be found at http://phplens.com/adodb/
Static Method debug (line 618)
Static Method get_object_info (line 690)
Static Method get_this_object_attributes (line 754)
WARNING: Inherited attributes are not returned by this function. You can fetch them by using PHP native function get_class_vars
Static Method get_this_object_methods (line 724)
WARNING: Inherited methods are not returned by this function. You can fetch them by using PHP native function get_class_methods
Static Method t (line 139)
When using Ak::t(), try to put entire sentences and strings in one Ak::t() call. This makes it easier for translators. HTML markup within translation strings is acceptable, if necessary. The suggested syntax for a link embedded within a translation string is:
Static Method trace (line 584)
Method array_sort_by (line 1633)
Method array_to_xml (line 1123)
Method blowfishDecrypt (line 1197)
Method blowfishEncrypt (line 1188)
Method call_user_func_array (line 1614)
Method client_api (line 1774)
Method collect (line 1053)
Method compat (line 1373)
Method compress (line 1222)
Method convert (line 1399)
You can find available converters on AkConverters
Usage Example: In order to convert from HTML to RTF you just need to call. $rtf = Ak::convert('html','rtf', $my_html_file, array('font_size'=> 24));
Where the last option is an array of options for selected converter.
Previous example is the same as.
$rtf = Ak::convert(array('from'=>'html','to'=>'rtf', 'source' => $my_html_file, 'font_size'=> 24));
In order to create converters, you just need to name them "SourceFormatName + To + DestinationFormatName". Whenever you need to call the, you need to specify the "path" option where your converter is located. The only thing you converter must implement is a convert function. Passes options will be made available as attributes on the converter. If your converter needs to prepare something before the convert method is called, you just need to implement a "init" method. You can avoid this by inspecting passed attributes to your constructor
Method copy (line 484)
It uses current installation settings, so it can perform copies via the filesystem or via FTP
Method decompress (line 1274)
Method decrypt (line 1166)
Method delete (line 1068)
Method deprecateWarning (line 74)
Method directory_delete (line 415)
Method encrypt (line 1141)
Method file_add_contents (line 391)
Method file_delete (line 397)
Method file_get_contents (line 370)
Method file_put_contents (line 326)
Method fromJson (line 1548)
Method getDate (line 847)
You can supply a format as defined at http://php.net/date
Default date is in ISO format
Method getTimestamp (line 811)
Method get_url_locale (line 259)
Method html_entity_decode (line 1792)
Method import (line 1297)
Method loadPlugins (line 1810)
Method locale (line 222)
This are common settings on the locale file: 'description' // Locale description Example. Spanish 'charset' // 'ISO-8859-1'; 'date_time_format' // '%d/%m/%Y %H:%i:%s'; 'date_format' // '%d/%m/%Y'; 'long_date_format' // '%d/%m/%Y'; 'time_format' // '%H:%i'; 'long_time_format' // '%H:%i:%s';
Method logObjectForModifications (line 1590)
Method mail (line 920)
Messaging subsystem for user communication. See PEAR::Mail() function in PHP documentation for information.
User must declare any of these variables for specify the outgoing method. Currently, only Sendmail and STMP methods are available . Variables for using any of these methods are:
AK_SENDMAIL = 0 AK_SMTP = 1
For future upgrades, you must define which constants must be declared and add the functionality.
NOTE: If messaging method is SMTP, you must declare in config file (/config/config.php) the outgoing SMTP server and the authentication pair user/password as constants AK_SMTP_SERVER, AK_SMTP_USER and AK_SMTP_PASSWORD, respectively.
Receiver, or receivers of the mail.
The formatting of this string must comply with RFC 2822. Some examples are:
user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com>
(optional)
Array to be inserted at the end of the email header.
This is typically used to add extra headers (Bcc) in an associative array, where the array key is the header name (i.e., 'Bcc'), and the array value is the header value (i.e., 'test'). The header produced from those values would be 'Bcc: test'.
Method make_dir (line 455)
Method objectHasBeenModified (line 1601)
Method permute (line 1686)
Method pick (line 1360)
This is useful to limit the parameters of an array used by a method.
This utility can be used for modifying arrays which is useful for securing record creation/updating.
If you have this code on a controller
$this->user->setAttributes($this->params['user']);
and your users table has a column named is_admin. All it would take to a malicious user is to modify the page html to add the need field and gain admin privileges.
You could avoid by using the new Ak::pick method which will return and array with desired keys.
$this->user->setAttributes(Ak::pick('name,email', $this->params['user']));
Method profile (line 973)
Method recode (line 1466)
Method resetObjectModificationsWacther (line 1596)
Method sanitize_include (line 1759)
Method select (line 1031)
This is useful when you just need some fields for generating tables, select lists with only desired fields.
$People = array( array('name'=>'Jose','email'=>'jose@example.com','address'=>'Colon, 52'), array('name'=>'Alicia','email'=>'alicia@example.com','address'=>'Mayor, 45'), array('name'=>'Hilario','email'=>'hilario@example.com','address'=>'Carlet, 78'), array('name'=>'Bermi','email'=>'bermi@example.com','address'=>'Vilanova, 33'), );
$people_for_table_generation = Ak::select($People,'name','email');
Now $people_for_table_generation will hold an array with array ( array ('name' => 'Jose','email' => 'jose@example.com'), array ('name' => 'Alicia','email' => 'alicia@example.com'), array ('name' => 'Hilario','email' => 'hilario@example.com'), array ('name' => 'Bermi','email' => 'bermi@example.com') );
Method singleton (line 1079)
Method size (line 992)
Method stream (line 1661)
Method strlen_utf8 (line 1509)
Taken from anpaza at mail dot ru post at http://php.net/strlen
Method test (line 1751)
Method toJson (line 1537)
For AJAX driven pages, JSON can come in handy – you can return send JavaScript objects directly from your actions.
Method toUrl (line 100)
Method uncompress (line 1243)
Method unzip (line 1266)
Method url_get_contents (line 562)
Method userEncoding (line 1489)
Method utf8 (line 1458)
Method uuid (line 1734)
RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt) defines a special type of Globally Unique IDentifiers (GUID), as well as several methods for producing them. One such method, described in section 4.4, is based on truly random or pseudo-random number generators, and is therefore implementable in a language like PHP.
We choose to produce pseudo-random numbers with the Mersenne Twister, and to always limit single generated numbers to 16 bits (ie. the decimal value 65535). That is because, even on 32-bit systems, PHP's RAND_MAX will often be the maximum *signed* value, with only the equivalent of 31 significant bits. Producing two 16-bit random numbers to make up a 32-bit one is less efficient, but guarantees that all 32 bits are random.
The algorithm for version 4 UUIDs (ie. those based on random number generators) states that all 128 bits separated into the various fields (32 bits, 16 bits, 16 bits, 8 bits and 8 bits, 48 bits) should be random, except : (a) the version number should be the last 4 bits in the 3rd field, and (b) bits 6 and 7 of the 4th field should be 01. We try to conform to that definition as efficiently as possible, generating smaller values where possible, and minimizing the number of base conversions.
Method _getRestrictedPath (line 532)
This is used by Akelos to prevent functions namespaced under Ak from writing out of the Akelos base directory for security reasons.