Skip to content

Latest commit

 

History

History
2552 lines (1312 loc) · 48.9 KB

class.ToolsCore.md

File metadata and controls

2552 lines (1312 loc) · 48.9 KB

Class ToolsCore

Contents

Properties

Methods

Properties

$_cache_nb_media_servers

private mixed $_cache_nb_media_servers = null

$_caching

protected mixed $_caching

$_forceCompile

protected mixed $_forceCompile

$a

public mixed $a

$file_exists_cache

protected mixed $file_exists_cache = array()

Methods

ZipExtract

boolean ToolsCore::ZipExtract($fromFile, $toDir)

Arguments

  • $fromFile mixed
  • $toDir mixed

ZipTest

boolean ToolsCore::ZipTest($fromFile)

Arguments

  • $fromFile mixed

addCSS

true ToolsCore::addCSS(mixed $css_uri, string $css_media_type)

addCSS allows you to add stylesheet at any time.

Arguments

  • $css_uri mixed
  • $css_media_type string

addJS

void ToolsCore::addJS(mixed $js_uri)

addJS load a javascript file in the header

Arguments

  • $js_uri mixed

apacheModExists

boolean ToolsCore::apacheModExists(string $name)

apacheModExists return true if the apache module $name is loaded

Arguments

  • $name string - module name

cccCss

mixed ToolsCore::cccCss($css_files)

Arguments

  • $css_files mixed

cccJS

mixed ToolsCore::cccJS($js_files)

Arguments

  • $js_files mixed

ceilf

mixed ToolsCore::ceilf($value, $precision)

Arguments

  • $value mixed
  • $precision mixed

checkPhpVersion

string ToolsCore::checkPhpVersion()

clearCache

mixed ToolsCore::clearCache(\objet $smarty)

Clear cache for Smarty

Arguments

  • $smarty objet

completeMetaTags

mixed ToolsCore::completeMetaTags($metaTags, $defaultValue, \Context $context)

Arguments

  • $metaTags mixed
  • $defaultValue mixed
  • $context Context

convertBytes

integer ToolsCore::convertBytes(string $value)

Convert a shorthand byte value from a PHP configuration directive to an integer value

Arguments

  • $value string - value to convert

convertPrice

mixed ToolsCore::convertPrice(float $price, object $currency, boolean $to_currency, \Context $context)

Return price converted

Arguments

  • $price float - Product price
  • $currency object - Current currency object
  • $to_currency boolean - convert to currency or from currency to default currency
  • $context Context

convertPriceFull

mixed ToolsCore::convertPriceFull(float $amount, \Currency $currency_from, \Currency $currency_to)

Convert amount from a currency to an other currency automatically

Arguments

  • $amount float
  • $currency_from Currency - if null we used the default currency
  • $currency_to Currency - if null we used the default currency

d

mixed ToolsCore::d(object $object, $kill)

ALIAS OF dieObject() - Display an error with detailed object

Arguments

  • $object object - Object to display
  • $kill mixed

dateDays

mixed ToolsCore::dateDays()

dateFormat

string ToolsCore::dateFormat(array $params, object $smarty)

Display date regarding to language preferences

Arguments

  • $params array - Date, format...
  • $smarty object - Smarty object for language preferences

dateFrom

mixed ToolsCore::dateFrom($date)

Arguments

  • $date mixed

dateMonths

mixed ToolsCore::dateMonths()

dateTo

mixed ToolsCore::dateTo($date)

Arguments

  • $date mixed

dateYears

array ToolsCore::dateYears()

Generate date form

deleteDirectory

mixed ToolsCore::deleteDirectory(string $dirname, $delete_self)

Delete directory and subdirectories

Arguments

  • $dirname string - Directory name
  • $delete_self mixed

dieObject

\$object ToolsCore::dieObject(mixed $object, boolean $kill)

Display an error with detailed object

Arguments

  • $object mixed
  • $kill boolean

dieOrLog

\success ToolsCore::dieOrLog(string $msg, boolean $die)

Display error and dies or silently log the error.

Arguments

  • $msg string
  • $die boolean

display404Error

mixed ToolsCore::display404Error()

displayAsDeprecated

mixed ToolsCore::displayAsDeprecated($message)

Display a warning message indicating that the method is deprecated

Arguments

  • $message mixed

displayDate

string ToolsCore::displayDate(string $date, integer $id_lang, boolean $full, string $separator)

Display date regarding to language preferences

Arguments

  • $date string - Date to display format UNIX
  • $id_lang integer - Language id
  • $full boolean - With time or not (optional)
  • $separator string - DEPRECATED

