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); }); }
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); }
public static function info($path = null) { if (!isset($path)) { $path = ar::context()->getPath(); } if (self::$enabled) { return ' data-ar-path="' . htmlspecialchars($path) . '"'; } else { return ''; } }
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()); } }
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; }
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"); }
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); } } }
public static function makeRealPath($path = '') { $path = (string) $path; return ar::context()->getPath(array('skipShortcuts' => true, 'path' => $path)); }
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); } }
private function getConfig($path) { $context = ar::context()->getObject(); return $context->loadConfig($path); }
protected static function getStore() { $ob = ar::context()->getObject(); return array($ob, $ob->store->get_filestore("files")); }
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); }
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; } }