本文整理汇总了PHP中prettify函数的典型用法代码示例。如果您正苦于以下问题:PHP prettify函数的具体用法?PHP prettify怎么用?PHP prettify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prettify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: smarty_function_header
function smarty_function_header($params, &$smarty)
{
$self = $smarty->getTemplateVars('self');
$theme = $smarty->getTemplateVars('theme');
$title = $smarty->getTemplateVars('page_title');
$inflector = new Inflector();
$item_name = prettify($inflector->singularize($smarty->getTemplateVars('controller')));
if (empty($title) || $title === 'Index') {
switch ($smarty->getTemplateVars('action')) {
case 'view':
$title = $item_name . ' Details';
break;
case 'edit':
$title = 'Editing ' . $item_name . ' Details';
break;
case 'new':
$title = 'Create new ' . $item_name;
break;
case 'index':
default:
$title = $item_name;
break;
}
}
return '<h1 class="page_title">' . $title . '</h1>';
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:26,代码来源:function.header.php
示例2: toHTML
public function toHTML()
{
// change to facilitate lists
$id = 'search_' . $this->fieldname;
$name = 'Search[' . $this->fieldname . ']';
if (count($this->options) > get_config('AUTOCOMPLETE_SELECT_LIMIT')) {
$html = '';
$selected = $this->value;
if (empty($selected)) {
$selected = $this->default;
}
$html .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . $selected . '" />';
$text_value = isset($this->options[$selected]) ? $this->options[$selected] : '';
$html .= '<input alt="Autocomplete enabled" type="text" id="' . $id . '_text" value="' . $text_value . '" class="uz-autocomplete ui-autocomplete-input icon slim" data-id="' . $id . '" data-action="array" />';
$html .= '<script type="text/javascript">' . 'var ' . $id . '=' . json_encode(dataObject::toJSONArray($this->options)) . '</script>';
} else {
$html = '<select id="' . $id . '" name="' . $name . '">';
foreach ($this->options as $val => $opt) {
$selected = '';
if ($this->value === "{$val}" || is_null($this->value) && $this->default === "{$val}") {
$selected = 'selected="selected"';
}
$html .= '<option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>';
}
$html .= '</select></li>';
}
return $this->labelHTML() . $html;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:28,代码来源:SelectSearchField.php
示例3: smarty_block_view_section
function smarty_block_view_section($params, $content, &$smarty, $repeat)
{
if (!empty($content)) {
$attrs = array();
$attrs['class'][] = 'heading';
if (isset($params['class'])) {
$attrs['class'][] = $params['class'];
}
if (isset($params['dont_prettify'])) {
$heading = $params['heading'];
} else {
$heading = prettify($params['heading']);
}
if ($heading === 'EGS_HIDDEN_SECTION') {
return '';
}
// convert attrs array to a string
if (isset($params['expand'])) {
$attrs['class'][] = 'expand';
$attrs['class'][] = $params['expand'];
$data['expand'] = $params['expand'] == 'closed' ? 'hidden' : '';
}
$data['attrs'] = build_attribute_string($attrs);
$data['heading'] = $heading;
$data['content'] = $content;
// fetch smarty plugin template
return smarty_plugin_template($smarty, $data, 'block.view_section');
}
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:29,代码来源:block.view_section.php
示例4: getObjectPolicyValue
function getObjectPolicyValue()
{
$policy_detail = DataObjectFactory::Factory('SystemObjectPolicy');
$policy_detail->load($this->object_policies_id);
$policy_value = $policy_detail->getComponentTitle() . ' ' . prettify($policy_detail->get_field()) . ' ' . $policy_detail->getFormatted('operator') . ' ' . $policy_detail->getvalue();
return $policy_value;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:SystemPolicyControlList.php
示例5: sendMessage
/**
* Write a message to channel/user
*/
function sendMessage($socket, $channel, $msg)
{
if (strlen($msg) > 2) {
//Avoid sending empty lines to server, since all data should contain a line break, 2 chars is minimum
$msg = prettify($msg);
sendData($socket, "PRIVMSG {$channel} :{$msg}");
}
}
开发者ID:fathkay,项目名称:VikingBot,代码行数:11,代码来源:functions.php
示例6: toSQL
function toSQL()
{
$sql = 'ALTER COLUMN ' . $this->name . ' ';
foreach ($this->options->toArray() as $key => $val) {
if ($val === true) {
$sql .= prettify($key);
}
}
return $sql;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:10,代码来源:AlterTableComponent.php
示例7: toHTML
/**
* @param void
* @return string
*
* returns the HTML representation of the status checkboxes, each with a label
* NOTE: This SearchField doesn't have an encompassing label, so will need to be considered should containing elements be required
*/
public function toHTML()
{
$html = '';
foreach ($this->statuses as $status) {
$checked = '';
if ($this->value_set && isset($this->value[$status]) || !$this->value_set && in_array($status, $this->default)) {
$checked = 'checked="checked"';
}
$html .= '<label>' . prettify($status) . '</label><input type="checkbox" class="checkbox" name="Search[' . $this->fieldname . '][' . $status . ']" ' . $checked . '/>';
}
return $html;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:19,代码来源:POrderSearchField.php
示例8: build
public function build($params, $data = false)
{
$script = '';
$url = '?';
$attrs = ' ';
foreach ($params as $key => $val) {
//special cases
if (substr($key, 0, 1) === '_') {
$attrs .= str_replace('_', '', $key) . '="' . $val . '" ';
continue;
}
if ($key == 'value' || $key == 'img' || $key == 'alt') {
continue;
}
//module and submodule
if ($key == 'modules') {
if (isset($val[0])) {
$url .= 'module=' . $val[0] . '&';
//only allow submodule if module is set
if (isset($val[1])) {
$url .= 'submodule=' . $val[1] . '&';
}
}
//everything else
} else {
$url .= strtolower($key) . '=' . urlencode($val) . '&';
}
}
//remove last ampersand
$url = substr($url, 0, -5);
$url = '/' . $url;
if (isset($params['link'])) {
$url = $params['link'];
}
if (empty($params['value'])) {
$params['value'] = 'link';
}
if (isset($params['img'])) {
$params['value'] = '<img src="' . $params['img'] . '" alt="' . $params['alt'] . '" />';
$string = '<a ' . $attrs . ' href="' . $url . '">' . $params['value'] . '</a>';
} else {
if ($data) {
$string = '<a ' . $attrs . ' href="' . $url . '">' . $params['value'] . '</a>';
} else {
$string = '<a ' . $attrs . ' href="' . $url . '">' . prettify($params['value']) . '</a>';
}
}
return $string;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:49,代码来源:EGSLinkBuilder.php
示例9: toHTML
public function toHTML()
{
$value = $this->value;
if (!empty($value)) {
$value['count'] = count($value['field']);
} else {
/*
* if the array hasn't been sent, set the value to 1
* and set some dummy data (or perhaps test in the loop
* we need to set the loop at 1 to load the default single row.
*/
$value = array('', '', '');
//
$value['count'] = 1;
}
$html .= '<dd><div id="matrix_' . $this->fieldname . '">';
for ($i = 0; $i <= $value['count'] - 1; $i++) {
// generate the matrix line
$html .= '<p id="p:' . $this->fieldname . ':' . $i . '" class="matrix_field">';
// generate the field selector
$html .= ' <select style="clear: both;" id="search:' . $this->fieldname . ':field:' . $i . '" name="Search[' . $this->fieldname . '][field][]">';
foreach ($this->options as $val => $opt) {
$selected = '';
if ($value['field'][$i] == $val || is_null($this->value) && $this->default == $val) {
$selected = 'selected="selected"';
}
$html .= ' <option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>';
}
$html .= ' </select>';
// generate the operator selector
$html .= ' <select id="search:' . $this->fieldname . ':operator:' . $i . '" name="Search[' . $this->fieldname . '][operator][]">';
foreach ($this->operators as $val => $opt) {
$selected = '';
if ($value['operator'][$i] == $val) {
$selected = 'selected="selected"';
}
$html .= ' <option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>';
}
$html .= ' </select>';
// generate the value input
$html .= ' <input id="search:' . $this->fieldname . ':value:' . $i . '" type="text" name="Search[' . $this->fieldname . '][value][]" value="' . $value['value'][$i] . '" />';
$html .= ' <a href="#" class="remove_matrix" id="search:' . $this->fieldname . ':delete:' . $i . '"><img src="' . THEME_URL . THEME . '/graphics/delete.png" /></a>';
$html .= '</p>';
}
$html .= '</div>';
$html .= '<p style="clear:both;"><a href="#" class="clone_matrix" rel="' . $this->fieldname . '"><img src="' . THEME_URL . THEME . '/graphics/add.png" style="float: left; margin-right: 5px;"/>Add a new constraint</a></p>';
$html .= '</dd><br />';
return $this->labelHTML() . $html;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:49,代码来源:MatrixSearchField.php
示例10: save_model
public function save_model($modelName, $dataIn = array(), &$errors = array(), &$warnings = array(), $duplicates = '')
{
// Need to define error array here due to too many nested levels
$flash = Flash::Instance();
$edi_errors = array();
if ($duplicates != 'R') {
// Do not reject duplicates - so check if record exists
$model = new $modelName();
$identifierFields = $model->getIdentifierFields();
$identifierValues = array();
foreach ($identifierFields as $key => $field) {
if (isset($dataIn[$modelName][$field]) && $model->checkUniqueness($field)) {
$identifier_string = $field . ' : ' . $dataIn[$modelName][$field] . ',';
$identifierValues[$key] = $dataIn[$modelName][$field];
} else {
unset($identifierFields[$key]);
}
}
if (count($identifierFields) > 0 && count($identifierFields) == count($identifierValues)) {
$model->loadBy($identifierFields, $identifierValues);
if ($model->isLoaded()) {
if ($duplicates == 'I') {
// Ignore duplicates so return true
$warnings[] = 'Duplicate ' . $identifier_string . ' Ignored';
return true;
} else {
// replace/update duplicate so set id field value
$dataIn[$modelName][$model->idField] = $model->{$model->idField};
}
}
}
}
$result = parent::save($modelName, $dataIn, $edi_errors);
if (count($edi_errors) > 0) {
// Add the Identifier Values to the errors to identify the data in error
// Assumes the $dataIn array is an array of [ModelName][ModelData]
// and that the input $modelName is the identifying model for the data
$model = new $modelName();
foreach ($model->getIdentifierFields() as $field) {
$errors[] = prettify($field) . ' : ' . $dataIn[$modelName][$field];
}
$flash->addErrors($edi_errors);
foreach ($edi_errors as $error) {
$errors[] = $error;
}
}
return $result;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:48,代码来源:EdiController.php
示例11: addPlots
function addPlots($data)
{
$plots = array();
$labels = array();
$i = 0;
foreach ($data as $key => $plot_data) {
$plot = new BarPlot(array_values($plot_data));
$plot->setLegend(prettify($key));
$plot->setFillColor(self::$colours[$i]);
$i++;
$plots[] = $plot;
$labels = array_merge($labels, array_keys($plot_data));
}
$group_plot = new GroupBarPlot($plots);
$this->grapher->add($group_plot);
$this->grapher->xaxis->setTickLabels($labels);
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:17,代码来源:EGSBar.php
示例12: smarty_function_eglet
function smarty_function_eglet($params, &$smarty)
{
$container = new EGletContainer();
$eglet_name = $params['name'];
$renderer = call_user_func(array($eglet_name, 'getRenderer'));
$eglet = new $eglet_name($renderer);
if (isset($params['title'])) {
$title = $params['title'];
} else {
$title = prettify($params['name']);
}
$container->addEGlet($title, $eglet);
if (isset($params['populate'])) {
$container->populate();
$container->render($params, $smarty);
}
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:17,代码来源:function.eglet.php
示例13: __construct
function __construct()
{
$this->css_title = empty($_SESSION['css']) ? $this->css : $_SESSION['css'];
$this->css = 'styles/' . $this->css_title . '/' . $this->css_title . '.php';
if ($_SERVER[QUERY_STRING]) {
$query_string = htmlspecialchars(strip_tags($_SERVER[QUERY_STRING]));
$crumbs = explode('/', $query_string);
$bread = '?';
foreach ($crumbs as $crumb) {
$bread .= $crumb == '' ? 'index' : $crumb . '/';
$breadcrumbs .= '<a href="' . $bread . '">' . prettify($crumb) . '</a> : ';
}
$this->breadcrumbs = '<a href="/" title="Home Page">Home</a> : ' . substr($breadcrumbs, 0, -2);
} else {
$this->breadcrumbs = '<a href="index.php" title="home page">home</a> : ';
}
$this->page = $_SERVER[SCRIPT_FILENAME];
$this->pagetitle = prettify($crumb);
}
开发者ID:Jaciss,项目名称:protoframe,代码行数:19,代码来源:Frame.php
示例14: toSQL
function toSQL()
{
//username varchar not null primary key
$sql = $this->name . ' ' . $this->type;
foreach ($this->options as $key => $val) {
$sql .= ' ' . prettify($key);
}
$refs = $this->references->toArray();
if (count($refs) > 0) {
$string = 'REFERENCES ' . $refs['table'] . '(' . $refs['column'] . ')';
if (!empty($refs['on_update'])) {
$string .= ' ON UPDATE ' . prettify($refs['on_update']);
}
if (!empty($refs['on_delete'])) {
$string .= ' ON DELETE ' . prettify($refs['on_delete']);
}
$sql .= ' ' . $string;
}
return $sql;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:20,代码来源:AddColumnComponent.php
示例15: smarty_block_heading_cell
function smarty_block_heading_cell($params, $content, &$smarty, $repeat)
{
if (!empty($content)) {
// why isn't this being done way sooner?!
if (substr($params['field'], -2) == 'id') {
return '';
}
// attribute variables
$attrs = array();
// merge data attributes with attributes array
$attrs = array_merge($attrs, build_data_attributes($params));
if ($smarty->getTemplateVars('no_ordering') !== TRUE) {
$link = $smarty->getTemplateVars('self');
$link['value'] = prettify($content);
$action = $smarty->getTemplateVars('action');
if (empty($action)) {
$action = 'index';
}
$link['action'] = $action;
if (isset($params['field'])) {
$link['orderby'] = $params['field'];
$attrs['data-column'] = $params['field'];
}
$content = link_to($link, $data = true);
// WTF
} else {
$content = prettify($content);
}
$model = $params['model'];
if ($model && $model->getField($params['field'])->type == 'numeric' || $params['field'] == 'right') {
$attrs['class'][] = 'right';
}
if (isset($params['class'])) {
$attrs['class'][] = $params['class'];
}
// build the attribute string based on the attribute array
$attrs = build_attribute_string($attrs);
// return the built string
return '<th ' . $attrs . '>' . $content . '</th>' . "\n";
}
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:41,代码来源:block.heading_cell.php
示例16: enable
function enable(&$errors = array(), $menu_options = array())
{
$position = Permission::getNextPosition();
if (!$position) {
$position = 0;
}
$data = array('permission' => $this->name, 'type' => 'm', 'description' => $this->description, 'title' => prettify($this->name), 'display' => true, 'position' => $position + 1);
$m_parent_id = $this->addPermission($data, $errors);
if (!$m_parent_id) {
return false;
}
$c_position = 1;
foreach ($this->module_components as $component) {
switch ($component->type) {
case 'C':
$name = str_replace('controller', '', strtolower($component->name));
if (isset($menu_options[$name])) {
$new_menu = $menu_options[$name];
$data = array('permission' => $new_menu['permission'], 'type' => 'c', 'description' => '', 'title' => $new_menu['title'], 'display' => $new_menu['display'], 'position' => $c_position++, 'parent_id' => $m_parent_id);
$c_parent_id = $this->addPermission($data, $errors);
if (!$c_parent_id) {
return false;
} else {
foreach ($new_menu['actions'] as $a_position => $action) {
$data = $action;
$data['type'] = 'a';
$data['position'] = $a_position + 1;
$data['parent_id'] = $c_parent_id;
if (!$this->addPermission($data, $errors)) {
return false;
}
}
}
}
break;
}
}
return $this->update($this->id, 'enabled', true);
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:39,代码来源:ModuleObject.php
示例17: translate
function translate($string)
{
// return, if set, the acronym for a string
if (isset($this->acronyms[strtolower($string)])) {
return $this->acronyms[strtolower($string)];
}
// return, if set, the over ride for a string
if (isset($this->over_ride[strtolower($string)])) {
return prettify($this->over_ride[strtolower($string)]);
}
// capatilse, replace "_" with " " and remove "_id" at end of string, apply this to $string
$string = substr($string, -3) == '_id' ? substr($string, 0, -3) : $string;
$string = ucwords(str_replace('_', ' ', $string));
/*
* Because some words may not exist atomically (such as the word CRM might)
* we need to find specific words and replace them with their known output,
* such as Uzlet -> uzLET
*/
foreach ($this->known_replacements as $find => $replace) {
$string = str_ireplace($find, $replace, $string);
}
// return the prettified word
return $string;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:24,代码来源:Prettifier.php
示例18: __construct
function __construct($tablename = 'person')
{
// Register non-persistent attributes
// Contruct the object
parent::__construct($tablename);
// Set specific characteristics
$this->idField = 'id';
$this->subClass = true;
$this->fkField = 'party_id';
$this->orderby = array('surname', 'firstname');
$this->identifier = 'surname';
$this->identifierField = 'firstname || \' \' || surname';
$this->identifierFieldJoin = ', ';
// Define relationships
$this->hasMany('PartyContactMethod', 'contactmethods', 'party_id', 'party_id', null, TRUE);
$this->hasMany('PartyAddress', 'addresses', 'party_id', 'party_id', null, TRUE);
$this->hasMany('PartyAddress', 'mainaddress', 'party_id', 'party_id');
$this->belongsTo('Company', 'company_id', 'company');
$this->belongsTo('User', 'alteredby', 'last_altered_by');
$this->belongsTo('User', 'assigned_to', 'person_assigned_to');
$this->hasOne('Party', 'party_id', 'party');
$this->hasOne('Company', 'company_id', 'companydetail');
$this->actsAsTree('reports_to');
$this->belongsTo('Person', 'reports_to', 'person_reports_to', null, 'surname || \', \' || firstname');
$this->belongsTo('Language', 'lang', 'language');
$this->setConcatenation('fullname', array('title', 'firstname', 'middlename', 'surname', 'suffix'));
$this->setConcatenation('titlename', array('title', 'firstname', 'surname'));
$this->hasMany('Opportunity', 'opportunities');
$this->hasMany('Project', 'projects');
$this->hasMany('Activity', 'activities');
// Define field formats
$this->getField('jobtitle')->tag = prettify('job_title');
// Define validation
// Define default values
// Define enumerated types
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:36,代码来源:Person.php
示例19: mktree
function mktree($items, $checked = array(), $admins, $setall = FALSE, $adchild = FALSE)
{
$html = '';
$mod = '';
if (isset($checked[$items['id']]) || $setall) {
$mod = ' CHECKED ';
}
/****
* If the item has children, we need to create the checkboxes for them by calling the mktree function on each of them
* If not, just return a single checkbox.
*/
if (!empty($items['children'])) {
$html .= '<li class="' . $items['type'] . '">';
if (trim($items['type']) == 'm' && !$adchild) {
if (isset($admins[$items['permission']])) {
$adcheck = 'checked';
}
$html .= '<input class="checkbox" type=checkbox name="admin[' . $items['permission'] . ']" value="admin' . $items['id'] . '" ' . $adcheck . ' /> ';
}
$html .= '<input class="checkbox" type=checkbox name="permission[' . $items['id'] . ']" value="' . $items['id'] . '"' . $mod . ' /> ' . prettify($items['permission']) . ": " . $items['description'] . '<ul class="permission">';
foreach ($items['children'] as $child) {
$html .= mktree($child, $checked, $admins, $setall, TRUE);
}
$html .= '</ul></li>';
} else {
$html .= '<li class="' . $items['type'] . '">';
if (trim($items['type']) == 'm' && !$adchild) {
if (isset($admins[$items['permission']])) {
$adcheck = 'checked';
}
$html .= '<input class="checkbox" type=checkbox name="admin[' . $items['permission'] . ']" value="admin' . $items['id'] . '" ' . $adcheck . ' /> ';
}
$html .= '<input class="checkbox" type=checkbox name="permission[' . $items['id'] . ']" value="' . $items['id'] . '"' . $mod . ' /> ' . prettify($items['permission']) . ': ' . $items['description'] . '</li>';
}
return $html;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:36,代码来源:function.checkbox_tree.php
示例20: smarty_function_datetime
function smarty_function_datetime($params, &$smarty)
{
$with =& $smarty->getTemplateVars('with');
$data['display_tags'] = FALSE;
$data['display_tags'] = !isset($params['notags']);
$data['label']['value'] = prettify(isset($params['attribute']) ? $params['attribute'] : '');
if (!empty($params['model'])) {
$model =& $params['model'];
} else {
$model = $with['model'];
}
if (!empty($params['readonly']) && $params['readonly']) {
$data['date']['attrs']['readonly'] = $params['readonly'];
$data['hour']['attrs']['readonly'] = $params['readonly'];
$data['minute']['attrs']['readonly'] = $params['readonly'];
$data['date']['additional_class'] = '';
} else {
$data['date']['additional_class'] = 'datefield';
}
$controller_data =& $smarty->getTemplateVars('controller_data');
# $html = <<<EOT
#<input type="text" name="%s" id="%s" class="icon date slim datefield%s" value="%s"/>
#<input type="text" name="%s" id="%s" class="timefield" value="%s" />:<input type="text" name="%s" id="%s" class="timefield" value="%s" />
#EOT;
$basename = $params['attribute'];
$model_name = get_class($model);
$field = $model->getField($basename);
$data['date']['attrs']['type'] = 'text';
$data['hour']['attrs']['type'] = 'text';
$data['minute']['attrs']['type'] = 'text';
$data['date']['attrs']['name'] = $model_name . '[' . $basename . ']';
$data['hour']['attrs']['name'] = $model_name . '[' . $basename . '_hours]';
$data['minute']['attrs']['name'] = $model_name . '[' . $basename . '_minutes]';
$data['date']['attrs']['id'] = strtolower($model_name . '_' . $basename);
$data['hour']['attrs']['id'] = strtolower($model_name . '_' . $basename . '_hours');
$data['minute']['attrs']['id'] = strtolower($model_name . '_' . $basename . '_minutes');
$data['label']['for'] = $data['date']['attrs']['id'];
$hidden = FALSE;
require_once __DIR__ . '/function.sessionvalue.php';
$start_date = smarty_function_sessionvalue($params, $model_name, $basename);
$start_date_hour = smarty_function_sessionvalue($params, $model_name, $basename . '_hours');
$start_date_minute = smarty_function_sessionvalue($params, $model_name, $basename . '_minutes');
if (!empty($start_date)) {
$value = $start_date;
$value .= ' ' . (empty($start_date_hour) ? '00' : $start_date_hour);
$value .= ':' . (empty($start_date_minute) ? '00' : $start_date_minute);
}
if (isset($controller_data[$basename])) {
$hidden = TRUE;
$value = $controller_data[$basename];
} elseif (empty($value)) {
$value = $field->value;
if (empty($value) && !empty($params['value'])) {
$value = $params['value'];
}
if (empty($value) && $field->has_default == 1) {
$value = date(DATE_TIME_FORMAT, $field->default_value);
}
$data['label']['value'] = $field->tag;
if ($field->not_null == 1) {
$data['label']['value'] .= '*';
$data['date']['additional_class'] .= ' required';
}
}
$data['label']['value'] = isset($params['label']) ? $params['label'] : $data['label']['value'];
if (!empty($value)) {
$format = format_for_strptime(DATE_TIME_FORMAT);
if (strptime($value, $format) !== FALSE) {
$date_value = array_shift(explode(' ', $value));
$hour_value = array_shift(explode(':', array_pop(explode(' ', $value))));
$minute_value = array_pop(explode(':', array_pop(explode(' ', $value))));
} else {
list($date_value, $rest) = explode(' ', $value, 2);
$date_value = date(DATE_FORMAT, strtotime($date_value));
list($hour_value, $minute_value) = explode(':', $rest);
}
$data['date']['attrs']['value'] = $date_value;
$data['hour']['attrs']['value'] = $hour_value;
$data['minute']['attrs']['value'] = $minute_value;
}
if ($hidden) {
$data['date']['attrs']['type'] = 'hidden';
$data['hour']['attrs']['type'] = 'hidden';
$data['minute']['attrs']['type'] = 'hidden';
}
foreach (array('date', 'hour', 'minute') as $type) {
$data[$type]['attrs'] = build_attribute_string($data[$type]['attrs']);
}
return smarty_plugin_template($smarty, $data, 'function.datetime');
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:90,代码来源:function.datetime.php
注:本文中的prettify函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论