Source for file MetaFragment.php
Documentation is available at MetaFragment.php
* Created on 10.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the GPL. For more information please see
* <http://opendocumentphp.org>.
* $Id: MetaFragment.php 183 2007-06-12 07:58:41Z nmarkgraf $
require_once 'OpenDocumentPHP/util/Fragment.php';
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by The OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version $Revision: 183 $
* @package OpenDocumentPHP
* @since 0.5.0 - 08.02.2007
* @since 0.5.0 - 08.02.2007
private $generator = null;
* @since 0.5.0 - 08.02.2007
private $initialCreator = null;
* @since 0.5.0 - 08.02.2007
private $creationDate = null;
* @since 0.5.0 - 08.02.2007
private $printedBy = null;
* @since 0.5.0 - 08.02.2007
private $printDate = null;
* @since 0.5.0 - 08.02.2007
private $editDuration = null;
* @since 0.5.0 - 08.02.2007
private $keywords = null;
* @since 0.5.0 - 08.02.2007
private $userDefineds = null;
* @since 0.5.0 - 08.02.2007
$this->keywords = array ();
$this->userDefineds = array (
//setlocale(LC_TIME, 'de_DE');
// $this->setUserDefinedArray($this->userDefineds);
* @since 0.5.0 - 08.02.2007
protected function getTag($tag, $defaultValue) {
return parent :: getTag('//*/office:meta/' . $tag, self :: META, $tag, $defaultValue);
* @deprecated 0.5.1 - 09.02.2007
* @since 0.5.0 - 08.02.2007
* Retrieve the so called initial-creator. This should be the first author of this document.
* In a meta document, if there is a tag like this one
* <meta:initial-creator>Alex Latchford</meta:initial-creator>
* this method will return "Alex Latchford" as a string.
* @return String The initial creator of this document.
* @since 0.5.0 - 08.02.2007
if (!isset ($this->initialCreator)) {
$this->initialCreator = $this->getTag('meta:initial-creator', '');
return $this->initialCreator->nodeValue;
* Put the so called initial-creator into the current meta document. The initial creator should be the first
* author of an OpenDocument and should allways be put in.
* If you write something like:
* $metaDoc->setInitialCreator('Norman Markgraf');
* to a MetaDocument $metaDoc, the initial creator is set to the string 'Norman Markgraf'.
* @param String $creator The new initial creator of this OpenDocument.
* @since 0.5.0 - 08.02.2007
$newNode = $this->domFragment->createElementNS(self :: META, 'meta:initial-creator', $creator);
$this->setTag($this->initialCreator, $newNode);
$this->initialCreator = $newNode;
* Retrieve the generator tag. The generator is the name of the programm on which the current OpenDocument was
* @return String The generator tag.
* @since 0.5.0 - 08.02.2007
if (!isset ($this->generator)) {
$this->generator = $this->getTag('meta:generator', '');
return $this->generator->nodeValue;
* Put the generator tag into the meta document. If called with no parameter the generator tag will be set to:
* 'OpenDocumentPHP/$Revision: 183 $', as this is the default value
* @param String The new generator tag.
* @since 0.5.0 - 08.02.2007
function setGenerator($generator = 'OpenDocumentPHP/$Revision: 183 $') {
$newNode = $this->domFragment->createElementNS(self :: META, 'meta:generator', $generator);
$this->setTag($this->generator, $newNode);
$this->generator = $newNode;
* @since 0.5.0 - 08.02.2007
* Retrieve the creation date of this document.
* @since 0.5.0 - 08.02.2007
if (!isset ($this->creationDate)) {
return $this->creationDate->nodeValue;
* Put the creation date into the meta document. If no date parameter where given, the current date
* @since 0.5.0 - 08.02.2007
$newNode = $this->domFragment->createElementNS(self :: META, 'meta:creation-date', $tmpdate);
$this->setTag($this->creationDate, $newNode);
$this->creationDate = $newNode;
* @since 0.5.0 - 08.02.2007
if (!isset ($this->printDate)) {
$this->printDate = $this->getTag('meta:print-date', '');
return $this->printDate->nodeValue;
* @since 0.5.0 - 08.02.2007
$newNode = $this->domFragment->createElementNS(self :: META, 'meta:print-date', $date);
$this->setTag($this->printDate, $newNode);
$this->printDate = $newNode;
* @param array $userDefined
* @since 0.5.2 - 03.03.2007
foreach ($userDefined as $name => $value) {
* @since 0.5.2 - 03.03.2007
$oldNode = $this->getTag('meta:user-defined/[meta:name="' . $name . '"]', $value);
$newNode = $this->domFragment->createElementNS(self :: META, 'meta:user-defined');
$newNode->setAttributeNS(self :: META, 'meta:name', $value);
$this->setTag($oldNode, $newNode);
|