public function action_index() { $this->response->headers('Pragma', 'no-cache'); $resources = new ResourceFactory(); foreach (ORM::factory('visit')->where('processed', '=', 0)->order_by('uri', 'ASC')->order_by('date', 'ASC')->limit(300)->find_all() as $v) { $resources->factory($v); } }
public static function build($id = 0, $resource) { if ($id) { $resource->setId($id); if (!parent::loadByID($resource)) { throw new \Exception('Resource id not found:' . $id); } } return $resource; }
public static function getSmartyInstance() { if (self::$smarty == NULL) { require PHPLIB_DIR . '/smarty/Smarty.class.php'; $smarty = new Smarty(); $smarty->setTemplateDir(SMARTY_TEMPLATE_DIR); $smarty->setCompileDir(SMARTY_COMPILE_DIR); $smarty->setConfigDir(SMARTY_CONFIG_DIR); $smarty->setCacheDir(SMARTY_CACHE_DIR); $smarty->addPluginsDir(SMARTY_PLUGIN_DIR); $smarty->left_delimiter = SMARTY_LEFT_DELIMITER; $smarty->right_delimiter = SMARTY_RIGHT_DELIMITER; self::$smarty = $smarty; } return self::$smarty; }
/** * Constructor for a file in use object. Should normally not be used * directly, use the corresponding factory methods instead. * * @param array $fileReferenceData * @param ResourceFactory $factory * * @throws \RuntimeException * @throws \InvalidArgumentException */ public function __construct(array $fileReferenceData, $factory = null) { $this->propertiesOfFileReference = $fileReferenceData; if (!$fileReferenceData['uid_local']) { throw new \InvalidArgumentException('Incorrect reference to original file given for FileReference.', 1300098528); } if (!$factory) { /** @var $factory ResourceFactory */ $factory = ResourceFactory::getInstance(); } $this->originalFile = $factory->getFileObject($fileReferenceData['uid_local']); if (!is_object($this->originalFile)) { throw new \RuntimeException('Original file not found for FileReference. UID given: "' . $fileReferenceData['uid_local'] . '"', 1300098529); } $this->name = $fileReferenceData['name'] !== '' ? $fileReferenceData['name'] : $this->originalFile->getName(); }
/** * Stamps the current datestamp and ip_address. */ public static function stampResource(\Resource $resource, $action) { $activity = new Activity(); $activity->class_name = $resource->getNamespace(); $activity->resource_id = $resource->getId(); $activity->action = $action; if (\User\Current::isLoggedIn()) { $activity->user_id = \User\Current::getUserId(); } try { $activity->ip_address = \Server::getUserIp(); } catch (Exception $e) { $activity->ip_address = '0.0.0.0'; \Error::log($e); } \ResourceFactory::saveResource($activity); }
public function __construct($controller) { $this->controller = $controller; $this->smarty = ResourceFactory::getSmartyInstance(); }
public static function deleteDevice($device_id, $specific_device_id, $device_type_id) { $systems_device = new Resource(); $systems_device->setId($device_id); if (!parent::loadByID($systems_device)) { throw new \Exception('Cannot load resource. System id not found:' . $device_id); } switch ($device_type_id) { case '1': case '2': $specific_device = new PCResource(); break; case '3': $specific_device = new IPADResource(); break; case '4': $specific_device = new PrinterResource(); break; case '5': $specific_device = new CameraResource(); break; case '6': $specific_device = new DigitalSignResource(); break; } $specific_device->setId($specific_device_id); if (!parent::loadByID($specific_device)) { throw new \Exception('Cannot load specific resource. System id not found:' . $specific_device_id); } if (!SystemDevice::deleteResource($specific_device)) { throw new \Exception('Cannot delete specific resource. Query failed'); } if (!SystemDevice::deleteResource($systems_device)) { throw new \Exception('Cannot delete resource. Query failed'); } }
/** * Saves the current resource object using the ResourceFactory class. * @return object */ public function save() { return ResourceFactory::saveResource($this); }
/** * @param string $type * @param string $identifier * @return Object */ public function persist($type, $identifier) { $class = $this->resolver->getClassForType($type); $args = $this->loader->load($type, $identifier); return $this->factory->buildPersistedObject($class, $type, $args); }