Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ProcessWire Entities Textformatter
- *
- * Formats text with PHP's htmlspecialchars() function.
- *
- * ProcessWire 2.x
- * Copyright (C) 2010 by Ryan Cramer
- * Licensed under GNU/GPL v2, see LICENSE.TXT
- *
- * http://www.processwire.com
- * http://www.ryancramer.com
- *
- */
- class TextformatterCoworker extends Textformatter {
- public static function getModuleInfo() {
- return array(
- 'title' => __('Coworker', __FILE__), // Module Title
- 'summary' => __("Formats - Max Mustermann <max.mustermann@xxx.de> - into an array with name and email property.", __FILE__), // Module Summary
- 'version' => 100,
- );
- }
- public function format(&$str) {
- $str = trim($str);
- $name = trim(substr($str, 0, strpos($str, "<")));
- $email = trim(substr($str, strpos($str, "<"), strlen($str) - 2), " \t\n\r\0\x0B<>");
- static $charset = false;
- if($charset === false) $charset = $this->config->dbCharset;
- if($charset == 'utf8'){
- $name = htmlspecialchars($name, ENT_QUOTES, "UTF-8");
- $email = htmlspecialchars($email, ENT_QUOTES, "UTF-8");
- }else{
- $name = htmlspecialchars($name, ENT_QUOTES);
- $email = htmlspecialchars($email, ENT_QUOTES);
- }
- $str = array(
- "name" => $name,
- "email" => $email
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement