コード例 #1
0
 public function index()
 {
     $tables = joosRequest::array_param('codertable', array(), $_POST);
     $ret = array('site' => array(), 'admin' => array());
     foreach ($tables as $table) {
         $model_code = modelAdminCoder::get_model($table, self::$implode_model);
         $ret['site'][] = $model_code['site'];
         $ret['admin'][] = $model_code['admin'];
     }
     $body_site = self::$implode_model ? implode('', $ret['site']) : implode("\n\n\n", $ret);
     $body_admin = self::$implode_model ? implode('', $ret['admin']) : implode("\n\n\n", $ret);
     $tables_count = count($tables);
     return array('success' => true, 'message' => $tables_count ? sprintf('Код для %s %s готов', $tables_count, joosText::declension($tables_count, array('модели', 'моделей', 'моделей'))) : 'Модели не выбраны', 'body_site' => '<pre>' . $body_site . '</pre>', 'body_admin' => '<pre>' . $body_admin . '</pre>');
 }
コード例 #2
0
ファイル: datetime.php プロジェクト: joostina/joostina
 /**
  * Получение логического представление строки времени
  *
  * @param  int    $time число секунд для анализа
  * @return string
  */
 public static function time_string($time)
 {
     $time = (int) $time;
     // года
     $years = floor($time / (365.242199 * 24 * 60 * 60));
     if ($years > 1) {
         return sprintf('%s %s', $years, joosText::declension($years, array('год', 'года', 'лет')));
     }
     if ($years == 1) {
         return 'год';
     }
     // месяцы
     $months = floor($time / (365.242199 / 12 * 24 * 60 * 60));
     if ($months > 1) {
         return sprintf('%s %s', $months, joosText::declension($months, array('месяц', 'месяца', 'месяцев')));
     }
     if ($months == 1) {
         return 'месяц';
     }
     // недели
     $weeks = floor($time / (7 * 24 * 60 * 60));
     if ($weeks > 1) {
         return sprintf('%s %s', $weeks, joosText::declension($weeks, array('неделя', 'недели', 'недель')));
     }
     if ($weeks == 1) {
         return 'неделю';
     }
     // дней
     $days = floor($time / (24 * 60 * 60));
     if ($days > 1) {
         return sprintf('%s %s', $days, joosText::declension($days, array('день', 'дня', 'дней')));
     }
     if ($days == 1) {
         return 'день';
     }
     // часов
     $hours = floor($time / (60 * 60));
     if ($hours > 1) {
         return sprintf('%s %s', $hours, joosText::declension($hours, array('час', 'часа', 'часов')));
     }
     if ($hours == 1) {
         return 'час';
     }
     // минут
     $minutes = floor($time / 60);
     if ($minutes > 1) {
         return sprintf('%s %s', $minutes, joosText::declension($minutes, array('минуту', 'минуты', 'минут')));
     }
     if ($minutes == 1) {
         return 'минута';
     }
 }