Example #1
0
 /**
  * Constructor
  *
  * @param \SimpleXMLElement|string $data
  * @throws InvalidArgumentException
  */
 public function __construct($data)
 {
     if ($data instanceof SimpleXMLElement) {
         $this->xml = $data;
     } else {
         if (is_string($data)) {
             $this->xml = new SimpleXMLElement($data);
         } else {
             throw new InvalidArgumentException(sprintf('Invalid data type for NcxResource'));
         }
     }
     $this->namespaces = $this->xml->getNamespaces(true);
 }
 function setIdentifier($form_values)
 {
     require_once drupal_get_path('module', 'Fedora_Repository') . '/ObjectHelper.php';
     require_once drupal_get_path('module', 'Fedora_Repository') . '/CollectionClass.php';
     $collectionHelper = new CollectionClass();
     $ppid = $_SESSION['pid'];
     $itqlquery = 'select $object from <#ri> where $object <fedora-rels-ext:isPartOf><info:fedora/' . $ppid . '> and $object <fedora-rels-ext:isMemberOfCollection><info:fedora/vre:mnpl-compounds>and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
     $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlquery);
     $sxe = new SimpleXMLElement($relatedItems);
     $nmspace = $sxe->getNamespaces(true);
     $regspace = $sxe->registerXPathNamespace('ri', implode($nmspace));
     $link = $sxe->xpath('//@uri');
     $labid = $_SESSION['labid'];
     if (empty($link)) {
         $ident = $labid . '-C-0';
     } else {
         //loop through returns , trim to create identifier and increment highest value
         $xia = array();
         foreach ($link as $path) {
             $path1 = substr($path, '30');
             $path2 = strrchr($path1, "-");
             $path = str_replace($path2, '', $path1);
             $xi = ltrim($path2, "-");
             $xnew = array_push($xia, $xi);
         }
         $num = max($xia);
         $numinc = $num + 1;
         $ident = $labid . '-C-' . $numinc;
     }
     return $ident;
 }
 public function authenticate($ticket, $service)
 {
     $r = \Httpful\Request::get($this->getValidateUrl($ticket, $service))->sendsXml()->timeoutIn($this->timeout)->send();
     $r->body = str_replace("\n", "", $r->body);
     // var_dump($r->body);
     try {
         $xml = new \SimpleXMLElement($r->body);
     } catch (\Exception $e) {
         throw new \Exception("Return cannot be parsed :\n {$r->body}", 1);
     }
     $namespaces = $xml->getNamespaces();
     $serviceResponse = $xml->children($namespaces['cas']);
     $user = $serviceResponse->authenticationSuccess->user;
     if ($user) {
         return (string) $user;
         // cast simplexmlelement to string
     } else {
         $authFailed = $serviceResponse->authenticationFailure;
         if ($authFailed) {
             $attributes = $authFailed->attributes();
             throw new \Exception("AuthenticationFailure : " . $attributes['code'] . " ({$ticket}, {$service})", 1);
         } else {
             throw new \Exception("Cas return is weird : '{$r->body}'", 1);
         }
     }
     // never reach there
 }
Example #4
0
    function validate_operations()
    {
        foreach ($this->calendar_users as $user) {
            $url = str_replace("#USER#", $user['user'], $this->calendar_url);
            $this->caldav = new CalDAVClient($url, trim($user['user']), trim($user['pass']), 'basic', false);
            //for debug = true
            $xmlC = <<<PROPP
<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:" xmlns:C="http://calendarserver.org/ns/">
     <D:prop>
             <D:displayname />
             <C:getctag />
             <D:resourcetype />
     </D:prop>
 </D:propfind>
PROPP;
            try {
                $this->caldav->SetDepth(1);
                $xml_response = $this->caldav->DoXMLRequest("PROPFIND", $xmlC);
                $xml_response = explode("\r\n\r\n", $xml_response)[1];
                $xml = new SimpleXMLElement($xml_response);
                $ns = $xml->getNamespaces(true);
                $responses = $xml->children($ns["d"]);
                $this->set_status(ok);
                $this->add_functional("calendar list events of " . $user['user'] . "(" . count($responses) . ")", ok);
            } catch (Exception $x) {
                $this->set_status(error);
                $this->add_message($x->getMessage());
                $fullerror = "url:" . $url . " " . $x->getMessage();
                error_log($fullerror);
                $this->add_functional("calendar list events of " . $user['user'], error, "Can't list events from {$url}");
            }
        }
    }
Example #5
0
 private function parseMaps(\SimpleXMLElement $xml)
 {
     $maps = array();
     if (array_key_exists('maps', $this->mapping)) {
         foreach ($this->mapping['maps'] as $key => $item) {
             /* --- XML NS --- */
             if ('MobileRelatedApps' == $this->name) {
                 /** @var $element \SimpleXMLElement */
                 $element = $xml->{'RelatedApps'};
                 $ns = $xml->getNamespaces(true);
                 $map = array();
                 foreach ($element->children($ns['d2p1']) as $element) {
                     $map[(string) $element->{$item['xml']['key']}] = (string) $element->{$item['xml']['value']};
                 }
                 $maps[$key] = $map;
                 continue;
             }
             /* --- XML NS --- */
             $map = array();
             $parts = explode('.', $item['xml']['field']);
             $items = array();
             if (2 == count($parts)) {
                 $items = $xml->{$parts[0]}->{$parts[1]};
             }
             foreach ($items as $element) {
                 $map[(string) $element->{$item['xml']['key']}] = (string) $element->{$item['xml']['value']};
             }
             $maps[$key] = $map;
         }
     }
     return $maps;
 }
Example #6
0
 function __construct(SimpleXMLElement $node, $namespaces = null)
 {
     $this->__name = $node->getName();
     $this->__value = $node;
     if ($namespaces === null) {
         $namespaces = $node->getNamespaces(true);
     }
     foreach ($namespaces as $ns => $uri) {
         foreach ($node->children($uri) as $child) {
             $childName = $ns ? "{$ns}:" . $child->getName() : $child->getName();
             if (array_key_exists($childName, $this->__children) && is_array($this->__children[$childName])) {
                 $this->__children[$childName][] = new clNode($child, $namespaces);
             } else {
                 if (array_key_exists($childName, $this->__children) && get_class($this->__children[$childName]) == "clNode") {
                     $childArray = array();
                     $childArray[] = $this->__children[$childName];
                     $childArray[] = new clNode($child, $namespaces);
                     $this->__children[$childName] = $childArray;
                 } else {
                     $this->__children[$childName] = new clNode($child, $namespaces);
                 }
             }
         }
         foreach ($node->attributes($ns) as $a) {
             $a = $a->asXML();
             @(list($name, $value) = split('=', $a));
             $this->__attributes[trim($name)] = substr($value, 1, strlen($value) - 2);
         }
     }
 }
