Esempio n. 1
0
 public function testDelete()
 {
     global $AR;
     $me = $this;
     ar::context()->callAtPath(TESTBASE . 'file-nls/', function () use($me) {
         ar_store_files::delete('test', 'nl');
         $result = ar_store_files::ls();
         $me->assertEquals(count($result), 0);
     });
 }
Esempio n. 2
0
 public function printResult($result)
 {
     $currentObject = ar::context()->getObject();
     $this->scope[$currentObject->id] = $currentObject;
     $this->printHeader();
     $this->printErrors($result);
     $this->printWarnings($result);
     $this->printFailures($result);
     $this->printFooter($result);
 }
Esempio n. 3
0
 public static function info($path = null)
 {
     if (!isset($path)) {
         $path = ar::context()->getPath();
     }
     if (self::$enabled) {
         return ' data-ar-path="' . htmlspecialchars($path) . '"';
     } else {
         return '';
     }
 }
Esempio n. 4
0
 public static function create($prefix = null, $timeout = 7200)
 {
     // this method is used by pinp scripts to create a specific cache
     // so it must be more restrictive than the constructor of the cacheStore
     // which must be able to clear any and all caches
     if (!$prefix) {
         // make sure you have a default prefix, so you won't clear other prefixes unintended
         $prefix = 'default';
     }
     $prefix = 'pinp/' . $prefix;
     // make sure the pinp scripts have their own top level
     $prefix = $prefix . ar::context()->getPath();
     // make sure the cache store is limited to the current path in the context stack
     try {
         return new ar_cacheStore($prefix, $timeout);
     } catch (Exception $e) {
         return ar_error::raiseError($e->getMessage(), $e->getCode());
     }
 }
Esempio n. 5
0
 public static function fire($eventName, $eventData = array(), $objectType = null, $path = '')
 {
     if (!isset(self::$listeners['capture'][$eventName]) && !isset(self::$listeners['listen'][$eventName])) {
         return $eventData;
         // no listeners for this event, so dont bother searching
     }
     $prevEvent = null;
     if (self::$event) {
         $prevEvent = self::$event;
     }
     $path = ar::context()->getPath(array('path' => $path));
     $me = ar::context()->getObject(array('path' => $path));
     if ($me && !isset($objectType)) {
         $objectType = $me->type;
     } else {
         if (!$objectType) {
             // when set to false to prevent automatic filling of the objectType, reset it to null
             $objectType = null;
         }
     }
     self::$event = new ar_eventsEvent($eventName, $eventData, $objectType, $path, $me);
     if (self::walkListeners(self::$listeners['capture'][$eventName], $path, $objectType, true)) {
         self::walkListeners(self::$listeners['listen'][$eventName], $path, $objectType, false);
     }
     if (self::$event->preventDefault) {
         $result = false;
     } else {
         if (self::$event->data) {
             $result = self::$event->data;
         } else {
             $result = true;
         }
     }
     self::$event = $prevEvent;
     return $result;
 }
Esempio n. 6
0
 public function __construct($tagName = 'ul', $attributes = array(), $childNodes = null, $parentNode = null)
 {
     if (!$attributes['class'] && !$attributes['id']) {
         $attributes['class'] = 'menu';
     }
     if (!$tagName) {
         $tagName = 'ul';
     }
     $this->options['listTag'] = $tagName;
     switch ($tagName) {
         case 'ul':
         case 'ol':
             $this->options['itemTag'] = 'li';
             break;
         case 'dl':
             $this->options['itemTag'] = 'dt';
             break;
         default:
             $this->options['itemTag'] = $tagName;
             break;
     }
     if (!$childNodes instanceof ar_htmlNodes) {
         $childNodes = null;
     }
     parent::__construct($tagName, $attributes, $childNodes, $parentNode);
     $this->items['[root]'] = $this;
     $context = ar::context();
     $me = $context->getObject();
     if ($me) {
         $this->root = $me->currentsite();
         $this->rooturl = $me->make_local_url($this->root);
     }
     if (!isset($this->root)) {
         $this->root = '/';
         $this->rooturl = '/';
     }
     $this->current = $this->root;
     $listTag = $this->options['listTag'];
     $itemTag = $this->options['itemTag'];
     if ($this->attributes['id']) {
         $prefix = '#' . $this->attributes['id'];
     } else {
         $prefix = $listTag . '.' . $this->attributes['class'];
     }
     $this->prefix = $prefix;
     $this->css = ar_css::stylesheet()->import("\n\t\t\t\t{$prefix}, {$prefix} {$listTag} {\n\t\t\t\t\tlist-style: none;\n\t\t\t\t\tmargin: 0px;\n\t\t\t\t\tpadding: 0px;\n\t\t\t\t}\n\n\t\t\t\t{$prefix} {$itemTag} {\n\t\t\t\t\tmargin: 0px;\n\t\t\t\t\tpadding: 0px;\n\t\t\t\t}\n\n\t\t\t\t{$prefix} {$itemTag} a {\n\t\t\t\t\ttext-decoration: none;\n\t\t\t\t}\n\t\t\t");
 }
Esempio n. 7
0
 public function remove($filename, $nls = 'none')
 {
     $filename = (string) $filename;
     $nls = (string) $nls;
     $registeredFiles = $this->ls();
     $info = $registeredFiles[$filename][$nls];
     unset($registeredFiles[$filename][$nls]);
     if (!$registeredFiles[$filename]) {
         unset($registeredFiles[$filename]);
     }
     $this->store->putvar('registeredFiles', $registeredFiles);
     if ($info && $info[$filename . '_temp']) {
         // check before removing
         $tempfile = preg_replace("|[\\\\/]|", "", $info[$filename . '_temp']);
         $tempOb = ar::context()->getObject();
         $tempfile = $tempOb->store->get_config('files') . 'temp/' . $tempfile;
         if ($tempfile && file_exists($tempfile)) {
             unlink($tempfile);
         }
     }
 }
Esempio n. 8
0
 public static function makeRealPath($path = '')
 {
     $path = (string) $path;
     return ar::context()->getPath(array('skipShortcuts' => true, 'path' => $path));
 }
Esempio n. 9
0
File: ar.php Progetto: poef/ariadne
 public static function setContext($context)
 {
     if (!isset(self::$context)) {
         self::$context = $context;
     } else {
         return self::error('Context can only be set once.', ar_exceptions::ACCESS_DENIED);
     }
 }
Esempio n. 10
0
 private function getConfig($path)
 {
     $context = ar::context()->getObject();
     return $context->loadConfig($path);
 }
Esempio n. 11
0
 protected static function getStore()
 {
     $ob = ar::context()->getObject();
     return array($ob, $ob->store->get_filestore("files"));
 }
Esempio n. 12
0
 public function makeURL($path = '', $nls = '', $session = true, $https = null, $keephost = null)
 {
     $context = ar::context();
     $me = $context->getObject();
     return $me->make_url($path, $nls, $session, $https, $keephost);
 }
Esempio n. 13
0
 public static function exists($template)
 {
     // will check if a template with the given name is available to call
     // template has format "library:type::function"
     // FIXME: allow search for specific nls as well
     $context = ar::context()->getObject();
     $templateData = $context->getPinpTemplate($template);
     if (!$templateData || !$templateData['arTemplateId']) {
         return false;
     } else {
         return $templateData;
     }
 }