Back to index

d-push  2.0
Static Public Member Functions
Utils Class Reference

List of all members.

Static Public Member Functions

static PrintAsString ($var)
 Prints a variable as string If a boolean is sent, 'true' or 'false' is displayed.
static SplitDomainUser ($domainuser)
 Splits a "domain\user" string into two values If the string cotains only the user, domain is returned empty.
static IcalTimezoneFix ($ical)
 iPhone defines standard summer time information for current year only, starting with time change in February.
static BuildAddressString ($street, $zip, $city, $state, $country)
 Build an address string from the components.
static CheckMapiExtVersion ($version="")
 Checks if the PHP-MAPI extension is available and in a requested version.
static GetICalUidFromOLUid ($olUid)
 Parses and returns an ecoded vCal-Uid from an OL compatible GlobalObjectID.
static GetOLUidFromICalUid ($icalUid)
 Checks the given UID if it is an OL compatible GlobalObjectID If not, the given UID is encoded inside the GlobalObjectID.
static ExtractBaseDate ($goid, $recurStartTime)
 Extracts the basedate of the GlobalObjectID and the RecurStartTime.
static GetCutOffDate ($restrict)
 Converts SYNC_FILTERTYPE into a timestamp.
static GetTruncSize ($truncation)
 Converts SYNC_TRUNCATION into bytes.
static Utf8_truncate ($string, $length)
 Truncate an UTF-8 encoded sting correctly.
static IsSystemFolder ($foldertype)
 Indicates if the specified folder type is a system folder.
static Utf7_iconv_decode ($string)
 Our own utf7_decode function because imap_utf7_decode converts a string into ISO-8859-1 encoding which doesn't have euro sign (it will be converted into two chars: [space](ascii 32) and "¬" ("not sign", ascii 172)).
static Utf7_iconv_encode ($string)
 Our own utf7_encode function because the string has to be converted from standard UTF7 into modified UTF7 (aka UTF7-IMAP).
static Utf7_to_utf8 ($string)
 Converts an UTF-7 encoded string into an UTF-8 string.
static Utf8_to_utf7 ($string)
 Converts an UTF-8 encoded string into an UTF-7 string.
static CheckEmail ($email)
 Checks for valid email addresses The used regex actually only checks if a valid email address is part of the submitted string it also returns true for the mailbox format, but this is not checked explicitly.
static IsBase64String ($string)
 Checks if a string is base64 encoded.
static DecodeBase64URI ($query)
 Decodes base64 encoded query parameters.
static GetCommandFromCode ($code)
 Returns a command string for a given command code.
static GetCodeFromCommand ($command)
 Returns a command code for a given command.
static getDayStartOfTimestamp ($timestamp)
 Normalize the given timestamp to the start of the day.
static GetFormattedTime ($timestamp=false)
 Returns a formatted string output from an optional timestamp.

Detailed Description

Definition at line 44 of file utils.php.


Member Function Documentation

static Utils::BuildAddressString ( street,
zip,
city,
state,
country 
) [static]

Build an address string from the components.

Parameters:
string$streetthe street
string$zipthe zip code
string$citythe city
string$statethe state
string$countrythe country

public

Returns:
string the address string or null

Definition at line 121 of file utils.php.

                                                                                      {
        $out = "";

        if (isset($country) && $street != "") $out = $country;

        $zcs = "";
        if (isset($zip) && $zip != "") $zcs = $zip;
        if (isset($city) && $city != "") $zcs .= (($zcs)?" ":"") . $city;
        if (isset($state) && $state != "") $zcs .= (($zcs)?" ":"") . $state;
        if ($zcs) $out = $zcs . "\r\n" . $out;

        if (isset($street) && $street != "") $out = $street . (($out)?"\r\n\r\n". $out: "") ;

        return ($out)?$out:null;
    }

Here is the caller graph for this function:

static Utils::CheckEmail ( email) [static]

Checks for valid email addresses The used regex actually only checks if a valid email address is part of the submitted string it also returns true for the mailbox format, but this is not checked explicitly.

Parameters:
string$emailaddress to be checked

public

Returns:
boolean

Definition at line 463 of file utils.php.

                                              {
        return (bool) preg_match('#([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*)|localhost)#', $email);
    }

Here is the caller graph for this function:

static Utils::CheckMapiExtVersion ( version = "") [static]

Checks if the PHP-MAPI extension is available and in a requested version.

