本文整理汇总了PHP中Horde_Date::before方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Date::before方法的具体用法?PHP Horde_Date::before怎么用?PHP Horde_Date::before使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Date
的用法示例。
在下文中一共展示了Horde_Date::before方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listTimeObjects
/**
*
* @param Horde_Date $start The start time of the period
* @param Horde_Date $end The end time of the period
*
* @return array of listTimeObjects arrays.
*/
public function listTimeObjects(Horde_Date $start = null, Horde_Date $end = null)
{
global $conf, $prefs;
// No need to continue if the forecast days are not in the current
// range.
$forecast_start = new Horde_Date(time());
$forecast_end = clone $forecast_start;
$forecast_end->mday += 7;
if ($end->before($forecast_start) || $start->after($forecast_end)) {
return array();
}
$weather = $this->_create();
$lengths = $weather->getSupportedForecastLengths();
try {
$units = $weather->getUnits($weather->units);
$forecast = $weather->getForecast($this->_location, max(array_keys($lengths)));
$current = $weather->getCurrentConditions($this->_location);
} catch (Horde_Service_Weather_Exception $e) {
throw new Timeobjects_Exception($e);
}
$objects = array();
foreach ($forecast as $data) {
$day = $data->date;
$day->hour = 0;
$day->min = 0;
$day->sec = 0;
$day_end = clone $day;
$day_end->mday++;
$title = sprintf('%s %d°%s/%d°%s', $data->conditions, $data->high, $units['temp'], $data->low, $units['temp']);
// Deterine what information we have to display.
$pop = $data->precipitation_percent === false ? _("N/A") : $data->precipitation_percent . '%';
if ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_STANDARD) {
if ($data->humidity !== false && $data->wind_direction !== false) {
$description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\nHumidity: %d%%\nWinds: From the %s at %d%s"), _($data->conditions), $data->high, '°' . $units['temp'], $pop, $data->humidity, $data->wind_direction, $data->wind_speed, $units['wind']);
} else {
$description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\n"), _($data->conditions), $data->high, '°' . $units['temp'], $pop);
}
} elseif ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_DETAILED) {
// @TODO
// No drivers support this yet. AccuWeather will, and possibly
// wunderground if they accept my request.
}
$station = $weather->getStation();
$body = sprintf(_("Location: %s"), $weather->getStation()->name);
if (!empty($weather->getStation()->sunrise)) {
$body .= sprintf(_("Sunrise: %s\nSunset: %s\n"), $weather->getStation()->sunrise, $weather->getStation()->sunset);
}
$body .= "\n" . $description;
$objects[] = array('id' => $day->timestamp(), 'title' => $title, 'description' => $body, 'start' => $day->strftime('%Y-%m-%dT00:00:00'), 'end' => $day_end->strftime('%Y-%m-%dT00:00:00'), 'recurrence' => Horde_Date_Recurrence::RECUR_NONE, 'params' => array(), 'link' => new Horde_Url('#'), 'icon' => (string) Horde_Themes::img('weather/23x23/' . $data->icon));
$day->mday++;
}
return $objects;
}
示例2: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $browser, $injector, $page_output, $prefs;
$page_output->addScriptPackage('IMP_Script_Package_Imp');
$p_css = new Horde_Themes_Element('prefs.css');
$page_output->addStylesheet($p_css->fs, $p_css->uri);
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
$view->addHelper('Horde_Core_View_Helper_Help');
if (!Horde::isConnectionSecure()) {
$view->notsecure = true;
return $view->render('smimeprivatekey');
}
$smime_url = IMP_Basic_Smime::url();
$view->has_key = $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key');
$view->has_sign_key = $prefs->getValue('smime_public_sign_key') && $prefs->getValue('smime_private_sign_key');
if ($browser->allowFileUploads()) {
$view->import = true;
$page_output->addInlineScript(array('$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 450, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true);
}
if (!$view->has_key) {
return $view->render('smimeprivatekey');
}
$smime = $injector->getInstance('IMP_Smime');
foreach (array('' => false, '_sign' => true) as $suffix => $secondary) {
if ($secondary && !$view->has_sign_key) {
continue;
}
$cert = $smime->parseCert($smime->getPersonalPublicKey($secondary));
if (!empty($cert['validity']['notafter'])) {
$expired = new Horde_Date($cert['validity']['notafter']);
if ($expired->before(time())) {
$view->{'expiredate' . $suffix} = $expired->strftime($prefs->getValue('date_format'));
$view->{'expiretime' . $suffix} = $expired->strftime($prefs->getValue('time_format'));
}
}
$view->{'viewpublic' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_public' . $suffix . '_key')->link(array('title' => $secondary ? _("View Secondary Personal Public Certificate") : _("View Personal Public Certificate"), 'target' => 'view_key')) . _("View") . '</a>';
$view->{'infopublic' . $suffix} = $smime_url->copy()->add('actionID', 'info_personal_public' . $suffix . '_key')->link(array('title' => _("Information on Personal Public Certificate"), 'target' => 'info_key')) . _("Details") . '</a>';
if ($smime->getPassphrase($secondary)) {
$view->{'passphrase' . $suffix} = $ui->selfUrl(array('special' => true, 'token' => true))->add('unset_smime' . $suffix . '_passphrase', 1)->link(array('title' => _("Unload Passphrase"))) . _("Unload Passphrase") . '</a>';
} else {
$imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true), 'secondary' => intval($secondary)), 'type' => 'smimePersonal'));
$view->{'passphrase' . $suffix} = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase");
}
$view->{'viewprivate' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_private' . $suffix . '_key')->link(array('title' => _("View Secondary Personal Private Key"), 'target' => 'view_key')) . _("View") . '</a>';
$page_output->addInlineScript(array('$("delete_smime_personal' . $suffix . '").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true);
}
return $view->render('smimeprivatekey');
}
示例3: _request
/**
* Sends a request and parses the response.
*
* @param string $method A HTTP request method (uppercase).
* @param string $namespace An API namespace.
* @param array $params URL parameters.
* @param array|string $data Request data.
*
* @return array The decoded result data or null if no data has been
* returned but the request was still successful.
* @throws Horde_OpenXchange_Exception.
*/
protected function _request($method, $namespace, $params, $data = array())
{
$uri = new Horde_Url($this->_uri . '/' . $namespace, true);
try {
$headers = array();
if (isset($this->_cookies)) {
$headers['Cookie'] = implode('; ', $this->_cookies);
}
if ($method == 'GET') {
$params = array_merge($params, $data);
$data = null;
}
$response = $this->_client->request($method, (string) $uri->add($params), $data, $headers);
if ($cookies = $response->getHeader('set-cookie')) {
if (!is_array($cookies)) {
$cookies = array($cookies);
}
foreach ($cookies as $cookie) {
$cookie = preg_split('/;\\s*/', $cookie);
for ($i = 1, $c = count($cookie); $i < $c; $i++) {
list($key, $value) = explode('=', $cookie[$i]);
if ($key == 'Expires') {
$expire = new Horde_Date($value);
if ($expire->before(time())) {
continue 2;
}
break;
}
}
$this->_cookies[] = $cookie[0];
}
}
$body = $response->getBody();
$data = json_decode($body, true);
if (!$data) {
if ($response->code == 200) {
return;
}
throw new Horde_OpenXchange_Exception($body);
}
if (isset($data['error'])) {
$e = new Horde_OpenXchange_Exception($data['error']);
$e->details = $data;
throw $e;
}
return $data;
} catch (Horde_Http_Exception $e) {
throw new Horde_OpenXchange_Exception($e);
}
}