displayError

mixed ToolsCore::displayError(string $string, boolean $htmlentities, \Context $context)

Display an error according to an error code

Arguments

  • $string string - Error message
  • $htmlentities boolean - By default at true for parsing error message with htmlentities
  • $context Context

displayFileAsDeprecated

mixed ToolsCore::displayFileAsDeprecated()

displayParameterAsDeprecated

mixed ToolsCore::displayParameterAsDeprecated($parameter)

Display a warning message indicating that the parameter is deprecated

Arguments

  • $parameter mixed

displayPrice

string ToolsCore::displayPrice(float $price, object $currency, $no_utf8, \Context $context)

Return price with currency sign for a given product

Arguments

  • $price float - Product price
  • $currency object - Current currency (object, id_currency, NULL => context currency)
  • $no_utf8 mixed
  • $context Context

displayPriceSmarty

mixed ToolsCore::displayPriceSmarty($params, $smarty)

Arguments

  • $params mixed
  • $smarty mixed

enableCache

mixed ToolsCore::enableCache($level, \Context $context)

Arguments

encrypt

mixed ToolsCore::encrypt($passwd)

Encrypt password

Arguments

  • $passwd mixed

fd

mixed ToolsCore::fd(object $object)

Display a var dump in firebug console

Arguments

  • $object object - Object to display

file_exists_cache

boolean ToolsCore::file_exists_cache(string $filename)

file_exists() wrapper with cache to speedup performance

Arguments

  • $filename string - File name

file_get_contents

mixed ToolsCore::file_get_contents($url, $useIncludePath, $streamContext, $curlTimeOut)

Arguments

  • $url mixed
  • $useIncludePath mixed
  • $streamContext mixed
  • $curlTimeOut mixed

floorf

mixed ToolsCore::floorf($value, $precision)

Arguments

  • $value mixed
  • $precision mixed

generateHtaccess

mixed ToolsCore::generateHtaccess($path, $rewrite_settings, $cache_control, $specific, $disable_multiviews)

Arguments

  • $path mixed
  • $rewrite_settings mixed
  • $cache_control mixed
  • $specific mixed
  • $disable_multiviews mixed

getAdminToken

mixed ToolsCore::getAdminToken($string)

Encrypt password

Arguments

  • $string mixed

getAdminTokenLite

mixed ToolsCore::getAdminTokenLite($tab, \Context $context)

Arguments

getAdminTokenLiteSmarty

mixed ToolsCore::getAdminTokenLiteSmarty($params, $smarty)

Arguments

  • $params mixed
  • $smarty mixed

getBrightness

mixed ToolsCore::getBrightness($hex)

Arguments

  • $hex mixed

getCurrentUrlProtocolPrefix

string ToolsCore::getCurrentUrlProtocolPrefix()

Get the current url prefix protocol (https/http)

getFullPath

mixed ToolsCore::getFullPath($id_category, $end, $type_cat, \Context $context)

Arguments

  • $id_category mixed
  • $end mixed
  • $type_cat mixed
  • $context Context

getHomeMetaTags

array ToolsCore::getHomeMetaTags(integer $id_lang, $page_name)

Get meta tags for a given page

Arguments

  • $id_lang integer - Language id
  • $page_name mixed

getHttpHost

string ToolsCore::getHttpHost(boolean $http, boolean $entities)

getHttpHost return the current host used, with the protocol (http or https) if $http is true This function should not be used to choose http or https domain name.

Use Tools::getShopDomain() or Tools::getShopDomainSsl instead

Arguments

  • $http boolean
  • $entities boolean

getIsset

mixed ToolsCore::getIsset($key)

Arguments

  • $key mixed

getMaxUploadSize

integer ToolsCore::getMaxUploadSize(integer $max_size)

Get max file upload size considering server settings and optional max value

Arguments

  • $max_size integer - optional max file size

getMediaServer

mixed ToolsCore::getMediaServer($filename)

Arguments

  • $filename mixed

getMemoryLimit

integer ToolsCore::getMemoryLimit()

getMemoryLimit allow to get the memory limit in octet

getMetaTags

array ToolsCore::getMetaTags(integer $id_lang, $page_name, $title)

Get meta tages for a given page

Arguments

  • $id_lang integer - Language id
  • $page_name mixed
  • $title mixed

getPath

mixed ToolsCore::getPath(integer $id_category, string $path, boolean $linkOntheLastItem, $categoryType, \Context $context)

Get the user's journey

