Exemple #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;
 }
Exemple #2
0
 /**
  * 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 '';
     }
 }
Exemple #3
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;
 }
};
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);
    if (!$post) {
        return $id;