Example #7
0
 /**
  * Method to parse the feed into a JFeed object.
  *
  * @return  JFeed
  *
  * @since   12.3
  */
 public function parse()
 {
     $feed = new JFeed();
     // Detect the feed version.
     $this->initialise();
     // Let's get this party started...
     do {
         // Expand the element for processing.
         $el = new SimpleXMLElement($this->stream->readOuterXml());
         // Get the list of namespaces used within this element.
         $ns = $el->getNamespaces(true);
         // Get an array of available namespace objects for the element.
         $namespaces = array();
         foreach ($ns as $prefix => $uri) {
             // Ignore the empty namespace prefix.
             if (empty($prefix)) {
                 continue;
             }
             // Get the necessary namespace objects for the element.
             $namespace = $this->fetchNamespace($prefix);
             if ($namespace) {
                 $namespaces[] = $namespace;
             }
         }
         // Process the element.
         $this->processElement($feed, $el, $namespaces);
         // Skip over this element's children since it has been processed.
         $this->moveToClosingElement();
     } while ($this->moveToNextElement());
     return $feed;
 }
 /**
  * Get a specific attribute in a namespaced tag
  * @param  \SimpleXMLElement $xml            
  * @param  string $attributeFocus 
  * @param  string $namespaceFocus 
  * @param  string $tagFocus       
  * @return string 
  */
 public static function extractAttributeFromXml($xml, $attributeFocus, $namespaceFocus, $tagFocus)
 {
     $namespace = $xml->getNamespaces(true);
     $attributes = $xml->children($namespace[$namespaceFocus])->{$tagFocus}->attributes();
     $finalAttribute = $attributes[$attributeFocus];
     return $finalAttribute->__toString();
 }
Example #9
0
 public static function xmlToArray(\SimpleXMLElement $xml, $options = [])
 {
     $defaults = ['namespaceSeparator' => ':', 'attributePrefix' => '@', 'alwaysArray' => [], 'autoArray' => true, 'textContent' => '_v_', 'autoText' => true, 'keySearch' => false, 'keyReplace' => false];
     $options = array_merge($defaults, $options);
     $namespaces = $xml->getNamespaces(true);
     $namespaces[''] = null;
     //add base (empty) namespace
     //get attributes from all namespaces
     $attributesArray = [];
     foreach ($namespaces as $prefix => $namespace) {
         foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
             //replace characters in attribute name
             if ($options['keySearch']) {
                 $attributeName = str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
             }
             $attributeKey = $options['attributePrefix'] . ($prefix ? $prefix . $options['namespaceSeparator'] : '') . $attributeName;
             $attributesArray[$attributeKey] = (string) $attribute;
         }
     }
     //get child nodes from all namespaces
     $tagsArray = [];
     foreach ($namespaces as $prefix => $namespace) {
         foreach ($xml->children($namespace) as $childXml) {
             //recurse into child nodes
             $childArray = self::xmlToArray($childXml, $options);
             list($childTagName, $childProperties) = each($childArray);
             //replace characters in tag name
             if ($options['keySearch']) {
                 $childTagName = str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
             }
             //add namespace prefix, if any
             if ($prefix) {
                 $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
             }
             if (!isset($tagsArray[$childTagName])) {
                 //only entry with this key
                 //test if tags of this type should always be arrays, no matter the element count
                 $tagsArray[$childTagName] = in_array($childTagName, $options['alwaysArray']) || !$options['autoArray'] ? [$childProperties] : $childProperties;
             } elseif (is_array($tagsArray[$childTagName]) && array_keys($tagsArray[$childTagName]) === range(0, count($tagsArray[$childTagName]) - 1)) {
                 //key already exists and is integer indexed array
                 $tagsArray[$childTagName][] = $childProperties;
             } else {
                 //key exists so convert to integer indexed array with previous value in position 0
                 $tagsArray[$childTagName] = [$tagsArray[$childTagName], $childProperties];
             }
         }
     }
     //get text content of node
     $textContentArray = [];
     $plainText = trim((string) $xml);
     if ($plainText !== '') {
         $textContentArray[$options['textContent']] = $plainText;
     }
     //stick it all together
     $propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || $plainText === '' ? array_merge($attributesArray, $tagsArray, $textContentArray) : $plainText;
     //return node as array
     return [$xml->getName() => $propertiesArray];
 }
