nitf.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 755 行 · 第 1/2 页

PHP
755
字号
<?php/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */// +----------------------------------------------------------------------+// | PHP version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 2003-2004 TownNews.com                                 |// +----------------------------------------------------------------------+// | This source file is subject to version 2.0 of the PHP license,       |// | that is bundled with this package in the file LICENSE, and is        |// | available at through the world-wide-web at                           |// | http://www.php.net/license/2_02.txt.                                 |// | If you did not receive a copy of the PHP license and are unable to   |// | obtain it through the world-wide-web, please send a note to          |// | license@php.net so we can mail you a copy immediately.               |// +----------------------------------------------------------------------+// | Authors: Patrick O'Lone <polone@townnews.com>                        |// +----------------------------------------------------------------------+//// NITF.php,v 1.4 2005/01/17 23:46:32 polone Exprequire_once('XML/Parser.php');/*** Generic NITF Parser class** This class provides basic NITF parsing. Many of the major elements of the NITF* standard are supported. This implementation is based off the NITF 3.1 DTD,* publicly available at the following URL:** http://www.nitf.org/site/nitf-documentation/nitf-3-1.dtd** Note that not all elements of this standard are not supported.** @author Patrick O'Lone <polone@townnews.com>* @version 1.4* @package XML*/class XML_NITF extends XML_Parser{    /**    * @var array    * Document metadata. Container for metadata information about this    * particular document.    * @see getDocData()    * @access private    */    var $m_kDocData = array('key-list' => array());        /**    * @var array    * Information about specific instance of an item's publication. Contains    * metadata about how the particular news object was used in a specific    * instance.    * @see getPubData()    * @access private    */    var $m_kPubData = array();        /**    * @var array    * Information about the creative history of the document; also used as an    * audit trail. Includes who made changes, when the changes were made, and    * why. Each element of the array is a key-based array that corresponds to    * the <revision-history> element.    * @see getRevision()    * @access private    */    var $m_akRevisions = array();        /**    * @var array    * The various headlines that were found in the document. The headlines are    * keyed by the levels of HLX. The default hedline (if no level is found) is    * HL1.    * @see getHedlines()    * @access private    */    var $m_kHedlines = array( 'HL1' => null, 'HL2' => array() );    /**    * @var string    * Story abstract summary or synopsis of the contents of the document.    * @access private    */    var $m_sAbstract = null;        /**    * @var string    * Significant place mentioned in an article. Used to normalize locations.    * The location in this variable is the place where the story's events will    * or have unfolded.    * @access private    */    var $m_sLocation = null;        /**    * @var string    * Information distributor. May or may not be the owner or creator.    * @access private    */    var $m_sDistributor = null;    /**    * @var string    * The elements of the byline, including the author's name and title.    * @see getByline()    * @access private    */    var $m_kByline = array( 'author' => null, 'title' => null );        /**    * @var array    * An array of paragraphs extracted from the document    * @see getLede(), getContent()    * @access private    */    var $m_aContent = array();    /**    * @var array    * A list of media reference elements as found in the body section of the    * document. Each element is an array itself with keyed properties related    * to media element in question.    * @see getMedia()    * @access private    */    var $m_aMedia = array();    /**    * @var array    * A list of tags that were parsed (in order) denoting the current sequence    * of tags that were parsed. This is array is used for parsing the document    * elements in a particular order (if needed).    * @see StartHandler(), EndHandler(), cdataHandler()    * @access private    */    var $m_aParentTags = array();        /**    * @var string    * A byline at the end of a story. Example: Stuart Myles contributed to this    * article.    * @see getTagline()    * @access private    */    var $m_sTagline = null;        /**    * @var string    * Free-form bibliographic data. Used to elaborate on the source of    * information.    * @see getBibliography()    * @access private    */    var $m_sBibliography = null;        /**    * Access all or specific elements of the <docdata> block    *    * @return mixed    * All of the elements from the <docdata> block will be returned if a specific    * property is not provided. If a specific property is requested and is found    * in the docdata block, then that property will be returned. If the property    * cannot be found, null is returned.    *    * @param string    * The property of the <docdata> block to return, the most common being:    *    * "doc-id" - a unique identifier of this document (string)    * "key-list" - a list of keywords provided with the document (array)    * "copyright" - the copyright holder (string)    * "series" - if the document is part of series (string)    * "urgency" - a number between 1 (urgent) and 8 (not urgent) (integer)    * "date.issue" - date the document was issued (UNIX timestamp)    * "date.release" - date the document is publicly available (UNIX timestamp)    * "date.expires" - date the document is no longer valid (UNIX timestamp)    *    * @see getDocDataElement()    * @access public    */    function getDocData( $sProperty = null )    {        if (!empty($sProperty)) {            $sProperty = strtolower($sProperty);            if (isset($this->m_kDocData[$sProperty])) {                return $this->m_kDocData[$sProperty];            }            return null;                }        return $this->m_kDocData;    }    /**    * Returns all elements or a specific element from the <pubdata> block    *    * @return mixed    * Returns string, numeric, or array values depending on the property being    * accessed from the <pubdata> block.    *    * @access public    */    function getPubData( $sProperty = null )    {        if (!empty($sProperty)) {            $sProperty = strtolower($sProperty);            if (isset($this->m_kPubData[$sProperty])) {                return $this->m_kPubData[$sProperty];            }            return null;        }                return $this->m_kPubData;    }        /**    * Get the revision history    *    * @return array    * An array containing key-value arrays. The properties of each array element    * in this array are:    *    * "comment" - Reason for the revision    * "function" - Job function of individual performing revision    * "name" - Name of the person who made the revision    * "norm" - Date of the revision    *    * @access public    */    function getRevision()    {        return $this->m_akRevisions;    }    /**    * Retrieve all headlines or a single headline denoted by key    *    * @return mixed    * Returns an array if no specific headline element is requested, or a string    * if the specific headline element requested exists    *    * @param string    * The key value corresponding to the headline to be retrieved    *    * @access public    */    function getHeadline( $nLevel = 1 )    {        return $this->m_kHedlines["HL$nLevel"];    }    /**    * Return information about the author of a document    *    * @param string    * The field of the byline to retrieve.    *    * @access public    */    function getByline( $sProperty = 'author' )    {        $sProperty = strtolower($sProperty);        if (isset($this->m_kByline[$sProperty])) {            return $this->m_kByline[$sProperty];        }                return null;    }        /**    * Query for a list of related media elements    *    * @return array    * Returns an array of all media reference data, or an array of select media    * reference data determined by the property parameter passed.    *    * @param string    * If supplied, only this property will be returned for each element of the    * media reference array.    *    * @access public    */    function getMedia( $sProperty = null )    {        if (empty($sProperty)) {           return $this->m_aMedia;        } else {           $aMediaRefs = array();           foreach($this->m_aMedia as $aMediaElem) {              if (isset($aMediaElem[$sProperty])) {                 array_push($aMediaRefs, $aMediaElem[$sProperty]);              }           }                      return $aMediaRefs;        }    }        /**    * Returns the lede (sometimes called lead) paragraph    *    * @return string    * Returns the lede paragraph if it is defined, or null otherwise    *    * @access public    */    function getLede()    {        if (isset($this->m_aContent[0])) {           return $this->m_aContent[0];        }        return null;    }        /**    * Returns the paragraphs of content    *    * @return array    * An array of elements that represent a single paragraph each    *    * @access public    */    function &getContent()    {        return $this->m_aContent;    }        /**    * Returns the tag line (if one exists)    *    * @return string    * The tag line extracted from the NITF data source    *    * @access public    */    function getTagline()    {        return $this->m_sTagline;    }        /**    * Returns the free-form bibliographic data    *    * @return string    * The bibliography (if one exists) is returned    *    * @access public    */    function getBibliography()    {        return $this->m_sBibliography;    }        /**    * Get a string version of the article    *    * @return string    * A string representing the main headline, author, content, and tagline.    *    * @param string

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?