PageRenderTime 63ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/cake/libs/view/helper.php

https://github.com/hardsshah/bookmarks
PHP | 753 lines | 413 code | 37 blank | 303 comment | 110 complexity | ac9f7c0147ff8d5d19d95a1741da8fcf MD5 | raw file
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * Backend for helpers.
  5. *
  6. * Internal methods for the Helpers.
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
  11. * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  12. *
  13. * Licensed under The MIT License
  14. * Redistributions of files must retain the above copyright notice.
  15. *
  16. * @filesource
  17. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  18. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  19. * @package cake
  20. * @subpackage cake.cake.libs.view
  21. * @since CakePHP(tm) v 0.2.9
  22. * @version $Revision$
  23. * @modifiedby $LastChangedBy$
  24. * @lastmodified $Date$
  25. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  26. */
  27. /**
  28. * Included libs
  29. */
  30. App::import('Core', 'Overloadable');
  31. /**
  32. * Backend for helpers.
  33. *
  34. * Long description for class
  35. *
  36. * @package cake
  37. * @subpackage cake.cake.libs.view
  38. */
  39. class Helper extends Overloadable {
  40. /**
  41. * List of helpers used by this helper
  42. *
  43. * @var array
  44. */
  45. var $helpers = null;
  46. /**
  47. * Base URL
  48. *
  49. * @var string
  50. */
  51. var $base = null;
  52. /**
  53. * Webroot path
  54. *
  55. * @var string
  56. */
  57. var $webroot = null;
  58. /**
  59. * Theme name
  60. *
  61. * @var string
  62. */
  63. var $themeWeb = null;
  64. /**
  65. * URL to current action.
  66. *
  67. * @var string
  68. */
  69. var $here = null;
  70. /**
  71. * Parameter array.
  72. *
  73. * @var array
  74. */
  75. var $params = array();
  76. /**
  77. * Current action.
  78. *
  79. * @var string
  80. */
  81. var $action = null;
  82. /**
  83. * Plugin path
  84. *
  85. * @var string
  86. */
  87. var $plugin = null;
  88. /**
  89. * POST data for models
  90. *
  91. * @var array
  92. */
  93. var $data = null;
  94. /**
  95. * List of named arguments
  96. *
  97. * @var array
  98. */
  99. var $namedArgs = null;
  100. /**
  101. * URL argument separator character
  102. *
  103. * @var string
  104. */
  105. var $argSeparator = null;
  106. /**
  107. * Contains model validation errors of form post-backs
  108. *
  109. * @access public
  110. * @var array
  111. */
  112. var $validationErrors = null;
  113. /**
  114. * Holds tag templates.
  115. *
  116. * @access public
  117. * @var array
  118. */
  119. var $tags = array();
  120. /**
  121. * Holds the content to be cleaned.
  122. *
  123. * @access private
  124. * @var mixed
  125. */
  126. var $__tainted = null;
  127. /**
  128. * Holds the cleaned content.
  129. *
  130. * @access private
  131. * @var mixed
  132. */
  133. var $__cleaned = null;
  134. /**
  135. * Default overload methods
  136. *
  137. * @access protected
  138. */
  139. function get__($name) {}
  140. function set__($name, $value) {}
  141. function call__($method, $params) {
  142. trigger_error(sprintf(__('Method %1$s::%2$s does not exist', true), get_class($this), $method), E_USER_WARNING);
  143. }
  144. /**
  145. * Parses tag templates into $this->tags.
  146. *
  147. * @param $name file name
  148. * @return array merged tags from config/$name.php
  149. */
  150. function loadConfig($name = 'tags') {
  151. if (file_exists(CONFIGS . $name .'.php')) {
  152. require(CONFIGS . $name .'.php');
  153. if (isset($tags)) {
  154. $this->tags = array_merge($this->tags, $tags);
  155. }
  156. }
  157. return $this->tags;
  158. }
  159. /**
  160. * Finds URL for specified action.
  161. *
  162. * Returns an URL pointing to a combination of controller and action. Param
  163. * $url can be:
  164. * + Empty - the method will find adress to actuall controller/action.
  165. * + '/' - the method will find base URL of application.
  166. * + A combination of controller/action - the method will find url for it.
  167. *
  168. * @param mixed $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4"
  169. * or an array specifying any of the following: 'controller', 'action',
  170. * and/or 'plugin', in addition to named arguments (keyed array elements),
  171. * and standard URL arguments (indexed array elements)
  172. * @param boolean $full If true, the full base URL will be prepended to the result
  173. * @return string Full translated URL with base path.
  174. */
  175. function url($url = null, $full = false) {
  176. return h(Router::url($url, $full));
  177. }
  178. /**
  179. * Checks if a file exists when theme is used, if no file is found default location is returned
  180. *
  181. * @param string $file
  182. * @return string $webPath web path to file.
  183. */
  184. function webroot($file) {
  185. $webPath = "{$this->webroot}" . $file;
  186. if (!empty($this->themeWeb)) {
  187. $os = env('OS');
  188. if (!empty($os) && strpos($os, 'Windows') !== false) {
  189. if (strpos(WWW_ROOT . $this->themeWeb . $file, '\\') !== false) {
  190. $path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb . $file);
  191. }
  192. } else {
  193. $path = WWW_ROOT . $this->themeWeb . $file;
  194. }
  195. if (file_exists($path)) {
  196. $webPath = "{$this->webroot}" . $this->themeWeb . $file;
  197. }
  198. }
  199. if (strpos($webPath, '//') !== false) {
  200. return str_replace('//', '/', $webPath);
  201. }
  202. return $webPath;
  203. }
  204. /**
  205. * Used to remove harmful tags from content
  206. *
  207. * @param mixed $output
  208. * @return cleaned content for output
  209. * @access public
  210. */
  211. function clean($output) {
  212. $this->__reset();
  213. if (empty($output)) {
  214. return null;
  215. }
  216. if (is_array($output)) {
  217. foreach ($output as $key => $value) {
  218. $return[$key] = $this->clean($value);
  219. }
  220. return $return;
  221. }
  222. $this->__tainted = $output;
  223. $this->__clean();
  224. return $this->__cleaned;
  225. }
  226. /**
  227. * Returns a space-delimited string with items of the $options array. If a
  228. * key of $options array happens to be one of:
  229. * + 'compact'
  230. * + 'checked'
  231. * + 'declare'
  232. * + 'readonly'
  233. * + 'disabled'
  234. * + 'selected'
  235. * + 'defer'
  236. * + 'ismap'
  237. * + 'nohref'
  238. * + 'noshade'
  239. * + 'nowrap'
  240. * + 'multiple'
  241. * + 'noresize'
  242. *
  243. * And its value is one of:
  244. * + 1
  245. * + true
  246. * + 'true'
  247. *
  248. * Then the value will be reset to be identical with key's name.
  249. * If the value is not one of these 3, the parameter is not output.
  250. *
  251. * @param array $options Array of options.
  252. * @param array $exclude Array of options to be excluded.
  253. * @param string $insertBefore String to be inserted before options.
  254. * @param string $insertAfter String to be inserted ater options.
  255. * @return string
  256. */
  257. function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
  258. if (is_array($options)) {
  259. $options = array_merge(array('escape' => true), $options);
  260. if (!is_array($exclude)) {
  261. $exclude = array();
  262. }
  263. $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape')));
  264. $values = array_intersect_key(array_values($options), $keys);
  265. $escape = $options['escape'];
  266. $attributes = array();
  267. foreach ($keys as $index => $key) {
  268. $attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
  269. }
  270. $out = implode(' ', $attributes);
  271. } else {
  272. $out = $options;
  273. }
  274. return $out ? $insertBefore . $out . $insertAfter : '';
  275. }
  276. /**
  277. * @param string $key
  278. * @param string $value
  279. * @return string
  280. * @access private
  281. */
  282. function __formatAttribute($key, $value, $escape = true) {
  283. $attribute = '';
  284. $attributeFormat = '%s="%s"';
  285. $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
  286. if (is_array($value)) {
  287. $value = '';
  288. }
  289. if (in_array($key, $minimizedAttributes)) {
  290. if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
  291. $attribute = sprintf($attributeFormat, $key, $key);
  292. }
  293. } else {
  294. $attribute = sprintf($attributeFormat, $key, ($escape ? h($value) : $value));
  295. }
  296. return $attribute;
  297. }
  298. /**
  299. * Sets this helper's model and field properties to the dot-separated value-pair in $entity.
  300. *
  301. * @param mixed $entity A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName"
  302. * @param boolean $setScope Sets the view scope to the model specified in $tagValue
  303. * @return void
  304. */
  305. function setEntity($entity, $setScope = false) {
  306. $view =& ClassRegistry::getObject('view');
  307. if ($setScope) {
  308. $view->modelScope = false;
  309. } elseif (join('.', $view->entity()) == $entity) {
  310. return;
  311. }
  312. if ($entity === null) {
  313. $view->model = null;
  314. $view->association = null;
  315. $view->modelId = null;
  316. $view->modelScope = false;
  317. return;
  318. }
  319. $model = $view->model;
  320. $sameScope = $hasField = false;
  321. $parts = array_values(Set::filter(explode('.', $entity), true));
  322. if (empty($parts)) {
  323. return;
  324. }
  325. if (count($parts) === 1 || is_numeric($parts[0])) {
  326. $sameScope = true;
  327. } else {
  328. if (ClassRegistry::isKeySet($parts[0])) {
  329. $model = $parts[0];
  330. }
  331. }
  332. if (ClassRegistry::isKeySet($model)) {
  333. $ModelObj =& ClassRegistry::getObject($model);
  334. for ($i = 0; $i < count($parts); $i++) {
  335. if ($ModelObj->hasField($parts[$i]) || array_key_exists($parts[$i], $ModelObj->validate)) {
  336. $hasField = $i;
  337. if ($hasField === 0 || ($hasField === 1 && is_numeric($parts[0]))) {
  338. $sameScope = true;
  339. }
  340. break;
  341. }
  342. }
  343. if ($sameScope === true && in_array($parts[0], array_keys($ModelObj->hasAndBelongsToMany))) {
  344. $sameScope = false;
  345. }
  346. }
  347. if (!$view->association && $parts[0] == $view->field && $view->field != $view->model) {
  348. array_unshift($parts, $model);
  349. $hasField = true;
  350. }
  351. $view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
  352. switch (count($parts)) {
  353. case 1:
  354. if ($view->modelScope === false) {
  355. $view->model = $parts[0];
  356. } else {
  357. $view->field = $parts[0];
  358. if ($sameScope === false) {
  359. $view->association = $parts[0];
  360. }
  361. }
  362. break;
  363. case 2:
  364. if ($view->modelScope === false) {
  365. list($view->model, $view->field) = $parts;
  366. } elseif ($sameScope === true && $hasField === 0) {
  367. list($view->field, $view->fieldSuffix) = $parts;
  368. } elseif ($sameScope === true && $hasField === 1) {
  369. list($view->modelId, $view->field) = $parts;
  370. } else {
  371. list($view->association, $view->field) = $parts;
  372. }
  373. break;
  374. case 3:
  375. if ($sameScope === true && $hasField === 1) {
  376. list($view->modelId, $view->field, $view->fieldSuffix) = $parts;
  377. } elseif ($hasField === 2) {
  378. list($view->association, $view->modelId, $view->field) = $parts;
  379. } else {
  380. list($view->association, $view->field, $view->fieldSuffix) = $parts;
  381. }
  382. break;
  383. case 4:
  384. if ($parts[0] === $view->model) {
  385. list($view->model, $view->modelId, $view->field, $view->fieldSuffix) = $parts;
  386. } else {
  387. list($view->association, $view->modelId, $view->field, $view->fieldSuffix) = $parts;
  388. }
  389. break;
  390. }
  391. if (!isset($view->model) || empty($view->model)) {
  392. $view->model = $view->association;
  393. $view->association = null;
  394. } elseif ($view->model === $view->association) {
  395. $view->association = null;
  396. }
  397. if ($setScope) {
  398. $view->modelScope = true;
  399. }
  400. }
  401. /**
  402. * Gets the currently-used model of the rendering context.
  403. *
  404. * @return string
  405. */
  406. function model() {
  407. $view =& ClassRegistry::getObject('view');
  408. if (!empty($view->association)) {
  409. return $view->association;
  410. } else {
  411. return $view->model;
  412. }
  413. }
  414. /**
  415. * Gets the ID of the currently-used model of the rendering context.
  416. *
  417. * @return mixed
  418. */
  419. function modelID() {
  420. $view =& ClassRegistry::getObject('view');
  421. return $view->modelId;
  422. }
  423. /**
  424. * Gets the currently-used model field of the rendering context.
  425. *
  426. * @return string
  427. */
  428. function field() {
  429. $view =& ClassRegistry::getObject('view');
  430. return $view->field;
  431. }
  432. /**
  433. * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors.
  434. *
  435. * @param string $model Model name as string
  436. * @param string $field Fieldname as string
  437. * @param integer $modelID Unique index identifying this record within the form
  438. * @return boolean True on errors.
  439. */
  440. function tagIsInvalid($model = null, $field = null, $modelID = null) {
  441. foreach (array('model', 'field', 'modelID') as $key) {
  442. if (empty(${$key})) {
  443. ${$key} = $this->{$key}();
  444. }
  445. }
  446. $view =& ClassRegistry::getObject('view');
  447. $errors = $this->validationErrors;
  448. if ($view->model !== $model && isset($errors[$view->model][$model])) {
  449. $errors = $errors[$view->model];
  450. }
  451. if (!isset($modelID)) {
  452. return empty($errors[$model][$field]) ? 0 : $errors[$model][$field];
  453. } else {
  454. return empty($errors[$model][$modelID][$field]) ? 0 : $errors[$model][$modelID][$field];
  455. }
  456. }
  457. /**
  458. * Generates a DOM ID for the selected element, if one is not set.
  459. *
  460. * @param mixed $options
  461. * @param string $id
  462. * @return mixed
  463. */
  464. function domId($options = null, $id = 'id') {
  465. $view =& ClassRegistry::getObject('view');
  466. if (is_array($options) && array_key_exists($id, $options) && $options[$id] === null) {
  467. unset($options[$id]);
  468. return $options;
  469. } elseif (!is_array($options) && $options !== null) {
  470. $this->setEntity($options);
  471. return $this->domId();
  472. }
  473. $dom = $this->model() . $this->modelID() . Inflector::camelize($view->field) . Inflector::camelize($view->fieldSuffix);
  474. if (is_array($options) && !array_key_exists($id, $options)) {
  475. $options[$id] = $dom;
  476. } elseif ($options === null) {
  477. return $dom;
  478. }
  479. return $options;
  480. }
  481. /**
  482. * Gets the input field name for the current tag
  483. *
  484. * @param array $options
  485. * @param string $key
  486. * @return array
  487. */
  488. function __name($options = array(), $field = null, $key = 'name') {
  489. $view =& ClassRegistry::getObject('view');
  490. if ($options === null) {
  491. $options = array();
  492. } elseif (is_string($options)) {
  493. $field = $options;
  494. $options = 0;
  495. }
  496. if (!empty($field)) {
  497. $this->setEntity($field);
  498. }
  499. if (is_array($options) && array_key_exists($key, $options)) {
  500. return $options;
  501. }
  502. switch ($field) {
  503. case '_method':
  504. $name = $field;
  505. break;
  506. default:
  507. $name = 'data[' . join('][', $view->entity()) . ']';
  508. break;
  509. }
  510. if (is_array($options)) {
  511. $options[$key] = $name;
  512. return $options;
  513. } else {
  514. return $name;
  515. }
  516. }
  517. /**
  518. * Gets the data for the current tag
  519. *
  520. * @param array $options
  521. * @param string $key
  522. * @return array
  523. * @access public
  524. */
  525. function value($options = array(), $field = null, $key = 'value') {
  526. if ($options === null) {
  527. $options = array();
  528. } elseif (is_string($options)) {
  529. $field = $options;
  530. $options = 0;
  531. }
  532. if (!empty($field)) {
  533. $this->setEntity($field);
  534. }
  535. if (is_array($options) && isset($options[$key])) {
  536. return $options;
  537. }
  538. $result = null;
  539. $modelName = $this->model();
  540. $fieldName = $this->field();
  541. $modelID = $this->modelID();
  542. if (is_null($fieldName)) {
  543. $fieldName = $modelName;
  544. $modelName = null;
  545. }
  546. if (isset($this->data[$fieldName]) && $modelName === null) {
  547. $result = $this->data[$fieldName];
  548. } elseif (isset($this->data[$modelName][$fieldName])) {
  549. $result = $this->data[$modelName][$fieldName];
  550. } elseif (isset($this->data[$fieldName]) && is_array($this->data[$fieldName])) {
  551. if (ClassRegistry::isKeySet($fieldName)) {
  552. $model =& ClassRegistry::getObject($fieldName);
  553. $result = $this->__selectedArray($this->data[$fieldName], $model->primaryKey);
  554. }
  555. } elseif (isset($this->data[$modelName][$modelID][$fieldName])) {
  556. $result = $this->data[$modelName][$modelID][$fieldName];
  557. }
  558. if (is_array($result)) {
  559. $view =& ClassRegistry::getObject('view');
  560. if (isset($result[$view->fieldSuffix])) {
  561. $result = $result[$view->fieldSuffix];
  562. }
  563. }
  564. if (is_array($options)) {
  565. if (empty($result) && isset($options['default'])) {
  566. $result = $options['default'];
  567. }
  568. unset($options['default']);
  569. }
  570. if (is_array($options)) {
  571. $options[$key] = $result;
  572. return $options;
  573. } else {
  574. return $result;
  575. }
  576. }
  577. /**
  578. * Sets the defaults for an input tag
  579. *
  580. * @param array $options
  581. * @param string $key
  582. * @return array
  583. * @access protected
  584. */
  585. function _initInputField($field, $options = array()) {
  586. if ($field !== null) {
  587. $this->setEntity($field);
  588. }
  589. $options = (array)$options;
  590. $options = $this->__name($options);
  591. $options = $this->value($options);
  592. $options = $this->domId($options);
  593. if ($this->tagIsInvalid()) {
  594. $options = $this->addClass($options, 'form-error');
  595. }
  596. return $options;
  597. }
  598. /**
  599. * Adds the given class to the element options
  600. *
  601. * @param array $options
  602. * @param string $class
  603. * @param string $key
  604. * @return array
  605. */
  606. function addClass($options = array(), $class = null, $key = 'class') {
  607. if (isset($options[$key]) && trim($options[$key]) != '') {
  608. $options[$key] .= ' ' . $class;
  609. } else {
  610. $options[$key] = $class;
  611. }
  612. return $options;
  613. }
  614. /**
  615. * Returns a string generated by a helper method
  616. *
  617. * This method can be overridden in subclasses to do generalized output post-processing
  618. *
  619. * @param string $str String to be output.
  620. * @return string
  621. */
  622. function output($str) {
  623. return $str;
  624. }
  625. /**
  626. * Before render callback. Overridden in subclasses.
  627. *
  628. */
  629. function beforeRender() {
  630. }
  631. /**
  632. * After render callback. Overridden in subclasses.
  633. *
  634. */
  635. function afterRender() {
  636. }
  637. /**
  638. * Before layout callback. Overridden in subclasses.
  639. *
  640. */
  641. function beforeLayout() {
  642. }
  643. /**
  644. * After layout callback. Overridden in subclasses.
  645. *
  646. */
  647. function afterLayout() {
  648. }
  649. /**
  650. * Transforms a recordset from a hasAndBelongsToMany association to a list of selected
  651. * options for a multiple select element
  652. *
  653. * @param mixed $data
  654. * @param string $key
  655. * @return array
  656. * @access private
  657. */
  658. function __selectedArray($data, $key = 'id') {
  659. if (!is_array($data)) {
  660. $model = $data;
  661. if (!empty($this->data[$model][$model])) {
  662. return $this->data[$model][$model];
  663. }
  664. if (!empty($this->data[$model])) {
  665. $data = $this->data[$model];
  666. }
  667. }
  668. $array = array();
  669. if (!empty($data)) {
  670. foreach ($data as $var) {
  671. $array[$var[$key]] = $var[$key];
  672. }
  673. }
  674. return $array;
  675. }
  676. /**
  677. * Resets the vars used by Helper::clean() to null
  678. *
  679. * @access private
  680. */
  681. function __reset() {
  682. $this->__tainted = null;
  683. $this->__cleaned = null;
  684. }
  685. /**
  686. * Removes harmful content from output
  687. *
  688. * @access private
  689. */
  690. function __clean() {
  691. if (get_magic_quotes_gpc()) {
  692. $this->__cleaned = stripslashes($this->__tainted);
  693. } else {
  694. $this->__cleaned = $this->__tainted;
  695. }
  696. $this->__cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->__cleaned);
  697. $this->__cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $this->__cleaned);
  698. $this->__cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $this->__cleaned);
  699. $this->__cleaned = html_entity_decode($this->__cleaned, ENT_COMPAT, "UTF-8");
  700. $this->__cleaned = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $this->__cleaned);
  701. $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);
  702. $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);
  703. $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu','$1=$2nomozbinding...', $this->__cleaned);
  704. $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $this->__cleaned);
  705. $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
  706. $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
  707. $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);
  708. $this->__cleaned = preg_replace('#</*\w+:\w[^>]*>#i', "", $this->__cleaned);
  709. do {
  710. $oldstring = $this->__cleaned;
  711. $this->__cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->__cleaned);
  712. } while ($oldstring != $this->__cleaned);
  713. $this->__cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->__cleaned);
  714. }
  715. }
  716. ?>