CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * XML Helper class file.
  5:  *
  6:  * Simplifies the output of XML documents.
  7:  *
  8:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  9:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 10:  *
 11:  * Licensed under The MIT License
 12:  * Redistributions of files must retain the above copyright notice.
 13:  *
 14:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 15:  * @link          http://cakephp.org CakePHP(tm) Project
 16:  * @package       cake
 17:  * @subpackage    cake.cake.libs.view.helpers
 18:  * @since         CakePHP(tm) v 1.2
 19:  * @version       $Revision$
 20:  * @modifiedby    $LastChangedBy$
 21:  * @lastmodified  $Date$
 22:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 23:  */
 24: App::import('Core', array('Xml', 'Set'));
 25: 
 26: /**
 27:  * XML Helper class for easy output of XML structures.
 28:  *
 29:  * XmlHelper encloses all methods needed while working with XML documents.
 30:  *
 31:  * @package       cake
 32:  * @subpackage    cake.cake.libs.view.helpers
 33:  */
 34: class XmlHelper extends AppHelper {
 35: /**
 36:  * Default document encoding
 37:  *
 38:  * @access public
 39:  * @var string
 40:  */
 41:     var $encoding = 'UTF-8';
 42: 
 43:     var $Xml;
 44:     var $XmlElement;
 45: /**
 46:  * Constructor
 47:  * @return void
 48:  */
 49:     function __construct() {
 50:         parent::__construct();
 51:         $this->Xml =& new Xml();
 52:         $this->Xml->options(array('verifyNs' => false));
 53:     }
 54: /**
 55:  * Returns an XML document header
 56:  *
 57:  * @param  array $attrib Header tag attributes
 58:  * @return string XML header
 59:  */
 60:     function header($attrib = array()) {
 61:         if (Configure::read('App.encoding') !== null) {
 62:             $this->encoding = Configure::read('App.encoding');
 63:         }
 64: 
 65:         if (is_array($attrib)) {
 66:             $attrib = array_merge(array('encoding' => $this->encoding), $attrib);
 67:         }
 68:         if (is_string($attrib) && strpos($attrib, 'xml') !== 0) {
 69:             $attrib = 'xml ' . $attrib;
 70:         }
 71: 
 72:         return $this->output($this->Xml->header($attrib));
 73:     }
 74: /**
 75:  * Adds a namespace to any documents generated
 76:  *
 77:  * @param  string  $name The namespace name
 78:  * @param  string  $url  The namespace URI; can be empty if in the default namespace map
 79:  * @return boolean False if no URL is specified, and the namespace does not exist
 80:  *                 default namespace map, otherwise true
 81:  * @deprecated
 82:  * @see Xml::addNs()
 83:  */
 84:     function addNs($name, $url = null) {
 85:         return $this->Xml->addNamespace($name, $url);
 86:     }
 87: /**
 88:  * Removes a namespace added in addNs()
 89:  *
 90:  * @param  string  $name The namespace name or URI
 91:  * @deprecated
 92:  * @see Xml::removeNs()
 93:  */
 94:     function removeNs($name) {
 95:         return $this->Xml->removeGlobalNamespace($name);
 96:     }
 97: /**
 98:  * Generates an XML element
 99:  *
100:  * @param  string   $name The name of the XML element
101:  * @param  array    $attrib The attributes of the XML element
102:  * @param  mixed    $content XML element content
103:  * @param  boolean  $endTag Whether the end tag of the element should be printed
104:  * @return string XML
105:  */
106:     function elem($name, $attrib = array(), $content = null, $endTag = true) {
107:         $namespace = null;
108:         if (isset($attrib['namespace'])) {
109:             $namespace = $attrib['namespace'];
110:             unset($attrib['namespace']);
111:         }
112:         $cdata = false;
113:         if (is_array($content) && isset($content['cdata'])) {
114:             $cdata = true;
115:             unset($content['cdata']);
116:         }
117:         if (is_array($content) && array_key_exists('value', $content)) {
118:             $content = $content['value'];
119:         }
120:         $children = array();
121:         if (is_array($content)) {
122:             $children = $content;
123:             $content = null;
124:         }
125: 
126:         $elem =& $this->Xml->createElement($name, $content, $attrib, $namespace);
127:         foreach ($children as $child) {
128:             $elem->createElement($child);
129:         }
130:         $out = $elem->toString(array('cdata' => $cdata, 'leaveOpen' => !$endTag));
131: 
132:         if (!$endTag) {
133:             $this->XmlElement =& $elem;
134:         }
135:         return $this->output($out);
136:     }
137: /**
138:  * Create closing tag for current element
139:  *
140:  * @return string
141:  */
142:     function closeElem() {
143:         $elem = (empty($this->XmlElement)) ? $this->Xml : $this->XmlElement;
144:         $name = $elem->name();
145:         if ($parent =& $elem->parent()) {
146:             $this->XmlElement =& $parent;
147:         }
148:         return $this->output('</' . $name . '>');
149:     }
150: /**
151:  * Serializes a model resultset into XML
152:  *
153:  * @param  mixed  $data The content to be converted to XML
154:  * @param  array  $options The data formatting options.  For a list of valid options, see
155:  *                         XmlNode::__construct().
156:  * @return string A copy of $data in XML format
157:  * @see XmlNode
158:  */
159:     function serialize($data, $options = array()) {
160:         $options += array('attributes' => false, 'format' => 'attributes');
161:         $data =& new Xml($data, $options);
162:         return $data->toString($options + array('header' => false));
163:     }
164: }
165: 
166: ?>
167: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs