Comments: on this page. Click to read or post your own.

Class Convert

Description

Library of conversion functions, implemented as static methods.

The methods are all of the form (format)2(format), where the format is one of

raw: A UTF8 string attr: A UTF8 string suitable for inclusion in an HTML attribute js: A UTF8 string suitable for inclusion in a double-quoted javascript string.

array: A PHP associative array json: JavaScript object notation

html: HTML source suitable for use in a page or email text: Plain-text content, suitable for display to a user as-is, or insertion in a plaintext email.

Objects of type ViewableData can have an "escaping type", which determines if they are automatically escaped before output by SSViewer.

Located in /sapphire/core/Convert.php (line 24)

Object
   |
   --Convert
Method Summary
static void array2json ( $array)
static void html2raw ($data $data, [$preserveLinks $preserveLinks = false], [$wordwrap $wordWrap = 60], [ $config = null])
static void js2att ( $val)
static void js2raw ( $val)
static void js2sql ( $val)
static void js2xml ( $val)
static void json2array ( $val)
static mixed json2obj (string $val)
static A linkIfMatch (string $string)
static void raw2att ( $val)
static void raw2htmlatt ( $val)
static void raw2js ( $val)
static string raw2json (mixed $val)
static string raw2mailto ($data $data)
static void raw2sql ( $val)
static void raw2xml ( $val)
static void recursiveXMLToArray ( $xml)
static void xml2array ( $val)
static void xml2att ( $val)
static void xml2js ( $val)
static void xml2raw ( $val)
static void xml2sql ( $val)
Variables
Methods
static method array2json (line 242)
static void array2json ( $array)
  • $array
static method html2raw (line 290)

Simple conversion of HTML to plaintext.

static void html2raw ($data $data, [$preserveLinks $preserveLinks = false], [$wordwrap $wordWrap = 60], [ $config = null])
  • $data $data: string
  • $preserveLinks $preserveLinks: boolean
  • $wordwrap $wordWrap: array
  • $config
static method js2att (line 172)
  • deprecated: 2.3 Use raw2att()
static void js2att ( $val)
  • $val
static method js2raw (line 152)
  • deprecated: 2.3
static void js2raw ( $val)
  • $val
static method js2sql (line 179)
  • deprecated: 2.3 Use raw2sql()
static void js2sql ( $val)
  • $val
static method js2xml (line 165)
  • deprecated: 2.3 Use raw2xml()
static void js2xml ( $val)
  • $val
static method json2array (line 205)
static void json2array ( $val)
  • $val
static method json2obj (line 192)

Uses the PHP5.2 native json_decode function if available, otherwise falls back to the Services_JSON class.

static mixed json2obj (string $val)
  • string $val
static method linkIfMatch (line 264)

Create a link if the string is a valid URL

  • return: link to the URL if string is a URL
static A linkIfMatch (string $string)
  • string $string: The string to linkify
static method raw2att (line 26)
static void raw2att ( $val)
  • $val
static method raw2htmlatt (line 40)
static void raw2htmlatt ( $val)
  • $val
static method raw2js (line 61)
static void raw2js ( $val)
  • $val
static method raw2json (line 82)

Uses the PHP5.2 native json_encode function if available, otherwise falls back to the Services_JSON class.

static string raw2json (mixed $val)
  • mixed $val
static method raw2mailto (line 375)

There are no real specifications on correctly encoding mailto-links, but this seems to be compatible with most of the user-agents.

Does nearly the same as rawurlencode(). Please only encode the values, not the whole url, e.g. "mailto:test@test.com?subject=" . Convert::raw2mailto($subject)

static string raw2mailto ($data $data)
  • $data $data: string
static method raw2sql (line 93)
static void raw2sql ( $val)
  • $val
static method raw2xml (line 52)
static void raw2xml ( $val)
  • $val
static method recursiveXMLToArray (line 222)
static void recursiveXMLToArray ( $xml)
  • $xml
static method xml2array (line 217)
static void xml2array ( $val)
  • $val
static method xml2att (line 138)
  • deprecated: 2.3 use raw2att()
static void xml2att ( $val)
  • $val
static method xml2js (line 131)
  • deprecated: 2.3 Functionality too ambiguous - not sure if its converting xml trees to js objects, xml properties to json, ...
static void xml2js ( $val)
  • $val
static method xml2raw (line 108)

Convert XML to raw text

  • todo: Currently &#xxx; entries are stripped; they should be converted
  • uses: Convert::html2raw()
static void xml2raw ( $val)
  • $val
static method xml2sql (line 145)
  • deprecated: 2.3 Use raw2sql()
static void xml2sql ( $val)
  • $val

Inherited Methods

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::hasExtension()
Object::hasMethod()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Sun, 19 Oct 2008 06:39:22 +1300 by phpDocumentor 1.3.2