Parameters:
string$versionthe version to be checked ("6.30.10-18495", parts or build number)

public

Returns:
boolean installed version is superior to the checked strin

Definition at line 145 of file utils.php.

                                                              {
        // compare build number if requested
        if (preg_match('/^\d+$/', $version) && strlen($version) > 3) {
            $vs = preg_split('/-/', phpversion("mapi"));
            return ($version <= $vs[1]);
        }

        if (extension_loaded("mapi")){
            if (version_compare(phpversion("mapi"), $version) == -1){
                return false;
            }
        }
        else
            return false;

        return true;
    }

Here is the caller graph for this function:

static Utils::DecodeBase64URI ( query) [static]

Decodes base64 encoded query parameters.

Based on dw2412 contribution.

Parameters:
string$querythe query to decode

public

Returns:
array

Definition at line 487 of file utils.php.

                                                   {
        /*
         * The query string has a following structure. Number in () is position:
         * 1 byte       - protocoll version (0)
         * 1 byte       - command code (1)
         * 2 bytes      - locale (2)
         * 1 byte       - device ID length (4)
         * variable     - device ID (4+device ID length)
         * 1 byte       - policy key length (5+device ID length)
         * 0 or 4 bytes - policy key (5+device ID length + policy key length)
         * 1 byte       - device type length (6+device ID length + policy key length)
         * variable     - device type (6+device ID length + policy key length + device type length)
         * variable     - command parameters, array which consists of:
         *                      1 byte      - tag
         *                      1 byte      - length
         *                      variable    - value of the parameter
         *
         */
        $decoded = base64_decode($query);
        $devIdLength = ord($decoded[4]); //device ID length
        $polKeyLength = ord($decoded[5+$devIdLength]); //policy key length
        $devTypeLength = ord($decoded[6+$devIdLength+$polKeyLength]); //device type length
        //unpack the decoded query string values
        $unpackedQuery = unpack("CProtVer/CCommand/vLocale/CDevIDLen/H".($devIdLength*2)."DevID/CPolKeyLen".($polKeyLength == 4 ? "/VPolKey" : "")."/CDevTypeLen/A".($devTypeLength)."DevType", $decoded);

        //get the command parameters
        $pos = 7 + $devIdLength + $polKeyLength + $devTypeLength;
        $decoded = substr($decoded, $pos);
        while (strlen($decoded) > 0) {
            $paramLength = ord($decoded[1]);
            $unpackedParam = unpack("CParamTag/CParamLength/A".$paramLength."ParamValue", $decoded);
            $unpackedQuery[ord($decoded[0])] = $unpackedParam['ParamValue'];
            //remove parameter from decoded query string
            $decoded = substr($decoded, 2 + $paramLength);
        }
        return $unpackedQuery;
    }

Here is the caller graph for this function:

static Utils::ExtractBaseDate ( goid,
recurStartTime 
) [static]

Extracts the basedate of the GlobalObjectID and the RecurStartTime.

Parameters:
string$goidOL compatible GlobalObjectID
long$recurStartTimepublic
Returns:
long basedate

Definition at line 216 of file utils.php.

                                                                   {
        $hexbase = substr(bin2hex($goid), 32, 8);
        $day = hexdec(substr($hexbase, 6, 2));
        $month = hexdec(substr($hexbase, 4, 2));
        $year = hexdec(substr($hexbase, 0, 4));

        if ($day && $month && $year) {
            $h = $recurStartTime >> 12;
            $m = ($recurStartTime - $h * 4096) >> 6;
            $s = $recurStartTime - $h * 4096 - $m * 64;

            return gmmktime($h, $m, $s, $month, $day, $year);
        }
        else
            return false;
    }

Here is the caller graph for this function:

static Utils::GetCodeFromCommand ( command) [static]

Returns a command code for a given command.

Parameters:
string$commandpublic
Returns:
int or false if command is unknown

