src/snac/util/EACCPFParser.php
/**
     * Parse the given date element into its appropriate object.
     * This requires testing for both a dateRange, as well
     * as notBefore and notAfter ranges on each date given.
     *
     * @param \SimpleXMLElement $dateElement Date element to parse
     * @param string[] $xpath All pieces of the xpath leading up to the date to parse
     * @return \snac\data\SNACDate The resulting date object
     */
Parse the given date element into its appropriate object.
This requires testing for both a dateRange, as well
as notBefore and notAfter ranges on each date given.

@param \SimpleXMLElement $dateElement Date element to parse
@param string[] $xpath All pieces of the xpath leading up to the date to parse
@return \snac\data\SNACDate The resulting date object
Parse the given date element into its appropriate object . This requires testing for both a dateRange as well as notBefore and notAfter ranges on each date given . @param \ SimpleXMLElement $dateElement Date element to parse @param string [] $xpath All pieces of the xpath leading up to the date to parse @return \ snac \ data \ SNACDate The resulting date object
private function parseDate($dateElement, $xpath) {
        $date = new \snac\data\SNACDate();
        if ($dateElement->getName() == "dateRange") {
            $date->setRange(true);
            foreach ($this->getChildren($dateElement) as $dateTag) {
                $dateAtts = $this->getAttributes($dateTag);
                switch ($dateTag->getName()) {
                case "fromDate":
                    if (((string) $dateTag) != null && ((string) $dateTag) != '') {
                        $dateType = null;
                        if (isset($dateAtts["localType"]))
                            $dateType = $this->getTerm($this->getValue($dateAtts["localType"]), "date_type");
                        if (! isset($dateAtts['standardDate']))
                        {
                            $dateAtts['standardDate'] = '';
                        }
                        $date->setFromDate((string) $dateTag,
                                           $dateAtts["standardDate"],
                                           $dateType);
                        $notBefore = null;
                        $notAfter = null;
                        if (isset($dateAtts["notBefore"]))
                            $notBefore = $dateAtts["notBefore"];
                        if (isset($dateAtts["notAfter"]))
                            $notAfter = $dateAtts["notAfter"];
                        $date->setFromDateRange($notBefore, $notAfter);
                        unset($dateAtts["notBefore"]);
                        unset($dateAtts["notAfter"]);
                        unset($dateAtts["standardDate"]);
                        unset($dateAtts["localType"]);
                        $this->markUnknownAtt(
                            array_merge($xpath,
                                        array (
                                            $dateElement->getName(),
                                            $dateTag->getName()
                                        )), $dateAtts);
                    }
                    break;
                case "toDate":
                    if (((string) $dateTag) != null && ((string) $dateTag) != '') {
                        $dateType = null;
                        if (isset($dateAtts["localType"]))
                            $dateType = $this->getTerm($this->getValue($dateAtts["localType"]), "date_type");
                        if (! isset($dateAtts['standardDate']))
                        {
                            $dateAtts['standardDate'] = '';
                        }
                        $date->setToDate((string) $dateTag,
                                $dateAtts["standardDate"],
                                $dateType);
                        $notBefore = null;
                        $notAfter = null;
                        if (isset($dateAtts["notBefore"]))
                            $notBefore = $dateAtts["notBefore"];
                        if (isset($dateAtts["notAfter"]))
                            $notAfter = $dateAtts["notAfter"];
                        $date->setToDateRange($notBefore, $notAfter);
                        unset($dateAtts["notBefore"]);
                        unset($dateAtts["notAfter"]);
                        unset($dateAtts["standardDate"]);
                        unset($dateAtts["localType"]);
                        $this->markUnknownAtt(
                            array_merge($xpath,
                                        array (
                                            $dateElement->getName(),
                                            $dateTag->getName()
                                        )), $dateAtts);
                    }
                    break;
                default:
                    $this->markUnknownTag(
                        array_merge($xpath,
                                    array (
                                        $dateElement->getName()
                                    )),
                        array (
                            $dateTag
                        ));
                }
            }
        } elseif ($dateElement->getName() == "date") {
            if (isset($dateAtts["standardDate"]))
            {
                $date->setRange(false);
                $dateAtts = $this->getAttributes($dateElement);
                $dateType = null;
                if (isset($dateAtts["localType"]))
                    $dateType = $this->getTerm($this->getValue($dateAtts["localType"]), "date_type");
                $date->setDate((string) $dateElement,
                        $dateAtts["standardDate"],
                        $dateType);
                $notBefore = null;
                $notAfter = null;
                if (isset($dateAtts["notBefore"]))
                    $notBefore = $dateAtts["notBefore"];
                if (isset($dateAtts["notAfter"]))
                    $notAfter = $dateAtts["notAfter"];
                $date->setDateRange($notBefore, $notAfter);
                unset($dateAtts["notBefore"]);
                unset($dateAtts["notAfter"]);
                unset($dateAtts["standardDate"]);
                unset($dateAtts["localType"]);
                $this->markUnknownAtt(
                    array_merge($xpath,
                                array (
                                    $dateElement->getName()
                                )), $dateAtts);
            }
            else
            {
                $date->setDate((string) $dateElement, '', null);
            }
        }
        $date->setOperation($this->operation);
        return $date;
    }