Example #10
0
 /**
  * Convert SimpleXMLElement to multidimensional array.
  *
  * @param \SimpleXMLElement $xml
  * @param string            $namespace The namespace that schould be used.
  *
  * @throws \OutOfBoundsException If namespace not found in the xml.
  * @return array
  */
 public static function toArray(\SimpleXMLElement $xml, $namespace = null)
 {
     if ($namespace !== null) {
         $namespaces = $xml->getNamespaces();
         if (false === isset($namespaces[$namespace])) {
             throw new \OutOfBoundsException('namespace [' . $namespace . '] not found');
         }
         $xml = $xml->children($namespaces[$namespace]);
     }
     return Json::decode(Json::encode($xml), true);
 }
 public function watchFolder(KalturaDropFolder $dropFolder)
 {
     /* @var $dropFolder KalturaFeedDropFolder */
     KalturaLog::info("Watching drop folder with ID [" . $dropFolder->id . "]");
     $this->dropFolder = $dropFolder;
     //Get Drop Folder feed and import it into a SimpleXMLElement
     $feed = new SimpleXMLElement(file_get_contents($dropFolder->path));
     $this->feedNamespaces = $feed->getNamespaces(true);
     //get items
     $feedItems = $feed->xpath($this->dropFolder->feedItemInfo->itemXPath);
     if ($this->dropFolder->itemHandlingLimit > 0 && count($feedItems) > $this->dropFolder->itemHandlingLimit) {
         KalturaLog::err("Reached pulling limit for drop folder ID [" . $this->dropFolder->id . "].");
         array_splice($feedItems, $this->dropFolder->itemHandlingLimit);
         $dropFolderUpdate = new KalturaFeedDropFolder();
         $dropFolderUpdate->errorDescription = FeedDropFolderPlugin::ERROR_MESSAGE_INCOMPLETE_HANDLING . $this->dropFolder->id;
         $this->dropFolderPlugin->dropFolder->update($this->dropFolder->id, $dropFolderUpdate);
     }
     $existingDropFolderFilesMap = $this->loadDropFolderFiles();
     $counter = 0;
     foreach ($feedItems as $feedItem) {
         if ($counter > intval(KBatchBase::$taskConfig->params->mrss->limitProcessEachRun)) {
             KalturaLog::info('Finished current run.');
             break;
         }
         /* @var $feedItem SimpleXMLElement */
         $uniqueId = strval($this->getSingleXPathResult($this->dropFolder->feedItemInfo->itemUniqueIdentifierXPath, $feedItem));
         //If we already encountered this uniqueId in this run- ignore subsequent iterations.
         if (in_array($uniqueId, $this->handledUniqueIds)) {
             KalturaLog::err("The unique identifer value [{$uniqueId}] was encountered before during this scan of the feed. Ignoring.");
             continue;
         }
         // The unique feed item identifier is the GUID, so that is what we set as the drop folder file name.
         if (!array_key_exists($uniqueId, $existingDropFolderFilesMap)) {
             //In this case, we are required to add this item as a new drop folder file
             KalturaLog::info("Item not found in drop folder file list- adding as new drop folder file.");
             $this->handleItemAdded($uniqueId, $feedItem);
             $counter++;
         } else {
             KalturaLog::info("Item found in drop folder file list- adding as existing drop folder file.");
             $dropFolderFile = $existingDropFolderFilesMap[$uniqueId];
             unset($existingDropFolderFilesMap[$uniqueId]);
             //if file exist in the folder remove it from the map
             //all the files that are left in a map will be marked as PURGED
             if ($this->handleExistingItem($dropFolderFile, $feedItem)) {
                 $counter++;
             }
         }
         $this->handledUniqueIds[] = $uniqueId;
     }
     foreach ($existingDropFolderFilesMap as $existingDropFolderFile) {
         $this->handleFilePurged($existingDropFolderFile->id);
     }
 }
Example #12
0
 /**
  * @return string[] The attributes
  */
 public function getAttributes()
 {
     //include namespace declarations as attributes
     $xmlnsRaw = $this->_element->getNamespaces();
     $xmlns = array();
     foreach ($xmlnsRaw as $key => $val) {
         $label = 'xmlns' . ($key ? ":{$key}" : $key);
         $xmlns[$label] = $val;
     }
     //get attributes and merge with namespaces
     $attrRaw = $this->_element->attributes();
     $attr = array();
     foreach ($attrRaw as $key => $val) {
         $attr[$key] = $val;
     }
     $attr = array_merge((array) $xmlns, (array) $attr);
     $result = array();
     foreach ($attr as $key => $val) {
         $result[$key] = (string) $val;
     }
     return $result;
 }
 private function getStatus($type, $path, $response)
 {
     $data = new \SimpleXMLElement($response);
     $namespaces = $data->getNamespaces(true);
     foreach ($namespaces as $key => $value) {
         $namespace = $value;
     }
     $data->registerXPathNamespace($type, $namespace);
     foreach ($data->xpath($path) as $value) {
         $status = json_decode(json_encode((array) $value), TRUE);
     }
     return $status;
 }
 public function getBillingAgreementDetailsStatus($response)
 {
     $data = new \SimpleXMLElement($response);
     $namespaces = $data->getNamespaces(true);
     foreach ($namespaces as $key => $value) {
         $namespace = $value;
     }
     $data->registerXPathNamespace('GetBA', $namespace);
     foreach ($data->xpath('//GetBA:BillingAgreementStatus') as $value) {
         $baStatus = json_decode(json_encode((array) $value), TRUE);
     }
     return $baStatus;
 }
Example #15
0
 public static function fromSimpleXMLElement(SimpleXMLElement $element)
 {
     // Traverse all existing namespaces in element.
     $namespaces = $element->getNamespaces();
     foreach ($namespaces as $prefix => $ns) {
         $element[$prefix === '' ? 'xmlns' : 'xmlns:' . $prefix] = $ns;
     }
     /* Create a new parser with the xml document where the namespace definitions
      * are added.
      */
     $parser = new SimpleSAML_XML_Parser($element->asXML());
     return $parser;
 }
Example #16
0
 /**
  * Attach $child to $parent.  Adapted from function defined in PHP docs here:
  *      http://www.php.net/manual/en/class.simplexmlelement.php#99071
  *
  * @param SimpleXMLElement $parent Parent element to modify
  * @param SimpleXMLElement $child  Child element to attach
  *
  * @return void
  */
 public static function appendElement($parent, $child)
 {
     // get all namespaces for document
     $namespaces = $child->getNamespaces(true);
     // check if there is a default namespace for the current node
     $currentNs = $child->getNamespaces();
     $defaultNs = count($currentNs) > 0 ? current($currentNs) : null;
     $prefix = count($currentNs) > 0 ? current(array_keys($currentNs)) : '';
     $childName = strlen($prefix) > 1 ? $prefix . ':' . $child->getName() : $child->getName();
     // check if the value is string value / data
     if (trim((string) $child) == '') {
         $element = $parent->addChild($childName, null, $defaultNs);
     } else {
         $element = $parent->addChild($childName, htmlspecialchars((string) $child), $defaultNs);
     }
     foreach ($child->attributes() as $attKey => $attValue) {
         $element->addAttribute($attKey, $attValue);
     }
     foreach ($namespaces as $nskey => $nsurl) {
         foreach ($child->attributes($nsurl) as $attKey => $attValue) {
             $element->addAttribute($nskey . ':' . $attKey, $attValue, $nsurl);
         }
     }
     // add children -- try with namespaces first, but default to all children
     // if no namespaced children are found.
     $children = 0;
     foreach ($namespaces as $nskey => $nsurl) {
         foreach ($child->children($nsurl) as $currChild) {
             self::appendElement($element, $currChild);
             $children++;
         }
     }
     if ($children == 0) {
         foreach ($child->children() as $currChild) {
             self::appendElement($element, $currChild);
         }
     }
 }