Definition at line 576 of file utils.php.

                                                        {
        switch ($command) {
            case 'Sync':                 return ZPush::COMMAND_SYNC;
            case 'SendMail':             return ZPush::COMMAND_SENDMAIL;
            case 'SmartForward':         return ZPush::COMMAND_SMARTFORWARD;
            case 'SmartReply':           return ZPush::COMMAND_SMARTREPLY;
            case 'GetAttachment':        return ZPush::COMMAND_GETATTACHMENT;
            case 'FolderSync':           return ZPush::COMMAND_FOLDERSYNC;
            case 'FolderCreate':         return ZPush::COMMAND_FOLDERCREATE;
            case 'FolderDelete':         return ZPush::COMMAND_FOLDERDELETE;
            case 'FolderUpdate':         return ZPush::COMMAND_FOLDERUPDATE;
            case 'MoveItems':            return ZPush::COMMAND_MOVEITEMS;
            case 'GetItemEstimate':      return ZPush::COMMAND_GETITEMESTIMATE;
            case 'MeetingResponse':      return ZPush::COMMAND_MEETINGRESPONSE;
            case 'Search':               return ZPush::COMMAND_SEARCH;
            case 'Settings':             return ZPush::COMMAND_SETTINGS;
            case 'Ping':                 return ZPush::COMMAND_PING;
            case 'ItemOperations':       return ZPush::COMMAND_ITEMOPERATIONS;
            case 'Provision':            return ZPush::COMMAND_PROVISION;
            case 'ResolveRecipients':    return ZPush::COMMAND_RESOLVERECIPIENTS;
            case 'ValidateCert':         return ZPush::COMMAND_VALIDATECERT;

            // Deprecated commands
            case 'GetHierarchy':         return ZPush::COMMAND_GETHIERARCHY;
            case 'CreateCollection':     return ZPush::COMMAND_CREATECOLLECTION;
            case 'DeleteCollection':     return ZPush::COMMAND_DELETECOLLECTION;
            case 'MoveCollection':       return ZPush::COMMAND_MOVECOLLECTION;
            case 'Notify':               return ZPush::COMMAND_NOTIFY;

            // Webservice commands
            case 'WebserviceDevice':     return ZPush::COMMAND_WEBSERVICE_DEVICE;
        }
        return false;
    }

Here is the caller graph for this function:

static Utils::GetCommandFromCode ( code) [static]

Returns a command string for a given command code.

Parameters:
int$codepublic
Returns:
string or false if code is unknown

Definition at line 533 of file utils.php.

                                                     {
        switch ($code) {
            case ZPush::COMMAND_SYNC:                 return 'Sync';
            case ZPush::COMMAND_SENDMAIL:             return 'SendMail';
            case ZPush::COMMAND_SMARTFORWARD:         return 'SmartForward';
            case ZPush::COMMAND_SMARTREPLY:           return 'SmartReply';
            case ZPush::COMMAND_GETATTACHMENT:        return 'GetAttachment';
            case ZPush::COMMAND_FOLDERSYNC:           return 'FolderSync';
            case ZPush::COMMAND_FOLDERCREATE:         return 'FolderCreate';
            case ZPush::COMMAND_FOLDERDELETE:         return 'FolderDelete';
            case ZPush::COMMAND_FOLDERUPDATE:         return 'FolderUpdate';
            case ZPush::COMMAND_MOVEITEMS:            return 'MoveItems';
            case ZPush::COMMAND_GETITEMESTIMATE:      return 'GetItemEstimate';
            case ZPush::COMMAND_MEETINGRESPONSE:      return 'MeetingResponse';
            case ZPush::COMMAND_SEARCH:               return 'Search';
            case ZPush::COMMAND_SETTINGS:             return 'Settings';
            case ZPush::COMMAND_PING:                 return 'Ping';
            case ZPush::COMMAND_ITEMOPERATIONS:       return 'ItemOperations';
            case ZPush::COMMAND_PROVISION:            return 'Provision';
            case ZPush::COMMAND_RESOLVERECIPIENTS:    return 'ResolveRecipients';
            case ZPush::COMMAND_VALIDATECERT:         return 'ValidateCert';

            // Deprecated commands
            case ZPush::COMMAND_GETHIERARCHY:         return 'GetHierarchy';
            case ZPush::COMMAND_CREATECOLLECTION:     return 'CreateCollection';
            case ZPush::COMMAND_DELETECOLLECTION:     return 'DeleteCollection';
            case ZPush::COMMAND_MOVECOLLECTION:       return 'MoveCollection';
            case ZPush::COMMAND_NOTIFY:               return 'Notify';

            // Webservice commands
            case ZPush::COMMAND_WEBSERVICE_DEVICE:    return 'WebserviceDevice';
        }
        return false;
    }

Here is the caller graph for this function:

static Utils::GetCutOffDate ( restrict) [static]

Converts SYNC_FILTERTYPE into a timestamp.

