Created
April 17, 2012 09:03
-
-
Save anonymous/2404734 to your computer and use it in GitHub Desktop.
Expression Engine Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Prime { | |
public function __construct() { | |
$this->EE =& get_instance(); | |
} | |
public function no_spaces() { | |
return str_replace(' ', '', $this->EE->TMPL->tagdata); | |
} | |
function format_phone() { | |
$number = $this->EE->TMPL->tagdata; | |
$pieces = array(); | |
$result = preg_match('^\(?(?<areacode>[2-9]\d{2})(\)?)(-|.|\s)?(?<prefix>[1-9]\d{2})(-|.|\s)?(?<suffix>\d{4})$^', $number, $pieces); | |
if($result !== FALSE) { | |
if(!empty($pieces['areacode']) && !empty($pieces['prefix']) && !empty($pieces['suffix'])) { | |
return '('.$pieces['areacode'].') '.$pieces['prefix'].'-'.$pieces['suffix']; | |
} | |
} | |
return $number; | |
} | |
function strip() { | |
$allowable = $this->EE->TMPL->fetch_param('allow'); | |
return strip_tags($this->EE->TMPL->tagdata, $allowable); | |
} | |
} | |
/* End of file pi.prime.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment