helper.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: helper_8php-source.html 580 2008-07-01 14:45:49Z gwoo $ */
00003 
00004 /**
00005  * Backend for helpers.
00006  *
00007  * Internal methods for the Helpers.
00008  *
00009  * PHP versions 4 and 5
00010  *
00011  * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
00012  * Copyright 2005-2008, Cake Software Foundation, Inc.
00013  *                              1785 E. Sahara Avenue, Suite 490-204
00014  *                              Las Vegas, Nevada 89104
00015  *
00016  * Licensed under The MIT License
00017  * Redistributions of files must retain the above copyright notice.
00018  *
00019  * @filesource
00020  * @copyright       Copyright 2005-2008, Cake Software Foundation, Inc.
00021  * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00022  * @package         cake
00023  * @subpackage      cake.cake.libs.view
00024  * @since           CakePHP(tm) v 0.2.9
00025  * @version         $Revision: 580 $
00026  * @modifiedby      $LastChangedBy: gwoo $
00027  * @lastmodified    $Date: 2008-07-01 09:45:49 -0500 (Tue, 01 Jul 2008) $
00028  * @license         http://www.opensource.org/licenses/mit-license.php The MIT License
00029  */
00030 
00031 /**
00032  * Included libs
00033  */
00034 App::import('Core', 'Overloadable');
00035 
00036 /**
00037  * Backend for helpers.
00038  *
00039  * Long description for class
00040  *
00041  * @package     cake
00042  * @subpackage  cake.cake.libs.view
00043  */
00044 class Helper extends Overloadable {
00045 
00046 /**
00047  * List of helpers used by this helper
00048  *
00049  * @var array
00050  */
00051     var $helpers = null;
00052 /**
00053  * Base URL
00054  *
00055  * @var string
00056  */
00057     var $base = null;
00058 /**
00059  * Webroot path
00060  *
00061  * @var string
00062  */
00063     var $webroot = null;
00064 /**
00065  * Theme name
00066  *
00067  * @var string
00068  */
00069     var $themeWeb = null;
00070 /**
00071  * URL to current action.
00072  *
00073  * @var string
00074  */
00075     var $here = null;
00076 /**
00077  * Parameter array.
00078  *
00079  * @var array
00080  */
00081     var $params = array();
00082 /**
00083  * Current action.
00084  *
00085  * @var string
00086  */
00087     var $action = null;
00088 /**
00089  * Plugin path
00090  *
00091  * @var string
00092  */
00093     var $plugin = null;
00094 /**
00095  * POST data for models
00096  *
00097  * @var array
00098  */
00099     var $data = null;
00100 /**
00101  * List of named arguments
00102  *
00103  * @var array
00104  */
00105     var $namedArgs = null;
00106 /**
00107  * URL argument separator character
00108  *
00109  * @var string
00110  */
00111     var $argSeparator = null;
00112 /**
00113  * Contains model validation errors of form post-backs
00114  *
00115  * @access public
00116  * @var array
00117  */
00118     var $validationErrors = null;
00119 /**
00120  * Holds tag templates.
00121  *
00122  * @access public
00123  * @var array
00124  */
00125     var $tags = array();
00126 /**
00127  * Holds the content to be cleaned.
00128  *
00129  * @access private
00130  * @var mixed
00131  */
00132     var $__tainted = null;
00133 /**
00134  * Holds the cleaned content.
00135  *
00136  * @access private
00137  * @var mixed
00138  */
00139     var $__cleaned = null;
00140 /**
00141  * Default overload methods
00142  *
00143  * @access protected
00144  */
00145     function get__($name) {}
00146     function set__($name, $value) {}
00147     function call__($method, $params) {
00148         trigger_error(sprintf(__('Method %1$s::%2$s does not exist', true), get_class($this), $method), E_USER_WARNING);
00149     }
00150 
00151 /**
00152  * Parses tag templates into $this->tags.
00153  *
00154  * @param $name file name
00155  * @return array merged tags from config/$name.php
00156  */
00157     function loadConfig($name = 'tags') {
00158         if (file_exists(CONFIGS . $name .'.php')) {
00159             require(CONFIGS . $name .'.php');
00160             if (isset($tags)) {
00161                 $this->tags = array_merge($this->tags, $tags);
00162             }
00163         }
00164         return $this->tags;
00165     }
00166 /**
00167  * Finds URL for specified action.
00168  *
00169  * Returns an URL pointing to a combination of controller and action. Param
00170  * $url can be:
00171  *  + Empty - the method will find adress to actuall controller/action.
00172  *  + '/' - the method will find base URL of application.
00173  *  + A combination of controller/action - the method will find url for it.
00174  *
00175  * @param  mixed  $url    Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
00176  *                        or an array specifying any of the following: 'controller', 'action',
00177  *                        and/or 'plugin', in addition to named arguments (keyed array elements),
00178  *                        and standard URL arguments (indexed array elements)
00179  * @param boolean $full   If true, the full base URL will be prepended to the result
00180  * @return string  Full translated URL with base path.
00181  */
00182     function url($url = null, $full = false) {
00183         return Router::url($url, $full);
00184     }
00185 /**
00186  * Checks if a file exists when theme is used, if no file is found default location is returned
00187  *
00188  * @param  string  $file
00189  * @return string  $webPath web path to file.
00190  */
00191     function webroot($file) {
00192         $webPath = "{$this->webroot}" . $file;
00193         if (!empty($this->themeWeb)) {
00194             $os = env('OS');
00195             if (!empty($os) && strpos($os, 'Windows') !== false) {
00196                 $path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb  . $file);
00197             } else {
00198                 $path = WWW_ROOT . $this->themeWeb  . $file;
00199             }
00200             if (file_exists($path)) {
00201                 $webPath = "{$this->webroot}" . $this->themeWeb . $file;
00202             }
00203         }
00204         return str_replace('//', '/', $webPath);
00205     }
00206 
00207 /**
00208  * Used to remove harmful tags from content
00209  *
00210  * @param mixed $output
00211  * @return cleaned content for output
00212  * @access public
00213  */
00214     function clean($output) {
00215         $this->__reset();
00216         if (empty($output)) {
00217             return null;
00218         }
00219         if (is_array($output)) {
00220             foreach ($output as $key => $value) {
00221                 $return[$key] = $this->clean($value);
00222             }
00223             return $return;
00224         }
00225         $this->__tainted = $output;
00226         $this->__clean();
00227         return $this->__cleaned;
00228     }
00229 /**
00230  * Returns a space-delimited string with items of the $options array. If a
00231  * key of $options array happens to be one of:
00232  *  + 'compact'
00233  *  + 'checked'
00234  *  + 'declare'
00235  *  + 'readonly'
00236  *  + 'disabled'
00237  *  + 'selected'
00238  *  + 'defer'
00239  *  + 'ismap'
00240  *  + 'nohref'
00241  *  + 'noshade'
00242  *  + 'nowrap'
00243  *  + 'multiple'
00244  *  + 'noresize'
00245  *
00246  * And its value is one of:
00247  *  + 1
00248  *  + true
00249  *  + 'true'
00250  *
00251  * Then the value will be reset to be identical with key's name.
00252  * If the value is not one of these 3, the parameter is not output.
00253  *
00254  * @param  array  $options Array of options.
00255  * @param  array  $exclude Array of options to be excluded.
00256  * @param  string $insertBefore String to be inserted before options.
00257  * @param  string $insertAfter  String to be inserted ater options.
00258  * @return string
00259  */
00260     function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
00261         if (is_array($options)) {
00262             $options = array_merge(array('escape' => true), $options);
00263 
00264             if (!is_array($exclude)) {
00265                 $exclude = array();
00266             }
00267             $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape')));
00268             $values = array_intersect_key(array_values($options), $keys);
00269             $escape = $options['escape'];
00270             $attributes = array();
00271 
00272             foreach ($keys as $index => $key) {
00273                 $attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
00274             }
00275             $out = implode(' ', $attributes);
00276         } else {
00277             $out = $options;
00278         }
00279         return $out ? $insertBefore . $out . $insertAfter : '';
00280     }
00281 /**
00282  * @param  string $key
00283  * @param  string $value
00284  * @return string
00285  * @access private
00286  */
00287     function __formatAttribute($key, $value, $escape = true) {
00288         $attribute = '';
00289         $attributeFormat = '%s="%s"';
00290         $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
00291         if (is_array($value)) {
00292             $value = '';
00293         }
00294 
00295         if (in_array($key, $minimizedAttributes)) {
00296             if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
00297                 $attribute = sprintf($attributeFormat, $key, $key);
00298             }
00299         } else {
00300             $attribute = sprintf($attributeFormat, $key, ife($escape, h($value), $value));
00301         }
00302         return $attribute;
00303     }
00304 /**
00305  * Sets this helper's model and field properties to the dot-separated value-pair in $entity.
00306  *
00307  * @param mixed $entity A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName"
00308  * @param boolean $setScope Sets the view scope to the model specified in $tagValue
00309  * @return void
00310  */
00311     function setEntity($entity, $setScope = false) {
00312         $view =& ClassRegistry::getObject('view');
00313 
00314         if ($setScope) {
00315             $view->modelScope = false;
00316         } elseif (join('.', $view->entity()) == $entity) {
00317             return;
00318         }
00319 
00320         if ($entity === null) {
00321             $view->model = null;
00322             $view->association = null;
00323             $view->modelId = null;
00324             $view->modelScope = false;
00325             return;
00326         }
00327 
00328         $model = $view->model;
00329         $sameScope = $hasField = false;
00330         $parts = array_values(Set::filter(preg_split('/\/|\./', $entity), true));
00331 
00332         if (empty($parts)) {
00333             return;
00334         }
00335 
00336         if (count($parts) === 1 || is_numeric($parts[0])) {
00337             $sameScope = true;
00338         } else {
00339             if (ClassRegistry::isKeySet($parts[0])) {
00340                 $model = $parts[0];
00341             }
00342         }
00343 
00344         if (ClassRegistry::isKeySet($model)) {
00345             $ModelObj =& ClassRegistry::getObject($model);
00346             for ($i = 0; $i < count($parts); $i++) {
00347                 if ($ModelObj->hasField($parts[$i]) || array_key_exists($parts[$i], $ModelObj->validate)) {
00348                     $hasField = $i;
00349                     if ($hasField === 0 || ($hasField === 1 && is_numeric($parts[0]))) {
00350                         $sameScope = true;
00351                     }
00352                     break;
00353                 }
00354             }
00355 
00356             if ($sameScope === true && in_array($parts[0], array_keys($ModelObj->hasAndBelongsToMany))) {
00357                 $sameScope = false;
00358             }
00359         }
00360 
00361         if (!$view->association && $parts[0] == $view->field && $view->field != $view->model) {
00362             array_unshift($parts, $model);
00363             $hasField = true;
00364         }
00365         $view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
00366 
00367         switch (count($parts)) {
00368             case 1:
00369                 if($view->modelScope === false) {
00370                     $view->model = $parts[0];
00371                 } else {
00372                     $view->field = $parts[0];
00373                     if($sameScope === false) {
00374                         $view->association = $parts[0];
00375                     }
00376                 }
00377             break;
00378             case 2:
00379                 if ($view->modelScope === false) {
00380                     list($view->model, $view->field) = $parts;
00381                 } elseif ($sameScope === true && $hasField === 0) {
00382                     list($view->field, $view->fieldSuffix) = $parts;
00383                 } elseif ($sameScope === true && $hasField === 1) {
00384                     list($view->modelId, $view->field) = $parts;
00385                 } else {
00386                     list($view->association, $view->field) = $parts;
00387                 }
00388             break;
00389             case 3:
00390                 if ($sameScope === true && $hasField === 1) {
00391                     list($view->modelId, $view->field, $view->fieldSuffix) = $parts;
00392                 } elseif ($hasField === 2) {
00393                     list($view->association, $view->modelId, $view->field) = $parts;
00394                 } else {
00395                     list($view->association, $view->field, $view->fieldSuffix) = $parts;
00396                 }
00397             break;
00398             case 4:
00399                 if ($parts[0] === $view->model) {
00400                     list($view->model, $view->modelId, $view->field, $view->fieldSuffix) = $parts;
00401                 } else {
00402                     list($view->association, $view->modelId, $view->field, $view->fieldSuffix) = $parts;
00403                 }
00404             break;
00405         }
00406 
00407         if (!isset($view->model) || empty($view->model)) {
00408             $view->model = $view->association;
00409             $view->association = null;
00410         } elseif ($view->model === $view->association) {
00411             $view->association = null;
00412         }
00413 
00414         if ($setScope) {
00415             $view->modelScope = true;
00416         }
00417     }
00418 /**
00419  * Gets the currently-used model of the rendering context.
00420  *
00421  * @return string
00422  */
00423     function model() {
00424         $view =& ClassRegistry::getObject('view');
00425         if (!empty($view->association)) {
00426             return $view->association;
00427         } else {
00428             return $view->model;
00429         }
00430     }
00431 /**
00432  * Gets the ID of the currently-used model of the rendering context.
00433  *
00434  * @return mixed
00435  */
00436     function modelID() {
00437         $view =& ClassRegistry::getObject('view');
00438         return $view->modelId;
00439     }
00440 /**
00441  * Gets the currently-used model field of the rendering context.
00442  *
00443  * @return string
00444  */
00445     function field() {
00446         $view =& ClassRegistry::getObject('view');
00447         return $view->field;
00448     }
00449 /**
00450  * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
00451  *
00452  * @param string $model     Model name as string
00453  * @param string $field     Fieldname as string
00454  * @param integer $modelID  Unique index identifying this record within the form
00455  * @return boolean True on errors.
00456  */
00457     function tagIsInvalid($model = null, $field = null, $modelID = null) {
00458         foreach (array('model', 'field', 'modelID') as $key) {
00459             if (empty(${$key})) {
00460                 ${$key} = $this->{$key}();
00461             }
00462         }
00463         $view =& ClassRegistry::getObject('view');
00464         $errors = $this->validationErrors;
00465 
00466         if ($view->model !== $model && isset($errors[$view->model][$model])) {
00467             $errors = $errors[$view->model];
00468         }
00469 
00470         if (!isset($modelID)) {
00471             return empty($errors[$model][$field]) ? 0 : $errors[$model][$field];
00472         } else {
00473             return empty($errors[$model][$modelID][$field]) ? 0 : $errors[$model][$modelID][$field];
00474         }
00475     }
00476 /**
00477  * Generates a DOM ID for the selected element, if one is not set.
00478  *
00479  * @param mixed $options
00480  * @param string $id
00481  * @return mixed
00482  */
00483     function domId($options = null, $id = 'id') {
00484         $view =& ClassRegistry::getObject('view');
00485 
00486         if (is_array($options) && array_key_exists($id, $options) && $options[$id] === null) {
00487             unset($options[$id]);
00488             return $options;
00489         } elseif (!is_array($options) && $options !== null) {
00490             $this->setEntity($options);
00491             return $this->domId();
00492         }
00493 
00494         $dom = $this->model() . $this->modelID() . Inflector::camelize($view->field) . Inflector::camelize($view->fieldSuffix);
00495 
00496         if (is_array($options) && !array_key_exists($id, $options)) {
00497             $options[$id] = $dom;
00498         } elseif ($options === null) {
00499             return $dom;
00500         }
00501         return $options;
00502     }
00503 /**
00504  * Gets the input field name for the current tag
00505  *
00506  * @param array $options
00507  * @param string $key
00508  * @return array
00509  */
00510     function __name($options = array(), $field = null, $key = 'name') {
00511         $view =& ClassRegistry::getObject('view');
00512 
00513         if ($options === null) {
00514             $options = array();
00515         } elseif (is_string($options)) {
00516             $field = $options;
00517             $options = 0;
00518         }
00519 
00520         if (!empty($field)) {
00521             $this->setEntity($field);
00522         }
00523 
00524         if (is_array($options) && array_key_exists($key, $options)) {
00525             return $options;
00526         }
00527 
00528         switch ($field) {
00529             case '_method':
00530                 $name = $field;
00531             break;
00532             default:
00533                 $name = 'data[' . join('][', $view->entity()) . ']';
00534             break;
00535         }
00536 
00537         if (is_array($options)) {
00538             $options[$key] = $name;
00539             return $options;
00540         } else {
00541             return $name;
00542         }
00543     }
00544 /**
00545  * Gets the data for the current tag
00546  *
00547  * @param array $options
00548  * @param string $key
00549  * @return array
00550  * @access public
00551  */
00552     function value($options = array(), $field = null, $key = 'value') {
00553         if ($options === null) {
00554             $options = array();
00555         } elseif (is_string($options)) {
00556             $field = $options;
00557             $options = 0;
00558         }
00559 
00560         if (!empty($field)) {
00561             $this->setEntity($field);
00562         }
00563 
00564         if (is_array($options) && isset($options[$key])) {
00565             return $options;
00566         }
00567 
00568         $result = null;
00569 
00570         if (isset($this->data[$this->model()][$this->field()])) {
00571             $result = $this->data[$this->model()][$this->field()];
00572         } elseif (isset($this->data[$this->field()]) && is_array($this->data[$this->field()])) {
00573             if (ClassRegistry::isKeySet($this->field())) {
00574                 $model =& ClassRegistry::getObject($this->field());
00575                 $result = $this->__selectedArray($this->data[$this->field()], $model->primaryKey);
00576             }
00577         } elseif (isset($this->data[$this->model()][$this->modelID()][$this->field()])) {
00578             $result = $this->data[$this->model()][$this->modelID()][$this->field()];
00579         }
00580 
00581         if (is_array($result)) {
00582             $view =& ClassRegistry::getObject('view');
00583             if(isset($result[$view->fieldSuffix])) {
00584                 $result = $result[$view->fieldSuffix];
00585             }
00586         }
00587 
00588         if (is_array($options)) {
00589             if (empty($result) && isset($options['default'])) {
00590                 $result = $options['default'];
00591             }
00592             unset($options['default']);
00593         }
00594 
00595         if (is_array($options)) {
00596             $options[$key] = $result;
00597             return $options;
00598         } else {
00599             return $result;
00600         }
00601     }
00602 /**
00603  * Sets the defaults for an input tag
00604  *
00605  * @param array $options
00606  * @param string $key
00607  * @return array
00608  */
00609     function __initInputField($field, $options = array()) {
00610         if ($field !== null) {
00611             $this->setEntity($field);
00612         }
00613         $options = (array)$options;
00614         $options = $this->__name($options);
00615         $options = $this->value($options);
00616         $options = $this->domId($options);
00617         if ($this->tagIsInvalid()) {
00618             $options = $this->addClass($options, 'form-error');
00619         }
00620         return $options;
00621     }
00622 /**
00623  * Adds the given class to the element options
00624  *
00625  * @param array $options
00626  * @param string $class
00627  * @param string $key
00628  * @return array
00629  */
00630     function addClass($options = array(), $class = null, $key = 'class') {
00631         if (isset($options[$key]) && trim($options[$key]) != '') {
00632             $options[$key] .= ' ' . $class;
00633         } else {
00634             $options[$key] = $class;
00635         }
00636         return $options;
00637     }
00638 /**
00639  * Returns a string generated by a helper method
00640  *
00641  * This method can be overridden in subclasses to do generalized output post-processing
00642  *
00643  * @param  string  $str String to be output.
00644  * @return string
00645  */
00646     function output($str) {
00647         return $str;
00648     }
00649 /**
00650  * Assigns values to tag templates.
00651  *
00652  * Finds a tag template by $keyName, and replaces $values's keys with
00653  * $values's keys.
00654  *
00655  * @param  string $keyName Name of the key in the tag array.
00656  * @param  array  $values  Values to be inserted into tag.
00657  * @return string Tag with inserted values.
00658  */
00659     function assign($keyName, $values) {
00660         $out = $keyName;
00661         if (isset($this->tags) && isset($this->tags[$keyName])) {
00662             $out = $this->tags[$keyName];
00663         }
00664 
00665         //$out =
00666     }
00667 /**
00668  * Before render callback.  Overridden in subclasses.
00669  *
00670  */
00671     function beforeRender() {
00672     }
00673 /**
00674  * After render callback.  Overridden in subclasses.
00675  *
00676  */
00677     function afterRender() {
00678     }
00679 /**
00680  * Before layout callback.  Overridden in subclasses.
00681  *
00682  */
00683     function beforeLayout() {
00684     }
00685 /**
00686  * After layout callback.  Overridden in subclasses.
00687  *
00688  */
00689     function afterLayout() {
00690     }
00691 /**
00692  * Transforms a recordset from a hasAndBelongsToMany association to a list of selected
00693  * options for a multiple select element
00694  *
00695  * @param mixed $data
00696  * @param string $key
00697  * @return array
00698  * @access private
00699  */
00700     function __selectedArray($data, $key = 'id') {
00701         if (!is_array($data)) {
00702             $model = $data;
00703             if (!empty($this->data[$model][$model])) {
00704                 return $this->data[$model][$model];
00705             }
00706             if (!empty($this->data[$model])) {
00707                 $data = $this->data[$model];
00708             }
00709         }
00710         $array = array();
00711         if (!empty($data)) {
00712             foreach ($data as $var) {
00713                 $array[$var[$key]] = $var[$key];
00714             }
00715         }
00716         return $array;
00717     }
00718 /**
00719  * Resets the vars used by Helper::clean() to null
00720  *
00721  * @access private
00722  */
00723     function __reset() {
00724         $this->__tainted = null;
00725         $this->__cleaned = null;
00726     }
00727 /**
00728  * Removes harmful content from output
00729  *
00730  * @access private
00731  */
00732     function __clean() {
00733         if (get_magic_quotes_gpc()) {
00734             $this->__cleaned = stripslashes($this->__tainted);
00735         } else {
00736             $this->__cleaned = $this->__tainted;
00737         }
00738 
00739         $this->__cleaned = str_replace(array("&amp;","&lt;","&gt;"),array("&amp;amp;","&amp;lt;","&amp;gt;"), $this->__cleaned);
00740         $this->__cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u',"$1;", $this->__cleaned);
00741         $this->__cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu',"$1$2;", $this->__cleaned);
00742         $this->__cleaned = html_entity_decode($this->__cleaned, ENT_COMPAT, "UTF-8");
00743         $this->__cleaned = preg_replace('#(<*[^>]*[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',"$1>", $this->__cleaned);
00744         $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2nojavascript...', $this->__cleaned);
00745         $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2novbscript...', $this->__cleaned);
00746         $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu','$1=$2nomozbinding...', $this->__cleaned);
00747         $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>", $this->__cleaned);
00748         $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',"$1>", $this->__cleaned);
00749         $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$this->__cleaned);
00750         $this->__cleaned = preg_replace('#</*\w+:\w[^>]*>#i',"", $this->__cleaned);
00751         do {
00752             $oldstring = $this->__cleaned;
00753             $this->__cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$this->__cleaned);
00754         } while ($oldstring != $this->__cleaned);
00755     }
00756 
00757 /**
00758  * @deprecated
00759  */
00760     function setFormTag($tagValue, $setScope = false) {
00761         trigger_error(__('Helper::setFormTag() Deprecated, use Helper::setEntity()', true), E_USER_WARNING);
00762         return $this->setEntity($tagValue, $setScope);
00763     }
00764 }
00765 ?>