public function headScriptExhibit($propertyInfo = null)
 {
     if ($propertyInfo == null) {
         // set default info
         $propertyInfo = $this->_defaultPropertyInfo;
     } else {
         if (is_string($propertyInfo)) {
             // transform string to array
             $propertyInfo = array(array('uri' => $propertyInfo));
         } else {
             if (is_array($propertyInfo) && isset($propertyInfo['uri'])) {
                 // transform single level array to multi-hierarchy form
                 $propertyInfo = array($propertyInfo);
             }
         }
     }
     // if we have something completly different as option
     if (!is_array($propertyInfo)) {
         return;
     }
     $description = new Erfurt_Rdf_MemoryModel($this->view->description);
     $resourceUri = $this->view->resourceUri;
     $propertyUri = null;
     $literalMod = null;
     // the main loop to search for a valid property value
     // first hit is taken and every other value is not used
     foreach ($propertyInfo as $info) {
         if (isset($info['uri'])) {
             $propertyUri = $info['uri'];
             $literalMod = isset($info['sprintf']) ? $info['sprintf'] : null;
             // check for exhibit data URI and integrate this as well as exhibit
             if ($description->hasSP($resourceUri, $propertyUri)) {
                 // we've found something, so we can add the exhibit script
                 echo '    <script src="' . $this->_exhibitScript . '" type="text/javascript"></script>' . PHP_EOL;
                 $value = $description->getValue($resourceUri, $propertyUri);
                 if ($literalMod != null) {
                     $value = sprintf($literalMod, $value);
                 }
                 // output the data script and return
                 $type = "application/jsonp";
                 $rel = "exhibit/data";
                 echo '    <link href="' . $value . '" type="' . $type . '" rel="' . $rel . '" ex:jsonp-callback="cb" />';
                 echo PHP_EOL;
                 return;
             }
         }
     }
 }
Beispiel #2
0
 /**
  * read a private config part from a doap Erfurt_Rdf_MemoryModel (recursive)
  *
  * @static
  *
  * @param $memModel
  * @param $bnUri
  * @param $privateNS
  * @param $mapping
  *
  * @return array
  */
 private static function getSubConfig(Erfurt_Rdf_MemoryModel $memModel, $bnUri, $privateNS, $mapping)
 {
     $kv = array();
     $name = $memModel->getValue($bnUri, self::$_owconfigNS . 'id');
     if ($name == null) {
         return array();
     }
     foreach ($memModel->getPO($bnUri) as $key => $values) {
         if ($key == EF_RDF_TYPE || $key == self::$_owconfigNS . 'id') {
             continue;
         }
         if ($key == self::$_owconfigNS . 'config') {
             foreach ($values as $value) {
                 $kv = array_merge($kv, self::getSubConfig($memModel, $value['value'], $privateNS, $mapping));
             }
         } else {
             $mappedKey = self::getPrivateKey($key, $privateNS, $mapping);
             foreach ($values as $value) {
                 $value = self::getValue($value, $memModel);
                 self::addValue($mappedKey, $value, $kv);
             }
         }
     }
     $r = array($name => $kv);
     return $r;
 }