[Piwik-svn] r359 - trunk/libs/Zend
svnmaster at piwik.org
svnmaster at piwik.org
Tue Mar 11 20:07:22 CET 2008
Author: matt
Date: 2008-03-11 20:07:20 +0100 (Tue, 11 Mar 2008)
New Revision: 359
Removed:
trunk/libs/Zend/Feed.php
trunk/libs/Zend/Feed/
trunk/libs/Zend/Gdata.php
trunk/libs/Zend/Json/
trunk/libs/Zend/Mail.php
trunk/libs/Zend/Mail/
trunk/libs/Zend/Mime.php
trunk/libs/Zend/Mime/
trunk/libs/Zend/Pdf.php
trunk/libs/Zend/Uri.php
trunk/libs/Zend/Uri/
trunk/libs/Zend/XmlRpc/
Log:
- deleting useless libraries
Deleted: trunk/libs/Zend/Feed.php
===================================================================
--- trunk/libs/Zend/Feed.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Feed.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,395 +0,0 @@
-<?php
-
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Feed
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
-
-
-/**
- * Feed utility class
- *
- * Base Zend_Feed class, containing constants and the Zend_Http_Client instance
- * accessor.
- *
- * @category Zend
- * @package Zend_Feed
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Feed
-{
-
- /**
- * HTTP client object to use for retrieving feeds
- *
- * @var Zend_Http_Client
- */
- protected static $_httpClient = null;
-
- /**
- * Override HTTP PUT and DELETE request methods?
- *
- * @var boolean
- */
- protected static $_httpMethodOverride = false;
-
- /**
- * @var array
- */
- protected static $_namespaces = array(
- 'opensearch' => 'http://a9.com/-/spec/opensearchrss/1.0/',
- 'atom' => 'http://www.w3.org/2005/Atom',
- 'rss' => 'http://blogs.law.harvard.edu/tech/rss',
- );
-
-
- /**
- * Set the HTTP client instance
- *
- * Sets the HTTP client object to use for retrieving the feeds.
- *
- * @param Zend_Http_Client $httpClient
- * @return void
- */
- public static function setHttpClient(Zend_Http_Client $httpClient)
- {
- self::$_httpClient = $httpClient;
- }
-
-
- /**
- * Gets the HTTP client object. If none is set, a new Zend_Http_Client will be used.
- *
- * @return Zend_Http_Client_Abstract
- */
- public static function getHttpClient()
- {
- if (!self::$_httpClient instanceof Zend_Http_Client) {
- /**
- * @see Zend_Http_Client
- */
- require_once 'Zend/Http/Client.php';
- self::$_httpClient = new Zend_Http_Client();
- }
-
- return self::$_httpClient;
- }
-
-
- /**
- * Toggle using POST instead of PUT and DELETE HTTP methods
- *
- * Some feed implementations do not accept PUT and DELETE HTTP
- * methods, or they can't be used because of proxies or other
- * measures. This allows turning on using POST where PUT and
- * DELETE would normally be used; in addition, an
- * X-Method-Override header will be sent with a value of PUT or
- * DELETE as appropriate.
- *
- * @param boolean $override Whether to override PUT and DELETE.
- * @return void
- */
- public static function setHttpMethodOverride($override = true)
- {
- self::$_httpMethodOverride = $override;
- }
-
-
- /**
- * Get the HTTP override state
- *
- * @return boolean
- */
- public static function getHttpMethodOverride()
- {
- return self::$_httpMethodOverride;
- }
-
-
- /**
- * Get the full version of a namespace prefix
- *
- * Looks up a prefix (atom:, etc.) in the list of registered
- * namespaces and returns the full namespace URI if
- * available. Returns the prefix, unmodified, if it's not
- * registered.
- *
- * @return string
- */
- public static function lookupNamespace($prefix)
- {
- return isset(self::$_namespaces[$prefix]) ?
- self::$_namespaces[$prefix] :
- $prefix;
- }
-
-
- /**
- * Add a namespace and prefix to the registered list
- *
- * Takes a prefix and a full namespace URI and adds them to the
- * list of registered namespaces for use by
- * Zend_Feed::lookupNamespace().
- *
- * @param string $prefix The namespace prefix
- * @param string $namespaceURI The full namespace URI
- * @return void
- */
- public static function registerNamespace($prefix, $namespaceURI)
- {
- self::$_namespaces[$prefix] = $namespaceURI;
- }
-
-
- /**
- * Imports a feed located at $uri.
- *
- * @param string $uri
- * @throws Zend_Feed_Exception
- * @return Zend_Feed_Abstract
- */
- public static function import($uri)
- {
- $client = self::getHttpClient();
- $client->setUri($uri);
- $response = $client->request('GET');
- if ($response->getStatus() !== 200) {
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
- }
- $feed = $response->getBody();
- return self::importString($feed);
- }
-
-
- /**
- * Imports a feed represented by $string.
- *
- * @param string $string
- * @throws Zend_Feed_Exception
- * @return Zend_Feed_Abstract
- */
- public static function importString($string)
- {
- // Load the feed as an XML DOMDocument object
- @ini_set('track_errors', 1);
- $doc = new DOMDocument();
- $success = @$doc->loadXML($string);
- @ini_restore('track_errors');
-
- if (!$success) {
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg");
- }
-
- // Try to find the base feed element or a single <entry> of an Atom feed
- if ($doc->getElementsByTagName('feed')->item(0) ||
- $doc->getElementsByTagName('entry')->item(0)) {
- /**
- * @see Zend_Feed_Atom
- */
- require_once 'Zend/Feed/Atom.php';
- // return a newly created Zend_Feed_Atom object
- return new Zend_Feed_Atom(null, $string);
- }
-
- // Try to find the base feed element of an RSS feed
- if ($doc->getElementsByTagName('channel')->item(0)) {
- /**
- * @see Zend_Feed_Rss
- */
- require_once 'Zend/Feed/Rss.php';
- // return a newly created Zend_Feed_Rss object
- return new Zend_Feed_Rss(null, $string);
- }
-
- // $string does not appear to be a valid feed of the supported types
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception('Invalid or unsupported feed format');
- }
-
-
- /**
- * Imports a feed from a file located at $filename.
- *
- * @param string $filename
- * @throws Zend_Feed_Exception
- * @return Zend_Feed_Abstract
- */
- public static function importFile($filename)
- {
- @ini_set('track_errors', 1);
- $feed = @file_get_contents($filename);
- @ini_restore('track_errors');
- if ($feed === false) {
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception("File could not be loaded: $php_errormsg");
- }
- return self::importString($feed);
- }
-
-
- /**
- * Attempts to find feeds at $uri referenced by <link ... /> tags. Returns an
- * array of the feeds referenced at $uri.
- *
- * @todo Allow findFeeds() to follow one, but only one, code 302.
- *
- * @param string $uri
- * @throws Zend_Feed_Exception
- * @return array
- */
- public static function findFeeds($uri)
- {
- // Get the HTTP response from $uri and save the contents
- $client = self::getHttpClient();
- $client->setUri($uri);
- $response = $client->request();
- if ($response->getStatus() !== 200) {
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception("Failed to access $uri, got response code " . $response->getStatus());
- }
- $contents = $response->getBody();
-
- // Parse the contents for appropriate <link ... /> tags
- @ini_set('track_errors', 1);
- $pattern = '~(<link[^>]+)/?>~i';
- $result = @preg_match_all($pattern, $contents, $matches);
- @ini_restore('track_errors');
- if ($result === false) {
- /**
- * @see Zend_Feed_Exception
- */
- require_once 'Zend/Feed/Exception.php';
- throw new Zend_Feed_Exception("Internal error: $php_errormsg");
- }
-
- // Try to fetch a feed for each link tag that appears to refer to a feed
- $feeds = array();
- if (isset($matches[1]) && count($matches[1]) > 0) {
- foreach ($matches[1] as $link) {
- // force string to be an utf-8 one
- if (!mb_check_encoding($link, 'UTF-8')) {
- $link = mb_convert_encoding($link, 'UTF-8');
- }
- $xml = @simplexml_load_string(rtrim($link, ' /') . ' />');
- if ($xml === false) {
- continue;
- }
- $attributes = $xml->attributes();
- if (!isset($attributes['rel']) || !@preg_match('~^(?:alternate|service\.feed)~i', $attributes['rel'])) {
- continue;
- }
- if (!isset($attributes['type']) ||
- !@preg_match('~^application/(?:atom|rss|rdf)\+xml~', $attributes['type'])) {
- continue;
- }
- if (!isset($attributes['href'])) {
- continue;
- }
- try {
- // checks if we need to canonize the given uri
- try {
- $uri = Zend_Uri::factory((string) $attributes['href']);
- } catch (Zend_Uri_Exception $e) {
- // canonize the uri
- $path = (string) $attributes['href'];
- $query = $fragment = '';
- if (substr($path, 0, 1) != '/') {
- // add the current root path to this one
- $path = rtrim($client->getUri()->getPath(), '/') . '/' . $path;
- }
- if (strpos($path, '?') !== false) {
- list($path, $query) = explode('?', $path, 2);
- }
- if (strpos($query, '#') !== false) {
- list($query, $fragment) = explode('#', $query, 2);
- }
- $uri = Zend_Uri::factory($client->getUri(true));
- $uri->setPath($path);
- $uri->setQuery($query);
- $uri->setFragment($fragment);
- }
-
- $feed = self::import($uri);
- } catch (Exception $e) {
- continue;
- }
- $feeds[] = $feed;
- }
- }
-
- // Return the fetched feeds
- return $feeds;
- }
-
- /**
- * Construct a new Zend_Feed_Abstract object from a custom array
- *
- * @param array $data
- * @param string $format (rss|atom) the requested output format
- * @return Zend_Feed_Abstract
- */
- public static function importArray(array $data, $format = 'atom')
- {
- $obj = 'Zend_Feed_' . ucfirst(strtolower($format));
- /**
- * @see Zend_Loader
- */
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($obj);
- Zend_Loader::loadClass('Zend_Feed_Builder');
-
- return new $obj(null, null, new Zend_Feed_Builder($data));
- }
-
- /**
- * Construct a new Zend_Feed_Abstract object from a Zend_Feed_Builder_Interface data source
- *
- * @param Zend_Feed_Builder_Interface $builder this object will be used to extract the data of the feed
- * @param string $format (rss|atom) the requested output format
- * @return Zend_Feed_Abstract
- */
- public static function importBuilder(Zend_Feed_Builder_Interface $builder, $format = 'atom')
- {
- $obj = 'Zend_Feed_' . ucfirst(strtolower($format));
- /**
- * @see Zend_Loader
- */
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($obj);
-
- return new $obj(null, null, $builder);
- }
-}
Deleted: trunk/libs/Zend/Gdata.php
===================================================================
--- trunk/libs/Zend/Gdata.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Gdata.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,133 +0,0 @@
-<?php
-
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Gdata
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * Zend_Gdata_App
- */
-require_once 'Zend/Gdata/App.php';
-
-/**
- * Provides functionality to interact with Google data APIs
- * Subclasses exist to implement service-specific features
- *
- * As the Google data API protocol is based upon the Atom Publishing Protocol
- * (APP), GData functionality extends the appropriate Zend_Gdata_App classes
- *
- * @link http://code.google.com/apis/gdata/overview.html
- *
- * @category Zend
- * @package Zend_Gdata
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Gdata extends Zend_Gdata_App
-{
-
- /**
- * Service name for use with Google's authentication mechanisms
- *
- * @var string
- */
- const AUTH_SERVICE_NAME = 'xapi';
-
- /**
- * Default URI to which to POST.
- *
- * @var string
- */
- protected $_defaultPostUri = null;
-
- /**
- * Packages to search for classes when using magic __call method, in order.
- *
- * @var array
- */
- protected $_registeredPackages = array(
- 'Zend_Gdata_Kind',
- 'Zend_Gdata_Extension',
- 'Zend_Gdata',
- 'Zend_Gdata_App_Extension',
- 'Zend_Gdata_App');
-
- /**
- * Namespaces used for GData data
- *
- * @var array
- */
- public static $namespaces = array(
- 'openSearch' => 'http://a9.com/-/spec/opensearchrss/1.0/',
- 'rss' => 'http://blogs.law.harvard.edu/tech/rss',
- 'gd' => 'http://schemas.google.com/g/2005');
-
- /**
- * Create Gdata object
- *
- * @param Zend_Http_Client $client
- */
- public function __construct($client = null)
- {
- parent::__construct($client);
- }
-
- /**
- * Retreive feed object
- *
- * @param mixed $location The location as string or Zend_Gdata_Query
- * @param string $className The class type to use for returning the feed
- * @return Zend_Gdata_Feed
- */
- public function getFeed($location, $className='Zend_Gdata_Feed')
- {
- if (is_string($location)) {
- $uri = $location;
- } elseif ($location instanceof Zend_Gdata_Query) {
- $uri = $location->getQueryUrl();
- } else {
- require_once 'Zend/Gdata/App/InvalidArgumentException.php';
- throw new Zend_Gdata_App_InvalidArgumentException(
- 'You must specify the location as either a string URI ' .
- 'or a child of Zend_Gdata_Query');
- }
- return parent::getFeed($uri, $className);
- }
-
- /**
- * Retreive entry object
- *
- * @param mixed $location The location as string or Zend_Gdata_Query
- * @return Zend_Gdata_Feed
- */
- public function getEntry($location, $className='Zend_Gdata_Entry')
- {
- if (is_string($location)) {
- $uri = $location;
- } elseif ($location instanceof Zend_Gdata_Query) {
- $uri = $location->getQueryUrl();
- } else {
- require_once 'Zend/Gdata/App/InvalidArgumentException.php';
- throw new Zend_Gdata_App_InvalidArgumentException(
- 'You must specify the location as either a string URI ' .
- 'or a child of Zend_Gdata_Query');
- }
- return parent::getEntry($uri, $className);
- }
-
-}
Deleted: trunk/libs/Zend/Mail.php
===================================================================
--- trunk/libs/Zend/Mail.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Mail.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,649 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Mail
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-
-/**
- * Zend_Mail_Exception
- */
-require_once 'Zend/Mail/Exception.php';
-
-/**
- * Zend_Mail_Transport_Abstract
- */
-require_once 'Zend/Mail/Transport/Abstract.php';
-
-/**
- * Zend_Mime
- */
-require_once 'Zend/Mime.php';
-
-/**
- * Zend_Mail_Transport_Abstract
- */
-require_once 'Zend/Mail/Transport/Abstract.php';
-
-/**
- * Zend_Mime_Message
- */
-require_once 'Zend/Mime/Message.php';
-
-/**
- * Zend_Mime_Part
- */
-require_once 'Zend/Mime/Part.php';
-
-
-/**
- * Class for sending an email.
- *
- * @category Zend
- * @package Zend_Mail
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Mail extends Zend_Mime_Message
-{
- /**#@+
- * @access protected
- */
-
- /**
- * @var Zend_Mail_Transport_Abstract
- * @static
- */
- protected static $_defaultTransport = null;
-
- /**
- * Mail character set
- * @var string
- */
- protected $_charset = null;
-
- /**
- * Mail headers
- * @var array
- */
- protected $_headers = array();
-
- /**
- * From: address
- * @var string
- */
- protected $_from = null;
-
- /**
- * To: addresses
- * @var array
- */
- protected $_to = array();
-
- /**
- * Array of all recipients
- * @var array
- */
- protected $_recipients = array();
-
- /**
- * Return-Path header
- * @var string
- */
- protected $_returnPath = null;
-
- /**
- * Subject: header
- * @var string
- */
- protected $_subject = null;
-
- /**
- * text/plain MIME part
- * @var false|Zend_Mime_Part
- */
- protected $_bodyText = false;
-
- /**
- * text/html MIME part
- * @var false|Zend_Mime_Part
- */
- protected $_bodyHtml = false;
-
- /**
- * MIME boundary string
- * @var string
- */
- protected $_mimeBoundary = null;
-
- /**
- * Content type of the message
- * @var string
- */
- protected $_type = null;
-
- /**#@-*/
-
- /**
- * Flag: whether or not email has attachments
- * @var boolean
- */
- public $hasAttachments = false;
-
-
- /**
- * Sets the default mail transport for all following uses of
- * Zend_Mail::send();
- *
- * @todo Allow passing a string to indicate the transport to load
- * @todo Allow passing in optional options for the transport to load
- * @param Zend_Mail_Transport_Abstract $transport
- */
- public static function setDefaultTransport(Zend_Mail_Transport_Abstract $transport)
- {
- self::$_defaultTransport = $transport;
- }
-
- /**
- * Public constructor
- *
- * @param string $charset
- */
- public function __construct($charset='iso-8859-1')
- {
- $this->_charset = $charset;
- }
-
- /**
- * Return charset string
- *
- * @return string
- */
- public function getCharset()
- {
- return $this->_charset;
- }
-
- /**
- * Set content type
- *
- * Should only be used for manually setting multipart content types.
- *
- * @param string $type Content type
- * @return Zend_Mail Implements fluent interface
- * @throws Zend_Mail_Exception for types not supported by Zend_Mime
- */
- public function setType($type)
- {
- $allowed = array(
- Zend_Mime::MULTIPART_ALTERNATIVE,
- Zend_Mime::MULTIPART_MIXED,
- Zend_Mime::MULTIPART_RELATED,
- );
- if (!in_array($type, $allowed)) {
- throw new Zend_Mail_Exception('Invalid content type "' . $type . '"');
- }
-
- $this->_type = $type;
- return $this;
- }
-
- /**
- * Get content type of the message
- *
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * Set an arbitrary mime boundary for the message
- *
- * If not set, Zend_Mime will generate one.
- *
- * @param string $boundary
- * @return Zend_Mail Provides fluent interface
- */
- public function setMimeBoundary($boundary)
- {
- $this->_mimeBoundary = $boundary;
- }
-
- /**
- * Return the boundary string used for the message
- *
- * @return string
- */
- public function getMimeBoundary()
- {
- return $this->_mimeBoundary;
- }
-
- /**
- * Sets the text body for the message.
- *
- * @param string $txt
- * @param string $charset
- * @param string $encoding
- * @return Zend_Mail Provides fluent interface
- */
- public function setBodyText($txt, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
- {
- if ($charset === null) {
- $charset = $this->_charset;
- }
-
- $mp = new Zend_Mime_Part($txt);
- $mp->encoding = $encoding;
- $mp->type = Zend_Mime::TYPE_TEXT;
- $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
- $mp->charset = $charset;
-
- $this->_bodyText = $mp;
-
- return $this;
- }
-
- /**
- * Return text body Zend_Mime_Part or string
- *
- * @param bool textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part
- * @return false|Zend_Mime_Part|string
- */
- public function getBodyText($textOnly = false)
- {
- if ($textOnly && $this->_bodyText) {
- $body = $this->_bodyText;
- return $body->getContent();
- }
-
- return $this->_bodyText;
- }
-
- /**
- * Sets the HTML body for the message
- *
- * @param string $html
- * @param string $charset
- * @param string $encoding
- * @return Zend_Mail Provides fluent interface
- */
- public function setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
- {
- if ($charset === null) {
- $charset = $this->_charset;
- }
-
- $mp = new Zend_Mime_Part($html);
- $mp->encoding = $encoding;
- $mp->type = Zend_Mime::TYPE_HTML;
- $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
- $mp->charset = $charset;
-
- $this->_bodyHtml = $mp;
-
- return $this;
- }
-
- /**
- * Return Zend_Mime_Part representing body HTML
- *
- * @param bool $htmlOnly Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part
- * @return false|Zend_Mime_Part|string
- */
- public function getBodyHtml($htmlOnly = false)
- {
- if ($htmlOnly && $this->_bodyHtml) {
- $body = $this->_bodyHtml;
- return $body->getContent();
- }
-
- return $this->_bodyHtml;
- }
-
- /**
- * Adds an existing attachment to the mail message
- *
- * @param Zend_Mime_Part $attachment
- * @return Zend_Mail Provides fluent interface
- */
- public function addAttachment(Zend_Mime_Part $attachment)
- {
- $this->addPart($attachment);
- $this->hasAttachments = true;
-
- return $this;
- }
-
- /**
- * Creates a Zend_Mime_Part attachment
- *
- * Attachment is automatically added to the mail object after creation. The
- * attachment object is returned to allow for further manipulation.
- *
- * @param string $body
- * @param string $mimeType
- * @param string $disposition
- * @param string $encoding
- * @param string $filename OPTIONAL A filename for the attachment
- * @return Zend_Mime_Part Newly created Zend_Mime_Part object (to allow
- * advanced settings)
- */
- public function createAttachment($body,
- $mimeType = Zend_Mime::TYPE_OCTETSTREAM,
- $disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
- $encoding = Zend_Mime::ENCODING_BASE64,
- $filename = null)
- {
-
- $mp = new Zend_Mime_Part($body);
- $mp->encoding = $encoding;
- $mp->type = $mimeType;
- $mp->disposition = $disposition;
- $mp->filename = $filename;
-
- $this->addAttachment($mp);
-
- return $mp;
- }
-
- /**
- * Return a count of message parts
- *
- * @return void
- */
- public function getPartCount()
- {
- return count($this->_parts);
- }
-
- /**
- * Encode header fields
- *
- * Encodes header content according to RFC1522 if it contains non-printable
- * characters.
- *
- * @param string $value
- * @return string
- */
- protected function _encodeHeader($value)
- {
- if (Zend_Mime::isPrintable($value)) {
- return $value;
- } else {
- $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
- $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'), $quotedValue);
- return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
- }
- }
-
- /**
- * Add a header to the message
- *
- * Adds a header to this message. If append is true and the header already
- * exists, raises a flag indicating that the header should be appended.
- *
- * @param string $headerName
- * @param string $value
- * @param boolean $append
- */
- protected function _storeHeader($headerName, $value, $append=false)
- {
- $value = strtr($value,"\r\n\t",'???');
- if (isset($this->_headers[$headerName])) {
- $this->_headers[$headerName][] = $value;
- } else {
- $this->_headers[$headerName] = array($value);
- }
-
- if ($append) {
- $this->_headers[$headerName]['append'] = true;
- }
-
- }
-
- /**
- * Add a recipient
- *
- * @param string $email
- */
- protected function _addRecipient($email, $to = false)
- {
- // prevent duplicates
- $this->_recipients[$email] = 1;
-
- if ($to) {
- $this->_to[] = $email;
- }
- }
-
- /**
- * Helper function for adding a recipient and the corresponding header
- *
- * @param string $headerName
- * @param string $name
- * @param string $email
- */
- protected function _addRecipientAndHeader($headerName, $name, $email)
- {
- $email = strtr($email,"\r\n\t",'???');
- $this->_addRecipient($email, ('To' == $headerName) ? true : false);
- if ($name != '') {
- $name = '"' . $this->_encodeHeader($name) . '" ';
- }
-
- $this->_storeHeader($headerName, $name .'<'. $email . '>', true);
- }
-
- /**
- * Adds To-header and recipient
- *
- * @param string $name
- * @param string $email
- * @return Zend_Mail Provides fluent interface
- */
- public function addTo($email, $name='')
- {
- $this->_addRecipientAndHeader('To', $name, $email);
- return $this;
- }
-
- /**
- * Adds Cc-header and recipient
- *
- * @param string $name
- * @param string $email
- * @return Zend_Mail Provides fluent interface
- */
- public function addCc($email, $name='')
- {
- $this->_addRecipientAndHeader('Cc', $name, $email);
- return $this;
- }
-
- /**
- * Adds Bcc recipient
- *
- * @param string $email
- * @return Zend_Mail Provides fluent interface
- */
- public function addBcc($email)
- {
- $this->_addRecipientAndHeader('Bcc', '', $email);
- return $this;
- }
-
- /**
- * Return list of recipient email addresses
- *
- * @return array (of strings)
- */
- public function getRecipients()
- {
- return array_keys($this->_recipients);
- }
-
- /**
- * Sets From-header and sender of the message
- *
- * @param string $email
- * @param string $name
- * @return Zend_Mail Provides fluent interface
- * @throws Zend_Mail_Exception if called subsequent times
- */
- public function setFrom($email, $name = '')
- {
- if ($this->_from === null) {
- $email = strtr($email,"\r\n\t",'???');
- $this->_from = $email;
- $this->_storeHeader('From', $this->_encodeHeader('"'.$name.'"').' <'.$email.'>', true);
- } else {
- throw new Zend_Mail_Exception('From Header set twice');
- }
- return $this;
- }
-
- /**
- * Returns the sender of the mail
- *
- * @return string
- */
- public function getFrom()
- {
- return $this->_from;
- }
-
- /**
- * Sets the Return-Path header for an email
- *
- * @param string $email
- * @return Zend_Mail Provides fluent interface
- * @throws Zend_Mail_Exception if set multiple times
- */
- public function setReturnPath($email)
- {
- if ($this->_returnPath === null) {
- $email = strtr($email,"\r\n\t",'???');
- $this->_returnPath = $email;
- $this->_storeHeader('Return-Path', $email, false);
- } else {
- throw new Zend_Mail_Exception('Return-Path Header set twice');
- }
- return $this;
- }
-
- /**
- * Returns the current Return-Path address for the email
- *
- * If no Return-Path header is set, returns the value of {@link $_from}.
- *
- * @return string
- */
- public function getReturnPath()
- {
- if (null !== $this->_returnPath) {
- return $this->_returnPath;
- }
-
- return $this->_from;
- }
-
- /**
- * Sets the subject of the message
- *
- * @param string $subject
- * @return Zend_Mail Provides fluent interface
- */
- public function setSubject($subject)
- {
- if ($this->_subject === null) {
- $subject = strtr($subject,"\r\n\t",'???');
- $this->_subject = $this->_encodeHeader($subject);
- $this->_storeHeader('Subject', $this->_subject);
- } else {
- throw new Zend_Mail_Exception('Subject set twice');
- }
- return $this;
- }
-
- /**
- * Returns the encoded subject of the message
- *
- * @return string
- */
- public function getSubject()
- {
- return $this->_subject;
- }
-
- /**
- * Add a custom header to the message
- *
- * @param string $name
- * @param string $value
- * @param boolean $append
- * @return Zend_Mail Provides fluent interface
- * @throws Zend_Mail_Exception on attempts to create standard headers
- */
- public function addHeader($name, $value, $append = false)
- {
- if (in_array(strtolower($name), array('to', 'cc', 'bcc', 'from', 'subject', 'return-path'))) {
- throw new Zend_Mail_Exception('Cannot set standard header from addHeader()');
- }
-
- $value = strtr($value,"\r\n\t",'???');
- $value = $this->_encodeHeader($value);
- $this->_storeHeader($name, $value, $append);
- }
-
- /**
- * Return mail headers
- *
- * @return void
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Sends this email using the given transport or a previously
- * set DefaultTransport or the internal mail function if no
- * default transport had been set.
- *
- * @param Zend_Mail_Transport_Abstract $transport
- * @return Zend_Mail Provides fluent interface
- */
- public function send($transport = null)
- {
- if ($transport === null) {
- if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {
- require_once 'Zend/Mail/Transport/Sendmail.php';
- $transport = new Zend_Mail_Transport_Sendmail();
- } else {
- $transport = self::$_defaultTransport;
- }
- }
-
- $transport->send($this);
-
- return $this;
- }
-
-}
Deleted: trunk/libs/Zend/Mime.php
===================================================================
--- trunk/libs/Zend/Mime.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Mime.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,251 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Mime
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-
-/**
- * Support class for MultiPart Mime Messages
- *
- * @category Zend
- * @package Zend_Mime
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Mime
-{
- const TYPE_OCTETSTREAM = 'application/octet-stream';
- const TYPE_TEXT = 'text/plain';
- const TYPE_HTML = 'text/html';
- const ENCODING_7BIT = '7bit';
- const ENCODING_8BIT = '8bit';
- const ENCODING_QUOTEDPRINTABLE = 'quoted-printable';
- const ENCODING_BASE64 = 'base64';
- const DISPOSITION_ATTACHMENT = 'attachment';
- const DISPOSITION_INLINE = 'inline';
- const LINELENGTH = 74;
- const LINEEND = "\n";
- const MULTIPART_ALTERNATIVE = 'multipart/alternative';
- const MULTIPART_MIXED = 'multipart/mixed';
- const MULTIPART_RELATED = 'multipart/related';
-
- protected $_boundary;
- protected static $makeUnique = 0;
-
- // lookup-Tables for QuotedPrintable
- public static $qpKeys = array(
- "\x00","\x01","\x02","\x03","\x04","\x05","\x06","\x07",
- "\x08","\x09","\x0A","\x0B","\x0C","\x0D","\x0E","\x0F",
- "\x10","\x11","\x12","\x13","\x14","\x15","\x16","\x17",
- "\x18","\x19","\x1A","\x1B","\x1C","\x1D","\x1E","\x1F",
- "\x7F","\x80","\x81","\x82","\x83","\x84","\x85","\x86",
- "\x87","\x88","\x89","\x8A","\x8B","\x8C","\x8D","\x8E",
- "\x8F","\x90","\x91","\x92","\x93","\x94","\x95","\x96",
- "\x97","\x98","\x99","\x9A","\x9B","\x9C","\x9D","\x9E",
- "\x9F","\xA0","\xA1","\xA2","\xA3","\xA4","\xA5","\xA6",
- "\xA7","\xA8","\xA9","\xAA","\xAB","\xAC","\xAD","\xAE",
- "\xAF","\xB0","\xB1","\xB2","\xB3","\xB4","\xB5","\xB6",
- "\xB7","\xB8","\xB9","\xBA","\xBB","\xBC","\xBD","\xBE",
- "\xBF","\xC0","\xC1","\xC2","\xC3","\xC4","\xC5","\xC6",
- "\xC7","\xC8","\xC9","\xCA","\xCB","\xCC","\xCD","\xCE",
- "\xCF","\xD0","\xD1","\xD2","\xD3","\xD4","\xD5","\xD6",
- "\xD7","\xD8","\xD9","\xDA","\xDB","\xDC","\xDD","\xDE",
- "\xDF","\xE0","\xE1","\xE2","\xE3","\xE4","\xE5","\xE6",
- "\xE7","\xE8","\xE9","\xEA","\xEB","\xEC","\xED","\xEE",
- "\xEF","\xF0","\xF1","\xF2","\xF3","\xF4","\xF5","\xF6",
- "\xF7","\xF8","\xF9","\xFA","\xFB","\xFC","\xFD","\xFE",
- "\xFF"
- );
-
- public static $qpReplaceValues = array(
- "=00","=01","=02","=03","=04","=05","=06","=07",
- "=08","=09","=0A","=0B","=0C","=0D","=0E","=0F",
- "=10","=11","=12","=13","=14","=15","=16","=17",
- "=18","=19","=1A","=1B","=1C","=1D","=1E","=1F",
- "=7F","=80","=81","=82","=83","=84","=85","=86",
- "=87","=88","=89","=8A","=8B","=8C","=8D","=8E",
- "=8F","=90","=91","=92","=93","=94","=95","=96",
- "=97","=98","=99","=9A","=9B","=9C","=9D","=9E",
- "=9F","=A0","=A1","=A2","=A3","=A4","=A5","=A6",
- "=A7","=A8","=A9","=AA","=AB","=AC","=AD","=AE",
- "=AF","=B0","=B1","=B2","=B3","=B4","=B5","=B6",
- "=B7","=B8","=B9","=BA","=BB","=BC","=BD","=BE",
- "=BF","=C0","=C1","=C2","=C3","=C4","=C5","=C6",
- "=C7","=C8","=C9","=CA","=CB","=CC","=CD","=CE",
- "=CF","=D0","=D1","=D2","=D3","=D4","=D5","=D6",
- "=D7","=D8","=D9","=DA","=DB","=DC","=DD","=DE",
- "=DF","=E0","=E1","=E2","=E3","=E4","=E5","=E6",
- "=E7","=E8","=E9","=EA","=EB","=EC","=ED","=EE",
- "=EF","=F0","=F1","=F2","=F3","=F4","=F5","=F6",
- "=F7","=F8","=F9","=FA","=FB","=FC","=FD","=FE",
- "=FF"
- );
-
- public static $qpKeysString =
- "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF";
-
- /**
- * Check if the given string is "printable"
- *
- * Checks that a string contains no unprintable characters. If this returns
- * false, encode the string for secure delivery.
- *
- * @param string $str
- * @return boolean
- */
- public static function isPrintable($str)
- {
- return (strcspn($str, self::$qpKeysString) == strlen($str));
- }
-
- /**
- * Encode a given string with the QUOTED_PRINTABLE mechanism
- *
- * @param string $str
- * @param int $lineLength Defaults to {@link LINELENGTH}
- * @param int $lineEnd Defaults to {@link LINEEND}
- * @return string
- */
- public static function encodeQuotedPrintable($str,
- $lineLength = self::LINELENGTH,
- $lineEnd = self::LINEEND)
- {
- $out = '';
- $str = str_replace('=', '=3D', $str);
- $str = str_replace(self::$qpKeys, self::$qpReplaceValues, $str);
- $str = rtrim($str);
-
- // Split encoded text into separate lines
- while ($str) {
- $ptr = strlen($str);
- if ($ptr > $lineLength) {
- $ptr = $lineLength;
- }
-
- // Ensure we are not splitting across an encoded character
- $pos = strrpos(substr($str, 0, $ptr), '=');
- if ($pos !== false && $pos >= $ptr - 2) {
- $ptr = $pos;
- }
-
- // Check if there is a space at the end of the line and rewind
- if ($ptr > 0 && $str[$ptr - 1] == ' ') {
- --$ptr;
- }
-
- // Add string and continue
- $out .= substr($str, 0, $ptr) . '=' . $lineEnd;
- $str = substr($str, $ptr);
- }
-
- $out = rtrim($out, $lineEnd);
- $out = rtrim($out, '=');
- return $out;
- }
-
- /**
- * Encode a given string in base64 encoding and break lines
- * according to the maximum linelength.
- *
- * @param string $str
- * @param int $lineLength Defaults to {@link LINELENGTH}
- * @param int $lineEnd Defaults to {@link LINEEND}
- * @return string
- */
- public static function encodeBase64($str,
- $lineLength = self::LINELENGTH,
- $lineEnd = self::LINEEND)
- {
- return rtrim(chunk_split(base64_encode($str), $lineLength, $lineEnd));
- }
-
- /**
- * Constructor
- *
- * @param null|string $boundary
- * @access public
- * @return void
- */
- public function __construct($boundary = null)
- {
- // This string needs to be somewhat unique
- if ($boundary === null) {
- $this->_boundary = '=_' . md5(microtime(1) . self::$makeUnique++);
- } else {
- $this->_boundary = $boundary;
- }
- }
-
- /**
- * Encode the given string with the given encoding.
- *
- * @param string $str
- * @param string $encoding
- * @return string
- */
- public static function encode($str, $encoding)
- {
- switch ($encoding) {
- case self::ENCODING_BASE64:
- return self::encodeBase64($str);
-
- case self::ENCODING_QUOTEDPRINTABLE:
- return self::encodeQuotedPrintable($str);
-
- default:
- /**
- * @todo 7Bit and 8Bit is currently handled the same way.
- */
- return $str;
- }
- }
-
- /**
- * Return a MIME boundary
- *
- * @access public
- * @return string
- */
- public function boundary()
- {
- return $this->_boundary;
- }
-
- /**
- * Return a MIME boundary line
- *
- * @param mixed $EOL Defaults to {@link LINEEND}
- * @access public
- * @return string
- */
- public function boundaryLine($EOL = self::LINEEND)
- {
- return $EOL . '--' . $this->_boundary . $EOL;
- }
-
- /**
- * Return MIME ending
- *
- * @access public
- * @return string
- */
- public function mimeEnd($EOL = self::LINEEND)
- {
- return $EOL . '--' . $this->_boundary . '--' . $EOL;
- }
-}
Deleted: trunk/libs/Zend/Pdf.php
===================================================================
--- trunk/libs/Zend/Pdf.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Pdf.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,685 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Pdf
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-
-/** Zend_Pdf_Exception */
-require_once 'Zend/Pdf/Exception.php';
-
-/** Zend_Pdf_Page */
-require_once 'Zend/Pdf/Page.php';
-
-/** Zend_Pdf_Cmap */
-require_once 'Zend/Pdf/Cmap.php';
-
-/** Zend_Pdf_Font */
-require_once 'Zend/Pdf/Font.php';
-
-/** Zend_Pdf_Style */
-require_once 'Zend/Pdf/Style.php';
-
-/** Zend_Pdf_Parser */
-require_once 'Zend/Pdf/Parser.php';
-
-/** Zend_Pdf_Trailer */
-require_once 'Zend/Pdf/Trailer.php';
-
-/** Zend_Pdf_Trailer_Generator */
-require_once 'Zend/Pdf/Trailer/Generator.php';
-
-/** Zend_Pdf_Color */
-require_once 'Zend/Pdf/Color.php';
-
-/** Zend_Pdf_Color_GrayScale */
-require_once 'Zend/Pdf/Color/GrayScale.php';
-
-/** Zend_Pdf_Color_Rgb */
-require_once 'Zend/Pdf/Color/Rgb.php';
-
-/** Zend_Pdf_Color_Cmyk */
-require_once 'Zend/Pdf/Color/Cmyk.php';
-
-/** Zend_Pdf_Color_Html */
-require_once 'Zend/Pdf/Color/Html.php';
-
-/** Zend_Pdf_Image */
-require_once 'Zend/Pdf/Resource/Image.php';
-
-/** Zend_Pdf_Image */
-require_once 'Zend/Pdf/Image.php';
-
-/** Zend_Pdf_Image_Jpeg */
-require_once 'Zend/Pdf/Resource/Image/Jpeg.php';
-
-/** Zend_Pdf_Image_Tiff */
-require_once 'Zend/Pdf/Resource/Image/Tiff.php';
-
-/** Zend_Pdf_Image_Png */
-require_once 'Zend/Pdf/Resource/Image/Png.php';
-
-
-/** Zend_Memory */
-require_once 'Zend/Memory.php';
-
-
-/**
- * General entity which describes PDF document.
- * It implements document abstraction with a document level operations.
- *
- * Class is used to create new PDF document or load existing document.
- * See details in a class constructor description
- *
- * Class agregates document level properties and entities (pages, bookmarks,
- * document level actions, attachments, form object, etc)
- *
- * @category Zend
- * @package Zend_Pdf
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Pdf
-{
- /**** Class Constants ****/
-
- /**
- * Version number of generated PDF documents.
- */
- const PDF_VERSION = 1.4;
-
- /**
- * PDF file header.
- */
- const PDF_HEADER = "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n";
-
-
-
- /**
- * Pages collection
- *
- * @todo implement it as a class, which supports ArrayAccess and Iterator interfaces,
- * to provide incremental parsing and pages tree updating.
- * That will give good performance and memory (PDF size) benefits.
- *
- * @var array - array of Zend_Pdf_Page object
- */
- public $pages = array();
-
- /**
- * Document properties
- *
- * @var array
- */
- private $_properties = array();
-
- /**
- * Document level javascript
- *
- * @var string
- */
- private $_javaScript = null;
-
- /**
- * Document named actions
- * "GoTo..." actions, used to refer document parts
- * from outside PDF
- *
- * @var array - array of Zend_Pdf_Action objects
- */
- private $_namedActions = array();
-
-
- /**
- * Pdf trailer (last or just created)
- *
- * @var Zend_Pdf_Trailer
- */
- private $_trailer = null;
-
-
- /**
- * PDF objects factory.
- *
- * @var Zend_Pdf_ElementFactory_Interface
- */
- private $_objFactory = null;
-
- /**
- * Memory manager for stream objects
- *
- * @var Zend_Memory_Manager|null
- */
- private static $_memoryManager = null;
-
- /**
- * Pdf file parser.
- * It's not used, but has to be destroyed only with Zend_Pdf object
- *
- * @var Zend_Pdf_Parser
- */
- private $_parser;
-
- /**
- * Request used memory manager
- *
- * @return Zend_Memory_Manager
- */
- static public function getMemoryManager()
- {
- if (self::$_memoryManager === null) {
- self::$_memoryManager = Zend_Memory::factory('none');
- }
-
- return self::$_memoryManager;
- }
-
- /**
- * Set user defined memory manager
- *
- * @param Zend_Memory_Manager $memoryManager
- */
- static public function setMemoryManager(Zend_Memory_Manager $memoryManager)
- {
- self::$_memoryManager = $memoryManager;
- }
-
-
- /**
- * Create new PDF document from a $source string
- *
- * @param string $source
- * @param integer $revision
- * @return Zend_Pdf
- */
- public static function parse(&$source = null, $revision = null)
- {
- return new Zend_Pdf($source, $revision);
- }
-
- /**
- * Load PDF document from a file
- *
- * @param string $source
- * @param integer $revision
- * @return Zend_Pdf
- */
- public static function load($source = null, $revision = null)
- {
- return new Zend_Pdf($source, $revision, true);
- }
-
- /**
- * Render PDF document and save it.
- *
- * If $updateOnly is true, then it only appends new section to the end of file.
- *
- * @param string $filename
- * @param boolean $updateOnly
- * @throws Zend_Pdf_Exception
- */
- public function save($filename, $updateOnly = false)
- {
- if (($file = @fopen($filename, $updateOnly ? 'ab':'wb')) === false ) {
- throw new Zend_Pdf_Exception( "Can not open '$filename' file for writing." );
- }
-
- $this->render($updateOnly, $file);
-
- fclose($file);
- }
-
- /**
- * Creates or loads PDF document.
- *
- * If $source is null, then it creates a new document.
- *
- * If $source is a string and $load is false, then it loads document
- * from a binary string.
- *
- * If $source is a string and $load is true, then it loads document
- * from a file.
-
- * $revision used to roll back document to specified version
- * (0 - currtent version, 1 - previous version, 2 - ...)
- *
- * @param string $source - PDF file to load
- * @param integer $revision
- * @throws Zend_Pdf_Exception
- * @return Zend_Pdf
- */
- public function __construct($source = null, $revision = null, $load = false)
- {
- $this->_objFactory = Zend_Pdf_ElementFactory::createFactory(1);
-
- if ($source !== null) {
- $this->_parser = new Zend_Pdf_Parser($source, $this->_objFactory, $load);
- $this->_trailer = $this->_parser->getTrailer();
- if ($revision !== null) {
- $this->rollback($revision);
- } else {
- $this->_loadPages($this->_trailer->Root->Pages);
- }
- } else {
- $trailerDictionary = new Zend_Pdf_Element_Dictionary();
-
- /**
- * Document id
- */
- $docId = md5(uniqid(rand(), true)); // 32 byte (128 bit) identifier
- $docIdLow = substr($docId, 0, 16); // first 16 bytes
- $docIdHigh = substr($docId, 16, 16); // second 16 bytes
-
- $trailerDictionary->ID = new Zend_Pdf_Element_Array();
- $trailerDictionary->ID->items[] = new Zend_Pdf_Element_String_Binary($docIdLow);
- $trailerDictionary->ID->items[] = new Zend_Pdf_Element_String_Binary($docIdHigh);
-
- $trailerDictionary->Size = new Zend_Pdf_Element_Numeric(0);
-
- $this->_trailer = new Zend_Pdf_Trailer_Generator($trailerDictionary);
-
- /**
- * Document catalog indirect object.
- */
- $docCatalog = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
- $docCatalog->Type = new Zend_Pdf_Element_Name('Catalog');
- $docCatalog->Version = new Zend_Pdf_Element_Name(Zend_Pdf::PDF_VERSION);
- $this->_trailer->Root = $docCatalog;
-
- /**
- * Pages container
- */
- $docPages = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
- $docPages->Type = new Zend_Pdf_Element_Name('Pages');
- $docPages->Kids = new Zend_Pdf_Element_Array();
- $docPages->Count = new Zend_Pdf_Element_Numeric(0);
- $docCatalog->Pages = $docPages;
- }
- }
-
- /**
- * Retrive number of revisions.
- *
- * @return integer
- */
- public function revisions()
- {
- $revisions = 1;
- $currentTrailer = $this->_trailer;
-
- while ($currentTrailer->getPrev() !== null && $currentTrailer->getPrev()->Root !== null ) {
- $revisions++;
- $currentTrailer = $currentTrailer->getPrev();
- }
-
- return $revisions++;
- }
-
- /**
- * Rollback document $steps number of revisions.
- * This method must be invoked before any changes, applied to the document.
- * Otherwise behavior is undefined.
- *
- * @param integer $steps
- */
- public function rollback($steps)
- {
- for ($count = 0; $count < $steps; $count++) {
- if ($this->_trailer->getPrev() !== null && $this->_trailer->getPrev()->Root !== null) {
- $this->_trailer = $this->_trailer->getPrev();
- } else {
- break;
- }
- }
- $this->_objFactory->setObjectCount($this->_trailer->Size->value);
-
- // Mark content as modified to force new trailer generation at render time
- $this->_trailer->Root->touch();
-
- $this->pages = array();
- $this->_loadPages($this->_trailer->Root->Pages);
- }
-
-
-
- /**
- * List of inheritable attributesfor pages tree
- *
- * @var array
- */
- private static $_inheritableAttributes = array('Resources', 'MediaBox', 'CropBox', 'Rotate');
-
-
- /**
- * Load pages recursively
- *
- * @param Zend_Pdf_Element_Reference $pages
- * @param array|null $attributes
- */
- private function _loadPages(Zend_Pdf_Element_Reference $pages, $attributes = array())
- {
- if ($pages->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
- throw new Zend_Pdf_Exception('Wrong argument');
- }
-
- foreach ($pages->getKeys() as $property) {
- if (in_array($property, self::$_inheritableAttributes)) {
- $attributes[$property] = $pages->$property;
- $pages->$property = null;
- }
- }
-
-
- foreach ($pages->Kids->items as $child) {
- if ($child->Type->value == 'Pages') {
- $this->_loadPages($child, $attributes);
- } else if ($child->Type->value == 'Page') {
- foreach (self::$_inheritableAttributes as $property) {
- if ($child->$property === null && array_key_exists($property, $attributes)) {
- /**
- * Important note.
- * If any attribute or dependant object is an indirect object, then it's still
- * shared between pages.
- */
- if ($attributes[$property] instanceof Zend_Pdf_Element_Object) {
- $child->$property = $attributes[$property];
- } else {
- $child->$property = $this->_objFactory->newObject($attributes[$property]);
- }
- }
- }
- $this->pages[] = new Zend_Pdf_Page($child, $this->_objFactory);
- }
- }
- }
-
-
- /**
- * Orginize pages to tha pages tree structure.
- *
- * @todo atomatically attach page to the document, if it's not done yet.
- * @todo check, that page is attached to the current document
- *
- * @todo Dump pages as a balanced tree instead of a plain set.
- */
- private function _dumpPages()
- {
- $pagesContainer = $this->_trailer->Root->Pages;
- $pagesContainer->touch();
- $pagesContainer->Kids->items->clear();
-
- foreach ($this->pages as $page ) {
- $page->render($this->_objFactory);
-
- $pageDictionary = $page->getPageDictionary();
- $pageDictionary->touch();
- $pageDictionary->Parent = $pagesContainer;
-
- $pagesContainer->Kids->items[] = $pageDictionary;
- }
-
- $pagesContainer->Count->touch();
- $pagesContainer->Count->value = count($this->pages);
- }
-
-
- /**
- * Create page object, attached to the PDF document.
- * Method signatures:
- *
- * 1. Create new page with a specified pagesize.
- * If $factory is null then it will be created and page must be attached to the document to be
- * included into output.
- * ---------------------------------------------------------
- * new Zend_Pdf_Page(string $pagesize);
- * ---------------------------------------------------------
- *
- * 2. Create new page with a specified pagesize (in default user space units).
- * If $factory is null then it will be created and page must be attached to the document to be
- * included into output.
- * ---------------------------------------------------------
- * new Zend_Pdf_Page(numeric $width, numeric $height);
- * ---------------------------------------------------------
- *
- * @param mixed $param1
- * @param mixed $param2
- * @return Zend_Pdf_Page
- */
- public function newPage($param1, $param2 = null)
- {
- if ($param2 === null) {
- return new Zend_Pdf_Page($param1, $this->_objFactory);
- } else {
- return new Zend_Pdf_Page($param1, $param2, $this->_objFactory);
- }
- }
-
- /**
- * Return return the an associative array with PDF meta information, values may
- * be string, boolean or float.
- * Returned array could be used directly to access, add, modify or remove
- * document properties.
- *
- * Standard document properties: Title (must be set for PDF/X documents), Author,
- * Subject, Keywords (comma separated list), Creator (the name of the application,
- * that created document, if it was converted from other format), Trapped (must be
- * true, false or null, can not be null for PDF/X documents)
- *
- * @todo implementation
- *
- * @return array
- */
- public function properties()
- {
- return $this->_properties;
- }
-
-
- /**
- * Return the document-level JavaScript
- * or null if there is no JavaScript for this document
- *
- * @return string
- */
- public function getJavaScript()
- {
- return $this->_javaScript;
- }
-
-
- /**
- * Return an associative array containing all the named actions in the PDF.
- * Named actions (it's always "GoTo" actions) can be used to reference from outside
- * the PDF, ex: 'http://www.something.com/mydocument.pdf#MyAction'
- *
- * @return array
- */
- public function getNamedActions()
- {
- return $this->_namedActions;
- }
-
-
- /**
- * Render the completed PDF to a string.
- * If $newSegmentOnly is true, then only appended part of PDF is returned.
- *
- * @param boolean $newSegmentOnly
- * @param resource $outputStream
- * @return string
- */
- public function render($newSegmentOnly = false, $outputStream = null)
- {
- $this->_dumpPages();
-
- // Check, that PDF file was modified
- // File is always modified by _dumpPages() now, but future implementations may eliminate this.
- if (!$this->_objFactory->isModified()) {
- if ($newSegmentOnly) {
- // Do nothing, return
- return '';
- }
-
- if ($outputStream === null) {
- return $this->_trailer->getPDFString();
- } else {
- $pdfData = $this->_trailer->getPDFString();
- while ( strlen($pdfData) > 0 && ($byteCount = fwrite($outputStream, $pdfData)) != false ) {
- $pdfData = substr($pdfData, $byteCount);
- }
-
- return '';
- }
- }
-
- // offset (from a start of PDF file) of new PDF file segment
- $offset = $this->_trailer->getPDFLength();
- // Last Object number in a list of free objects
- $lastFreeObject = $this->_trailer->getLastFreeObject();
-
- // Array of cross-reference table subsections
- $xrefTable = array();
- // Object numbers of first objects in each subsection
- $xrefSectionStartNums = array();
-
- // Last cross-reference table subsection
- $xrefSection = array();
- // Dummy initialization of the first element (specail case - header of linked list of free objects).
- $xrefSection[] = 0;
- $xrefSectionStartNums[] = 0;
- // Object number of last processed PDF object.
- // Used to manage cross-reference subsections.
- // Initialized by zero (specail case - header of linked list of free objects).
- $lastObjNum = 0;
-
- if ($outputStream !== null) {
- if (!$newSegmentOnly) {
- $pdfData = $this->_trailer->getPDFString();
- while ( strlen($pdfData) > 0 && ($byteCount = fwrite($outputStream, $pdfData)) != false ) {
- $pdfData = substr($pdfData, $byteCount);
- }
- }
- } else {
- $pdfSegmentBlocks = ($newSegmentOnly) ? array() : array($this->_trailer->getPDFString());
- }
-
- // Iterate objects to create new reference table
- foreach ($this->_objFactory->listModifiedObjects() as $updateInfo) {
- $objNum = $updateInfo->getObjNum();
-
- if ($objNum - $lastObjNum != 1) {
- // Save cross-reference table subsection and start new one
- $xrefTable[] = $xrefSection;
- $xrefSection = array();
- $xrefSectionStartNums[] = $objNum;
- }
-
- if ($updateInfo->isFree()) {
- // Free object cross-reference table entry
- $xrefSection[] = sprintf("%010d %05d f \n", $lastFreeObject, $updateInfo->getGenNum());
- $lastFreeObject = $objNum;
- } else {
- // In-use object cross-reference table entry
- $xrefSection[] = sprintf("%010d %05d n \n", $offset, $updateInfo->getGenNum());
-
- $pdfBlock = $updateInfo->getObjectDump();
- $offset += strlen($pdfBlock);
-
- if ($outputStream === null) {
- $pdfSegmentBlocks[] = $pdfBlock;
- } else {
- while ( strlen($pdfBlock) > 0 && ($byteCount = fwrite($outputStream, $pdfBlock)) != false ) {
- $pdfBlock = substr($pdfBlock, $byteCount);
- }
- }
- }
- $lastObjNum = $objNum;
- }
- // Save last cross-reference table subsection
- $xrefTable[] = $xrefSection;
-
- // Modify first entry (specail case - header of linked list of free objects).
- $xrefTable[0][0] = sprintf("%010d 65535 f \n", $lastFreeObject);
-
- $xrefTableStr = "xref\n";
- foreach ($xrefTable as $sectId => $xrefSection) {
- $xrefTableStr .= sprintf("%d %d \n", $xrefSectionStartNums[$sectId], count($xrefSection));
- foreach ($xrefSection as $xrefTableEntry) {
- $xrefTableStr .= $xrefTableEntry;
- }
- }
-
- $this->_trailer->Size->value = $this->_objFactory->getObjectCount();
-
- $pdfBlock = $xrefTableStr
- . $this->_trailer->toString()
- . "startxref\n" . $offset . "\n"
- . "%%EOF\n";
-
- if ($outputStream === null) {
- $pdfSegmentBlocks[] = $pdfBlock;
-
- return implode('', $pdfSegmentBlocks);
- } else {
- while ( strlen($pdfBlock) > 0 && ($byteCount = fwrite($outputStream, $pdfBlock)) != false ) {
- $pdfBlock = substr($pdfBlock, $byteCount);
- }
-
- return '';
- }
- }
-
-
- /**
- * Set the document-level JavaScript
- *
- * @param string $javascript
- */
- public function setJavaScript($javascript)
- {
- $this->_javaScript = $javascript;
- }
-
-
- /**
- * Convert date to PDF format (it's close to ASN.1 (Abstract Syntax Notation
- * One) defined in ISO/IEC 8824).
- *
- * @todo This really isn't the best location for this method. It should
- * probably actually exist as Zend_Pdf_Element_Date or something like that.
- *
- * @todo Address the following E_STRICT issue:
- * PHP Strict Standards: date(): It is not safe to rely on the system's
- * timezone settings. Please use the date.timezone setting, the TZ
- * environment variable or the date_default_timezone_set() function. In
- * case you used any of those methods and you are still getting this
- * warning, you most likely misspelled the timezone identifier.
- *
- * @param integer $timestamp (optional) If omitted, uses the current time.
- * @return string
- */
- public static function pdfDate($timestamp = null)
- {
- if (is_null($timestamp)) {
- $date = date('\D\:YmdHisO');
- } else {
- $date = date('\D\:YmdHisO', $timestamp);
- }
- return substr_replace($date, '\'', -2, 0) . '\'';
- }
-
-}
Deleted: trunk/libs/Zend/Uri.php
===================================================================
--- trunk/libs/Zend/Uri.php 2008-03-11 09:32:30 UTC (rev 358)
+++ trunk/libs/Zend/Uri.php 2008-03-11 19:07:20 UTC (rev 359)
@@ -1,163 +0,0 @@
-<?php
-
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license at zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Uri
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
-
-
-/**
- * @see Zend_Uri_Exception
- */
-require_once 'Zend/Uri/Exception.php';
-
-
-/**
- * @see Zend_Loader
- */
-require_once 'Zend/Loader.php';
-
-
-/**
- * @category Zend
- * @package Zend_Uri
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-abstract class Zend_Uri
-{
- /**
- * Scheme of this URI (http, ftp, etc.)
- * @var string
- */
- protected $_scheme = '';
-
- /**
- * Return a string representation of this URI.
- *
- * @see getUri()
- * @return string
- */
- public function __toString()
- {
- return $this->getUri();
- }
-
- /**
- * Convenience function, checks that a $uri string is well-formed
- * by validating it but not returning an object. Returns TRUE if
- * $uri is a well-formed URI, or FALSE otherwise.
- *
- * @param string $uri
- * @return boolean
- */
- public static function check($uri)
- {
- try {
- $uri = self::factory($uri);
- } catch (Exception $e) {
- return false;
- }
-
- return $uri->valid();
- }
-
- /**
- * Create a new Zend_Uri object for a URI. If building a new URI, then $uri should contain
- * only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI.
- *
- * @param string $uri
- * @throws Zend_Uri_Exception
- * @return Zend_Uri
- */
- public static function factory($uri = 'http')
- {
- /**
- * Separate the scheme from the scheme-specific parts
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- $uri = explode(':', $uri, 2);
- $scheme = strtolower($uri[0]);
- $schemeSpecific = isset($uri[1]) ? $uri[1] : '';
-
- if (!strlen($scheme)) {
- throw new Zend_Uri_Exception('An empty string was supplied for the scheme');
- }
-
- // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.
- if (!ctype_alnum($scheme)) {
- throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
- }
-
- /**
- * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the
- * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown.
- */
- switch ($scheme) {
- case 'http':
- case 'https':
- $className = 'Zend_Uri_Http';
- break;
- case 'mailto':
- // @todo
- default:
- throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported");
- }
- Zend_Loader::loadClass($className);
- return new $className($scheme, $schemeSpecific);
-
- }
-
- /**
- * Get the URI's scheme
- *
- * @return string|false Scheme or false if no scheme is set.
- */
- public function getScheme()
- {
- if (!empty($this->_scheme)) {
- return $this->_scheme;
- } else {
- return false;
- }
- }
-
- /******************************************************************************
- * Abstract Methods
- *****************************************************************************/
-
- /**
- * Zend_Uri and its subclasses cannot be instantiated directly.
- * Use Zend_Uri::factory() to return a new Zend_Uri object.
- */
- abstract protected function __construct($scheme, $schemeSpecific = '');
-
- /**
- * Return a string representation of this URI.
- *
- * @return string
- */
- abstract public function getUri();
-
- /**
- * Returns TRUE if this URI is valid, or FALSE otherwise.
- *
- * @return boolean
- */
- abstract public function valid();
-}
More information about the Piwik-svn
mailing list