source: trunk/admin/inc/ckeditor/filemanager/lib/helper_text.php@ 427

Last change on this file since 427 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1<?php
2
3/** This file is part of KCFinder project
4 *
5 * @desc Text processing helper class
6 * @package KCFinder
7 * @version 2.51
8 * @author Pavel Tzonkov <pavelc@users.sourceforge.net>
9 * @copyright 2010, 2011 KCFinder Project
10 * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11 * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12 * @link http://kcfinder.sunhater.com
13 */
14
15class text {
16
17 /** Replace repeated white spaces to single space
18 * @param string $string
19 * @return string */
20
21 static function clearWhitespaces($string) {
22 return trim(preg_replace('/\s+/s', " ", $string));
23 }
24
25 /** Normalize the string for HTML attribute value
26 * @param string $string
27 * @return string */
28
29 static function htmlValue($string) {
30 return
31 str_replace('"', "&quot;",
32 str_replace("'", '&#39;',
33 str_replace('<', '&lt;',
34 str_replace('&', "&amp;",
35 $string))));
36 }
37
38 /** Normalize the string for JavaScript string value
39 * @param string $string
40 * @return string */
41
42 static function jsValue($string) {
43 return
44 preg_replace('/\r?\n/', "\\n",
45 str_replace('"', "\\\"",
46 str_replace("'", "\\'",
47 str_replace("\\", "\\\\",
48 $string))));
49 }
50
51 /** Normalize the string for XML tag content data
52 * @param string $string
53 * @param bool $cdata */
54
55 static function xmlData($string, $cdata=false) {
56 $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
57 if (!$cdata)
58 $string = "<![CDATA[$string]]>";
59 return $string;
60 }
61
62 /** Returns compressed content of given CSS code
63 * @param string $code
64 * @return string */
65
66 static function compressCSS($code) {
67 $code = self::clearWhitespaces($code);
68 $code = preg_replace('/ ?\{ ?/', "{", $code);
69 $code = preg_replace('/ ?\} ?/', "}", $code);
70 $code = preg_replace('/ ?\; ?/', ";", $code);
71 $code = preg_replace('/ ?\> ?/', ">", $code);
72 $code = preg_replace('/ ?\, ?/', ",", $code);
73 $code = preg_replace('/ ?\: ?/', ":", $code);
74 $code = str_replace(";}", "}", $code);
75 return $code;
76 }
77}
78
79?>
Note: See TracBrowser for help on using the repository browser.