本文整理汇总了PHP中Format类的典型用法代码示例。如果您正苦于以下问题:PHP Format类的具体用法?PHP Format怎么用?PHP Format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process()
{
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'ProductComponents');
$format = new Format();
parent::process();
if ($this->viaAJAX) {
// override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"productComponentsQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"productcomponents\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_productcomponents\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('productComponentsQuickCreate');
$focus = new ProductComponents();
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$app_list_strings['products_format_options'] = $format->Get_Dropdown_Data();
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
$this->ss->assign('run_style_options', get_select_options_with_id($app_list_strings['layout_type_options'], ''));
$this->ss->assign('type_options', get_select_options_with_id($app_list_strings['type_options'], $focus->type));
$this->ss->assign('color_side_a', get_select_options_with_id($app_list_strings['color_side_a'], $focus->color_side_a));
$this->ss->assign('color_side_b', get_select_options_with_id($app_list_strings['color_side_b'], $focus->color_side_b));
$this->ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['project_task_status_options'], $focus->status));
$this->ss->assign("FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->format));
$this->ss->assign("RUN_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->format));
$this->ss->assign("BLEED_FORMAT_OPTIONS", get_select_options_with_id($app_list_strings['products_format_options'], $focus->format));
$ppref = 'PRD';
$pnumber = $focus->get_pnum();
$number_suf = $focus->generate_number();
$this->ss->assign('number_pref', $ppref);
$this->ss->assign('pnum', $pnumber);
$this->ss->assign('number_suf', $number_suf);
$this->ss->assign("LAYOUTROWS", $focus->getLayoutRow(new Layoutline(), 0, true, true));
//$this->ss->parse("main.row1");
$json = getJSONobj();
///////////////////////////////////////
///
/// SETUP PARENT POPUP
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'projectTypeQuickCreate', 'field_to_name_array' => array('id' => 'parent_id', 'name' => 'parent_name'));
$encoded_parent_popup_request_data = $json->encode($popup_request_data);
$this->ss->assign('encoded_parent_popup_request_data', $encoded_parent_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'productComponentsQuickCreate', 'field_to_name_array' => array('id' => 'paperid', 'pname' => 'paper'));
$this->ss->assign('encoded_paper_popup_request_data', $json->encode($popup_request_data));
//machines popup
/* $popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'productComponentsQuickCreate',
'field_to_name_array' => array(
'id' => 'machine_id',
'name' => 'machine',
),
);
$encoded_popup_request_data = $json->encode($popup_request_data);
$this->ss->assign('encoded_machine_popup_request_data', $encoded_popup_request_data);
*/
}
示例2: testSetGetFormat
/**
* @covers \Tivie\GitLogParser\Format::setFormat
* @covers \Tivie\GitLogParser\Format::getFormatString
* @covers \Tivie\GitLogParser\Format::getCommitDelimiter
* @covers \Tivie\GitLogParser\Format::getFieldDelimiter
*/
public function testSetGetFormat()
{
$format = new Format();
$cDel = '<br>';
$fDel = '|';
$formatStr = "%h{$fDel}%d{$fDel}%B{$cDel}";
$format->setFormat($formatStr, $cDel, $fDel);
self::assertEquals($cDel, $format->getCommitDelimiter());
self::assertEquals($fDel, $format->getFieldDelimiter());
self::assertEquals($formatStr, $format->getFormatString());
}
示例3: action_add_blocked
public function action_add_blocked($block = null)
{
if (empty($block) === true) {
$block = $_POST['blocked'];
} else {
$block = str_replace('-', '.', $block);
}
$blacklist_item = Model_Blacklist::query()->where('expression', $block)->get_one();
if (empty($blacklist_item) === true) {
$blacklist_item = Model_Blacklist::forge(array('expression' => $block));
$blacklist_item->save();
if (Input::is_ajax() === true) {
echo $blacklist_item->id;
}
} else {
if (Input::is_ajax() === true) {
print_r(Format::forge(array('error' => 'Already Exists'))->to_json());
} else {
Session::set('error', $block . ' is already in the blacklist!');
}
}
if (Input::is_ajax() === true) {
die;
}
Response::Redirect_Back();
}
示例4: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try {
//dd($this->req);
\DB::begintransaction();
$me = \Me::data()->id_karyawan;
// Create PO
$po = data_po::create(['id_sph' => $this->req['id'], 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => $me, 'id_acc' => 0, 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket'], 'titipan' => $this->req['titipan']]);
foreach ($this->req['id_barang'] as $i => $id_barang) {
data_po_item::create(['id_po' => $po->id_po, 'id_item' => $id_barang, 'req_qty' => $this->req['qty'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i], 'id_prq' => $this->req['id_prq'][$i]]);
data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]);
// update Harga
data_barang::find($id_barang)->update(['harga_beli' => $this->req['harga'][$i]]);
// Update Log harga
data_harga::create(['id_barang' => $id_barang, 'harga' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me, 'tipe' => 1]);
data_prq_item::find($this->req['id_prq_item'][$i])->update(['status' => 2]);
}
$format = 'PO-';
$po->no_po = $format . \Format::code($po->id_po);
$po->save();
\Loguser::create('Membuat PO dengan No. PO ' . $po->no_po);
\DB::commit();
return ['result' => true, 'err' => 'PO berhasil dibuat dengan No. ' . $po->no_po];
} catch (\Exception $e) {
\DB::rollback();
return ['result' => false, 'err' => $e->getMessage()];
}
}
示例5: filter_comment_content_out
public function filter_comment_content_out($content, $comment)
{
if ($this->should_pee('C-' . $comment->typename)) {
$content = Format::autop($content);
}
return $content;
}
示例6: validate_url
/**
* A validation function that returns an error if the value passed in is not a valid URL.
*
* @param string $text A string to test if it is a valid URL
* @param FormControl $control The control that defines the value
* @param FormContainer $form The container that holds the control
* @param string $warning An optional error message
* @return array An empty array if the string is a valid URL, or an array with strings describing the errors
*/
public static function validate_url($text, $control, $form, $warning = null, $schemes = array('http', 'https'), $guess = true)
{
if (!empty($text)) {
$parsed = InputFilter::parse_url($text);
if ($parsed['is_relative']) {
if ($guess) {
// guess if they meant to use an absolute link
$parsed = InputFilter::parse_url('http://' . $text);
if ($parsed['is_error']) {
// disallow relative URLs
$warning = empty($warning) ? _t('Relative urls are not allowed') : $warning;
return array($warning);
} else {
$warning = empty($warning) ? _t('Relative urls are not allowed') : $warning;
return array($warning);
}
}
}
if ($parsed['is_pseudo'] || !in_array($parsed['scheme'], $schemes)) {
// allow only http(s) URLs
$warning = empty($warning) ? _t('Only %s urls are allowed', array(Format::and_list($schemes))) : $warning;
return array($warning);
}
}
return array();
}
示例7: add_user_play
public static function add_user_play($username, $password, $artist, $album, $title, $length)
{
// ensure we have the length in milliseconds.
$length = Format::fix_length($length);
if ($length === -1) {
Logger::log("add_play: failed to convert length to milliseconds");
return false;
}
// unknown artist/album ("") becomes "N/A"
if ($artist === "") {
$artist = "N/A";
}
if ($album === "") {
$album = "N/A";
}
$db = Database::instance();
$sql = 'SELECT api_add_user_play(?, ?, ?, ?, ?, ?) AS success';
$params = array($username, $password, $artist, $album, $title, $length);
try {
$rows = $db->select($sql, $params);
} catch (Exception $e) {
Logger::log("add_user_play: database failure: " . $e->getMessage());
return false;
}
return count($rows) === 1 && $rows[0]['success'] === true;
}
示例8: getDatapembelian
public function getDatapembelian(Request $req)
{
if ($req->ajax()) {
$res = [];
$out = '';
$kat = [];
$seri = [];
$items = data_po::grafikpembelian($req->tahun)->get();
foreach ($items as $item) {
$kat[] = \Format::indoDate2($item->tanggal);
$seri[] = (int) $item->total;
}
$res['po'] = ['kategori' => $kat, 'data' => $seri];
$kato = [];
$serio = [];
$obats = data_po_item::grafikpembelian(1, $req->tahun)->get();
foreach ($obats as $o) {
$kato[] = \Format::indoDate2($o->tanggal);
$serio[] = (int) $o->total;
}
$res['obat'] = ['kategori' => $kato, 'data' => $serio];
$katb = [];
$serib = [];
$barangs = data_po_item::grafikpembelian(2, $req->tahun)->get();
foreach ($barangs as $b) {
$katb[] = \Format::indoDate2($b->tanggal);
$serib[] = (int) $b->total;
}
$res['barang'] = ['kategori' => $katb, 'data' => $serib];
return json_encode($res);
}
}
示例9: _to_client
protected function _to_client()
{
$web_format = config('settings', 'web_format');
header('Content-type: application/' . $web_format);
echo Format::converter(Command::get_report(), $web_format);
exit;
}
示例10: onTicketCreated
function onTicketCreated($answer)
{
try {
global $ost;
if (!($ticket = Ticket::lookup($answer->object_id))) {
die('Unknown or invalid ticket ID.');
}
//Slack payload
$payload = array('attachments' => array(array('pretext' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'fallback' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'color' => "#D00000", 'fields' => array(array('title' => "From: " . mb_convert_case(Format::htmlchars($ticket->getName()), MB_CASE_TITLE) . " (" . $ticket->getEmail() . ")", 'value' => '', 'short' => false)))));
//Curl to webhook
$data_string = utf8_encode(json_encode($payload));
$url = $this->getConfig()->get('slack-webhook-url');
if (!function_exists('curl_init')) {
error_log('osticket slackplugin error: cURL is not installed!');
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
if ($result === false) {
error_log($url . ' - ' . curl_error($ch));
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != '200') {
error_log($url . ' Http code: ' . $statusCode);
}
}
curl_close($ch);
} catch (Exception $e) {
error_log('Error posting to Slack. ' . $e->getMessage());
}
}
示例11: getAllitems
public function getAllitems(Request $req)
{
if ($req->ajax()) {
$res = [];
$items = ref_jabatan::where('nm_jabatan', $req->src)->paginate(10);
$out = '';
if ($items->total() > 0) {
$no = $items->currentPage() == 1 ? 1 : $items->perPage() * $items->currentPage() - $items->perPage() + 1;
foreach ($items as $item) {
$out .= '
<tr class="item_' . $item->id . ' items">
<td>' . $no . '</td>
<td>' . $item->nm_jabatan . '</td>
<td>
<div>
' . \Format::indoDate($item->created_at) . '
</div>
<small class="text-muted">' . \Format::hari($item->created_at) . ', ' . \Format::jam($item->created_at) . '</small>
</td>
</tr>
';
$no++;
}
} else {
$out = '
<tr>
<td colspan="3">Tidak ditemukan</td>
</tr>
';
}
$res['data'] = $out;
$res['pagin'] = $items->render();
return json_encode($res);
}
}
示例12: getSubstitution
function getSubstitution()
{
$subs = array();
$subs['[today]'] = Format::date(date("Y-m-d H:i:s"), 'date');
$subs['[year]'] = date("Y");
return $subs;
}
示例13: converter
public static function converter($data, $format = NULL, $decode = FALSE)
{
if (!$format) {
$format = config('data_format');
}
if ($decode) {
$result = array();
switch ($format) {
case 'json':
$result = json_decode($data, TRUE);
break;
}
return is_array($result) ? $result : array();
}
//encode
switch ($format) {
case 'json':
Format::$_code = 0;
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($val) {
$val = hexdec($val[1]);
if (Format::$_code) {
$val = ((Format::$_code & 0x3ff) << 10) + ($val & 0x3ff) + 0x10000;
Format::$_code = 0;
} elseif ($val >= 0xd800 and $val < 0xe000) {
Format::$_code = $val;
return '';
}
return html_entity_decode(sprintf('&#x%x;', $val), ENT_NOQUOTES, 'utf-8');
}, json_encode($data));
break;
}
}
示例14: getTransaction
public function getTransaction($start_index, $results, $sort, $dir, $filter = false)
{
$query = "SELECT t.id_trans, t.date_creation, t.date_activated, t.paid, SUM(ti.price) as price, u.userid, u.firstname, u.lastname" . " FROM %adm_transaction as t" . " JOIN %adm_transaction_info as ti ON t.id_trans = ti.id_trans" . " JOIN %adm_user as u ON t.id_user = u.idst" . " WHERE 1";
$query .= " GROUP BY t.id_trans";
switch ($sort) {
case 'userid':
$query .= " ORDER BY u.userid " . $dir;
break;
case 'firstname':
$query .= " ORDER BY u.firstname " . $dir;
break;
case 'lastname':
$query .= " ORDER BY u.lastname " . $dir;
break;
case 'date_creation':
$query .= " ORDER BY t.date_creation " . $dir;
break;
case 'date_activated':
$query .= " ORDER BY t.date_activated " . $dir;
break;
}
$start_index === false ? '' : ($query .= " LIMIT " . $start_index . ", " . $results);
$result = sql_query($query);
$res = array();
while ($row = sql_fetch_assoc($result)) {
$row['userid'] = $this->acl_man->relativeId($row['userid']);
$row['date_creation'] = Format::date($row['date_creation'], 'datetime');
$row['date_activated'] = Format::date($row['date_activated'], 'datetime');
$row['paid'] = $row['paid'] == 1 ? Get::img('standard/status_active.png', Lang::t('_ACTIVATED', 'transaction')) : Get::img('standard/status_deactive.png', Lang::t('_NOT_ACTIVATED', 'transaction'));
$row['edit'] = '<a href="index.php?r=alms/transaction/mod&id_trans=' . $row['id_trans'] . '" title="' . Lang::t('_MOD', 'transaction') . '">' . Get::img('standard/edit.png', Lang::t('_MOD', 'transaction')) . '</a>';
$res[] = $row;
}
return $res;
}
示例15: Dados
function Dados($setor)
{
$this->AddPage();
$this->setFillColor(200);
$periodo = explode(' - ', Input::get('periodo'));
$periodo[0] = Format::dbDate($periodo[0]);
$periodo[1] = Format::dbDate($periodo[1]);
$this->Cell(0, 5, $setor->descricao, 0, 0, 'C', 1);
$this->Ln();
foreach ($setor->colaboradores()->orderBy('nome')->get() as $colaborador) {
if ($colaborador->monitoramentos($periodo[0], $periodo[1])->count()) {
$this->SetFont('Arial', '', 8);
$this->Cell(0, 5, utf8_decode($colaborador->nome . ' - ' . $colaborador->posto_trabalho_descricao), 1, 0, 'L', 0);
$this->Ln();
$this->SetFont('Arial', '', 6);
$count = 0;
foreach ($colaborador->monitoramentos($periodo[0], $periodo[1]) as $monitoramento) {
$this->Cell(38, 4, date('d/m/Y', strtotime($monitoramento->created_at)) . ' - ' . utf8_decode(substr($monitoramento->diagnostico, 0, 17)), 0, 0, 'L', 0);
$count = $count + 1;
if ($count == 5) {
$this->Ln();
$count = 0;
}
}
$this->Ln();
}
}
}