예제 #1
0
파일: store.php 프로젝트: nsteiner/kdoc
 /**
  * Resets store if necessary to stay in sync with content file
  */
 public function sync()
 {
     $file = $this->structure->model()->textfile();
     $ageModel = f::exists($file) ? f::modified($file) : 0;
     $ageStore = s::get($this->id() . '_age');
     if ($ageStore < $ageModel) {
         $this->reset();
         $this->age = $ageModel;
     } else {
         $this->age = $ageStore;
     }
 }
예제 #2
0
 public function check_cache($type)
 {
     $cache_path = __DIR__ . '/../cache/' . $type . '.json';
     if (\f::exists($cache_path)) {
         $cache = json_decode(\f::read($cache_path, 'json'));
         if ($cache->to < time()) {
             return false;
         } else {
             return $cache->payload;
         }
     } else {
         return false;
     }
 }
예제 #3
0
/**
 * Determines the size/length of numbers, strings, arrays and files
 *
 * @param mixed $value
 * @return int
 */
function size($value)
{
    if (is_numeric($value)) {
        return $value;
    }
    if (is_string($value)) {
        return str::length(trim($value));
    }
    if (is_array($value)) {
        return count($value);
    }
    if (f::exists($value)) {
        return f::size($value) / 1024;
    }
}
예제 #4
0
 public function isUserAlreadyInSession()
 {
     //get full path to user's results' file (if any) in results folder
     $userResultsFile = $this->resultsFolderPath . DS . $this->username . '.' . c::get('results.file.ext');
     //if usre's file exists
     if (f::exists($userResultsFile)) {
         //add error: the username is already present in the session
         $this->addError('session.fail.email.alreadyUsed');
         //return true
         return true;
     }
     //return false
     return false;
 }
function resizeOnDemandDeleteDir($pageId)
{
    $path = str_replace('/', DS, $pageId);
    $root = kirby()->roots()->index() . DS . 'thumbs' . DS . $path;
    // delete directory with resized images
    if (f::exists($root)) {
        dir::remove($root, false);
    }
}
예제 #6
0
 public function testExists()
 {
     $this->assertTrue(f::exists($this->contentFile));
 }