Beispiel #1
0
 public function setValue($value)
 {
     if ($value) {
         $date = Nette\Utils\DateTime::from($value);
         $this->day = $date->format('j');
         $this->month = $date->format('n');
         $this->year = $date->format('Y');
     } else {
         $this->day = $this->month = $this->year = NULL;
     }
 }
Beispiel #2
0
 /**
  * Return requested update if any or prepare record to create one.
  * @param string $dateTime
  * @return UpdateEntity
  */
 private function getOrCreateUpdate($dateTime)
 {
     $dt = new \Nette\Utils\DateTime();
     $dateTimeObj = $dt->from($dateTime);
     $timestamp = $dateTimeObj->getTimestamp();
     if (!array_key_exists($timestamp, $this->updates)) {
         $this->updates[$timestamp] = new UpdateEntity($dateTime);
     }
     return $this->updates[$timestamp];
 }
use Nette\Utils\Html;
function safe($content)
{
    return Html::el()->setHtml($content);
}
MangoFilters::$set['url'] = 'rawurlencode';
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
    MangoFilters::$set[$name] = 'Nette\\Utils\\Strings::' . $name;
}
MangoFilters::$set['null'] = function () {
};
MangoFilters::$set['length'] = function ($var) {
    return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
};
MangoFilters::$set['modifyDate'] = function ($time, $delta, $unit = NULL) {
    return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
    // intentionally ==
};
function lazy_post($id)
{
    if (is_object($id)) {
        return $id;
    }
    return get_post($id);
}
MangoFilters::$set['wp_title'] = function ($id) {
    $post = lazy_post($id);
    if (!$post) {
        return $id;
    }
    return safe(apply_filters('the_title', $post->post_title));