Parameters:
intFiltertype

public

Returns:
long

Definition at line 241 of file utils.php.

                                                    {
        switch($restrict) {
            case SYNC_FILTERTYPE_1DAY:
                $back = 60 * 60 * 24;
                break;
            case SYNC_FILTERTYPE_3DAYS:
                $back = 60 * 60 * 24 * 3;
                break;
            case SYNC_FILTERTYPE_1WEEK:
                $back = 60 * 60 * 24 * 7;
                break;
            case SYNC_FILTERTYPE_2WEEKS:
                $back = 60 * 60 * 24 * 14;
                break;
            case SYNC_FILTERTYPE_1MONTH:
                $back = 60 * 60 * 24 * 31;
                break;
            case SYNC_FILTERTYPE_3MONTHS:
                $back = 60 * 60 * 24 * 31 * 3;
                break;
            case SYNC_FILTERTYPE_6MONTHS:
                $back = 60 * 60 * 24 * 31 * 6;
                break;
            default:
                break;
        }

        if(isset($back)) {
            $date = time() - $back;
            return $date;
        } else
            return 0; // unlimited
    }

Here is the caller graph for this function:

static Utils::getDayStartOfTimestamp ( timestamp) [static]

Normalize the given timestamp to the start of the day.

Parameters:
long$timestampprivate
Returns:
long

Definition at line 619 of file utils.php.

                                                              {
        return $timestamp - ($timestamp % (60 * 60 * 24));
    }

Here is the caller graph for this function:

static Utils::GetFormattedTime ( timestamp = false) [static]

Returns a formatted string output from an optional timestamp.

If no timestamp is sent, NOW is used.

Parameters:
long$timestamppublic
Returns:
string

Definition at line 632 of file utils.php.

                                                                {
        if (!$timestamp)
            return @strftime("%d/%m/%Y %H:%M:%S");
        else
            return @strftime("%d/%m/%Y %H:%M:%S", $timestamp);
    }

Here is the caller graph for this function:

static Utils::GetICalUidFromOLUid ( olUid) [static]

Parses and returns an ecoded vCal-Uid from an OL compatible GlobalObjectID.

Parameters:
string$olUidan OL compatible GlobalObjectID

public

Returns:
string the vCal-Uid if available in the olUid, else the original olUid as HEX

Definition at line 172 of file utils.php.

                                                      {
        //check if "vCal-Uid" is somewhere in outlookid case-insensitive
        $icalUid = stristr($olUid, "vCal-Uid");
        if ($icalUid !== false) {
            //get the length of the ical id - go back 4 position from where "vCal-Uid" was found
            $begin = unpack("V", substr($olUid, strlen($icalUid) * (-1) - 4, 4));
            //remove "vCal-Uid" and packed "1" and use the ical id length
            return substr($icalUid, 12, ($begin[1] - 13));
        }
        return strtoupper(bin2hex($olUid));
    }

Here is the caller graph for this function:

static Utils::GetOLUidFromICalUid ( icalUid) [static]

Checks the given UID if it is an OL compatible GlobalObjectID If not, the given UID is encoded inside the GlobalObjectID.

Parameters:
string$icalUidan appointment uid as HEX

public

Returns:
string an OL compatible GlobalObjectID

Definition at line 194 of file utils.php.

                                                         {
        if (strlen($icalUid) <= 64) {
            $len = 13 + strlen($icalUid);
            $OLUid = pack("V", $len);
            $OLUid .= "vCal-Uid";
            $OLUid .= pack("V", 1);
            $OLUid .= $icalUid;
            return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000". bin2hex($OLUid). "00");
        }
        else
           return hex2bin($icalUid);
    }

Here is the caller graph for this function:

static Utils::GetTruncSize ( truncation) [static]

Converts SYNC_TRUNCATION into bytes.

Parameters:
intSYNC_TRUNCATION
Returns:
long

Definition at line 282 of file utils.php.

                                                     {
        switch($truncation) {
            case SYNC_TRUNCATION_HEADERS:
                return 0;
            case SYNC_TRUNCATION_512B:
                return 512;
            case SYNC_TRUNCATION_1K:
                return 1024;
            case SYNC_TRUNCATION_2K:
                return 2*1024;
            case SYNC_TRUNCATION_5K:
                return 5*1024;
            case SYNC_TRUNCATION_10K:
                return 10*1024;
            case SYNC_TRUNCATION_20K:
                return 20*1024;
            case SYNC_TRUNCATION_50K:
                return 50*1024;
            case SYNC_TRUNCATION_100K:
                return 100*1024;
            case SYNC_TRUNCATION_ALL:
                return 1024*1024; // We'll limit to 1MB anyway
            default:
                return 1024; // Default to 1Kb
        }
    }

