Ejemplo n.º 1
0
 /**
  * Legge i jumper da file XML.
  * Cerca il file in  "$content_path/$itemid/$itemid.xml".
  * 
  * @param int $itemid ID del contenuto di cui si vogliono i jumper. 
  * @param string $content_path Percorso dove cercare il file XML.
  * @return array 
  */
 public function getJumperXML($path)
 {
     try {
         $id = JRequest::getInt('id', 0);
         $path .= '/' . $id . '.xml';
         FB::log($path, "path");
         if (!file_exists($path)) {
             FB::ERROR("Il file CUE_POINTS.XML non esiste! Nessun jumper verrà visualizzato e le eventuali slide non saranno sincronizzate.");
             return array();
         }
         // if (empty($itemid) || !filter_var($itemid, FILTER_VALIDATE_INT))
         //     throw new BadMethodCallException('Parametro non valido, atteso un intero valido - Jumper', E_USER_ERROR);
         // if (empty($jumpers) || !is_array($jumpers))
         //     throw new BadMethodCallException('Parametro non valido, atteso un array valido - Jumper', E_USER_ERROR);
         $jumpers = array();
         $xml = new DOMDocument();
         $xml->load($path);
         $cue_points = $xml->getElementsByTagName('CuePoint');
         $i = 0;
         foreach ($cue_points as $point) {
             foreach ($point->childNodes as $node) {
                 if ('Time' == $node->nodeName) {
                     $jumpers[$i]['tstart'] = $node->nodeValue;
                 } elseif ('Name' == $node->nodeName) {
                     $jumpers[$i]['titolo'] = $node->nodeValue;
                 }
             }
             $i++;
             /** @todo se il nodo non contiene time e name incremento i e non faccio nessun controllo se il jumper abbia 2 elementi tstart e titolo */
         }
         unset($xml);
         unset($cue_points);
         return $jumpers;
     } catch (Exception $e) {
         FB::error($e, "error");
     }
     return 0;
 }