| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | <?php/** * Define a page. * @author Valentin CARRUESCO * @category Plugin * @license copyright */class WikiPage extends Entity{	public $id,$label,$content,$state,$path,$category,$slug;	const PUBLISHED = 'published';	const DRAFT = 'draft';	protected $TABLE_NAME = 'wiki_page';	public $links = array(		'category' => 'WikiCategory'	);	public $fields =	array(		'id' => 'key',		'label' => 'string',		'state' => 'string',		'category' => 'int',		'slug' => 'string',		'path' => 'string'	);	public static function workspace(){		return File::dir().'wiki'.SLASH.'pages';	}	public static function uploads(){		return File::dir().'wiki'.SLASH.'uploads';	}	public static function path_from_label($label){		return preg_replace('|[\?\\\/\*\:\|\<\>]|i', '-',$label);	}	public function author(){		return User::byLogin($this->creator)->fullName();	}	public function created(){		return relative_time($this->created);	}	public function updater(){		return User::byLogin($this->updater)->fullName();	}	public function updated(){		return relative_time($this->updated);	}	public function html(){		require_once(__DIR__.SLASH.'lib'.SLASH.'Parsedown.php');		$markdown = new Parsedown();		return $markdown->text($this->content);	}	public function content(){		$this->content = file_get_contents(self::workspace().SLASH.wiki_os_encode($this->path));	}}?>
 |