Example #17
0
 function Svg($svg)
 {
     $xml = new SimpleXMLElement($svg, 1, 1);
     $this->width = (string) $xml['width'];
     $this->height = (string) $xml['height'];
     $this->id = (string) $xml['id'];
     $this->version = (string) $xml['version'];
     $this->namespaces = $xml->getNamespaces();
     $sodipodi = $xml->attributes($this->namespaces['sodipodi']);
     $this->docname = (string) $sodipodi['docname'];
     $this->docbase = (string) $sodipodi['docbase'];
     $this->sodipodiversion = (string) $sodipodi['version'];
     $inkscape = $xml->attributes($this->namespaces['inkscape']);
     $this->inkscapeversion = (string) $inkscape['version'];
     $this->output_extension = (string) $inkscape['ouput_extension'];
 }
Example #18
0
 static function fromResponse($string)
 {
     $xml = new \SimpleXMLElement($string);
     $ns = $xml->getNamespaces(true);
     $soap = $xml->children($ns['soap']);
     $body = $soap->Body->children($ns['soap']);
     if (isset($body->Fault)) {
         $fault = $body->Fault->children();
         $exception = new ServerException((string) $fault->faultstring);
         $exception->faultcode = (string) $fault->faultcode;
         $exception->faultstring = (string) $fault->faultstring;
         $exception->faultactor = (string) $fault->faultactor;
     } else {
         throw new Exception('Invalid server response');
     }
     return $exception;
 }
function add_mods_namespace(SimpleXMLElement &$mods)
{
    static $used_namespace = NULL;
    static $mods_namespace = 'http://www.loc.gov/mods/v3';
    $namespaces = $mods->getNamespaces();
    if (is_null($used_namespace)) {
        if (array_search($mods_namespace, $namespaces) !== FALSE) {
            //The namespace is there; possibly default, though
            $used_namespace = $mods_namespace;
        } else {
            $used_namespace = '';
        }
    }
    if (array_key_exists('mods', $namespaces) === FALSE) {
        $mods->registerXPathNamespace('mods', $used_namespace);
    }
}
Example #20
0
function cfdi_reader($xml_data)
{
    $xml = new SimpleXMLElement($xml_data);
    // if is a CFDI
    echo 'validating';
    if (array_key_exists("cfdi", $xml->getNamespaces())) {
        print_r($xml->attributes()->fecha);
        $date = (string) $xml->attributes()->fecha;
        $children = $xml->children("cfdi", true);
        print_r($children->Emisor->attributes()->nombre);
        foreach ($children->Conceptos->children("cfdi", true) as $value) {
            $values = $value->attributes();
            $data = array("code" => (string) $values->noIdentificacion, "concept" => (string) $values->descripcion, "amount" => (string) $values->importe, "source" => "CFDI " . $children->Emisor->attributes()->nombre, "date" => $date);
            print_r($data);
            # code...
        }
    }
}
Example #21
0
 public static function parseElement(SimpleXMLElement $element, array $options = array())
 {
     $options += array('simplify' => TRUE, 'namespaces' => $element->getNamespaces(TRUE));
     $result = array();
     $result['key'] = $element->getName();
     if (!empty($options['prefix'])) {
         $result['key'] = $options['prefix'] . ':' . $result['key'];
     }
     foreach ($element->attributes() as $attribute_key => $attribute_value) {
         $result['attributes'][$attribute_key] = (string) $attribute_value;
     }
     if (!empty($options['namespaces'])) {
         foreach (array_keys($options['namespaces']) as $namespace) {
             foreach ($element->attributes($namespace, TRUE) as $attribute_key => $attribute_value) {
                 $result['attributes'][$namespace . ':' . $attribute_key] = (string) $attribute_value;
             }
         }
     }
     $children = array();
     foreach ($element->children() as $child) {
         $children[] = static::parseElement($child, $options);
     }
     if (!empty($options['namespaces'])) {
         foreach (array_keys($options['namespaces']) as $namespace) {
             foreach ($element->children($namespace, TRUE) as $child) {
                 $children[] = static::parseElement($child, array('prefix' => $namespace) + $options);
             }
         }
     }
     if (!empty($children)) {
         if (!empty($options['simplify'])) {
             static::simplifyElements($children);
         }
         $result['value'] = $children;
     } else {
         $result['value'] = (string) $element;
         if (!empty($options['simplify'])) {
             $result['value'] = trim($result['value']);
         }
     }
     return $result;
 }
Example #22
0
$xml=<<<XML
<?xml version="1.0" standalone="yes"?>
<cars xmlns:c="http://w3schools.com/ns" xmlns:a="http://w3schools.com/country">
  <c:car id="1">Volvo</c:car>
  <c:car id="2">BMW</c:car>
  <c:car id="3">Saab</c:car>
</cars>
XML;

$sxe = new SimpleXMLElement($xml);
$ns = $sxe->getNamespaces(true);
var_dump($ns);
?> 


<?php
echo "<br/><br/>";
$xml = <<<XML
<?xml version="1.0" standalone="yes"?>
<people xmlns:t="http://example.org/ns" xmlns:o="http://example.org/test">
    <t:person id="1">John Doe</t:person>
    <t:person id="2">Susie Q. Public</t:person>
</people>
XML;
 
$sxe = new SimpleXMLElement($xml);

$namespaces = $sxe->getNamespaces(TRUE);
var_dump($namespaces);

