本文整理汇总了PHP中HCM::_n方法的典型用法代码示例。如果您正苦于以下问题:PHP HCM::_n方法的具体用法?PHP HCM::_n怎么用?PHP HCM::_n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HCM
的用法示例。
在下文中一共展示了HCM::_n方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_text
function get_text($object, $user = NULL)
{
$return = array();
if (!is_object($object)) {
return $return;
}
$notes = $this->get($object, $user);
if ($notes) {
$label = sprintf(HCM::_n('%d Comment', '%d Comments', count($notes)), count($notes));
$return[] = $label;
foreach ($notes as $e) {
$this_note = array();
$this_note[] = $e->author->present_title(HC_PRESENTER::VIEW_RAW) . ' [' . $e->present_created(HC_PRESENTER::VIEW_TEXT) . ']' . ':';
$this_note[] = $e->present_content(HC_PRESENTER::VIEW_TEXT);
$return[] = $this_note;
}
}
return $return;
}
示例2: deleterel
function deleterel($id, $relname, $relid)
{
$model = HC_App::model('shift');
$model->get_by_id($id);
$this->_check_model($model);
$acl = HC_App::acl();
if (!$acl->set_object($model)->can($relname . '::delete')) {
return;
}
$rel = $model->{$relname}->get_by_id($relid);
if ($model->delete($rel, $relname)) {
$this->session->set_flashdata('message', sprintf(HCM::_n('%d shift updated', '%d shifts updated', 1), 1));
} else {
$this->session->set_flashdata('error', HCM::__('Error'));
}
$redirect_to = 'shifts/zoom/' . $id;
// $redirect_to = '-referrer-';
$this->redirect($redirect_to);
return;
}
示例3: sprintf
<?php
$my_own = FALSE;
if (!$wrap) {
$my_own = TRUE;
$wrap = HC_Html_Factory::widget('list')->add_attr('class', 'list-inline')->add_attr('class', 'list-separated');
}
if ($count_fail) {
$title = sprintf(HCM::_n('%d Conflict', '%d Conflicts', $count_fail), $count_fail);
$item = HC_Html_Factory::element('titled', 'span')->add_attr('class', 'display-block')->add_attr('class', 'alert')->add_attr('class', 'alert-condensed2')->add_attr('class', 'alert-danger')->add_attr('class', 'text-smaller2')->add_child($title);
$wrap->add_item($item);
}
if ($my_own) {
if ($wrap->items()) {
echo $wrap->render();
}
}
示例4: sprintf
<?php
if (!$count) {
return;
}
$title = sprintf(HCM::_n('%d Pending Timeoff Request', '%d Pending Timeoff Requests', $count), $count);
$temp_shift = HC_App::model('shift');
$linkto = HC_Lib::link('list/browse', array('type' => $temp_shift->_const('TYPE_TIMEOFF'), 'status' => $temp_shift->_const('STATUS_DRAFT'), 'range' => 'upcoming'));
$item = HC_Html_Factory::widget('titled', 'a')->add_attr('class', 'display-block')->add_attr('href', $linkto)->add_attr('class', 'alert')->add_attr('class', 'alert-archive')->add_attr('title', $title)->add_child($title);
echo $item->render();
示例5:
<?php
$out = HC_Html_Factory::widget('container')->add_item(HC_Html::icon('comment-o'))->add_item(sprintf(HCM::_n('%d Comment', '%d Comments', $count), $count));
echo $out;
示例6: formatPeriod
static function formatPeriod($ts, $limitMeasure = '')
{
// $conf =& ntsConf::getInstance();
// $limitMeasure = $conf->get('limitTimeMeasure');
// $limitMeasure = '';
switch ($limitMeasure) {
case 'minute':
$day = 0;
$hour = 0;
$minute = (int) $ts / 60;
break;
case 'hour':
$day = 0;
$hour = (int) ($ts / (60 * 60));
$minute = (int) ($ts - 60 * 60 * $hour) / 60;
break;
default:
$day = (int) ($ts / (24 * 60 * 60));
$hour = (int) (($ts - 24 * 60 * 60 * $day) / (60 * 60));
$minute = (int) ($ts - 24 * 60 * 60 * $day - 60 * 60 * $hour) / 60;
break;
}
$formatArray = array();
if ($day > 0) {
$formatArray[] = sprintf(HCM::_n('%d Day', '%d Days', $day), $day);
}
if ($hour > 0) {
$formatArray[] = sprintf(HCM::_n('%d Hour', '%d Hours', $hour), $hour);
}
if ($minute > 0) {
$formatArray[] = sprintf(HCM::_n('%d Minute', '%d Minutes', $minute), $minute);
}
$verbose = join(' ', $formatArray);
return $verbose;
}
示例7: foreach
if ($status_input !== NULL) {
$out->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Status'))->set_content($status_input));
}
/* ADD NOTE IF POSSIBLE */
$new_shift = HC_App::model('shift');
$extensions = HC_App::extensions();
$more_content = $extensions->run('shifts/add/confirm', $new_shift);
if ($more_content) {
$more_holder = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated2');
foreach ($more_content as $mc) {
$more_holder->add_item($mc);
}
$out->add_item($more_holder);
}
$out->add_divider();
$add_btn_label = HCM::__('Add');
$type = $params->get('type');
if ($type !== NULL) {
$shift = HC_App::model('shift');
switch ($type) {
case $shift->_const('TYPE_TIMEOFF'):
$add_btn_label = sprintf(HCM::_n('Request New Timeoff', 'Request %d New Timeoffs', $shifts_count), $shifts_count);
break;
case $shift->_const('TYPE_SHIFT'):
$add_btn_label = sprintf(HCM::_n('Add New Shift', 'Add %d New Shifts', $shifts_count), $shifts_count);
break;
}
}
$out->add_item(HC_Html_Factory::element('input')->add_attr('type', 'submit')->add_attr('class', array('btn', 'btn-success'))->add_attr('title', $add_btn_label)->add_attr('value', $add_btn_label));
$display_form->add_item($out);
echo $display_form->render();
示例8: array
<?php
$label = NULL;
if ($entries) {
$label = array();
$icon = HC_Html::icon(HC_App::icon_for('conflict'))->add_attr('class', 'text-danger');
$label[] = $icon;
$label[] = sprintf(HCM::_n('%d Conflict', '%d Conflicts', count($entries)), count($entries));
$label = join('', $label);
$label = HC_Html_Factory::widget('titled', 'span')->add_attr('class', array('alert', 'alert-danger'))->add_attr('class', array('alert-condensed'))->add_attr('class', array('display-block'))->add_child($label);
}
if ($label) {
$out = HC_Html_Factory::widget('container')->add_item($label);
echo $out;
}
示例9: insert
function insert()
{
$extensions = HC_App::extensions();
$params = $this->_init_add_params(func_get_args());
$params_array = $params->to_array();
$model = HC_App::model('shift');
$date_input = $this->form_add_time->input('date');
$date_input->set_value($params_array['date']);
$dates = $date_input->dates();
/* if post supplied */
$post = $this->input->post();
$this->form_confirm->grab($post);
$form_values = $this->form_confirm->values();
$possible_statuses = $params->get_options('status');
if (count($possible_statuses) > 1) {
if (array_key_exists('status', $form_values)) {
$params_array['status'] = $form_values['status'];
}
} elseif (count($possible_statuses) == 1) {
$params_array['status'] = array_shift($possible_statuses);
}
$success_count = 0;
$users_ids = $params_array['user'];
// $publish_now = ($form_values['status'] == $model->_const('STATUS_ACTIVE')) ? TRUE : FALSE;
$publish_now = $params_array['status'] == $model->_const('STATUS_ACTIVE') ? TRUE : FALSE;
unset($params_array['user']);
if (!$params_array['location']) {
unset($params_array['location']);
}
/* group id */
$group_id = 0;
if (count($dates) * count($users_ids) > 1) {
$max_group_id = $model->select_max('group_id')->get()->group_id;
if (!$max_group_id) {
$max_group_id = 0;
}
$group_id = $max_group_id + 1;
}
$result_models = array();
foreach ($dates as $date) {
foreach ($users_ids as $uid) {
$this_params = $params_array;
$this_params['date'] = $date;
if ($uid) {
$this_params['user'] = $uid;
}
$model->clear();
$related = $model->from_array($this_params);
$model->group_id = $group_id;
/* create shift */
if (!$model->save($related)) {
$errors = $model->errors();
$this->form_confirm->set_errors($errors);
$orphan_errors = $this->form_confirm->orphan_errors();
return $this->_add($params, 'confirm');
}
$success_count++;
$result_models[] = clone $model;
/* extensions */
$extensions->run('shifts/insert', $post, $model);
}
}
switch ($model->type) {
case $model->_const('TYPE_SHIFT'):
$msg = sprintf(HCM::_n('%d shift added', '%d shifts added', $success_count), $success_count);
break;
case $model->_const('TYPE_TIMEOFF'):
$msg = sprintf(HCM::_n('%d timeoff added', '%d timeoffs added', $success_count), $success_count);
break;
}
$this->session->set_flashdata('message', $msg);
$redirect_to = 'list/calendar';
$parent_refresh = array();
foreach ($result_models as $o) {
$this_parent_refresh = $o->present_calendar_refresh();
$parent_refresh = array_merge($parent_refresh, $this_parent_refresh);
}
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
}
示例10: sprintf
<?php
$my_own = FALSE;
if (!$wrap) {
$my_own = TRUE;
$wrap = HC_Html_Factory::widget('list')->add_attr('class', 'list-inline')->add_attr('class', 'list-separated');
}
if ($count) {
$title = sprintf(HCM::_n('%d Shift Release Pending', '%d Shift Release Pending', $count), $count);
$item = HC_Html_Factory::widget('titled', 'span')->add_attr('class', 'display-block')->add_attr('class', 'label')->add_attr('class', 'label-warning')->add_child($title);
$wrap->add_item($item);
}
if ($my_own) {
if ($wrap->items()) {
echo $wrap->render();
}
}
示例11: bulk
function bulk()
{
$acl = HC_App::acl();
$extensions = HC_App::extensions();
/* if post supplied */
$post = $this->input->post();
if (isset($post['id'])) {
$ids = $post['id'];
} elseif (isset($post['ids'])) {
$ids = explode('|', $post['ids']);
} else {
$ids = array();
}
// $action = isset($post['action']) ? $post['action'] : '';
// if( $ids && $action ){
if ($ids) {
$model = HC_App::model('shift');
$model->where_in('id', $ids)->get();
$success_count = 0;
$action = 'update';
/* delete */
if (isset($post['delete'])) {
$action = 'delete';
foreach ($model as $o) {
if (!$acl->set_object($o)->can('delete')) {
continue;
}
if ($o->delete()) {
$success_count++;
}
}
} else {
$this->form->grab($post);
$form_values = $this->form->values();
foreach ($model as $o) {
if (!$acl->set_object($o)->can('edit')) {
continue;
}
reset($form_values);
foreach ($form_values as $k => $v) {
if ($v === NULL) {
continue;
}
$o->{$k} = $v;
}
if ($o->save()) {
$success_count++;
} else {
$errors = $o->errors();
}
}
}
switch ($action) {
case 'delete':
$msg = sprintf(HCM::_n('%d shift deleted', '%d shifts deleted', $success_count), $success_count);
break;
default:
$msg = sprintf(HCM::_n('%d shift updated', '%d shifts updated', $success_count), $success_count);
break;
}
if ($msg) {
$this->session->set_flashdata('message', $msg);
}
foreach ($model as $o) {
$extensions->run('shifts/update', $post, $o);
}
}
$redirect_to = '-referrer-';
$parent_refresh = array();
foreach ($model as $o) {
$this_parent_refresh = $o->present_calendar_refresh();
$parent_refresh = array_merge($parent_refresh, $this_parent_refresh);
}
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
}
示例12: render
function render()
{
$enabled = $this->enabled();
$value = $this->value(TRUE);
$t = HC_Lib::time();
if (isset($value['datestart'])) {
$t->setDateDb($value['datestart']);
}
/* single date part */
$wrap_single = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated'));
$wrap_single->add_item($this->fields['datesingle']);
/* recurring part */
$wrap = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated'))->add_attr('class', 'hc-radio-info-container');
/* DATES */
$item_dates = HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated'));
$item_dates->add_item($this->fields['datestart']);
$item_dates->add_item(' - ');
$item_dates->add_item($this->fields['dateend']);
$wrap->add_item($item_dates);
/* RECURRING OPTIONS */
$repeat = clone $this->fields['repeat'];
$repeat->add_option('daily', HCM::__('Daily'));
$repeat->add_option('weekday', HCM::__('Every Weekday') . ' (' . $t->formatWeekdayShort(1) . ' - ' . $t->formatWeekdayShort(5) . ')');
$repeat->add_option('weekly', HCM::__('Weekly') . ' (' . $t->formatWeekdayShort() . ')');
$wkds = array(0, 1, 2, 3, 4, 5, 6);
$wkds = $t->sortWeekdays($wkds);
/* weekly custom */
$weekly_custom = clone $this->fields['weeklycustom'];
$this_weekday = $t->getWeekday();
if (!$weekly_custom->value()) {
$weekly_custom->set_value(array($this_weekday));
}
reset($wkds);
foreach ($wkds as $wkd) {
$weekly_custom->add_option($wkd, $t->formatWeekdayShort($wkd));
}
// $weekly_custom->set_readonly($this_weekday);
$repeat->add_option('weeklycustom', HCM::__('Weekly') . ' (' . HCM::__('Selected Days') . ')', $weekly_custom);
/* biweekly custom */
$this_weekday = $t->getWeekday();
$biweekly_custom1 = clone $this->fields['biweeklycustom1'];
if (!$biweekly_custom1->value()) {
$biweekly_custom1->set_value(array($this_weekday));
}
$biweekly_custom2 = clone $this->fields['biweeklycustom2'];
if (!$biweekly_custom2->value()) {
$biweekly_custom2->set_value(array($this_weekday));
}
reset($wkds);
foreach ($wkds as $wkd) {
$biweekly_custom1->add_option($wkd, $t->formatWeekdayShort($wkd));
$biweekly_custom2->add_option($wkd, $t->formatWeekdayShort($wkd));
}
// $weekly_custom->set_readonly($this_weekday);
$repeat->add_option('biweeklycustom', HCM::__('Biweekly') . ' (' . HCM::__('Selected Days') . ')', array($biweekly_custom1, $biweekly_custom2));
/* in/out */
if (!$this->fields['inoutin']->value()) {
$this->fields['inoutin']->set_value(2);
}
if (!$this->fields['inoutout']->value()) {
$this->fields['inoutout']->set_value(2);
}
$repeat->add_option('inout', join(' / ', array(sprintf(HCM::_n('%s Day On', '%s Days On', 100), 'X'), sprintf(HCM::_n('%s Day Off', '%s Days Off', 100), 'Y'))), HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated'))->add_item($this->fields['inoutin']->add_attr('size', 2))->add_item('/')->add_item($this->fields['inoutout']->add_attr('size', 2)));
$repeat->add_option('monthlyday', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonth())) . ')');
$repeat->add_option('monthlydayend', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonthFromEnd())) . ')');
$repeat->add_option('monthlydate', HCM::__('Monthly') . ' (' . HCM::__('Day') . ': ' . $t->getDay() . ')');
$wrap->add_item($repeat);
/* build output */
// $recurring_part = $wrap->render();
// $recurring_part = $this->decorate( $recurring_part );
// $single_part = $wrap_single->render();
// $single_part = $this->decorate( $wrap_single );
$return = HC_Html_Factory::widget('container');
if (count($enabled) > 1) {
$tabs = HC_Html_Factory::widget('tabs');
$tabs_id = 'nts' . hc_random();
$tabs->set_id($tabs_id);
$tabs->add_tab('single', HCM::__('Single Day'), $wrap_single);
$tabs->add_tab('recurring', HCM::__('Multiple Days'), $wrap);
$value_recurring = $value['recurring'];
$tabs->set_active($value_recurring);
$return->add_item($this->fields['recurring']);
$return->add_item($tabs);
$name_recurring = $this->fields['recurring']->name();
$tabs_js = <<<EOT
<script language="JavaScript">
jQuery('#{$tabs_id}').closest('form').find('[name={$name_recurring}]').val( "{$value_recurring}" )
jQuery('#{$tabs_id} a.hc-tab-toggler').on('shown.hc.tab', function(e)
{
\tvar active_tab = jQuery(this).data('toggle-tab');
\tjQuery(this).closest('form').find('[name={$name_recurring}]').val( active_tab );
});
</script>
EOT;
$return->add_item($tabs_js);
} else {
if (in_array('single', $enabled)) {
$return->add_item($wrap_single);
//.........这里部分代码省略.........
示例13: sprintf
<?php
if (!$count) {
return;
}
/* translators: title for shifts that have no employee assigned yet */
$title = sprintf(HCM::_n('%d Open Shift', '%d Open Shifts', $count), $count);
$linkto = HC_Lib::link('list/browse', array('staff' => 0, 'range' => 'upcoming'));
$item = HC_Html_Factory::widget('titled', 'a')->add_attr('class', 'display-block')->add_attr('href', $linkto)->add_attr('class', 'alert')->add_attr('class', 'alert-danger-o')->add_attr('title', $title)->add_child($title);
echo $item->render();
示例14: index
function index($id)
{
$extensions = HC_App::extensions();
$args = func_get_args();
$id = array_shift($args);
$model = HC_App::model('shift');
$model->where('id', $id)->get();
$this->_check_model($model);
$acl = HC_App::acl();
if (!$acl->set_object($model)->can('edit')) {
return;
}
$original_model = clone $model;
/* supplied as parameters */
$values = hc_parse_args($args);
/* if post supplied */
$form = $this->form_edit;
$post = $this->input->post();
if ($post) {
$form->grab($post);
$form_values = $form->values();
$values = array_merge($values, $form_values);
}
$relname = 'user';
$unassign = FALSE;
if ($values[$relname] === '0' or $values[$relname] === 0 or $values[$relname] == '' or $values[$relname] === NULL) {
// delete user relation
unset($values[$relname]);
if ($model->user_id) {
$unassign = TRUE;
}
}
if (!$values) {
return $this->_zoom($model, 'time');
}
if ($values['location'] === NULL) {
unset($values['location']);
}
$related = $model->from_array($values);
$action_result1 = $model->save($related);
$action_result2 = TRUE;
if ($unassign) {
$rel = $model->{$relname}->get();
$action_result2 = $model->delete($rel, $relname);
}
if ($action_result1 && $action_result2) {
/* extensions */
$extensions->run('shifts/update', $post, $model);
/* save and redirect here */
if ($id) {
$msg = sprintf(HCM::_n('%d shift updated', '%d shifts updated', 1), 1);
} else {
$msg = sprintf(HCM::_n('%d shift added', '%d shifts added', 1), 1);
}
$this->session->set_flashdata('message', $msg);
$redirect_to = 'shifts/zoom/index/id/' . $id;
// $redirect_to = '-referrer-';
/* what to refresh on referring page */
$parent_refresh = $model->present_calendar_refresh();
$parent_refresh = array_keys($parent_refresh);
$this->redirect($redirect_to, $parent_refresh);
} else {
/* final layout */
$this->layout->set_partial('content', Modules::run('shifts/zoom/index', 'id', $model));
$this->layout();
}
}
示例15: array
<?php
$temp_shift = HC_App::model('shift');
/* create buttons */
$create_btns = array();
$create_btns['shift'] = HC_Html_Factory::element('a')->add_attr('class', array('btn'))->add_attr('class', array('btn-success'))->add_attr('href', HC_Lib::link('shifts/add/index')->url(array('type' => $temp_shift->_const('TYPE_SHIFT'))))->add_child(HC_Html::icon(HC_App::icon_for('shift')))->add_attr('title', sprintf(HCM::_n('Add New Shift', 'Add %d New Shifts', 1), 1));
$create_btns['timeoff'] = HC_Html_Factory::element('a')->add_attr('class', array('btn'))->add_attr('class', array('btn-warning-o'))->add_attr('href', HC_Lib::link('shifts/add/index')->url(array('type' => $temp_shift->_const('TYPE_TIMEOFF'))))->add_child(HC_Html::icon(HC_App::icon_for('timeoff')))->add_child(sprintf(HCM::_n('Request New Timeoff', 'Request %d New Timeoffs', 1), 1))->add_attr('title', sprintf(HCM::_n('Request New Timeoff', 'Request %d New Timeoffs', 1), 1));
$btns = HC_Html_Factory::widget('list')->add_attr('class', 'list-inline')->add_attr('class', 'list-separated');
$this_user_id = $this->auth->user()->id;
$acl = HC_App::acl();
$test_shift = HC_App::model('shift');
$test_shift->user_id = $this_user_id;
$add_btns = array();
if (isset($fix) && isset($fix['type']) && $fix['type'] && is_array($fix['type']) && count($fix['type']) == 1) {
switch ($fix['type'][0]) {
case $test_shift->_const('TYPE_TIMEOFF'):
$test_shift->type = $fix['type'][0];
if ($acl->set_object($test_shift)->can('validate')) {
$add_btns[] = $create_btns['timeoff'];
}
break;
}
} else {
/*
$test_shift->type = $test_shift->_const('TYPE_SHIFT');
if( $acl->set_object($test_shift)->can('validate') ){
$add_btns[] = $create_btns['shift'];
}
$test_shift->type = $test_shift->_const('TYPE_TIMEOFF');
if( $acl->set_object($test_shift)->can('validate') ){