Function Create Alias From Title

Here is code of  function create alias form title:  /** *This function will replace vietnamese character with latin character,space with ‘-‘ * *@author : noname *@param string *@return string */ function convert2Alias($cs) { $marTViet=array(“à”,”á”,”ạ”,”ả”,”ã”,”â”,”ầ”,”ấ”,”ậ”,”ẩ”,”ẫ”,”ă”, “ằ”,”ắ”,”ặ”,”ẳ”,”ẵ”,”è”,”é”,”ẹ”,”ẻ”,”ẽ”,”ê”,”ề” ,”ế”,”ệ”,”ể”,”ễ”, “ì”,”í”,”ị”,”ỉ”,”ĩ”, “ò”,”ó”,”ọ”,”ỏ”,”õ”,”ô”,”ồ”,”ố”,”ộ”,”ổ”,”ỗ”,”ơ” ,”ờ”,”ớ”,”ợ”,”ở”,”ỡ”, “ù”,”ú”,”ụ”,”ủ”,”ũ”,”ư”,”ừ”,”ứ”,”ự”,”ử”,”ữ”, “ỳ”,”ý”,”ỵ”,”ỷ”,”ỹ”, “đ”, “À”,”Á”,”Ạ”,”Ả”,”Ô,””,”Ầ”,”Ấ”,”Ậ”,”Ẩ”,”Ẫ”,”Ă” ,”Ằ”,”Ắ”,”Ặ”,”Ẳ”,”Ẵ”, “È”,”É”,”Ẹ”,”Ẻ”,”Ẽ”,”Ê”,”Ề”,”Ế”,”Ệ”,”Ể”,”Ễ”, “Ì”,”Í”,”Ị”,”Ỉ”,”Ĩ”, “Ò”,”Ó”,”Ọ”,”Ỏ”,”Õ”,”Ô”,”Ồ”,”Ố”,”Ộ”,”Ổ”,”Ỗ”,”Ơ” ,”Ờ”,”Ớ”,”Ợ”,”Ở”,”Ỡ”, “Ù”,”Ú”,”Ụ”,”Ủ”,”Ũ”,”Ư”,”Ừ”,”Ứ”,”Ự”,”Ử”,”Ữ”, “Ỳ”,”Ý”,”Ỵ”,”Ỷ”,”Ỹ”, “Đ”,” “); $marKoDau=array(“a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a” ,”a”,”a”,”a”,”a”,”a”,”a”, “e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,…

Read More

Cake Bake – Cake Console

Some quick tip to use cake bake In normal, you will type :  $cake bake After that, you will answer each question of cake bake as what do you generate (D/M/V/C/P/Q …) … how to gen. We have a quickly statement to do that :  Want to direct generate models $cake bake model Want to…

Read More

Determine The First Day Of Week And The First Day Of Month

1. Determine the first day of week (Monday) To find Monday of next week, we change ‘last’ to ‘next’. To determine the distance of current day with the first day of week, we use function: <?php echo floor((strtotime (“now”)- strtotime(“last Monday”))/86400); ?> 2. Determine the first day of month <?php $day = date(‘Y-m-d’, strtotime(date(‘Y-m-01’, strtotime(“now”))));…

Read More

Limit Download Speed With PHP

http://code.google.com/p/phptraining/source/browse/trunk/download_limited.php class DownloadLimited { /** * Send the local file to client with limit download rate as user view file name * * @param string $localFile file to send * @param string $userViewFileName filename client will see * @param float $downloadRate download limit speed in kb/s (ex: 50 kb/s) * @return no return */ function…

Read More

PHP World – The First Concepts

Using mature PHP or a particular programming language, the first step you should remember and distinguish between the terms / concepts most basic commonly used in relation to the language itself or enforcement platform of that language. PHP also has a list of terms (simple but easy to ignore as): PHP: PHP Hypertext Preprocesser or Personal…

Read More

Short PHP Code

This is some example of short code in PHP Exp1 : // A lot of code $status = fwrite($h, ‘some text’); if (!$status) { log(‘Writing failed’); } // Less code ${0} = fwrite($h, ‘some text’); if (!${0}) log(‘Writing failed’); // Even less code fwrite($h, ‘some text’) or log(‘Writing failed’); Exp2 : // A lot of…

Read More

Helper tinyMCE

You can refer manual at : http://blog.javamonday.com/2016/06/using-helper-tinymce-in-cakephp-12.html Create file app/views/helpers/tinymce.php with content : <?php class TinyMceHelper extends AppHelper { // Take advantage of other helpers var $helpers = array(‘Javascript’, ‘Form’); // Check if the tiny_mce.js file has been added or not var $_script = false; /** * Adds the tiny_mce.js file and constructs the options *…

Read More

Using TinyMCE, iBrowser With CakePHP

TinyMCE Setup Download TinyMCE in Here After downloaded, extract to TinyMCE folder and copy /tiny_mce folder into /webroot/js in cakePHP. Config Putting this code to layout (or view if you don’t want to use default for all layout) <?php if(isset($javascript)): echo $javascript->link(‘tiny_mce/tiny_mce.js’); endif; ?> Define to use javascript helper in Controller: <script type=”text/javascript”> tinyMCE.init({ theme :…

Read More