Tuesday, 6 September 2011

How to change FCKeditor skin, ToolbarSet, height and width


 How to  change FCKeditor skin, ToolbarSet, height and width


CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.

Because CKEditor is licensed under flexible Open Source and commercial licenses, you'll be able to integrate and use it inside any kind of application. This is the ideal editor for developers, created to provide easy and powerful solutions to their users.

Implement with cakephp, Its an easy just follow the some steps. How to implement?


 How to  change FCKeditor skin, ToolbarSet, height and width.
Suppose in one page you have 3 editor and each need different height, width, skin or toolbarset. for this, Follow the following lines.

1) open file "app/views/helpers/fck.php"
2) go to function "load"
3)set all the vars as below
load($id, $skin='silver', $toolbar = 'Basic', $height='400', $width='300');
4)put the variable $skin as below
 bFCKeditor_$did.Skin         = '$skin';

do all the same
5)open the ctp file for add/edit where u r using calling load function [where u r creating editor]
and pass the arguments as below
 $fck->load('id', 'silver','Basic','200px', '200px' );

Ajax AutoComplete for jQuery

Ajax AutoComplete for jQuery


Question: What is Autocomplete?
The Autocomplete widgets provides suggestions words or strings without the user needing to type them in full;
For Example:
When you start type "auto" in google search, Its provides you list of suggestions like below:
"auto liker", "autocard", "autocar", "autocar india", etc


Question: How to add "auto complete" in cakephp?
  In ajax autocomplete to add more than one value
You can use "tokens" like below
 new Ajax.Autocompleter('id','upd', 'url', { tokens: ',' });
 http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter

Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.



Question: How to add "auto complete" in jQuery?
jQuery(document).ready(function()  {
//Autocomplete config
  jQuery("#FriendMyLocation").autocomplete('/autocompletes/index/City/name', {minChars:3}); 
});         

List of config available in Autocomplete.
$.Autocompleter.defaults = {
    inputClass: "ac_input", 
    resultsClass: "ac_results", 
    loadingClass: "ac_loading",
    minChars: 1, 
    delay: 400, 
    matchCase: false,
    matchSubset: true,
    matchContains: false,
    cacheLength: 10,
    max: 100, 
    mustMatch: false,
    extraParams: {},
    selectFirst: true, 
    formatItem: function(row) { return row[0]; },
    autoFill: false, 
    width: 0, 
    multiple: false, 
    multipleSeparator: ", ",
    highlight: function(value, term) { 
        return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([^$()[]{}*.+?|\])/gi, "\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"); 
    }, 
    scroll: true, 
    scrollHeight: 180, 
    attachTo: 'body' 
};
Download the Plugins From https://plugins.jquery.com/ui.autocomplete/

Multilingual in Cakephp1.3

Multilingual in cakephp
Just do the following three points

1) In view file user as
echo __('USERNAME'); 

2) IN default.po locale/eng/LC_MESSAGES/default.po
msgid "USERNAME" 
msgstr "User Name"

3) // config/bootstrap.php
define(DEFAULT_LANGUAGE, 'eng');

4)In HTML head add Following
[meta charset="UTF-8"]

Compile .po file
msgfmt message.po.txt -o message.po 




Multilingual Characters save in Database
1. Table Collation should be utf8_general_ci
2. Table's Field Collation should be utf8_general_ci
3. While Save in Db, set character set utf8
4. When Display in Browser, add following tag in Head
<meta charset="UTF-8">




Paypal return error : malformed

Paypal return error : malformed

Problem:
Hi,
I am using payapl gateway for payment in my project.
It is working fine for sandbox(test account) but no working for paypal (original paypal detail on client server);
It return following errror from paypal
  Array
    (
        [Error] => Array
            (
                [Number] =>  malformed
            )

    )





Solution: When you are sending amount(money) in paypal api, Amount must be upto  2 digit decimal places. 

For Example
100.02  (Valid)
22.32 (Valid)
12.254 (invalid)

PHP Magic Methods with Examples

PHP Magic Methods with Examples

Explain the Magic Method in Detail


The function names __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(),  __debugInfo() and __clone() are magical in PHP classes.

1) You cannot create any usr-defined function with double underscore (i.e __) because double underscore is reserved.
2) Magic Methods are start with double underscore (i.e __).
3) When we create any magic method in class start calling automatically. that's why called magic method.



__construct
When we make init an class object, It will call __construct method.


__destruct
When class scope end, It will call __destruct method.


__call
When we make trying to access inaccessible methods, It will call the __call method.


__callStatic
When we make trying to access inaccessible methods in static, It will call the __callStatic method.


__get
When we make trying to access inaccessible variable, It will call the __get method.


__isset()
When we make trying to calling isset() or empty() on inaccessible properties, It will call the __isset method.


__unset()
When we make trying to calling unset on inaccessible properties, It will call the __unset method.


__sleep()
When we are using serialize() function, It will check for __sleep(). If __sleep() is defined, this function is executed prior to any serialization.


__wakeup()
When we are using unserialize() function, It will check for __wakeup(). If __wakeup() is defined, this function is executed prior to any unserialization.


__toString()
When we try to print an object, It will call __toString() function (if defined).


__invoke()
When we try to call object as function, It will call __invoke() function (if defined).


__set_state()
When we are using var_export() function, It will check for __set_state(). If __set_state() is defined, this function is executed prior to any var_export().


__debugInfo()
When we are using var_dump() function, It will check for __debugInfo. If __debugInfo is defined, this function is executed prior to any var_dump().



Example of __sleep and __wakeup:

/** class to test magic method i.e sleep and wakeup **/
  class magicmethod
{
    public $name1 = 'Hello';
    function __wakeup()    {  
        echo "__wakeup funx called \n";
        echo $this->name1;
    }
    function __sleep(){  
        echo "__sleep funx called \n";
        $this->name1 ='Arun kumar';
        return array('name1');
    }
}
$obj = new magicmethod();
$objString = serialize($obj);
echo $objString;
echo '\n' ;
unserialize($objString);


Output

__sleep funx called

O:11:"magicmethod":1:{s:5:"name1";s:10:"Arun kumar";}  
__wakeup funx called 
Arun kumar 



Share your Website

If you are running a blog or any kind of website, and you’re always trying to encourage more people to talk about and share your pages on social sites like facebook, LinkedIn, twitter etc and posts through a variety of channels, including social media and e-mail.


Share your website



Following are popular sites which provide you "embed code", After integration embed code, user can share your website on social sites.
1) https://www.addthis.com/
2) https://www.addtoany.com/
3) http://sharethis.com/