Exemplo n.º 1
0
 /**
  * Test method
  */
 public function test()
 {
     date_default_timezone_set('Europe/Warsaw');
     $system = System::getInstance();
     $this->assertTrue($system->getIpAddress()->getAddress() === System::DEFAULT_IP);
     $this->assertTrue($system->getIpAddress()->getAddress(true) === ip2long(System::DEFAULT_IP));
 }
Exemplo n.º 2
0
 /**
  * Instance of construct
  */
 public function __construct()
 {
     if (null === self::$dir) {
         self::$dir = APPLICATION_PATH . '/../public';
     }
     if (null === self::$domain) {
         self::$domain = System::getInstance()->getDomain()->getAddress();
     }
 }
Exemplo n.º 3
0
 /**
  * Create "nice" date
  * 
  * @param \DateTime $date
  * @return string
  */
 public function niceDate(\DateTime $date)
 {
     $now = $this->system->getDate();
     if ($now->format('Y-m-d') === $date->format('Y-m-d')) {
         return $date->format('H:i');
     } elseif ($now->format('Y-m') === $date->format('Y-m') && $date->format('d') + 1 == $now->format('d')) {
         return sprintf($this->translate('yesterday, %s'), $date->format('H:i'));
     }
     return $date->format('d-m-Y');
 }
Exemplo n.º 4
0
 /**
  * Get system object
  * 
  * @return \Extlib\System
  */
 public function getSystem()
 {
     if (null === $this->system) {
         $this->system = \Extlib\System::getInstance();
     }
     return $this->system;
 }
Exemplo n.º 5
0
 /**
  * Get date as directory - 2013-06-10 to 2013/06/10
  * 
  * @return string
  */
 public static function getDateDirectory()
 {
     return str_replace('-', DIRECTORY_SEPARATOR, \Extlib\System::getInstance()->getDate()->format('Y-m-d'));
 }
Exemplo n.º 6
0
 /**
  * Instance of construct
  * 
  * @param string $namespace
  * @param int $lifetime
  * @param string $path
  * @param string $secure
  * @param string $httponly
  */
 public function __construct($namespace = null, $lifetime = self::COOKIE_EXPIRES_ONE_YEAR, $path = null, $secure = false, $httponly = false)
 {
     $this->lifetime = $lifetime;
     $this->date = System::getInstance()->getDate();
     if (null !== $namespace) {
         $this->namespace = $namespace;
     }
     if (null !== $path) {
         $this->path = $path;
     }
     if (false !== $secure) {
         $this->secure = $secure;
     }
     if (false !== $httponly) {
         $this->httponly = $httponly;
     }
     if (self::isExist($this->namespace)) {
         $this->instance = unserialize(base64_decode(self::get($this->namespace)));
     } else {
         $this->instance = new \stdClass();
     }
 }
Exemplo n.º 7
0
 public function getUrl()
 {
     return \Extlib\System::getInstance()->getDomain()->getAddress() . '/system/image/hash/' . $this->getHash();
 }