Esempio n. 1
0
 /**
  * Create file with given SQL update. Name will be formatted timestamp of now.
  * @param bool $isFull If SQL is full database dump
  * @param string $sql
  * @return bool
  */
 public function createUpdate($isFull, $sql)
 {
     $createdAt = new \Nette\Utils\DateTime();
     $formatted = $createdAt->format("Y-m-d_H-i-s");
     $tail = $isFull ? "_full" : "";
     $filename = $this->sqlDir . $formatted . $tail . $this->sqlExt;
     $bytesOrState = file_put_contents($filename, $sql);
     return $bytesOrState === false ? false : true;
 }
Esempio n. 2
0
File: Date.php Progetto: vsek/grid
 /**
  * Vrati hodnotu z tabulky
  * @param Nette\Database\Table\ActiveRow $query
  * @return string
  */
 public function output(\Nette\Database\Table\ActiveRow $query)
 {
     $value = parent::output($query);
     if (!is_null($value)) {
         $date = new \Nette\Utils\DateTime($value);
         return date($date->format($this->format));
     } else {
         return '';
     }
 }
Esempio n. 3
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;
     }
 }
Esempio n. 4
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];
 }
Esempio n. 5
0
 /** 
  * Save file to folders
  * @note Folders are created automatically
  * 
  * @param string $dir
  * @param int $id
  * @param array $data
  * @param bool $custom Save custom
  * 
  * @return bool
  */
 private function fileSave($dir, $id, $data, $custom = FALSE)
 {
     $date = new \Nette\Utils\DateTime('now');
     $pathItem = $this->createPath($dir, $id) . $date->format('YmdHis') . '_' . rand(1000, 9999);
     if ($custom) {
         $pathItem .= '_custom';
     }
     /** Who was iniciator */
     if (intval($this->userId) > 0) {
         $data['__user'] = $this->userId;
     } else {
         $data['__user'] = '******';
     }
     /**
      * Save changes
      */
     return file_put_contents($pathItem . '.dat', json_encode($data)) ? TRUE : FALSE;
 }
Esempio n. 6
0
    }
    return safe(apply_filters('the_excerpt', $post->post_excerpt));
};
MangoFilters::$set['wp_permalink'] = function ($id) {
    $post = lazy_post($id);
    if (!$post) {
        return $id;
    }
    return get_permalink($id);
};
MangoFilters::$set['wp_date'] = function ($id, $format = null) {
    $post = lazy_post($id);
    if (!$post) {
        return $id;
    }
    $date = new Nette\Utils\DateTime($post->post_date);
    if ($format) {
        return $date->format($format);
    } else {
        return $date->format(get_option('date_format'));
    }
};
MangoFilters::$set['wp_DateTime'] = function ($id, $format = null) {
    $post = lazy_post($id);
    if (!$post) {
        return $id;
    }
    return new Nette\Utils\DateTime($post->post_date);
};
MangoFilters::$set['wp_meta'] = function ($id, $meta, $as = null) {
    $post = lazy_post($id);