Here is the caller graph for this function:

static Utils::IcalTimezoneFix ( ical) [static]

iPhone defines standard summer time information for current year only, starting with time change in February.

Dates from the 1st January until the time change are undefined and the server uses GMT or its current time. The function parses the ical attachment and replaces DTSTART one year back in VTIMEZONE section if the event takes place in this undefined time. See also http://developer.berlios.de/mantis/view.php?id=311

Parameters:
string$icaliCalendar data

public

Returns:
string

Definition at line 93 of file utils.php.

                                                  {
        $eventDate = substr($ical, (strpos($ical, ":", strpos($ical, "DTSTART", strpos($ical, "BEGIN:VEVENT")))+1), 8);
        $posStd = strpos($ical, "DTSTART:", strpos($ical, "BEGIN:STANDARD")) + strlen("DTSTART:");
        $posDst = strpos($ical, "DTSTART:", strpos($ical, "BEGIN:DAYLIGHT")) + strlen("DTSTART:");
        $beginStandard = substr($ical, $posStd , 8);
        $beginDaylight = substr($ical, $posDst , 8);

        if (($eventDate < $beginStandard) && ($eventDate < $beginDaylight) ) {
            ZLog::Write(LOGLEVEL_DEBUG,"icalTimezoneFix for event on $eventDate, standard:$beginStandard, daylight:$beginDaylight");
            $year = intval(date("Y")) - 1;
            $ical = substr_replace($ical, $year, (($beginStandard < $beginDaylight) ? $posDst : $posStd), strlen($year));
        }

        return $ical;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Utils::IsBase64String ( string) [static]

Checks if a string is base64 encoded.

Parameters:
string$stringthe string to be checked

public

Returns:
boolean

Definition at line 475 of file utils.php.

                                                   {
        return (bool) preg_match("#^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+/]{4})?$#", $string);
    }

Here is the caller graph for this function:

static Utils::IsSystemFolder ( foldertype) [static]

Indicates if the specified folder type is a system folder.

Parameters:
int$foldertypepublic
Returns:
boolean

Definition at line 339 of file utils.php.

                                                       {
        return ($foldertype == SYNC_FOLDER_TYPE_INBOX || $foldertype == SYNC_FOLDER_TYPE_DRAFTS || $foldertype == SYNC_FOLDER_TYPE_WASTEBASKET || $foldertype == SYNC_FOLDER_TYPE_SENTMAIL ||
                $foldertype == SYNC_FOLDER_TYPE_OUTBOX || $foldertype == SYNC_FOLDER_TYPE_TASK || $foldertype == SYNC_FOLDER_TYPE_APPOINTMENT || $foldertype == SYNC_FOLDER_TYPE_CONTACT ||
                $foldertype == SYNC_FOLDER_TYPE_NOTE || $foldertype == SYNC_FOLDER_TYPE_JOURNAL) ? true:false;
    }

Here is the caller graph for this function:

static Utils::PrintAsString ( var) [static]

Prints a variable as string If a boolean is sent, 'true' or 'false' is displayed.

Parameters:
string$varpublic
Returns:
string

Definition at line 53 of file utils.php.

                                               {
      return ($var)?(($var===true)?'true':$var):(($var===false)?'false':(($var==='')?'empty':$var));
//return ($var)?(($var===true)?'true':$var):'false';
    }

Here is the caller graph for this function:

static Utils::SplitDomainUser ( domainuser) [static]

Splits a "domain\user" string into two values If the string cotains only the user, domain is returned empty.

Parameters:
string$domainuserpublic
Returns:
array index 0: user 1: domain

Definition at line 67 of file utils.php.

                                                        {
        $pos = strrpos($domainuser, '\\');
        if($pos === false){
            $user = $domainuser;
            $domain = '';
        }
        else{
            $domain = substr($domainuser,0,$pos);
            $user = substr($domainuser,$pos+1);
        }
        return array($user, $domain);
    }

Here is the caller graph for this function:

static Utils::Utf7_iconv_decode ( string) [static]

Our own utf7_decode function because imap_utf7_decode converts a string into ISO-8859-1 encoding which doesn't have euro sign (it will be converted into two chars: [space](ascii 32) and "¬" ("not sign", ascii 172)).

Also php iconv function expects '+' as delimiter instead of '&' like in IMAP.

Parameters:
string$stringIMAP folder name

public

Returns:
string

Definition at line 356 of file utils.php.

                                                      {
        //do not alter string if there aren't any '&' or '+' chars because
        //it won't have any utf7-encoded chars and nothing has to be escaped.
        if (strpos($string, '&') === false && strpos($string, '+') === false ) return $string;

        //Get the string length and go back through it making the replacements
        //necessary
        $len = strlen($string) - 1;
        while ($len > 0) {
            //look for '&-' sequence and replace it with '&'
            if ($len > 0 && $string{($len-1)} == '&' && $string{$len} == '-') {
                $string = substr_replace($string, '&', $len - 1, 2);
                $len--; //decrease $len as this char has alreasy been processed
            }
            //search for '&' which weren't found in if clause above and
            //replace them with '+' as they mark an utf7-encoded char
            if ($len > 0 && $string{($len-1)} == '&') {
                $string = substr_replace($string, '+', $len - 1, 1);
                $len--; //decrease $len as this char has alreasy been processed
            }
            //finally "escape" all remaining '+' chars
            if ($len > 0 && $string{($len-1)} == '+') {
                $string = substr_replace($string, '+-', $len - 1, 1);
            }
            $len--;
        }
        return $string;
    }

Here is the caller graph for this function:

static Utils::Utf7_iconv_encode ( string) [static]

Our own utf7_encode function because the string has to be converted from standard UTF7 into modified UTF7 (aka UTF7-IMAP).

Parameters:
string$strIMAP folder name

public

Returns:
string

Definition at line 394 of file utils.php.

                                                      {
        //do not alter string if there aren't any '&' or '+' chars because
        //it won't have any utf7-encoded chars and nothing has to be escaped.
        if (strpos($string, '&') === false && strpos($string, '+') === false ) return $string;

        //Get the string length and go back through it making the replacements
        //necessary
        $len = strlen($string) - 1;
        while ($len > 0) {
            //look for '&-' sequence and replace it with '&'
            if ($len > 0 && $string{($len-1)} == '+' && $string{$len} == '-') {
                $string = substr_replace($string, '+', $len - 1, 2);
                $len--; //decrease $len as this char has alreasy been processed
            }
            //search for '&' which weren't found in if clause above and
            //replace them with '+' as they mark an utf7-encoded char
            if ($len > 0 && $string{($len-1)} == '+') {
                $string = substr_replace($string, '&', $len - 1, 1);
                $len--; //decrease $len as this char has alreasy been processed
            }
            //finally "escape" all remaining '+' chars
            if ($len > 0 && $string{($len-1)} == '&') {
                $string = substr_replace($string, '&-', $len - 1, 1);
            }
            $len--;
        }
        return $string;
    }

Here is the caller graph for this function:

static Utils::Utf7_to_utf8 ( string) [static]

Converts an UTF-7 encoded string into an UTF-8 string.

Parameters:
string$stringto convert

public

Returns:
string

Definition at line 431 of file utils.php.

                                                 {
        if (function_exists("iconv")){
            return @iconv("UTF-7", "UTF-8", $string);
        }
        return $string;
    }

Here is the caller graph for this function:

static Utils::Utf8_to_utf7 ( string) [static]

Converts an UTF-8 encoded string into an UTF-7 string.

Parameters:
string$stringto convert

public

Returns:
string

Definition at line 446 of file utils.php.

                                                 {
        if (function_exists("iconv")){
            return @iconv("UTF-8", "UTF-7", $string);
        }
        return $string;
    }

Here is the caller graph for this function:

static Utils::Utf8_truncate ( string,
length 
) [static]

Truncate an UTF-8 encoded sting correctly.

If it's not possible to truncate properly, an empty string is returned

Parameters:
string$string- the string
string$length- position where string should be cut
Returns:
string truncated string

Definition at line 318 of file utils.php.

                                                           {
        if (strlen($string) <= $length)
            return $string;

        while($length >= 0) {
            if ((ord($string[$length]) < 0x80) || (ord($string[$length]) >= 0xC0))
                return substr($string, 0, $length);

            $length--;
        }
        return "";
    }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: