/** @brief Displays an array of inputs using Wordpress table formatting. @param array $o Array of options. @since 20130416 **/ public function display_form_table($o = array()) { $o = \plainview\sdk_broadcast\base::merge_objects(array('base' => $this->base, 'header' => '', 'header_level' => 'h3', 'r' => ''), $o); $r = ''; $o->inputs = $this->inputs; $this->display_form_table_inputs($o); return $o->r; }
/** @brief Output the unix time as a human-readable string. @details In order to aid in translation, use the various text_* keys in the options array. See the source below for a list of keys to include. @param int $current Current timestamp. @param int $reference Reference timestamp, if not now. @param array $options Options. @since 20130809 **/ public static function human_time($current, $reference = null, $options = []) { $options = \plainview\sdk_broadcast\base::merge_objects(['time' => date('U'), 'text_day' => '1 day', 'text_days' => '%d days', 'text_hour' => '1 hour', 'text_hours' => '%d hours', 'text_minute' => '1 minute', 'text_minutes' => '%d minutes', 'text_second' => '1 second', 'text_seconds' => '%d seconds'], $options); if ($reference === null) { $reference = $options->time; } if (!is_int($current)) { $current = strtotime($current); } $difference = abs($reference - $current); $seconds = round($difference, 0); $minutes = round($difference / 60, 0); $hours = round($difference / (60 * 60), 0); $days = round($difference / (60 * 60 * 24), 0); if ($days > 0) { if ($days == 1) { return $options->text_day; } else { return sprintf($options->text_days, $days); } } if ($hours > 0) { if ($hours == 1) { return $options->text_hour; } else { return sprintf($options->text_hours, $hours); } } if ($minutes > 0) { if ($minutes == 1) { return $options->text_minute; } else { return sprintf($options->text_minutes, $minutes); } } if ($seconds == 1) { return $options->text_second; } else { return sprintf($options->text_seconds, $seconds); } }