本文整理汇总了PHP中format类的典型用法代码示例。如果您正苦于以下问题:PHP format类的具体用法?PHP format怎么用?PHP format使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($m, $a)
{
$ignore_ofs_methods = array('__destruct');
if (in_array($m, $ignore_ofs_methods)) {
return 'IGNORE_OFS_COMMAND_COMPLETE';
}
// if the command is in the list of commands to run on all ofs objects, do so
$all_ofs_methods = array('append_header', 'append_footer');
if (in_array($m, $all_ofs_methods)) {
foreach ($this->ofs as $set_id => $ofs) {
call_user_func_array(array(&$ofs, $m), $a);
}
return 'ALL_OFS_COMMAND_COMPLETE';
}
$use_replica_set_id = format::get_context_replica_set_id();
if ($use_replica_set_id == -10) {
// context_replica_set_id -10 means object does not have slonySetId defined
// use the natural first replica set as the replica context
$first_replica_set = pgsql8::get_slony_replica_set_natural_first(dbsteward::$new_database);
$use_replica_set_id = (int) $first_replica_set['id'];
}
// make sure replica set id to use is known
if (!isset($this->ofs[$use_replica_set_id])) {
if ($this->skip_unknown_set_ids) {
dbsteward::notice("[OFS RSR] context replica set ID is " . $use_replica_set_id . ", but no replica set by that ID, skipping output");
return FALSE;
}
throw new exception("context replica set ID " . $use_replica_set_id . " not defined");
}
$active_set_ofs = $this->ofs[$use_replica_set_id];
dbsteward::debug("[OFS RSR] __call calling " . $use_replica_set_id . " ofs::" . $m);
return call_user_func_array(array(&$active_set_ofs, $m), $a);
}
示例2: action_index
public function action_index()
{
// clear buffer
helper_ob::clean_all();
// validating
do {
$options = application::get('flag.numbers.backend.cron.base');
// token
if (!empty($options['token']) && request::input('token') != $options['token']) {
break;
}
// ip
if (!empty($options['ip']) && !in_array(request::ip(), $options['ip'])) {
break;
}
// get date parts
$date_parts = format::now('parts');
print_r($date_parts);
echo "GOOD\n";
} while (0);
// we need to validate token
//$token = request::input('token');
echo "OK\n";
// exit
exit;
}
示例3: __set
/**
* Whenever setting the slug, make sure that it conforms to requirements
* @developer Brandon Hansen
* @date Oct 26, 2010
*/
public function __set($key, $value)
{
if ($key == 'slug') {
$value = format::pretty_url($value);
}
parent::__set($key, $value);
}
示例4: get_title
/**
* Get the page title
* @Developer brandon
* @Date May 7, 2010
*/
public static function get_title()
{
if (!isset(self::$meta['title'])) {
return format::friendly_model_name(Router::$controller) . ' :: ' . format::friendly_model_name(Router::$method);
} else {
return strip_tags(self::$meta['title']);
}
}
示例5: variant_dropdown
/**
* Provide a dropdown for variants
* @developer Brandon Hansen
* @date Nov 2, 2010
*/
public static function variant_dropdown(Product_Model $product)
{
$options = array();
foreach ($product->variants as $variant) {
$options[(string) $variant] = $variant->name . ' - ' . format::dollar_format($variant->price);
}
return self::dropdown(array('name' => 'variant_id', 'id' => 'select-variant'), $options);
}
示例6: size
public static function size($file, $format = false)
{
$file = path::decode($file);
$size = @filesize($file);
if ($format) {
$size = format::byte($size, $format);
}
return $size;
}
示例7: show_path
/**
* Show path route
* @Developer brandon
* @Date Oct 11, 2010
*/
public function show_path($abs = true)
{
$path = $this->object_name . '/' . format::pretty_url($this->slug);
if ($abs) {
return url::site($path);
} else {
return $path;
}
}
示例8: show
/**
* Clean up the show page URL
* @Developer brandon
* @Date Oct 11, 2010
*/
public function show($name = NULL)
{
$blog = ORM::factory('blog')->where('name', format::dash_to_space($name))->find();
// Set the title
meta::set_title(ucwords($blog->name));
// Set the description
meta::set_description($blog->synopsis);
// Show the page
parent::show($blog);
}
示例9: onDefault
public function onDefault()
{
$tables = $this->db->table()->get(true);
$header['title'] = '数据库管理';
page::header($header);
page::add('<div id="page" class="clearfix">');
page::add('<div id="side">');
block::header('数据库基本信息');
table::header();
table::row(array('w60' => '数据库名称', '2' => '' . $this->db->config['database'] . ''));
table::row(array('w60' => '数据库版本', '2' => '' . $this->db->version(true) . ''));
table::row(array('w60' => '数据库大小', '2' => '<b>' . $this->db->size() . '</b> '));
table::row(array('w60' => '数据表个数', '2' => '<b>' . count($tables) . '</b> 个'));
table::footer();
block::footer();
page::add('</div>');
page::add('<div id="main">');
page::top();
page::navbar($this->navbar(), 'table');
//zotop::dump($tables);
form::header(array('class' => 'ajax'));
$column['select'] = '<input name="id" class="selectAll" type="checkbox"/>';
$column['name'] = '数据表名称';
$column['size w60'] = '大小';
$column['Rows w60'] = '记录数';
$column['Engine w60'] = '类型';
$column['Collation w100'] = '整理';
$column['manage view w60'] = '浏览';
$column['manage delete'] = '删除';
table::header('list', $column);
foreach ($tables as $table) {
$size = $table['Data_length'] + $table['Index_length'];
$column = array();
$column['select'] = '<input name="id[]" class="select" type="checkbox"/>';
$column['name'] = '<b>' . $table['Name'] . '</b><h5>' . $table['Comment'] . '</h5>';
$column['size w60'] = (string) format::size($size);
$column['Rows w60'] = $table['Rows'];
$column['Engine w60'] = $table['Engine'];
$column['collation w100'] = $table['Collation'];
$column['manage view w60'] = '<a href="' . url::build('system/database/table/record') . '">浏览</a>';
$column['manage delete'] = '<a href="' . url::build('system/database/table/delete') . '" class="confirm">删除</a>';
table::row($column);
}
table::footer();
page::add('<div style="height:200px;"></div>');
form::buttons(array('type' => 'select', 'style' => 'width:180px', 'options' => array('check' => '优化', 'delete' => '删除')), array('type' => 'submit', 'value' => '执行操作'));
form::footer();
page::bottom();
page::add('</div>');
page::add('</div>');
page::footer();
}
示例10: init
public function init() {
$total = $this->db->count();
$page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
$pagesize = 20;
$offset = ($page - 1) * $pagesize;
$list = $this->db->select('', '*', $offset.','.$pagesize);
pc_base::load_sys_class('format', '', 0);
foreach ($list as $key=> $v) {
$list[$key]['lastlogin'] = format::date($v['lastlogin'], 1);
}
$pages = pages($total, $page, $pagesize);
include $this->admin_tpl('administrator_list');
}
示例11: calendar
/**
* see html::calendar()
*/
public static function calendar($options = [])
{
// include js & css files
if (empty($options['readonly'])) {
layout::add_js('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_js_base.js');
layout::add_css('/numbers/media_submodules/numbers_frontend_components_calendar_numbers_media_css_base.css');
}
// font awesome icons
library::add('fontawesome');
// widget parameters
$type = $options['calendar_type'] ?? $options['type'] ?? 'date';
$widget_options = ['id' => $options['id'], 'type' => $type, 'format' => $options['calendar_format'] ?? format::get_date_format($type), 'date_week_start_day' => $options['calendar_date_week_start_day'] ?? 1, 'date_disable_week_days' => $options['calendar_date_disable_week_days'] ?? null, 'master_id' => $options['calendar_master_id'] ?? null, 'slave_id' => $options['calendar_slave_id'] ?? null];
$options['type'] = 'text';
// determine input size
$placeholder = format::get_date_placeholder($widget_options['format']);
$options['size'] = strlen($placeholder);
// set placeholder
if (!empty($options['placeholder']) && $options['placeholder'] == 'format::get_date_placeholder') {
$options['placeholder'] = $placeholder;
$options['title'] = ($options['title'] ?? '') . ' (' . $placeholder . ')';
}
if (isset($options['calendar_icon']) && ($options['calendar_icon'] == 'left' || $options['calendar_icon'] == 'right')) {
$position = $options['calendar_icon'];
if (i18n::rtl()) {
if ($position == 'left') {
$position = 'right';
} else {
$position = 'left';
}
}
$icon_type = $type == 'time' ? 'clock-o' : 'calendar';
unset($options['calendar_icon']);
if (empty($options['readonly'])) {
$icon_onclick = 'numbers_calendar_var_' . $options['id'] . '.show();';
} else {
$icon_onclick = null;
}
$icon_value = html::span(['onclick' => $icon_onclick, 'class' => 'numbers_calendar_icon numbers_prevent_selection', 'value' => html::icon(['type' => $icon_type])]);
$result = html::input_group(['value' => html::input($options), $position => $icon_value, 'dir' => 'ltr']);
$div_id = $options['id'] . '_div_holder';
$result .= html::div(['id' => $div_id, 'class' => 'numbers_calendar_div_holder']);
$widget_options['holder_div_id'] = $div_id;
} else {
$result = html::input($options);
}
// we do not render a widget if readonly
if (empty($options['readonly'])) {
layout::onload('numbers_calendar(' . json_encode($widget_options) . ');');
}
return $result;
}
示例12: set
/**
* see tinyurl::set();
*/
public static function set($url, $options = [])
{
// insert new row into the table
$object = new numbers_backend_misc_tinyurl_db_model_tinyurls();
$result = $object->insert(['sm_tinyurl_inserted' => format::now('datetime'), 'sm_tinyurl_url' => $url . '', 'sm_tinyurl_expires' => $options['expires'] ?? null]);
if ($result['success']) {
$result['data']['id'] = $result['last_insert_id'];
$result['data']['hash'] = base_convert($result['last_insert_id'] . '', 10, 36);
} else {
$result['data'] = [];
}
array_key_unset($result, ['success', 'error', 'data'], ['preserve' => true]);
return $result;
}
示例13: save
public function save(&$form)
{
$model = factory::model($form->options['other']['model']);
$save = [$model->column_prefix . 'important' => !empty($form->values['important']) ? 1 : 0, $model->column_prefix . 'comment_value' => $form->values['comment'] . '', $model->column_prefix . 'who_entity_id' => session::get('numbers.entity.em_entity_id'), $model->column_prefix . 'inserted' => format::now('timestamp')];
foreach ($form->options['other']['map'] as $k => $v) {
$save[$v] = $form->options['other']['pk'][$k];
}
$save_result = $model->save($save, ['ignore_not_set_fields' => true]);
if ($save_result['success']) {
$form->error('success', 'Comment has been added successfully!');
} else {
$form->error('danger', 'Could not add comment!');
}
}
示例14: process
/**
* Process the lock
* @param string $id
* @return boolean
*/
public static function process($id)
{
$lock_data = lock::exists($id);
if ($lock_data !== false) {
$minutes = round(abs(strtotime(format::now()) - strtotime($lock_data)) / 60, 2);
if ($minutes > 30) {
lock::release($id);
$lock_data = false;
}
}
// we are ok to proceed
if ($lock_data === false) {
lock::create($id);
return true;
} else {
return false;
}
}
示例15: public_get_one
public function public_get_one() {
$total = $this->comment_check_db->count(array('siteid'=>$this->get_siteid()));
$comment_check_data = $this->comment_check_db->select(array('siteid'=>$this->get_siteid()), '*', '19,1', 'id desc');
$comment_check_data = $comment_check_data[0];
$r = array();
if (is_array($comment_check_data) && !empty($comment_check_data)) {
$this->comment_data_db->table_name($comment_check_data['tableid']);
$r = $this->comment_data_db->get_one(array('id'=>$comment_check_data['comment_data_id'], 'siteid'=>$this->get_siteid()));
pc_base::load_sys_class('format','', 0);
$r['creat_at'] = format::date($r['creat_at'], 1);
if (pc_base::load_config('system','charset')=='gbk') {
foreach ($r as $k=>$v) {
$r[$k] = iconv('gbk', 'utf-8', $v);
}
}
}
echo json_encode(array('total'=>$total, 'data'=>$r));
}