?>
Example #23
0
 /**
  * Search items from XML.
  *
  * @param \SimpleXMLElement $items
  *
  * @return array
  */
 protected static function getRssItems(\SimpleXMLElement $items)
 {
     $rssItems = [];
     $namespaces = $items->getNamespaces(true);
     foreach ($items as $item) {
         $rssItem = ['url' => null, 'originUrl' => null, 'pubdate' => null];
         $rssItem['url'] = (string) $item->link;
         $rssItem['originUrl'] = (string) $item->origLink ?: (string) $item->comments;
         $rssItem['pubdate'] = (string) $item->pubdate ?: (string) $item->pubDate;
         if (!$rssItem['pubdate'] && isset($namespaces['dc']) && ($children = $item->children($namespaces['dc']))) {
             $rssItem['pubdate'] = (string) $children->date;
         }
         if (!$rssItem['originUrl'] && isset($namespaces['feedburner']) && ($children = $item->children($namespaces['feedburner']))) {
             $rssItem['originUrl'] = (string) $children->origLink;
         }
         if ($rssItem['url']) {
             $rssItems[] = $rssItem;
         }
     }
     return $rssItems;
 }
Example #24
0
 /**
  * Constructs an Album object.  
  * When called, this method will fill out each private member	
  * of the Album object based on XML returned from Picasa's Atom feed.  It will also create
  * a Picasa_Image object for each image in the Album by passing XML for each image into 
  * the Picasa_Image constructor.	
  *
  * @param string $url   The URL of the Picasa query to retrieve the XML from.  See
  *                      http://code.google.com/apis/picasaweb/gdata.html for information on
  *                      how to format the URL.  If null, it is assumed that $albums param
  *                      has been supplied.
  * @param SimpleXMLElement $albums  XML for constructing the object.  If null, it is assumed that the 
  *                                  URL to the Atom feed has been supplied.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See 
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $xmldata = false;
         $context = null;
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         if ($contextArray !== null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for key " . $url);
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
         // I'm not sure why there's a difference, but the icon is given in different ways
         // depending on if the document is just for an Album or if it's part of a larger document
         $this->icon = $albums->icon;
     }
     // Whether or not the contextArray is null, it should be set.
     $this->contextArray = $contextArray;
     if ($albums != null) {
         $namespaces = $albums->getNamespaces(true);
         $this->picasaAuthor = new Picasa_Author($albums->author);
         $this->editLink = null;
         $link = $albums->link[0];
         $i = 0;
         while ($link != null) {
             $attributes = $albums->link[$i]->attributes();
             if (strcmp($attributes["rel"], "edit") == 0) {
                 $this->editLink = $attributes["href"];
                 break;
             } else {
                 if (strcmp($attributes["rel"], "alternate") == 0) {
                     $this->weblink = $attributes["href"];
                 }
             }
             $i++;
             $link = $albums->link[$i];
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->location = $gphoto_ns->location;
             $this->idnum = $gphoto_ns->id;
             $this->numphotos = $gphoto_ns->numphotos;
             $this->photosRemaining = $gphoto_ns->numphotosremaining;
             $this->bytesUsed = $gphoto_ns->bytesUsed;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             $this->numComments = $gphoto_ns->commentCount;
             $this->timestamp = $gphoto_ns->timestamp;
             // The picasaAuthor field must be set before this line is executed
             if ($this->picasaAuthor->getUser() == null || strcmp($this->picasaAuthor->getUser(), "") == 0) {
                 $this->picasaAuthor->setUser($gphoto_ns->user);
             }
         }
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             // As stated above, this is to account for the different placement of icon
             if ($url === null) {
                 $thumbAtt = $media_ns->group->thumbnail->attributes();
                 $this->icon = $thumbAtt["url"];
             }
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = $georss_ns->children($namespaces["gml"]);
             $this->gmlPosition = @$gml_ns->Point->pos;
         }
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         $this->published = $albums->published;
         $this->summary = $albums->summary;
         $this->rights = $albums->rights;
         $this->author = $albums->author->name;
         $this->subtitle = $albums->subtitle;
         $this->comments = null;
         $this->images = array();
         $i = 0;
         //Create a new Image object for each Image element
         foreach ($albums->entry as $images) {
             $this->images[$i] = new Picasa_Image(null, $images);
             $i++;
         }
     }
 }
Example #25
0
 function handleSpecimenEditForm($form_id, $form_values, $soap_client)
 {
     // ======================================
     // = begin creation of foxml dom object for critter/specimen stream=
     // ======================================
     module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
     $objectHelper = new ObjectHelper();
     $critterStream = $objectHelper->getStream($form_values['pid'], 'CRITTER', true);
     $sxec = new SimpleXMLElement($critterStream);
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     ///begin writing critter datastream
     $spec = $dom->createElement("critters:sample");
     $spec->setAttribute('xmlns:critters', "http://vre.upei.ca/critters/");
     $spec->setAttribute('name', implode($sxec->xpath('//@name')));
     // critter sample (root) elements
     $date = $dom->createElement("critters:date_collected", $form_values['date']);
     $size = $dom->createElement("critters:samplesize", implode($sxec->xpath('//critters:samplesize')));
     $lab_id = $dom->createElement("critters:lab_id", implode($sxec->xpath('//critters:lab_id')));
     $type = $dom->createElement("critters:type", $form_values['type']);
     $desc = $dom->createElement("critters:description", implode($sxec->xpath('//critters:description')));
     $spec->appendChild($lab_id);
     $spec->appendChild($type);
     $spec->appendChild($date);
     $spec->appendChild($size);
     $spec->appendChild($desc);
     //critter taxonomy elements
     $taxon = $dom->createElement("critters:taxonomy");
     $phylum = $dom->createElement("critters:phylum", $form_values['phylum']);
     $subphylum = $dom->createElement("critters:subPhylum", $form_values['subphylum']);
     $class = $dom->createElement("critters:class", $form_values['class']);
     $order = $dom->createElement("critters:order", $form_values['order']);
     $family = $dom->createElement("critters:family", $form_values['family']);
     $genus = $dom->createElement("critters:genus", $form_values['genus']);
     $species = $dom->createElement("critters:species", $form_values['species']);
     $taxon->appendChild($phylum);
     $taxon->appendChild($subphylum);
     $taxon->appendChild($class);
     $taxon->appendChild($order);
     $taxon->appendChild($family);
     $taxon->appendChild($genus);
     $taxon->appendChild($species);
     // critter photos
     $photos = $dom->createElement("critters:photos");
     $photos->setAttribute('quantity', implode($sxec->xpath('//@quantity')));
     foreach ($sxec->xpath('//@id') as $idkey => $photo) {
         $image = $dom->createElement("critters:photo");
         $image->setAttribute('id', $photo);
         foreach ($sxec->xpath('//critters:location') as $key => $value) {
             if ($key == $idkey) {
                 $location = $dom->createElement("critters:location", $value);
                 $image->appendChild($location);
             }
         }
         $photos->appendChild($image);
     }
     // critter site elements
     $site = $dom->createElement("critters:site");
     $sitename = $dom->createElement("critters:sitename", $form_values['sitename']);
     $country = $dom->createElement("critters:country", $form_values['country']);
     $region = $dom->createElement("critters:region", $form_values['region']);
     $latitude = $dom->createElement("critters:latitude", $form_values['latitude']);
     $longitude = $dom->createElement("critters:longitude", $form_values['longitude']);
     $depth = $dom->createElement("critters:depth", $form_values['depth']);
     $site->appendChild($sitename);
     $site->appendChild($country);
     $site->appendChild($region);
     $site->appendChild($latitude);
     $site->appendChild($longitude);
     $site->appendChild($depth);
     // critter collectors
     $collectors = $dom->createElement("critters:collectors");
     foreach ($sxec->xpath('//critters:collector') as $individual) {
         $collector = $dom->createElement("critters:collector", $individual);
         $collectors->appendChild($collector);
     }
     // append nested elements
     $spec->appendChild($taxon);
     $spec->appendChild($photos);
     $spec->appendChild($site);
     $spec->appendChild($collectors);
     $dom->appendChild($spec);
     $newxml = $dom->saveXML();
     // map critter form elements to DC stream
     // loop through taxonomy to create label pulled from dctitle
     if ($form_values['species'] != '' and $form_values['genus'] != '') {
         $label = " <i>" . $form_values['genus'] . " " . $form_values['species'] . "</i>";
     } elseif ($form_values['species'] != '' and $form_values['genus'] == '') {
         $label = " <i>" . $form_values['species'] . "</i>";
     } elseif ($form_values['species'] == '' and $form_values['genus'] != '') {
         $label = " <i>" . $form_values['genus'] . "</i>";
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] != '') {
         $label = " " . $form_values['family'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] != '') {
         $label = " " . $form_values['order'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] != '') {
         $label = " " . $form_values['class'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] == '' and $form_values['subphylum'] != '') {
         $label = " " . $form_values['subphylum'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] == '' and $form_values['subphylum'] == '' and $form_values['phylum'] != '') {
         $label = " " . $form_values['phylum'];
     }
     $dom2 = new DomDocument("1.0", "UTF-8");
     $dom2->formatOutput = true;
     ///begin writing dc datastream
     $oai = $dom2->createElement("oai_dc:dc");
     $oai->setAttribute('xmlns:oai_dc', "http://www.openarchives.org/OAI/2.0/oai_dc/");
     $oai->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/");
     $oai->setAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
     $oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $dctitle = $dom2->createElement("dc:title", implode($sxec->xpath('//critters:lab_id')) . $label);
     $dccreator = $dom2->createElement("dc:creator", 'Marine Natural Products Lab, University of Prince Edward Island');
     // list specimen taxonomy as dc:subject
     $dcphylum = $dom2->createElement("dc:subject", $form_values['phylum']);
     $dcsubphylum = $dom2->createElement("dc:subject", $form_values['subphylum']);
     $dcclass = $dom2->createElement("dc:subject", $form_values['class']);
     $dcorder = $dom2->createElement("dc:subject", $form_values['order']);
     $dcfamily = $dom2->createElement("dc:subject", $form_values['family']);
     $dcgenus = $dom2->createElement("dc:subject", $form_values['genus']);
     $dcspecies = $dom2->createElement("dc:subject", $form_values['species']);
     // end taxonomy
     $dcdesc = $dom2->createElement("dc:description", implode($sxec->xpath('//critters:description')));
     $dcpublisher = $dom2->createElement("dc:publisher", 'Marine Natural Products Lab, University of Prince Edward Island');
     $dcpid = $dom2->createElement("dc:identifier", $form_values['pid']);
     $dcident = $dom2->createElement("dc:identifier", implode($sxec->xpath('//critters:lab_id')));
     $dcid = $dom2->createElement("dc:identifier", implode($sxec->xpath('//@name')));
     $dcdate = $dom2->createElement("dc:date", implode($sxec->xpath('//critters:date_collected')));
     $dctype = $dom2->createElement("dc:type", implode($sxec->xpath('//critters:type')));
     $dcformat = $dom2->createElement("dc:format", 'text/html');
     $dclang = $dom2->createElement("dc:language", 'eng');
     $dcsource = $dom2->createElement("dc:source", '');
     $dcrelation = $dom2->createElement("dc:relation", 'vre:mnpl-specimens');
     $dcrights = $dom2->createElement("dc:rights", 'All Rights Reserved - Marine Natural Products Lab. For permission to use this material please contact MNPL at rkerr@upei.ca.');
     // append elements
     $oai->appendChild($dctitle);
     $oai->appendChild($dccreator);
     $oai->appendChild($dcphylum);
     $oai->appendChild($dcsubphylum);
     $oai->appendChild($dcclass);
     $oai->appendChild($dcorder);
     $oai->appendChild($dcfamily);
     $oai->appendChild($dcgenus);
     $oai->appendChild($dcspecies);
     $oai->appendChild($dcdesc);
     $oai->appendChild($dcpublisher);
     //loop for contributors
     foreach ($sxec->xpath('//critters:collector') as $individual) {
         $dccontrib = $dom2->createElement("dc:contributor", $individual);
         $oai->appendChild($dccontrib);
     }
     $oai->appendChild($dcdate);
     $oai->appendChild($dctype);
     $oai->appendChild($dcformat);
     $oai->appendChild($dcpid);
     $oai->appendChild($dcident);
     $oai->appendChild($dcid);
     $oai->appendChild($dcsource);
     $oai->appendChild($dcrelation);
     $oai->appendChild($dcrights);
     $dom2->appendChild($oai);
     $dcxml = $dom2->saveXML();
     $params = array("pid" => $form_values['pid'], "dsID" => 'DC', "altIDs" => "", "dsLabel" => "Dublin Core Record", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $dcxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
     $soapHelper = new ConnectionHelper();
     $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://*****:*****@uri') as $link) {
         $partpid = ltrim($link, 'info:fedora/');
         $params = array("pid" => $partpid, "dsID" => $dsId, "altIDs" => "", "dsLabel" => "Parent Critter Record", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $newxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
     }
     // end of update other datastreams   - begin soap call for main critter record
     $params = array("pid" => $pid, "dsID" => $dsId, "altIDs" => "", "dsLabel" => "CRITTER", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $newxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
     try {
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         if ($client == null) {
             drupal_set_message(t('Error Getting Soap Client.'), 'error');
             return;
         }
         $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
         return true;
     } catch (exception $e) {
         drupal_set_message(t('Error Editing Specimen! ') . $e->getMessage(), 'error');
         watchdog(t("Fedora_Repository"), t("Error Editing Specimen!") . $e->getMessage(), WATCHDOG_ERROR);
         return;
     }
 }
 /**
  * Constructs an Image object.
  *
  * @param string $url   URL of the query for the data that should be returned based on Picasa's API documentation.
  *                      See {@link http://code.google.com/apis/picasaweb/gdata.html} for instructions on how to formulate
  *                      the URL.  The URL parameter can be left blank, which will still produce a populated Image
  *                      object as long as the $albums parameter contains XML from the Picasa Atom feed for an image.
  * @param SimpleXMLElement $albums  XML describing a Picasa image.  This can be left blank as long as a URL is specified in the
  *                                  url parameter that returns valid XML for a Picasa image.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled('Cached copy not available, requesting image freshly for URL: ' . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled('Saving account to cache.');
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled('Image retreived from cache.');
         }
         if ($xmldata == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     $this->contextArray = $contextArray;
     if ($albums != null) {
         foreach ($albums->link as $plink) {
             if ($plink['rel'] == 'alternate') {
                 $this->weblink = $plink['href'];
             }
         }
         $namespaces = $albums->getNamespaces(true);
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             $this->description = $media_ns->group->description;
             $this->keywords = $media_ns->group->keywords;
             $this->thumbUrlMap = array();
             $this->thumbHeightMap = array();
             $this->previous = null;
             $this->next = null;
             $i = 0;
             $this->thumbnails = array();
             $thumb = $media_ns->group->thumbnail[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 // These fields are deprecated but included for backwards compatibility
                 $this->thumbUrlMap[$width] = $url;
                 $this->thumbHeightMap[$width] = $height;
                 $this->thumbnails[$i] = new Picasa_Thumbnail($url, $thumbAtt['width'], $thumbAtt['height']);
                 $i++;
                 $thumb = $media_ns->group->thumbnail[$i];
             }
             /* This is to support the previous implementation.  It may seem inefficiant to loop
              * through twice, but typically there will be 1-3 iterations, so it is inconsequential. */
             $thumb = $media_ns->group->thumbnail[0];
             if ($thumb != null) {
                 $thumbAtt = $media_ns->group->thumbnail[0]->attributes();
                 $this->smallThumb = $thumbAtt['url'];
             } else {
                 $this->smallThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[1];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->mediumThumb = $thumbAtt['url'];
             } else {
                 $this->mediumThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[2];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->largeThumb = $thumbAtt['url'];
             } else {
                 $this->largeThumb = null;
             }
             $this->contentUrlMap = array();
             $this->contentHeightMap = array();
             $i = 0;
             $thumb = $media_ns->group->content[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 $this->contentUrlMap[$width] = $url;
                 $this->contentHeightMap[$width] = $height;
                 $i++;
                 $thumb = $media_ns->group->content[$i];
             }
             $this->content = $thumbAtt['url'];
             $this->imageType = $thumbAtt['type'];
             // Pull and parse the tags
             if ($media_ns->group->keywords != null || strcmp($media_ns->group->keywords, "") != 0) {
                 // Make an array for to hold all of a photo's tags
                 $this->tags = array();
                 /* Tags are stored as a comma-delimited list.
                  * Tokenize the list on comma and strip it to get just the tag.
                  */
                 $tok = strtok($media_ns->group->keywords, ",");
                 $i = 0;
                 while ($tok != false) {
                     // Set the tag in the array
                     $this->tags[$i] = trim($tok);
                     $tok = strtok(",");
                     $i++;
                 }
             } else {
                 $this->tags = null;
             }
         } else {
             $this->description = null;
             $this->keywords = null;
             $this->smallThumb = null;
             $this->mediumThumb = null;
             $this->largeThumb = null;
             $this->content = null;
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->idnum = $gphoto_ns->id;
             $this->width = $gphoto_ns->width;
             $this->height = $gphoto_ns->height;
             $this->albumid = $gphoto_ns->albumid;
             $this->albumTitle = $gphoto_ns->albumtitle;
             $this->albumDescription = $gphoto_ns->albumdesc;
             $this->version = $gphoto_ns->version;
             $this->timestamp = $gphoto_ns->timestamp;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             if (strcmp($gphoto_ns->commentCount, "") == 0 || $gphoto_ns->commentCount === null) {
                 $this->commentCount = null;
             } else {
                 $this->commentCount = intval($gphoto_ns->commentCount);
             }
         } else {
             $this->idnum = null;
             $this->width = null;
             $this->height = null;
             $this->albumid = null;
             $this->commentCount = null;
             $this->version = null;
             $this->timestamp = null;
         }
         if (array_key_exists("exif", $namespaces)) {
             $exif_ns = $albums->children($namespaces["exif"]);
             $this->flash = $exif_ns->tags->flash;
             $this->fstop = $exif_ns->tags->fstop;
             $this->cameraMake = $exif_ns->tags->make;
             $this->cameraModel = $exif_ns->tags->model;
             $this->exposure = $exif_ns->tags->exposure;
             $this->focalLength = $exif_ns->tags->focallength;
             $this->iso = $exif_ns->tags->iso;
         } else {
             $this->flash = null;
             $this->fstop = null;
             $this->cameraMake = null;
             $this->cameraModel = null;
             $this->exposure = null;
             $this->focalLength = null;
             $this->iso = null;
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = @$georss_ns->children($namespaces["gml"]);
             if ($gml_ns !== null || $gml_ns !== false) {
                 $this->gmlPosition = @$gml_ns->Point->pos;
             } else {
                 $this->gmlPosition = null;
             }
         } else {
             $this->gmlPosition = null;
         }
         // Set the basic attributes
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         if ($albums->author != null && strcmp($albums->author, "") != 0) {
             $this->author = new Picasa_Author($albums->author);
         } else {
             $this->author = new Picasa_Author();
         }
         // The user is not a field in the XML for an image like it is for an album.  Thus, we parse.
         if ($this->author->getUser() == null || strcmp($this->author->getUser(), "") == 0) {
             $startUser = strpos($this->id, '/user/') + 6;
             $endUser = strpos($this->id, '/', $startUser);
             $this->author->setUser(substr($this->id, $startUser, $endUser - $startUser));
         }
         // If there are comments, retrieve them and put them into the comments field of the object
         if ($this->commentCount === null) {
             $this->comments = null;
         } else {
             if ($this->commentCount === 0) {
                 $this->comments = array();
             } else {
                 $this->comments = array();
                 $i = 0;
                 // Grab each comment and make it into an object
                 foreach ($albums->entry as $comment) {
                     $this->comments[$i] = new Picasa_Comment($comment);
                     $i++;
                 }
             }
         }
     }
 }
