本文整理汇总了PHP中format_phone函数的典型用法代码示例。如果您正苦于以下问题:PHP format_phone函数的具体用法?PHP format_phone怎么用?PHP format_phone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_phone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_calls
/**
* Get a list of calls
*
* @param string $offset
* @param string $page_size
* @return void
*/
public function get_calls($offset = 0, $page_size = 20)
{
$output = array();
$page_cache = 'calls-' . $offset . '-' . $page_size;
$total_cache = 'calls-total';
$ci =& get_instance();
$tenant = $ci->tenant->id;
if ($cache = $ci->api_cache->get($page_cache, __CLASS__, $tenant) && ($cache_total = $ci->api_cache->get($total_cache, __CLASS__, $tenant))) {
$this->total = $cache_total;
return $cache;
}
$page = floor(($offset + 1) / $page_size);
try {
$account = OpenVBX::getAccount();
$calls = $account->calls->getIterator($page, $page_size, array());
if (count($calls)) {
$this->total = count($calls);
foreach ($calls as $call) {
$output[] = (object) array('id' => $call->sid, 'caller' => format_phone($call->from), 'called' => format_phone($call->to), 'status' => $call->status, 'start' => $call->start_time, 'end' => $call->end_time, 'seconds' => intval($call->recording_duration));
}
}
} catch (Exception $e) {
throw new VBX_CallException($e->getMessage());
}
$ci->api_cache->set($page_cache, $output, __CLASS__, $tenant, self::CACHE_TIME_SEC);
$ci->api_cache->set($total_cache, $this->total, __CLASS__, $tenant, self::CACHE_TIME_SEC);
return $output;
}
示例2: get_messages
/**
* Get SMS Messages
*
* @param string $offset
* @param string $page_size
* @return void
*/
function get_messages($offset = 0, $page_size = 20)
{
$output = array();
$ci =& get_instance();
$tenant_id = $ci->tenant->id;
$page_cache = 'messages-' . $offset . '-' . $page_size;
$total_cache = 'messages-total';
if ($cache = $ci->api_cache->get($page_cache, __CLASS__, $tenant_id) && ($cache_total = $ci->api_cache->get($total_cache, __CLASS__, $tenant_id))) {
$this->total = $cache_total;
return $cache;
}
$page = floor(($offset + 1) / $page_size);
try {
$account = OpenVBX::getAccount();
$messages = $account->messages->getIterator($page, $page_size, array());
if (count($messages)) {
$this->total = count($messages);
foreach ($messages as $message) {
$output[] = (object) array('id' => $message->sid, 'from' => format_phone($message->from), 'to' => format_phone($message->to), 'status' => $message->status);
}
}
} catch (Exception $e) {
throw new VBX_Sms_messageException($e->getMessage());
}
$ci->api_cache->set($page_cache, $output, __CLASS__, $tenant_id, self::CACHE_TIME_SEC);
$ci->api_cache->set($total_cache, $this->total, __CLASS__, $tenant_id, self::CACHE_TIME_SEC);
return $output;
}
示例3: init_browserphone_data
protected function init_browserphone_data($callerid_numbers)
{
// defaults
$browserphone = array('call_using' => 'browser', 'caller_id' => '(000) 000-0000', 'number_options' => array(), 'call_using_options' => array('browser' => array('title' => 'Your Computer', 'data' => array())), 'devices' => array());
$default_caller_id = false;
if (is_array($callerid_numbers) && !empty($callerid_numbers)) {
$numbered = $named = array();
$default_caller_id = current($callerid_numbers)->phone;
foreach ($callerid_numbers as $number) {
if (normalize_phone_to_E164($number->phone) != normalize_phone_to_E164($number->name)) {
$named[$number->phone] = $number->name;
} else {
$numbered[$number->phone] = $number->phone;
}
}
ksort($numbered);
asort($named);
$browserphone['number_options'] = $named + $numbered;
}
$user = VBX_User::get(array('id' => $this->session->userdata('user_id')));
// User preferences
$browserphone['caller_id'] = $user->setting('browserphone_caller_id', $default_caller_id);
$browserphone['call_using'] = $user->setting('browserphone_call_using', 'browser');
// Wether the user has an active device to use
if (count($user->devices)) {
foreach ($user->devices as $device) {
if (strpos($device->value, 'client:') !== false) {
continue;
}
$browserphone['call_using_options']['device:' . $device->id] = array('title' => 'Device: ' . $device->name, 'data' => (object) array('number' => format_phone($device->value), 'name' => $device->name));
}
}
return $browserphone;
}
示例4: testFormatPhone
public function testFormatPhone()
{
$this->assertSame('+6281802596094', format_phone('081802596094'));
$this->assertSame('+6281802596094', format_phone('+6281802596094'));
$this->assertSame('+6281802596094', format_phone('0818 0259 6094'));
$this->assertSame('+6281802596094', format_phone('0818-025 960-94'));
$this->assertSame('+62271715877', format_phone('(0271) 715 877'));
$this->assertSame('+65271715877', format_phone('(0271) 715 877', '+65'));
}
示例5: who_called
function who_called($number)
{
if (preg_match('|^client:|', $number)) {
$number = str_replace('client:', '', $number);
$ret = $number . ' (client)';
} else {
$ret = format_phone($number);
}
return $ret;
}
示例6: who_called
public function who_called($number)
{
if (preg_match('|^client:|', $number)) {
$user_id = str_replace('client:', '', $number);
$user = VBX_User::get(array('id' => $user_id));
$ret = $user->first_name . ' ' . $user->last_name . ' (client)';
} else {
$ret = format_phone($number);
}
return $ret;
}
示例7: testFormatPhone
function testFormatPhone()
{
$this->equals(format_phone('6154295938'), "(615) 429-5938");
$this->equals(format_phone('615-429-5938'), "(615) 429-5938");
$this->equals(format_phone("(615)-429-5938"), "(615) 429-5938");
$this->equals(format_phone('615.429.5938'), "(615) 429-5938");
$this->equals(format_phone('4295938'), '429-5938');
$this->equals(format_phone('429-5938'), '429-5938');
$this->equals(format_phone('429-5938'), '429-5938');
$this->equals(format_phone('429.5938'), '429-5938');
$this->equals(format_phone("429.ASF*^&%AS*^5938"), '429-5938');
}
示例8: get_all_twilio_numbers
public static function get_all_twilio_numbers()
{
global $ApiVersion, $AccountSid, $AuthToken;
$twilio_numbers = array();
$client = new TwilioRestClient($AccountSid, $AuthToken);
$response = $client->request("/{$ApiVersion}/Accounts/{$AccountSid}/IncomingPhoneNumbers", "GET");
// Get all twilio phone numbers
foreach ($response->ResponseXml->IncomingPhoneNumbers->IncomingPhoneNumber as $number) {
$twilio_numbers[format_phone($number->PhoneNumber)] = $number->FriendlyName;
}
return $twilio_numbers;
}
示例9: testFormatPhone
function testFormatPhone()
{
$this->assertEquals("(615) 429-5938", format_phone('6154295938'));
$this->assertEquals("(615) 429-5938", format_phone('615-429-5938'));
$this->assertEquals("(615) 429-5938", format_phone("(615)-429-5938"));
$this->assertEquals("(615) 429-5938", format_phone('615.429.5938'));
$this->assertEquals('429-5938', format_phone('4295938'));
$this->assertEquals('429-5938', format_phone('429-5938'));
$this->assertEquals('429-5938', format_phone('429-5938'));
$this->assertEquals('429-5938', format_phone('429.5938'));
$this->assertEquals('429-5938', format_phone("429.ASF*^&%AS*^5938"));
}
示例10: get_all_twilio_numbers
function get_all_twilio_numbers()
{
$app = \Jolt\Jolt::getInstance();
$ApiVersion = "2010-04-01";
$twilio_numbers = array();
$client = new Services_Twilio($app->option('twilio.accountsid'), $app->option('twilio.authtoken'));
// Loop over the list of numbers and echo a property for each one
foreach ($client->account->incoming_phone_numbers as $number) {
$twilio_numbers[format_phone($number->phone_number)] = $number->phone_number;
}
return $twilio_numbers;
}
示例11: render
public function render($data = array())
{
$hasValue = empty($this->mode) ? false : true;
$this->load =& load_class('Loader');
$this->load->model('vbx_audio_file');
$this->load->model('vbx_device');
// Get a list of all previously recorded items so we can populate the library
$ci =& get_instance();
$ci->db->where('url IS NOT NULL');
$ci->db->where('tag', $this->tag);
$ci->db->where('tenant_id', $ci->tenant->id);
$ci->db->from('audio_files');
$ci->db->order_by('created DESC');
$results = $ci->db->get()->result();
foreach ($results as $i => $result) {
$results[$i] = new VBX_Audio_File($result);
}
// Pre-fill the record text field with the the first device phone number we
// find for the current user that is active.
$ci =& get_instance();
$user = VBX_User::get($ci->session->userdata('user_id'));
$user_phone = '';
if (count($user->devices)) {
foreach ($user->devices as $device) {
if ($device->is_active) {
$user_phone = format_phone($device->value);
break;
}
}
}
// set the caller id for recording via the phone
$caller_id = '';
$ci->load->model('vbx_incoming_numbers');
try {
$numbers = $ci->vbx_incoming_numbers->get_numbers(false);
foreach ($numbers as $number) {
// find the first number that has voice enabled
// yes, this is a rather paranoid check
if (isset($number->capabilities->voice) && $number->capabilities->voice > 0) {
$caller_id = normalize_phone_to_E164($number->phone);
break;
}
}
} catch (VBX_IncomingNumberException $e) {
// fail silently, for better or worse
error_log($e->getMessage());
}
$data = array_merge(array('name' => $this->name, 'hasValue' => $hasValue, 'mode' => $this->mode, 'say' => $this->say_value, 'play' => $this->play_value, 'tag' => $this->tag, 'library' => $results, 'first_device_phone_number' => $user_phone, 'caller_id' => $caller_id), $data);
return parent::render($data);
}
示例12: index
function index($message_id = false)
{
try {
$content = substr($this->input->post('content'), 0, 160);
$to = preg_replace('/[^0-9]*/', '', $this->input->post('to'));
$from = $this->input->post('from');
$numbers = array();
if (empty($from)) {
try {
$numbers = $this->vbx_incoming_numbers->get_numbers();
if (empty($numbers)) {
throw new Message_TextException("No SMS Enabled numbers");
}
$from = $numbers[0]->phone;
} catch (VBX_IncomingNumberException $e) {
throw new Message_TextException("Unable to retrieve numbers: " . $e->getMessage());
}
}
if (empty($from)) {
$this->load->model('device');
$devices = $this->device->get_by_user($this->user_id);
if (!empty($devices[0])) {
$from = $devices[0]->value;
}
}
$rest_access = $this->make_rest_access();
$json['error'] = false;
$json['message'] = '';
try {
$this->vbx_sms_message->send_message($from, $to, $content);
if ($message_id) {
error_log("SMS Message ID: {$message_id}");
$annotation_id = $this->vbx_message->annotate($message_id, $this->user_id, "{$from} to " . format_phone($to) . ": {$content}", 'sms');
}
} catch (VBX_Sms_MessageException $e) {
throw new Message_TextException($e->getMessage());
}
} catch (Message_TextException $e) {
$json['message'] = $e->getMessage();
$json['error'] = true;
}
$data['json'] = $json;
if ($this->response_type == 'html') {
redirect('messages/inbox');
}
$this->respond('', 'message_sms', $data);
}
示例13: get_calls
function get_calls($offset = 0, $page_size = 20)
{
$output = array();
$page_cache_key = $this->cache_key . "_{$offset}_{$page_size}";
$total_cache_key = $this->cache_key . '_total';
if (function_exists('apc_fetch')) {
$success = FALSE;
$total = apc_fetch($total_cache_key, $success);
if ($total and $success) {
$this->total = $total;
}
$data = apc_fetch($page_cache_key, $success);
if ($data and $success) {
$output = @unserialize($data);
if (is_array($output)) {
return $output;
}
}
}
$page = floor(($offset + 1) / $page_size);
$params = array('num' => $page_size, 'page' => $page);
$response = $this->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'GET', $params);
if ($response->IsError) {
throw new VBX_CallException($response->ErrorMessage, $response->HttpStatus);
} else {
$this->total = (string) $response->ResponseXml->Calls['total'];
$records = $response->ResponseXml->Calls->Call;
foreach ($records as $record) {
$item = new stdClass();
$item->id = (string) $record->Sid;
$item->caller = format_phone($record->From);
$item->called = format_phone($record->To);
$item->status = (string) $record->Status;
$item->start = isset($record->StartTime) ? strtotime($record->StartTime) : null;
$item->end = isset($record->EndTime) ? strtotime($record->EndTime) : null;
$item->seconds = isset($record->RecordingDuration) ? (string) $record->RecordingDuration : 0;
$output[] = $item;
}
}
if (function_exists('apc_store')) {
apc_store($page_cache_key, serialize($output), self::CACHE_TIME_SEC);
apc_store($total_cache_key, $this->total, self::CACHE_TIME_SEC);
}
return $output;
}
示例14: index
function index()
{
$this->admin_only($this->section);
$this->template->add_js('assets/j/numbers.js');
$data = $this->init_view_data();
$numbers = array();
try {
$numbers = $this->vbx_incoming_numbers->get_numbers();
} catch (VBX_IncomingNumberException $e) {
$this->error_message = ErrorMessages::message('twilio_api', $e->getCode());
}
$incoming_numbers = array();
// now generate table
if (count($numbers) > 0) {
$flows = VBX_Flow::search();
foreach ($numbers as $item) {
$item_msg = '';
if (is_object($this->new_number) && $this->new_number->id == $item->id) {
$item_msg = 'New';
}
$flow_name = '(Not Set)';
foreach ($flows as $flow) {
if ($flow->id == $item->flow_id) {
$flow_name = '';
}
}
$incoming_numbers[] = array('id' => $item->id, 'name' => $item->name, 'trial' => isset($item->trial) && $item->trial == 1 ? 1 : 0, 'phone' => format_phone($item->phone), 'pin' => $item->pin, 'status' => $item_msg, 'flow_id' => $item->flow_id, 'flow_name' => $flow_name, 'flows' => $flows);
}
}
$data['highlighted_numbers'] = array($this->session->flashdata('new-number'));
$data['items'] = $incoming_numbers;
$data['twilio_sid'] = $this->twilio_sid;
if (empty($this->error_message)) {
$error_message = $this->session->flashdata('error');
if (!empty($error_message)) {
$this->error_message = $this->session->flashdata('error');
}
}
if (!empty($this->error_message)) {
$data['error'] = CI_Template::literal($this->error_message);
}
$data['counts'] = $this->message_counts();
$this->respond('', 'numbers', $data);
}
示例15: get_messages
function get_messages($offset = 0, $page_size = 20)
{
$output = array();
$page_cache_key = $this->cache_key . "_{$offset}_{$page_size}";
$total_cache_key = $this->cache_key . '_total';
if (function_exists('apc_fetch')) {
$success = FALSE;
$total = apc_fetch($total_cache_key, $success);
if ($total and $success) {
$this->total = $total;
}
$data = apc_fetch($page_cache_key, $success);
if ($data and $success) {
$output = @unserialize($data);
if (is_array($output)) {
return $output;
}
}
}
$page = floor(($offset + 1) / $page_size);
$params = array('num' => $page_size, 'page' => $page);
$response = $this->twilio->request("Accounts/{$this->twilio_sid}/SMS/Messages", 'GET', $params);
if ($response->IsError) {
throw new VBX_Sms_messageException($response->ErrorMessage, $response->HttpStatus);
} else {
$this->total = (string) $response->ResponseXml->SMSMessages['total'];
$records = $response->ResponseXml->SMSMessages->SMSMessage;
foreach ($records as $record) {
$item = new stdClass();
$item->id = (string) $record->Sid;
$item->from = format_phone($record->From);
$item->to = format_phone($record->To);
$item->status = Call::get_status((string) $record->Status);
$output[] = $item;
}
}
if (function_exists('apc_store')) {
apc_store($page_cache_key, serialize($output), self::CACHE_TIME_SEC);
apc_store($total_cache_key, $this->total, self::CACHE_TIME_SEC);
}
return $output;
}