Arguments

  • $id_category integer - Category ID
  • $path string - Path end
  • $linkOntheLastItem boolean - Put or not a link on the current category
  • $categoryType mixed
  • $context Context

getProductsOrder

mixed ToolsCore::getProductsOrder(string $type, string $value, $prefix)

Get products order field name for queries.

Arguments

  • $type string - by|way
  • $value string - If no index given, use default order from admin -> pref -> products
  • $prefix mixed

getProtocol

String ToolsCore::getProtocol($use_ssl)

getProtocol return the set protocol according to configuration (http[s])

Arguments

  • $use_ssl mixed

getRemoteAddr

string ToolsCore::getRemoteAddr()

Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy)

getServerName

string ToolsCore::getServerName()

Get the server variable SERVER_NAME

getShopDomain

string ToolsCore::getShopDomain(boolean $http, boolean $entities)

getShopDomain returns domain name according to configuration and ignoring ssl

Arguments

  • $http boolean - if true, return domain name with protocol
  • $entities boolean - if true,

getShopDomainSsl

string ToolsCore::getShopDomainSsl(boolean $http, boolean $entities)

getShopDomainSsl returns domain name according to configuration and depending on ssl activation

Arguments

  • $http boolean - if true, return domain name with protocol
  • $entities boolean - if true,

getToken

mixed ToolsCore::getToken($page, \Context $context)

Get token to prevent CSRF

Arguments

getValue

mixed ToolsCore::getValue(string $key, mixed $defaultValue)

Get a value from $_POST / $_GET if unavailable, take a default value

Arguments

  • $key string - Value key
  • $defaultValue mixed - (optional)

hourGenerate

mixed ToolsCore::hourGenerate($hours, $minutes, $seconds)

Arguments

  • $hours mixed
  • $minutes mixed
  • $seconds mixed

htmlentitiesDecodeUTF8

mixed ToolsCore::htmlentitiesDecodeUTF8($string)

Arguments

  • $string mixed

htmlentitiesUTF8

mixed ToolsCore::htmlentitiesUTF8($string, $type)

Arguments

  • $string mixed
  • $type mixed

iconv

mixed ToolsCore::iconv($from, $to, $string)

Arguments

  • $from mixed
  • $to mixed
  • $string mixed

isCallable

mixed ToolsCore::isCallable($function)

Arguments

  • $function mixed

isEmpty

mixed ToolsCore::isEmpty($field)

Arguments

  • $field mixed

isSubmit

mixed ToolsCore::isSubmit(string $submit)

Check if submit has been posted

Arguments

  • $submit string - submit name

isX86_64arch

boolean ToolsCore::isX86_64arch()

jsonDecode

array ToolsCore::jsonDecode(string $json, boolean $assoc)

jsonDecode convert json string to php array / object

Arguments

  • $json string
  • $assoc boolean - (since 1.4.2.4) if true, convert to associativ array

jsonEncode

string ToolsCore::jsonEncode(array $data)

Convert an array to json string

Arguments

  • $data array

link_rewrite

string ToolsCore::link_rewrite(string $str, boolean $utf8_decode)

Return the friendly url from the provided string

Arguments

  • $str string
  • $utf8_decode boolean - => needs to be marked as deprecated

minifyCSS

mixed ToolsCore::minifyCSS($css_content, $fileuri)

Arguments

  • $css_content mixed
  • $fileuri mixed

minifyHTML

mixed ToolsCore::minifyHTML($html_content)

Arguments

  • $html_content mixed

minifyHTMLpregCallback

mixed ToolsCore::minifyHTMLpregCallback($preg_matches)

Arguments

  • $preg_matches mixed

nl2br

string ToolsCore::nl2br($str)

Convert \n and \r\n and \r to

Arguments

  • $str mixed

orderbyPrice

mixed ToolsCore::orderbyPrice($array, $orderWay)

Arguments

  • $array mixed
  • $orderWay mixed

p

mixed ToolsCore::p(object $object)

ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution

Arguments

  • $object object - Object to display

pRegexp

mixed ToolsCore::pRegexp($s, $delim)

Arguments

  • $s mixed
  • $delim mixed

packJS

mixed ToolsCore::packJS($js_content)

Arguments

  • $js_content mixed

packJSinHTML

mixed ToolsCore::packJSinHTML($html_content)

Arguments

  • $html_content mixed

packJSinHTMLpregCallback

mixed ToolsCore::packJSinHTMLpregCallback($preg_matches)

Arguments

  • $preg_matches mixed

parserSQL

mixed ToolsCore::parserSQL($sql)

Arguments

  • $sql mixed

passwdGen

string ToolsCore::passwdGen(integer $length)

Random password generator

Arguments

  • $length integer - Desired length (optional)

property_exists

boolean ToolsCore::property_exists($class, string $property)

Function property_exists does not exist in PHP < 5.1

Arguments

  • $class mixed
  • $property string

ps_round

mixed ToolsCore::ps_round($value, $precision)

Arguments

  • $value mixed
  • $precision mixed

redirect

mixed ToolsCore::redirect(string $url, string $baseUri, \Link $link)

Redirect user to another page

Arguments

  • $url string - Desired URL
  • $baseUri string - Base URI (optional)
  • $link Link

redirectAdmin

mixed ToolsCore::redirectAdmin(string $url)

Redirect user to another admin page

Arguments

  • $url string - Desired URL

redirectLink

mixed ToolsCore::redirectLink(string $url)

Redirect url wich allready PS_BASE_URI

Arguments

  • $url string - Desired URL

replaceAccentedChars

string ToolsCore::replaceAccentedChars(string $str)

Replace all accented chars by their equivalent non accented chars.

Arguments

  • $str string

replaceByAbsoluteURL

mixed ToolsCore::replaceByAbsoluteURL($matches)

Arguments

  • $matches mixed

restoreCacheSettings

mixed ToolsCore::restoreCacheSettings(\Context $context)

Arguments

safeOutput

string ToolsCore::safeOutput(string $string, $html)

Sanitize a string

Arguments

  • $string string - String to sanitize
  • $html mixed

safePostVars

mixed ToolsCore::safePostVars()

secureReferrer

\secured ToolsCore::secureReferrer(string $referrer)

Secure an URL referrer

Arguments

  • $referrer string - URL referrer

setCookieLanguage

string ToolsCore::setCookieLanguage($cookie)

Change language in cookie while clicking on a flag

Arguments

  • $cookie mixed

setCurrency

\Currency ToolsCore::setCurrency($cookie)

Set cookie currency from POST or default currency

Arguments

  • $cookie mixed

simplexml_load_file

mixed ToolsCore::simplexml_load_file($url, $class_name)

Arguments

  • $url mixed
  • $class_name mixed

str2url

string ToolsCore::str2url(string $str)

Return a friendly url made from the provided string If the mbstring library is available, the output is the same as the js function of the same name

Arguments

  • $str string

strReplaceFirst

mixed ToolsCore::strReplaceFirst($search, $replace, $subject, $cur)

Arguments

  • $search mixed
  • $replace mixed
  • $subject mixed
  • $cur mixed

str_replace_once

mixed ToolsCore::str_replace_once($needle, $replace, $haystack)

Arguments

  • $needle mixed
  • $replace mixed
  • $haystack mixed

stripslashes

mixed ToolsCore::stripslashes($string)

Arguments

  • $string mixed

strlen

mixed ToolsCore::strlen($str, $encoding)

Arguments

  • $str mixed
  • $encoding mixed

strtolower

mixed ToolsCore::strtolower($str)

Arguments

  • $str mixed

strtoupper

mixed ToolsCore::strtoupper($str)

Arguments

  • $str mixed

substr

mixed ToolsCore::substr($str, $start, $length, $encoding)

Arguments

  • $str mixed
  • $start mixed
  • $length mixed
  • $encoding mixed

switchLanguage

mixed ToolsCore::switchLanguage(\Context $context)

Set cookie id_lang

Arguments

throwDeprecated

mixed ToolsCore::throwDeprecated($error, $message, $class)

Arguments

  • $error mixed
  • $message mixed
  • $class mixed

toCamelCase

mixed ToolsCore::toCamelCase($str, $capitaliseFirstChar)

Translates a string with underscores into camel case (e.g. first_name -> firstName)

Arguments

  • $str mixed
  • $capitaliseFirstChar mixed

toUnderscoreCase

string ToolsCore::toUnderscoreCase(string $string)

Transform a CamelCase string to underscore_case string

Arguments

  • $string string

truncate

mixed ToolsCore::truncate($str, $maxLen, $suffix)

Arguments

  • $str mixed
  • $maxLen mixed
  • $suffix mixed

ucfirst

mixed ToolsCore::ucfirst($str)

Arguments

  • $str mixed

url

string ToolsCore::url(string $begin, string $end)

Concat $begin and $end, add ? or & between strings

Arguments

  • $begin string
  • $end string

usingSecureMode

boolean ToolsCore::usingSecureMode()

Check if the current page use SSL connection on not