Example #27
0
 /**
  * Return an array of the current XRDS namespaces for working with any
  * XPath queries on the Service node.
  *
  * @return array
  */
 public function getNamespaces()
 {
     return $this->_namespace->getNamespaces();
 }
Example #28
0
		<div class="row">
			<div id="logo" class="col-md-4 col-md-offset-1"><img src="<?php 
echo base_url();
?>
images/logo.png" class="img-responsive" alt="logo"></div>
			<div class="col-md-6">
				<h3>Kontakt</h3><br>
				<p class="text-center">Küsimuste või probleemide korral palume ühendust võtta e-maili või telefoni teel.</p>
				<p class="text-center">p2pkuulutused@p2p.ee</p>
				<p class="text-center">+372 5858585</p>
				<div class="alert alert-info text-center">
				<strong>Aadress:</strong> <br><br>
				<!--xml ja namespaces-->
				<?php 
$feed = new SimpleXMLElement("http://localhost/P2P/xml/file.xml", NULL, TRUE);
$namespaces = $feed->getNamespaces(true);
$getChildren = $feed->children($namespaces["k"]);
echo $getChildren->TÄNAV . "<br>";
echo $getChildren->LINN . "<br>";
echo $getChildren->RIIK . "<br>";
echo $getChildren->POSTIINDEKS . "<br>";
//Ilma namespace'ita
$feed2 = simplexml_load_file("http://localhost/P2P/xml/file.xml");
echo $feed2->POSTIINDEKS;
?>
				</div>
			</div>
		</div>
		
		
	</div>
