Exemplo n.º 1
0
 public function locateObject($slug, $parent = null, $kind = null, $universe = null)
 {
     $query = array();
     $query['limit'] = 1;
     if ($parent !== false) {
         $query['parent'] = $parent;
     }
     if ($kind !== null) {
         $query['kind'] = $kind;
     }
     if ($universe !== null) {
         $query['universe'] = $universe;
     }
     if (null !== ($uuid = UUID::isUUID($slug))) {
         $query['uuid'] = $uuid;
     } else {
         if (strpos($slug, ':') !== false) {
             $query['iri'] = $slug;
         } else {
             $query['tag'] = $slug;
         }
     }
     $rs = $this->query($query);
     foreach ($rs as $obj) {
         return $obj;
     }
     return null;
 }
Exemplo n.º 2
0
 protected function getObject()
 {
     $this->title = $this->object->title;
     $this->crumbName = $this->object->title;
     $this->addCrumb();
     if (null !== ($tag = $this->request->consume())) {
         $obj = null;
         if (null !== ($uuid = UUID::isUUID($tag))) {
             $rs = $this->model->query(array('uuid' => $uuid, 'parent' => $this->object->uuid));
             $obj = $rs->next();
         } else {
             $rs = $this->model->query(array('tag' => $tag, 'parent' => $this->object->uuid));
             $obj = $rs->next();
         }
         if (!$obj) {
             return $this->error(Error::OBJECT_NOT_FOUND);
         }
         switch ($obj->kind) {
             case 'episode':
                 require_once dirname(__FILE__) . '/browse-episode.php';
                 $inst = new MediaBrowseEpisode();
                 $inst->object = $obj;
                 $inst->process($this->request);
                 return false;
         }
         print_r($obj);
         die('-- unhandled object --');
     }
     $this->object->merge();
     $this->episodes = $this->model->query(array('kind' => 'episode', 'parent' => $this->object->uuid));
     if ($this->episodes->EOF) {
         $this->episodes = null;
     }
     return true;
 }
Exemplo n.º 3
0
 public function verify()
 {
     $model = self::$models[get_class($this)];
     if (isset($this->show)) {
         if (null !== ($uuid = UUID::isUUID($this->show)) || null !== ($uuid = $model->uuidForCurie($this->show))) {
             $this->referenceObject('show', $uuid);
         } else {
             return "Referenced show '" . $this->show . "' does not exist yet.";
         }
     }
     return parent::verify();
 }
Exemplo n.º 4
0
 public function verify()
 {
     $model = self::$models[get_class($this)];
     if (isset($this->episode)) {
         if (null !== ($uuid = UUID::isUUID($this->episode)) || null !== ($uuid = $model->uuidForCurie($this->episode))) {
             $this->referenceObject('episode', $uuid);
         } else {
             return "Referenced episode '" . $this->episode . "' does not exist yet.";
         }
     }
     if (true !== ($r = $this->verifyCredits())) {
         return $r;
     }
     return parent::verify();
 }
Exemplo n.º 5
0
 protected function getObject()
 {
     if (null === ($tag = $this->request->consume())) {
         return true;
     }
     if ($uuid = UUID::isUUID($tag)) {
         $this->object = $this->model->objectForUUID($uuid);
     } else {
         $this->object = $this->model->locateObject($tag);
     }
     if ($this->object) {
         if ($this->object instanceof Episode) {
             if (isset($this->object->series) || isset($this->object->show)) {
                 $this->request->redirect($this->request->base . $this->object->relativeURI);
                 return false;
             }
             require_once dirname(__FILE__) . '/browse-episode.php';
             $inst = new MediaBrowseEpisode();
             $inst->object = $this->object;
             $inst->process($this->request);
             return false;
         }
         if ($this->object instanceof Show) {
             if ($this->object->kind == 'series') {
                 $this->request->redirect($this->request->base . $this->object->relativeURI);
             }
             require_once dirname(__FILE__) . '/browse-show.php';
             $inst = new MediaBrowseShow();
             $inst->object = $this->object;
             $inst->process($this->request);
             return false;
         }
         if ($this->object instanceof Scheme) {
             require_once dirname(__FILE__) . '/browse-classes.php';
             $inst = new MediaBrowseClasses();
             $inst->object = $this->object;
             $inst->process($this->request);
             return false;
         }
         print_r($this->object);
         die;
     }
     return $this->error(Error::OBJECT_NOT_FOUND);
 }
Exemplo n.º 6
0
 protected function writeRDFResource($tag, $uri, $fragment)
 {
     if (UUID::isUUID($uri)) {
         /* Fetch target */
     } else {
         if (substr($uri, 0, 1) == '/') {
             writeLn('<' . $tag . ' rdf:resource="' . _e($uri . '#' . $fragment) . '" />');
         } else {
             writeLn('<' . $tag . ' rdf:resource="' . _e($uri) . '" />');
         }
     }
 }
Exemplo n.º 7
0
 protected function rdfReference($uri, $request, $fragment = null, $all = false)
 {
     if (strlen($fragment)) {
         $fragment = '#' . $fragment;
     }
     if (null !== ($uuid = UUID::isUUID($uri))) {
         /* Fetch target */
         $obj = self::$models[get_class($this)]->objectForUUID($uuid);
         if ($all) {
             $list = array();
             while ($obj && $obj->kind != 'scheme') {
                 $list[] = new RDFURI($request->base . $obj->__get('instanceRelativeURI'));
                 $obj = $obj['parent'];
             }
             return $list;
         }
         return new RDFURI($request->base . $obj->__get('instanceRelativeURI'));
     }
     if (substr($uri, 0, 1) == '/') {
         return new RDFURI($uri . $fragment);
     }
     return new RDFURI($uri);
 }
Exemplo n.º 8
0
 public function verify()
 {
     if (true !== ($r = parent::verify())) {
         return $r;
     }
     $model = self::$models[get_class($this)];
     if (!isset($this->parent)) {
         $this->parent = null;
     }
     if (!isset($this->iri)) {
         $this->iri = null;
     }
     $cs = $model->locateObject('[scheme:' . $this->kind . ']', null, 'scheme');
     $this->referenceObject('scheme', $cs);
     if (!isset($this->fragment)) {
         $this->fragment = $cs->singular;
     }
     $root = '/' . $cs->relativeURI;
     $parent = $this->parent;
     if (substr($parent, 1, 0) == '/') {
         $parent = substr($parent, 1);
     }
     if (!strncmp($parent, $root, strlen($root))) {
         $parent = substr($parent, strlen($root));
     }
     if (strlen($parent)) {
         if (null === ($uuid = UUID::isUUID($parent))) {
             $uuid = $model->createClassificationPath($cs, $parent);
         }
         if (null === $uuid && strlen($parent)) {
             return 'Referenced parent path "' . $this->parent . '" is invalid';
         }
     } else {
         $this->parent = $parent = null;
         $uuid = $cs->uuid;
     }
     $this->referenceObject('parent', $uuid);
     if (!isset($this->slug) || !strlen($this->slug)) {
         $this->slug = $this->uuid;
     }
     $p = $this->parent;
     $uri = array($this->slug);
     $ancestors = array();
     while ($p !== null) {
         $ancestors[] = $p;
         $data = $model->dataForUUID($p);
         array_unshift($uri, $data['slug']);
         $p = isset($data['parent']) ? $data['parent'] : null;
     }
     $this->relativeURI = implode('/', $uri);
     $this->iri[] = $root . implode('/', $uri);
     $this->ancestors = $ancestors;
     return true;
 }