Changeset 12868
- Timestamp:
- Sep 9, 2009, 6:33:20 PM (13 years ago)
- Location:
- OpenPNE3/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/trunk/lib/helper/opUtilHelper.php
r12774 r12868 639 639 return true; 640 640 } 641 642 function op_decoration($string, $is_strip = false, $is_use_stylesheet = null) 643 { 644 if (is_null($is_use_stylesheet)) 645 { 646 $is_use_stylesheet = true; 647 if (sfConfig::get('sf_app') == 'mobile_frontend') 648 { 649 $is_use_stylesheet = false; 650 } 651 } 652 653 return opWidgetFormRichTextareaOpenPNE::toHtml($string, $is_strip, $is_use_stylesheet); 654 } -
OpenPNE3/trunk/lib/widget/opWidgetFormRichTextareaOpenPNE.class.php
r12821 r12868 47 47 48 48 static protected $defaultButtonOnclickActions = array('op_emoji_docomo' => ""); 49 50 static protected $htmlConvertList = array( 51 'op:b' => array('b'), 52 'op:u' => array('u'), 53 'op:i' => array('i'), 54 'op:s' => array('s'), 55 'op:large' => array('font', array('size' => 5)), 56 'op:small' => array('font', array('size' => 1)), 57 'op:color' => array('font'), 58 ); 49 59 50 60 public function configure($options = array(), $attributes = array()) … … 99 109 return $js.parent::render($name, $value, $attributes, $errors); 100 110 } 111 112 /** 113 * original tag to html 114 * 115 * @param string $string 116 * @param boolean $isStrip true if original tag is stripped from the string, false original tag convert html tag. 117 * @param boolean $isUseStylesheet 118 */ 119 static public function toHtml($string, $isStrip, $isUseStylesheet) 120 { 121 $regexp = '/(<|<)(\/?)(op:.+?)(?:\s+code=("|")(#[0-9a-f]{3,6})\4)?\s*(>|>)/i'; 122 123 if ($isStrip) 124 { 125 $converted = preg_replace($regexp, '', $string); 126 } 127 else 128 { 129 if ($isUseStylesheet) 130 { 131 $converted = preg_replace_callback($regexp, 'opWidgetFormRichTextareaOpenPNE::toHtmlUseStylesheet', $string); 132 } 133 else 134 { 135 $converted = preg_replace_callback($regexp, 'opWidgetFormRichTextareaOpenPNE::toHtmlNoStylesheet', $string); 136 } 137 } 138 139 return $converted; 140 } 141 142 static public function toHtmlUseStylesheet($matches) 143 { 144 $isEndtag = $matches[2]; 145 if ($isEndtag) { 146 return '</span>'; 147 } 148 149 $options = array(); 150 $tagname = strtolower($matches[3]); 151 $colorcode = strtolower($matches[5]); 152 $options['class'] = strtr($tagname, ':', '_'); 153 154 if ($tagname == 'op:color' && $colorcode) { 155 $options['style'] = 'color:'.$colorcode; 156 } 157 158 return tag('span', $options, true); 159 } 160 161 static public function toHtmlNoStylesheet($matches) 162 { 163 $options = array(); 164 $isEndtag = $matches[2]; 165 $tagname = strtolower($matches[3]); 166 $colorcode = strtolower($matches[5]); 167 $classname = strtr($tagname, ':', '_'); 168 169 if (!array_key_exists($tagname, self::$htmlConvertList)) { 170 return $value; 171 } 172 173 $htmlTagInfo = self::$htmlConvertList[$tagname]; 174 $htmlTagName = $htmlTagInfo[0]; 175 176 if ($isEndtag) { 177 return '</' . $htmlTagName . '>'; 178 } 179 180 if ($tagname == 'op:color' && $colorcode) { 181 $options['color'] = $colorcode; 182 } 183 184 if (isset($htmlTagInfo[1]) && is_array($htmlTagInfo[1])) 185 { 186 $options = array_merge($options, $htmlTagInfo[1]); 187 } 188 189 return tag($htmlTagName, $options, true); 190 } 101 191 } 102 192 -
OpenPNE3/trunk/web/css/main.css
r12664 r12868 1239 1239 background-color: #f8f8f8; 1240 1240 } 1241 1242 /*============================================================================== 1243 * Decoration by opWidgetFormRichTextareaOpenPNE 1244 *----------------------------------------------------------------------------*/ 1245 span.op_b { 1246 text-decoration: inherit; 1247 font-style: inherit; 1248 font-weight: bold; 1249 color: inherit; 1250 font-size: inherit; 1251 } 1252 1253 span.op_u { 1254 text-decoration: underline; 1255 font-style: inherit; 1256 font-weight: inherit; 1257 color: inherit; 1258 font-size: inherit; 1259 } 1260 1261 span.op_s { 1262 text-decoration: line-through; 1263 font-style: inherit; 1264 font-weight: inherit; 1265 color: inherit; 1266 font-size: inherit; 1267 } 1268 1269 span.op_i { 1270 text-decoration: inherit; 1271 font-style: italic; 1272 font-weight: inherit; 1273 color: inherit; 1274 font-size: inherit; 1275 } 1276 1277 span.op_large { 1278 text-decoration: inherit; 1279 font-style: inherit; 1280 font-weight: inherit; 1281 color: inherit; 1282 font-size: 20px; 1283 } 1284 1285 span.op_small { 1286 text-decoration: inherit; 1287 font-style: inherit; 1288 font-weight: inherit; 1289 color: inherit; 1290 font-size: 8px; 1291 } 1292 1293 span.op_color { 1294 text-decoration: inherit; 1295 font-style: inherit; 1296 font-weight: inherit; 1297 color: inherit; 1298 font-size: inherit; 1299 }
Note: See TracChangeset
for help on using the changeset viewer.