Example #29
0
    /**
     * Get a list of research and scholarship IDs
     *
     * @param   string  $ch
     * @return  array
     */
    private static function getResearchAndScholarshipIdps($ch)
    {
        // fetch the latest InCommon metadata, if needed
        curl_setopt($ch, CURLOPT_URL, self::$mdSource);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        if (file_exists(self::$mdDest)) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, ['If-Modified-Since: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', filemtime(self::$mdDest))]);
            $xml = curl_exec($ch);
            if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 304) {
                $xml = file_get_contents(self::$mdDest);
            } else {
                file_put_contents(self::$mdDest, $xml);
            }
        } else {
            $xml = curl_exec($ch);
            file_put_contents(self::$mdDest, curl_exec($ch));
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, []);
        $xp = new \SimpleXMLElement($xml);
        foreach ($xp->getNamespaces(TRUE) as $name => $url) {
            $xp->registerXPathNamespace($name ? $name : 'base', $url);
        }
        $rv = [];
        // select entities having the saml attribute indicating that they are research & scholarship category members
        // being members ourselves, we can get attributes about users released fromt these entities
        foreach ($xp->xpath('//base:EntityDescriptor[
			base:Extensions/
				mdattr:EntityAttributes/
					saml:Attribute[attribute::Name="http://macedir.org/entity-category-support"]/
						saml:AttributeValue[text()="http://id.incommon.org/category/research-and-scholarship" or text()="http://refeds.org/category/research-and-scholarship"]
			]') as $entity) {
            // easier to work with as an array, the SimpleXMLElement class is bizarre
            $entity = (array) $entity;
            $id = $entity['@attributes']['entityID'];
            $title = $xp->xpath('//base:EntityDescriptor[attribute::entityID="' . $id . '"]//mdui:DisplayName');
            if (isset($title[0])) {
                $title = (string) $title[0];
            } else {
                continue;
            }
            preg_match('/([^.:]+[.][^.]+?)(?:[\\/]|$)/', $id, $ma);
            $host = $ma[1];
            //			$logo = $xp->xpath('//base:EntityDescriptor[attribute::entityID="'.$id.'"]//mdui:Logo');
            //			$logo = isset($logo[0]) ? (string)$logo[0] : 'https://'.$host.'/favicon.ico';
            $rv[] = ['entity_id' => $id, 'label' => $title, 'host' => $host];
        }
        return $rv;
    }
Example #30
0
 private function _loadPlaylists($maxResults = 0, $startIndex = 0)
 {
     $this->_playlists_maxResults = $maxResults;
     $this->_playlists_startIndex = $startIndex;
     $data = $this->_youtube->getPlaylistsByUser($this->_username, $maxResults, $startIndex);
     $ids = array();
     $xml = new SimpleXMLElement($data);
     //count playlists
     $ns = $xml->getNamespaces(true);
     if ($ns) {
         $openSearch = $xml->children($ns['openSearch']);
         $this->_playlists_count = (int) $openSearch->totalResults;
     }
     if ($xml->entry) {
         foreach ($xml->entry as $playlist) {
             $namespaces = $playlist->getNamespaces(true);
             $yt = $playlist->children($namespaces['yt']);
             $ids[] = $yt->playlistId;
         }
     }
     $playlists = array();
     foreach ($ids as $id) {
         $playlists[] = new YouTubePlaylist($id, $this->_developerKey);
     }
     $this->_playlists = $playlists;
 }