private function parseDate ( $ dateElement , $ xpath ) { $ date = new \ snac \ data \ SNACDate ( ) ; if ( $ dateElement -> getName ( ) == " dateRange " ) { $ date -> setRange ( true ) ; foreach ( $ this -> getChildren ( $ dateElement ) as $ dateTag ) { $ dateAtts = $ this -> getAttributes ( $ dateTag ) ; switch ( $ dateTag -> getName ( ) ) { case " fromDate " : if ( ( ( string ) $ dateTag ) != null && ( ( string ) $ dateTag ) != '' ) { $ dateType = null ; if ( isset ( $ dateAtts [ " localType " ] ) ) $ dateType = $ this -> getTerm ( $ this -> getValue ( $ dateAtts [ " localType " ] ) , " date_type " ) ; if ( ! isset ( $ dateAtts [ 'standardDate' ] ) ) { $ dateAtts [ 'standardDate' ] = '' ; } $ date -> setFromDate ( ( string ) $ dateTag , $ dateAtts [ " standardDate " ] , $ dateType ) ; $ notBefore = null ; $ notAfter = null ; if ( isset ( $ dateAtts [ " notBefore " ] ) ) $ notBefore = $ dateAtts [ " notBefore " ] ; if ( isset ( $ dateAtts [ " notAfter " ] ) ) $ notAfter = $ dateAtts [ " notAfter " ] ; $ date -> setFromDateRange ( $ notBefore , $ notAfter ) ; unset ( $ dateAtts [ " notBefore " ] ) ; unset ( $ dateAtts [ " notAfter " ] ) ; unset ( $ dateAtts [ " standardDate " ] ) ; unset ( $ dateAtts [ " localType " ] ) ; $ this -> markUnknownAtt ( array_merge ( $ xpath , array ( $ dateElement -> getName ( ) , $ dateTag -> getName ( ) ) ) , $ dateAtts ) ; } break ; case " toDate " : if ( ( ( string ) $ dateTag ) != null && ( ( string ) $ dateTag ) != '' ) { $ dateType = null ; if ( isset ( $ dateAtts [ " localType " ] ) ) $ dateType = $ this -> getTerm ( $ this -> getValue ( $ dateAtts [ " localType " ] ) , " date_type " ) ; if ( ! isset ( $ dateAtts [ 'standardDate' ] ) ) { $ dateAtts [ 'standardDate' ] = '' ; } $ date -> setToDate ( ( string ) $ dateTag , $ dateAtts [ " standardDate " ] , $ dateType ) ; $ notBefore = null ; $ notAfter = null ; if ( isset ( $ dateAtts [ " notBefore " ] ) ) $ notBefore = $ dateAtts [ " notBefore " ] ; if ( isset ( $ dateAtts [ " notAfter " ] ) ) $ notAfter = $ dateAtts [ " notAfter " ] ; $ date -> setToDateRange ( $ notBefore , $ notAfter ) ; unset ( $ dateAtts [ " notBefore " ] ) ; unset ( $ dateAtts [ " notAfter " ] ) ; unset ( $ dateAtts [ " standardDate " ] ) ; unset ( $ dateAtts [ " localType " ] ) ; $ this -> markUnknownAtt ( array_merge ( $ xpath , array ( $ dateElement -> getName ( ) , $ dateTag -> getName ( ) ) ) , $ dateAtts ) ; } break ; default : $ this -> markUnknownTag ( array_merge ( $ xpath , array ( $ dateElement -> getName ( ) ) ) , array ( $ dateTag ) ) ; } } } elseif ( $ dateElement -> getName ( ) == " date " ) { if ( isset ( $ dateAtts [ " standardDate " ] ) ) { $ date -> setRange ( false ) ; $ dateAtts = $ this -> getAttributes ( $ dateElement ) ; $ dateType = null ; if ( isset ( $ dateAtts [ " localType " ] ) ) $ dateType = $ this -> getTerm ( $ this -> getValue ( $ dateAtts [ " localType " ] ) , " date_type " ) ; $ date -> setDate ( ( string ) $ dateElement , $ dateAtts [ " standardDate " ] , $ dateType ) ; $ notBefore = null ; $ notAfter = null ; if ( isset ( $ dateAtts [ " notBefore " ] ) ) $ notBefore = $ dateAtts [ " notBefore " ] ; if ( isset ( $ dateAtts [ " notAfter " ] ) ) $ notAfter = $ dateAtts [ " notAfter " ] ; $ date -> setDateRange ( $ notBefore , $ notAfter ) ; unset ( $ dateAtts [ " notBefore " ] ) ; unset ( $ dateAtts [ " notAfter " ] ) ; unset ( $ dateAtts [ " standardDate " ] ) ; unset ( $ dateAtts [ " localType " ] ) ; $ this -> markUnknownAtt ( array_merge ( $ xpath , array ( $ dateElement -> getName ( ) ) ) , $ dateAtts ) ; } else { $ date -> setDate ( ( string ) $ dateElement , '' , null ) ; } } $ date -> setOperation ( $ this -> operation ) ; return $ date ; }
Parse the given date element into its appropriate object.
Parse the given date element into its appropriate object .
// Handle the date range /*
                 *   File /data/merge/99166-w62r7n84.xml ok.
                 * PHP Notice:  Undefined index: standardDate in /lv1/home/twl8n/snac/src/snac/util/EACCPFParser.php on line 1255
                 * PHP Notice:  Undefined index: standardDate in /lv1/home/twl8n/snac/src/snac/util/EACCPFParser.php on line 1279
                 */ /*
                 * File /data/merge/99166-w6163116.xml ok.
                 * PHP Notice:  Undefined index: localType in /lv1/home/twl8n/snac/src/snac/util/EACCPFParser.php on line 1256
                 */ /*
             * Sanity check standardDate. Unclear what should happen if we don't have a standardDate
             * value. This code leaves $date unchanged, and hopes that the initialization was sane.
             */ // Handle the single date that appears /* Silently make dates with no standard date only partial complete.
                 *
                 * Arg 3 is type which is Term object
                 *
                 * $message = sprintf("Warning: empty standardDate in date for: %s\n", $this->arkID);
                 * $stderr = fopen('php://stderr', 'w');
                 * fwrite($stderr,"  $message\n");
                 * fclose($stderr);
                 *
                 *
                 *
                 */