示例#1
0
 /**
  * Get an array of custom field types for use with `Form::select`.
  *
  * @return array[]
  */
 public static function typesSelectOptions()
 {
     $options = [];
     foreach (static::types() as $type) {
         $options[] = ['label' => Language::translate($type), 'value' => $type];
     }
     return $options;
 }
示例#2
0
文件: Status.php 项目: nirix/traq
 /**
  * Returns an array formatted for the Form::select() method.
  *
  * @return array
  */
 public static function selectOptions($valueField = 'id')
 {
     $open = Language::translate('open');
     $closed = Language::translate('closed');
     $options = [$open => [], $closed => []];
     foreach (static::all() as $status) {
         $option = ['label' => $status['name'], 'value' => $status[$valueField]];
         if ($status->status) {
             $options[$open][] = $option;
         } else {
             $options[$closed][] = $option;
         }
     }
     return $options;
 }
示例#3
0
 /**
  * @return boolean
  */
 public function validate()
 {
     $validator = new ModelValidator(static::$_validations, $this);
     if (!$validator->validate()) {
         foreach ($validator->errors as $field => $errors) {
             foreach ($errors as $error => $options) {
                 if (is_numeric($error)) {
                     $error = $options;
                     $options = [];
                 }
                 $name = Language::translate($field);
                 $this->addError($field, Language::translate("errors.validations.{$error}", ['field' => $name] + $options));
             }
         }
     }
     return !count($this->_errors);
 }
示例#4
0
 /**
  * Returns contains/doesn't contain options for the `Form::select` helper.
  *
  * @return array
  */
 public static function containsFilterSelectOptions()
 {
     return [['label' => Language::translate('contains'), 'value' => ''], ['label' => Language::translate('doesnt_contain'), 'value' => '!']];
 }
示例#5
0
 /**
  * Returns the HTML for a modal header.
  *
  * @param string $title
  *
  * @return string
  */
 public static function modalHeader($title)
 {
     $header = ['<div class="modal-header">', '    <button type="button" class="close" data-dismiss="modal">', '        <span aria-hidden="true">&times;</span>', '        <span class="sr-only">' . Language::translate('close') . '</span>', '    </button>', '    <h4 class="modal-title">' . $title . '</h4>', '</div>'];
     return implode(PHP_EOL, $header);
 }
示例#6
0
 /**
  * Create a new account activation notification.
  *
  * @param  User $user
  *
  * @return Notification
  */
 public static function accountActivation(User $user, $activationCode)
 {
     $message = new static(Language::translate('notifications.account_activation.subject', ['title' => setting('title')]), View::render('notifications/account_activation.txt.php', ['user' => $user, 'activationCode' => $activationCode]));
     $message->setTo($user->email, $user->name);
     return $message;
 }
示例#7
0
 /**
  * Returns an array of milestone statuses formatted for the Form::select() helper.
  *
  * @return array
  */
 public static function statusSelectOptions()
 {
     return [['label' => Language::translate('active'), 'value' => 1], ['label' => Language::translate('completed'), 'value' => 2], ['label' => Language::translate('cancelled'), 'value' => 0]];
 }
示例#8
0
 /**
  * Returns the content for the ticket listing headers.
  *
  * @param string $column The column to get the content for.
  *
  * @return mixed
  */
 public static function headerFor($column)
 {
     switch ($column) {
         case 'ticket_id':
             return Language::translate('id');
             break;
         case 'summary':
         case 'status':
         case 'owner':
         case 'type':
         case 'component':
         case 'milestone':
         case 'version':
         case 'assigned_to':
         case 'updates':
         case 'votes':
         case 'priority':
         case 'severity':
             return Language::translate($column);
         case 'created_at':
             return Language::translate('created');
             break;
         case 'updated_at':
             return Language::translate('updated');
             break;
     }
     // If we're still here, it may be a custom field
     if ($column = CustomField::find($column)) {
         return $column->name;
     }
     // Nothing!
     return '';
 }
示例#9
0
文件: common.php 项目: nirix/dreamer
/**
 * Translate the string.
 *
 * @param string $string string or string key
 * @param array  $args   arguments for the string
 *
 * @return string
 */
function t($string, array $args = [])
{
    return Language::translate($string, $args);
}
示例#10
0
 /**
  * Adds a validation error for the specified field.
  *
  * @param string $field
  * @param mixed  $data
  * @param string $index
  */
 public function addValidationError($field, $validation, array $options = [], $index = null)
 {
     $this->addError($field, Language::translate("errors.validations.{$validation}", ['field' => Language::translate($field)] + $options));
 }
示例#11
0
文件: common.php 项目: nirix/traq
/**
 * Returns the time ago in words with the 'ago' suffix.
 *
 * @param string $timestamp
 *
 * @return string
 */
function timeAgoInWords($timestamp)
{
    return $timestamp ? Language::translate('time.x_ago', [Time::agoInWords($timestamp)]) : null;
}