Просмотр исходного кода

Removed TinySrc helper as the service itself no longer works. Resolves #206

If somebody uses nonfunctional service in his app, he probably won't upgrade Zend Framework.
Martin Hujer 12 лет назад
Родитель
Сommit
d12fec7009

+ 0 - 6
documentation/manual/en/module_specs/Zend_Http_UserAgent-Device.xml

@@ -532,12 +532,6 @@ echo '/>';
                 devices you wish to support, and then using the device capabilities to determine
                 devices you wish to support, and then using the device capabilities to determine
                 which image to use.
                 which image to use.
             </para>
             </para>
-
-            <para>
-                Another approach is to use third-party services. Zend Framework provides one
-                such capability via the <link
-                    linkend="zend.view.helpers.initial.tiny-src">TinySrc view helper</link>.
-            </para>
         </note>
         </note>
     </sect2>
     </sect2>
 </sect1>
 </sect1>

+ 0 - 391
documentation/manual/en/module_specs/Zend_View-Helpers-TinySrc.xml

@@ -1,391 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Reviewed: no -->
-<sect3 id="zend.view.helpers.initial.tiny-src">
-    <title>TinySrc Helper</title>
-
-    <sect4 id="zend.view.helpers.initial.tiny-src.intro">
-        <title>Overview</title>
-
-        <para>
-            <ulink url="http://tinysrc.net/">tinysrc.net</ulink> provides an API for automatic scaling
-            and image format conversion for use with mobile devices. The API is quite simple: you
-            simply create a standard HTML image tag, but append your image URL to a URL on the
-            tinysrc.net domain:
-        </para>
-
-        <programlisting language="html"><![CDATA[
-<img src="http://i.tinysrc.net/http://yourdomain.com/images/foo.jpg" />
-]]></programlisting>
-
-        <para>
-            Their service then sizes the image appropriately for the device requesting it.
-        </para>
-
-        <para>
-            You can control a number of aspects regarding image display, including:
-        </para>
-
-        <itemizedlist>
-            <listitem>
-                <para>
-                    <emphasis>Image dimensions</emphasis>. You may specify a width and optional
-                    height. These dimensions can be in absolute pixels, or use one of the adaptive
-                    mechanisms tinysrc.net offers. One is <emphasis>subtractive</emphasis>;
-                    prepending a dimension with a minus ("-") indicates that the image should fill
-                    the maximum physical dimensions, <emphasis>minus</emphasis> the value given in
-                    pixels. The other is <emphasis>percentage</emphasis> based; prepending a
-                    dimension with an "x" tells the service to size that dimension by that
-                    percentage -- e.g., "x20" indicates "20%".
-                </para>
-            </listitem>
-
-            <listitem>
-                <para>
-                    <emphasis>Image format</emphasis>. By default, tinysrc.net autodiscovers the
-                    format. Internally, it supports only <acronym>JPEG</acronym> or
-                    <acronym>PNG</acronym>, and autoconverts <acronym>GIF</acronym> to
-                    <acronym>PNG</acronym>. You can specifically request that it should convert an
-                    image to either <acronym>PNG</acronym> or <acronym>JPEG</acronym>, however.
-                </para>
-            </listitem>
-        </itemizedlist>
-
-        <para>
-            The <classname>TinySrc</classname> view helper provides functionality around the
-            tinysrc.net API, and gives you the ability to:
-        </para>
-
-        <itemizedlist>
-            <listitem>
-                <para>
-                    selectively enable or disable whether it returns just the tinysrc.net URL or a
-                    fully-populated HTML <acronym>img</acronym> tag (enabled by default);
-                </para>
-            </listitem>
-
-            <listitem>
-                <para>
-                    specify default values for image format as well as width and height;
-                </para>
-            </listitem>
-
-            <listitem>
-                <para>
-                    specify a default value for the base URL used (uses the <link
-                        linkend="zend.view.helpers.initial.baseurl">BaseUrl</link> view helper
-                    by default);
-                </para>
-            </listitem>
-
-            <listitem>
-                <para>
-                    override the default options on a per-image basis, via passed in options.
-                </para>
-            </listitem>
-        </itemizedlist>
-    </sect4>
-
-    <sect4 id="zend.view.helpers.initial.tiny-src.quick-start">
-        <title>Quick Start</title>
-
-        <para>
-            The most basic usage is simply to pass the path to an image, relative to your document
-            root or base URL, to create the appropriate image tag:
-        </para>
-
-        <programlisting language="php"><![CDATA[
-<?php echo $this->tinySrc('/images/foo.png'); ?>
-]]></programlisting>
-
-        <para>
-            You may specify default values for the base URL, conversion format, dimensions, and
-            whether or not to create an <acronym>img</acronym> tag by default:
-        </para>
-
-        <programlisting language="php"><![CDATA[
-<?php $this->tinySrc()
-           ->setBaseUrl('http://example.com/foo/')
-           ->setCreateTag(false)                // disable tag creation
-           ->setDefaultFormat('png')            // convert images to PNG
-           ->setDefaultDimensions('-5', 'x20'); // width should be 5 less than screen width;
-                                                // height should be 20% of total screen height
-?>
-]]></programlisting>
-
-        <para>
-            Finally, you can also pass in values as an array of options, passed as the second
-            parameter:
-        </para>
-
-        <programlisting language="php"><![CDATA[
-<?php echo $this->tinySrc('/images/foo.png', array(
-    'format' => 'jpg', // convert to JPEG
-    'width'  => 'x50', // 1/2 screen width
-); ?>
-]]></programlisting>
-    </sect4>
-
-    <sect4 id="zend.view.helpers.initial.tiny-src.options">
-        <title>Configuration Options</title>
-
-        <variablelist>
-            <title>TinySrc Helper Options</title>
-
-            <para>
-                The following options may be passed to the <varname>$options</varname> (second)
-                argument of the helper.
-            </para>
-
-            <varlistentry>
-                <term>base_url</term>
-
-                <listitem>
-                    <para>
-                        The base URL, including scheme, host, and optionally port and/or path; this
-                        value will be prepended to the image path provided in the first argument. By
-                        default, this uses the <classname>BaseUrl</classname> and
-                        <classname>ServerUrl</classname> view helpers to determine the value.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry>
-                <term>create_tag</term>
-
-                <listitem>
-                    <para>
-                        A boolean value indicating whether or not the helper should return an HTML
-                        <acronym>img</acronym> tag, or simply the tinysrc.net URL. By default, this
-                        flag is enabled.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry>
-                <term>format</term>
-
-                <listitem>
-                    <para>
-                        Should be one of the values "png" or "jpeg". If specified, this value will
-                        be used to indicate the image conversion format. If not specified, the
-                        default format will be used, or the format will be auto-determined based on
-                        the image itself.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry>
-                <term>width</term>
-
-                <listitem>
-                    <para>
-                        This should be either <constant>null</constant>, or an integer (optionally
-                        prefixed by "x" or "-"). If specified, this value will be used to determine
-                        the converted image width. If null, neither a width nor a height value will
-                        be used. If not specified, the default dimensions will be used.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry>
-                <term>height</term>
-
-                <listitem>
-                    <para>
-                        This should be either <constant>null</constant>, or an integer (optionally
-                        prefixed by "x" or "-"). If specified, this value will be used to determine
-                        the converted image height. If null, no height value will be used. If not
-                        specified, the default height will be used.
-                    </para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-
-        <para>
-            Any other options provided will be used as attributes to the HTML <acronym>img</acronym>
-            tag (if created).
-        </para>
-    </sect4>
-
-    <sect4 id="zend.view.helpers.initial.tiny-src.methods">
-        <title>Available Methods</title>
-
-        <variablelist>
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.tiny-src">
-                <term>
-                    <methodsynopsis>
-                        <methodname>tinySrc</methodname>
-                        <methodparam>
-                            <funcparams>$image = null, array $options = array()</funcparams>
-                        </methodparam>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Called with no arguments, returns the helper instance. This is useful for
-                        configuring the helper.
-                    </para>
-
-                    <para>
-                        If the <varname>$image</varname> argument is provided, it will either create and
-                        return the tinysrc.net URL for the image, or an image tag containing that URL as
-                        the source, depending on the status of the "create tag" flag (either the default
-                        value, or the value passed via <varname>$options</varname>).
-                    </para>
-
-                    <para>
-                        See the <link linkend="zend.view.helpers.initial.tiny-src.options">configuration
-                            section</link> for details on the <varname>$options</varname> array.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.set-base-url">
-                <term>
-                    <methodsynopsis>
-                        <methodname>setBaseUrl</methodname>
-                        <methodparam>
-                            <funcparams>$url</funcparams>
-                        </methodparam>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Use this method to manually specify the base URL to prepend to the
-                        <varname>$image</varname> argument of the <methodname>tinySrc()</methodname>
-                        method.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.get-base-url">
-                <term>
-                    <methodsynopsis>
-                        <methodname>getBaseUrl</methodname>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Retrieve the base URL for prepending to image URLs. By default, autodiscovers
-                        this from the <classname>BaseUrl</classname> and
-                        <classname>ServerUrl</classname> view helpers.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.set-default-format">
-                <term>
-                    <methodsynopsis>
-                        <methodname>setDefaultFormat</methodname>
-                        <methodparam>
-                            <funcparams>$format = null</funcparams>
-                        </methodparam>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Specifiy the default image conversion format. If none provided, the value is
-                        cleared. Otherwise, expects either "png" or "jpeg".
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.set-default-dimensions">
-                <term>
-                    <methodsynopsis>
-                        <methodname>setDefaultDimensions</methodname>
-                        <methodparam>
-                            <funcparams>$width = null, $height = null</funcparams>
-                        </methodparam>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Set the default dimensions for image conversion. If no <varname>$width</varname>
-                        is specified, an empty value is provided for all dimensions (setting the height
-                        requires a width as well). Passing no value for the height will set only a
-                        width. Dimensions should be specified as either pixel dimensions, or:
-                    </para>
-
-                    <itemizedlist>
-                        <listitem>
-                            <para>
-                                A pixel value, preceded by a "-" sign. This will indicate the width
-                                should take the entire screen size, minus the number of pixels
-                                specified.
-                            </para>
-                        </listitem>
-
-                        <listitem>
-                            <para>
-                                A percentage of the total screen dimensions, expressed as "x" followed
-                                by the percentage: "x20" is equivalent to 20%.
-                            </para>
-                        </listitem>
-                    </itemizedlist>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.set-create-tag">
-                <term>
-                    <methodsynopsis>
-                        <methodname>setCreateTag</methodname>
-                        <methodparam>
-                            <funcparams>$flag</funcparams>
-                        </methodparam>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Indicate whether the <methodname>tinySrc()</methodname> method should create an
-                        HTML image tag. If boolean <constant>false</constant>, only a tinysrc.net URL
-                        will be returned.
-                    </para>
-                </listitem>
-            </varlistentry>
-
-            <varlistentry id="zend.view.helpers.initial.tiny-src.methods.create-tag">
-                <term>
-                    <methodsynopsis>
-                        <methodname>createTag</methodname>
-                    </methodsynopsis>
-                </term>
-
-                <listitem>
-                    <para>
-                        Returns the status of the "create tag" flag.
-                    </para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-    </sect4>
-
-    <sect4 id="zend.view.helpers.initial.tiny-src.examples">
-        <title>Examples</title>
-
-        <example id="zend.view.helpers.initial.tiny-src.examples.url">
-            <title>Returning only a tinysrc.net URL</title>
-
-            <para>
-                You may want to return only a tinysrc.net URL. To do this, you have two options:
-                make this the default behavior, or specify in your <varname>$options</varname> not
-                to create a tag.
-            </para>
-
-            <programlisting language="php"><![CDATA[
-// Specifying default behavior:
-$this->tinySrc()->setCreateTag(false);
-echo $this->tinySrc('image.jpg');
-
-// Per-image:
-echo $this->tinySrc('image.jpg', array('create_tag' => false));
-]]></programlisting>
-        </example>
-    </sect4>
-</sect3>

+ 0 - 1
documentation/manual/en/module_specs/Zend_View-Helpers.xml

@@ -742,7 +742,6 @@ echo $this->serverUrl();
         <xi:include href="Zend_View-Helpers-RenderToPlaceholder.xml" />
         <xi:include href="Zend_View-Helpers-RenderToPlaceholder.xml" />
         <xi:include href="Zend_View-Helpers-Json.xml" />
         <xi:include href="Zend_View-Helpers-Json.xml" />
         <xi:include href="Zend_View-Helpers-Navigation.xml" />
         <xi:include href="Zend_View-Helpers-Navigation.xml" />
-        <xi:include href="Zend_View-Helpers-TinySrc.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml" />
     </sect2>
     </sect2>

+ 1 - 4
documentation/manual/fr/module_specs/Zend_View-Helpers.xml

@@ -402,9 +402,6 @@ array('us' => 'Etats-Unis', 'fr' => 'France', 'de' => 'Allemagne').
         <xi:include href="Zend_View-Helpers-Navigation.xml">
         <xi:include href="Zend_View-Helpers-Navigation.xml">
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-Navigation.xml" /></xi:fallback>
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-Navigation.xml" /></xi:fallback>
         </xi:include>
         </xi:include>
-        <xi:include href="Zend_View-Helpers-TinySrc.xml">
-            <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-TinySrc.xml" /></xi:fallback>
-        </xi:include>
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml">
         <xi:include href="Zend_View-Helpers-UserAgent.xml">
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-UserAgent.xml" /></xi:fallback>
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-UserAgent.xml" /></xi:fallback>
@@ -633,4 +630,4 @@ $view->registerHelper($helper, 'foo');
             </para>
             </para>
         </note>
         </note>
     </sect2>
     </sect2>
-</sect1>
+</sect1>

+ 0 - 3
documentation/manual/ja/module_specs/Zend_View-Helpers.xml

@@ -718,9 +718,6 @@ echo $this->serverUrl();
         <xi:include href="Zend_View-Helpers-Navigation.xml">
         <xi:include href="Zend_View-Helpers-Navigation.xml">
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-Navigation.xml" /></xi:fallback>
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-Navigation.xml" /></xi:fallback>
         </xi:include>
         </xi:include>
-        <xi:include href="Zend_View-Helpers-TinySrc.xml">
-            <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-TinySrc.xml" /></xi:fallback>
-        </xi:include>
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml">
         <xi:include href="Zend_View-Helpers-UserAgent.xml">
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-UserAgent.xml" /></xi:fallback>
             <xi:fallback><xi:include href="../../en/module_specs/Zend_View-Helpers-UserAgent.xml" /></xi:fallback>

+ 0 - 1
documentation/manual/pt-br/module_specs/Zend_View-Helpers.xml

@@ -404,7 +404,6 @@ echo $this->formCheckbox('foo',
         <xi:include href="Zend_View-Helpers-InlineScript.xml" />
         <xi:include href="Zend_View-Helpers-InlineScript.xml" />
         <xi:include href="Zend_View-Helpers-Json.xml" />
         <xi:include href="Zend_View-Helpers-Json.xml" />
         <xi:include href="Zend_View-Helpers-Navigation.xml" />
         <xi:include href="Zend_View-Helpers-Navigation.xml" />
-        <xi:include href="Zend_View-Helpers-TinySrc.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-Translate.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml" />
         <xi:include href="Zend_View-Helpers-UserAgent.xml" />
     </sect2>
     </sect2>

+ 0 - 317
library/Zend/View/Helper/TinySrc.php

@@ -1,317 +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@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_View
- * @subpackage Helper
- * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-/** Zend_View_Helper_HtmlElement */
-require_once 'Zend/View/Helper/HtmlElement.php';
-
-/**
- * Helper for generating urls and/or image tags for use with tinysrc.net
- *
- * tinysrc.net provides an API for generating scaled, browser device-specific
- * images. In essence, you pass the API the URL to an image on your own server,
- * and tinysrc.net then provides the appropriate image based on the device that
- * accesses it.
- *
- * Additionally, tinysrc.net allows you to specify additional configuration via
- * the API:
- *
- * - image size. You may define this as:
- *   - explicit size
- *   - subtractive size (size of screen minus specified number of pixels)
- *   - percentage size (percentage of screen size))
- * - image format. This will convert the image to the given format; allowed
- *   values are "png" or "jpeg". By default, gif images are converted to png.
- *
- * This helper allows you to specify all configuration options, as well as:
- *
- * - whether or not to generate the full image tag (or just the URL)
- * - base url to images (which should include the protocol, server, and
- *   optionally port and base path)
- *
- * @see        http://tinysrc.net/
- * @package    Zend_View
- * @subpackage Helper
- * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_View_Helper_TinySrc extends Zend_View_Helper_HtmlElement
-{
-    const TINYSRC_BASE = 'http://i.tinysrc.mobi';
-
-    /**
-     * @var string Base URL for images
-     */
-    protected $_baseUrl;
-
-    /**
-     * @var bool Whether or not to create an image tag
-     */
-    protected $_createTagFlag = true;
-
-    /**
-     * @var string Default width and height
-     */
-    protected $_dimensions = '';
-
-    /**
-     * Default options
-     *
-     * Used when determining what options were passed, and needing to merge
-     * them with default options.
-     *
-     * @var array
-     */
-    protected $_defaultOptions = array(
-        'base_url'   => null,
-        'format'     => null,
-        'width'      => false,
-        'height'     => false,
-        'create_tag' => true,
-    );
-
-    /**
-     * @var string Default image format to use
-     */
-    protected $_format = '';
-
-    /**
-     * Generate a link or image tag pointing to tinysrc.net
-     *
-     * @param mixed $image
-     * @param array $options
-     * @return void
-     */
-    public function tinySrc($image = null, array $options = array())
-    {
-        if (null === $image) {
-            return $this;
-        }
-
-        $defaultOptions = $this->_defaultOptions;
-        $defaultOptions['create_tag'] = $this->createTag();
-        $options = array_merge($defaultOptions, $options);
-
-        $url = '/' . $this->_mergeBaseUrl($options) . ltrim($image, '/');
-
-        $src = self::TINYSRC_BASE
-             . $this->_mergeFormat($options)
-             . $this->_mergeDimensions($options)
-             . $url;
-
-        if (!$options['create_tag']) {
-            return $src;
-        }
-
-        foreach (array_keys($this->_defaultOptions) as $key) {
-            switch ($key) {
-                case 'width':
-                case 'height':
-                    if (!is_int($options[$key]) || !is_numeric($options[$key]) || $options[$key] < 0) {
-                        unset($options[$key]);
-                    }
-                    break;
-                default:
-                    unset($options[$key]);
-                    break;
-            }
-        }
-
-        $options['src'] = $src;
-
-        $tag = '<img' . $this->_htmlAttribs($options) . $this->getClosingBracket();
-        return $tag;
-    }
-
-    /**
-     * Set base URL for images
-     *
-     * @param  string $url
-     * @return Zend_View_Helper_TinySrc
-     */
-    public function setBaseUrl($url)
-    {
-        $this->_baseUrl = rtrim($url, '/') . '/';
-        return $this;
-    }
-
-    /**
-     * Get base URL for images
-     *
-     * If none already set, uses the ServerUrl and BaseUrl view helpers to
-     * determine the base URL to images.
-     *
-     * @return string
-     */
-    public function getBaseUrl()
-    {
-        if (null === $this->_baseUrl) {
-            $this->setBaseUrl($this->view->serverUrl($this->view->baseUrl()));
-        }
-        return $this->_baseUrl;
-    }
-
-    /**
-     * Set default image format
-     *
-     * If set, this will set the default format to use on all images.
-     *
-     * @param  null|string $format
-     * @return Zend_View_Helper_TinySrc
-     * @throws Zend_View_Exception
-     */
-    public function setDefaultFormat($format = null)
-    {
-        if (null === $format) {
-            $this->_format = '';
-            return $this;
-        }
-
-        $format = strtolower($format);
-        if (!in_array($format, array('png', 'jpeg'))) {
-            require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid format; must be one of "jpeg" or "png"');
-        }
-        $this->_format = "/$format";
-        return $this;
-    }
-
-    /**
-     * Set default dimensions
-     *
-     * If null is specified for width, default dimensions will be cleared. If
-     * only width is specified, only width will be used. If either dimension
-     * fails validation, an exception is raised.
-     *
-     * @param  null|int|string $width
-     * @param  null|int|string $height
-     * @return Zend_View_Helper_TinySrc
-     * @throws Zend_View_Exception
-     */
-    public function setDefaultDimensions($width = null, $height = null)
-    {
-        if (null === $width) {
-            $this->_dimensions = '';
-            return $this;
-        }
-
-        if (!$this->_validateDimension($width)) {
-            require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid dimension; must be an integer, optionally preceded by "-" or "x"');
-        }
-
-        $this->_dimensions = "/$width";
-        if (null === $height) {
-            return $this;
-        }
-
-        if (!$this->_validateDimension($height)) {
-            require_once 'Zend/View/Exception.php';
-            throw new Zend_View_Exception('Invalid dimension; must be an integer, optionally preceded by "-" or "x"');
-        }
-        $this->_dimensions .= "/$height";
-        return $this;
-    }
-
-    /**
-     * Set state of "create tag" flag
-     *
-     * @param  bool $flag
-     * @return Zend_View_Helper_TinySrc
-     */
-    public function setCreateTag($flag)
-    {
-        $this->_createTagFlag = (bool) $flag;
-        return $this;
-    }
-
-    /**
-     * Should the helper create an image tag?
-     *
-     * @return bool
-     */
-    public function createTag()
-    {
-        return $this->_createTagFlag;
-    }
-
-    /**
-     * Validate a dimension
-     *
-     * Dimensions may be integers, optionally preceded by '-' or 'x'.
-     *
-     * @param  string $dim
-     * @return bool
-     */
-    protected function _validateDimension($dim)
-    {
-        if (!is_scalar($dim) || is_bool($dim)) {
-            return false;
-        }
-        return preg_match('/^(-|x)?\d+$/', (string) $dim);
-    }
-
-    /**
-     * Determine whether to use default base URL, or base URL from options
-     *
-     * @param  array $options
-     * @return string
-     */
-    protected function _mergeBaseUrl(array $options)
-    {
-        if (null === $options['base_url']) {
-            return $this->getBaseUrl();
-        }
-        return rtrim($options['base_url'], '/') . '/';
-    }
-
-    /**
-     * Determine whether to use default format or format provided in options.
-     *
-     * @param  array $options
-     * @return string
-     */
-    protected function _mergeFormat(array $options)
-    {
-        if (in_array($options['format'], array('png', 'jpeg'))) {
-            return '/' . $options['format'];
-        }
-        return $this->_format;
-    }
-
-    /**
-     * Determine whether to use default dimensions, or those passed in options.
-     *
-     * @param  array $options
-     * @return string
-     */
-    protected function _mergeDimensions(array $options)
-    {
-        if (!$this->_validateDimension($options['width'])) {
-            return $this->_dimensions;
-        }
-        $dimensions = '/' . $options['width'];
-        if (!$this->_validateDimension($options['height'])) {
-            return $dimensions;
-        }
-        $dimensions .= '/' . $options['height'];
-        return $dimensions;
-    }
-}

+ 0 - 2
tests/Zend/View/Helper/AllTests.php

@@ -69,7 +69,6 @@ require_once 'Zend/View/Helper/Placeholder/ContainerTest.php';
 require_once 'Zend/View/Helper/Placeholder/RegistryTest.php';
 require_once 'Zend/View/Helper/Placeholder/RegistryTest.php';
 require_once 'Zend/View/Helper/Placeholder/StandaloneContainerTest.php';
 require_once 'Zend/View/Helper/Placeholder/StandaloneContainerTest.php';
 require_once 'Zend/View/Helper/ServerUrlTest.php';
 require_once 'Zend/View/Helper/ServerUrlTest.php';
-require_once 'Zend/View/Helper/TinySrcTest.php';
 require_once 'Zend/View/Helper/TranslateTest.php';
 require_once 'Zend/View/Helper/TranslateTest.php';
 require_once 'Zend/View/Helper/UrlTest.php';
 require_once 'Zend/View/Helper/UrlTest.php';
 require_once 'Zend/View/Helper/UserAgentTest.php';
 require_once 'Zend/View/Helper/UserAgentTest.php';
@@ -139,7 +138,6 @@ class Zend_View_Helper_AllTests
         $suite->addTestSuite('Zend_View_Helper_Placeholder_RegistryTest');
         $suite->addTestSuite('Zend_View_Helper_Placeholder_RegistryTest');
         $suite->addTestSuite('Zend_View_Helper_Placeholder_StandaloneContainerTest');
         $suite->addTestSuite('Zend_View_Helper_Placeholder_StandaloneContainerTest');
         $suite->addTestSuite('Zend_View_Helper_ServerUrlTest');
         $suite->addTestSuite('Zend_View_Helper_ServerUrlTest');
-        $suite->addTestSuite('Zend_View_Helper_TinySrcTest');
         $suite->addTestSuite('Zend_View_Helper_TranslateTest');
         $suite->addTestSuite('Zend_View_Helper_TranslateTest');
         $suite->addTestSuite('Zend_View_Helper_UrlTest');
         $suite->addTestSuite('Zend_View_Helper_UrlTest');
         $suite->addTestSuite('Zend_View_Helper_UserAgentTest');
         $suite->addTestSuite('Zend_View_Helper_UserAgentTest');

+ 0 - 236
tests/Zend/View/Helper/TinySrcTest.php

@@ -1,236 +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@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_View
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-// Call Zend_View_Helper_TinySrcTest::main() if this source file is executed directly.
-if (!defined('PHPUnit_MAIN_METHOD')) {
-    define('PHPUnit_MAIN_METHOD', 'Zend_View_Helper_TinySrcTest::main');
-}
-
-/**
- * @see Zend_View_Helper_TinySrc
- */
-require_once 'Zend/View/Helper/TinySrc.php';
-
-/**
- * @see Zend_View
- */
-require_once 'Zend/View.php';
-
-/**
- * @category   Zend
- * @package    Zend_View
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * @group      Zend_View
- * @group      Zend_View_Helper
- */
-class Zend_View_Helper_TinySrcTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * @var Zend_View_Helper_TinySrc
-     */
-    public $helper;
-
-    /**
-     * @var Zend_View
-     */
-    public $view;
-
-    /**
-     * Main
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite(__CLASS__);
-        $result = PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
-     * Prepares the environment before running a test.
-     */
-    protected function setUp()
-    {
-        $this->helper = new Zend_View_Helper_TinySrc();
-        $this->view   = new Zend_View();
-        $this->view->doctype()->setDoctype(strtoupper("XHTML1_STRICT"));
-        $this->helper->setView($this->view);
-    }
-
-    public function testCallingHelperMethodWithNoArgumentsReturnsHelperInstance()
-    {
-        $test = $this->helper->tinySrc();
-        $this->assertSame($this->helper, $test);
-    }
-
-    public function testHelperUsesServerAndBaseUrlFromHelpersByDefault()
-    {
-        $base   = $this->view->getHelper('baseUrl');
-        $base->setBaseUrl('/foo/bar');
-
-        $server = $this->view->getHelper('serverUrl');
-        $server->setScheme('https')
-               ->setHost('example.com:8080');
-
-        $test = $this->helper->getBaseUrl();
-        $this->assertEquals('https://example.com:8080/foo/bar/', $test);
-    }
-
-    public function testAllowsSettingDefaultFormat()
-    {
-        $this->helper->setDefaultFormat('png')
-                     ->setBaseUrl('http://example.com');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertContains('/png/', $image);
-    }
-
-    public function testSettingInvalidDefaultFormatRaisesException()
-    {
-        $this->setExpectedException('Zend_View_Exception', 'Invalid format');
-        $this->helper->setDefaultFormat('gif');
-    }
-
-    public function testPassingNullValueToDefaultFormatClearsSetFormat()
-    {
-        $this->helper->setDefaultFormat('png')
-                     ->setBaseUrl('http://example.com');
-        $this->helper->setDefaultFormat(null);
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertNotContains('/png/', $image);
-    }
-
-    public function testAllowsPassingDefaultWidth()
-    {
-        $this->helper->setBaseUrl('http://example.com')
-                     ->setDefaultDimensions('-5');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertContains('/-5/', $image);
-    }
-
-    /**
-     * @dataProvider invalidDimensions
-     */
-    public function testRaisesExceptionOnInvalidDefaultWidthValue($dim)
-    {
-        $this->setExpectedException('Zend_View_Exception', 'Invalid dimension');
-        $this->helper->setDefaultDimensions($dim);
-    }
-
-    public function testAllowsPassingDefaultWidthAndHeight()
-    {
-        $this->helper->setBaseUrl('http://example.com')
-                     ->setDefaultDimensions('5', 'x20');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertContains('/5/x20/', $image);
-    }
-
-    /**
-     * @dataProvider invalidDimensions
-     */
-    public function testRaisesExceptionOnInvalidDefaultHeightValue($dim)
-    {
-        $this->setExpectedException('Zend_View_Exception', 'Invalid dimension');
-        $this->helper->setDefaultDimensions('10', $dim);
-    }
-
-    public function testPassingNullAsDefaultWidthValueClearsBothWidthAndHeight()
-    {
-        $this->helper->setBaseUrl('http://example.com')
-                     ->setDefaultDimensions('5', 'x20');
-        $this->helper->setDefaultDimensions(null, 'x20');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertNotContains('/5/x20/', $image);
-        $this->assertNotContains('/5/', $image);
-        $this->assertNotContains('/x20/', $image);
-    }
-
-    public function testPassingNullAsDefaultHeightValueClearsHeight()
-    {
-        $this->helper->setBaseUrl('http://example.com')
-                     ->setDefaultDimensions('5', 'x20');
-        $this->helper->setDefaultDimensions('5');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertNotContains('/5/x20/', $image);
-        $this->assertContains('/5/', $image);
-    }
-
-    public function testCreatesImageTagByDefault()
-    {
-        $this->helper->setBaseUrl('http://example.com');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertContains('<img src="', $image);
-    }
-
-    public function testImageTagObeysDoctype()
-    {
-        $this->view->doctype('XHTML1_STRICT');
-        $this->helper->setBaseUrl('http://example.com');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertContains('/>', $image);
-    }
-
-    public function testAllowsSpecifyingTagCreation()
-    {
-        $this->helper->setCreateTag(false);
-        $this->helper->setBaseUrl('http://example.com');
-        $image = $this->helper->tinySrc('foo.jpg');
-        $this->assertNotContains('<img src="', $image);
-    }
-
-    public function testPassingOptionsToHelperMethodOverridesDefaults()
-    {
-        $this->helper->setBaseUrl('http://example.com')
-                     ->setCreateTag(false)
-                     ->setDefaultDimensions(320, 480);
-        $image = $this->helper->tinySrc('foo.jpg', array(
-            'base_url'   => 'https://example.org:8080/public',
-            'format'     => 'png',
-            'width'      => 160,
-            'height'     => null,
-            'create_tag' => true,
-        ));
-        $this->assertContains('<img width="160" src="http://i.tinysrc.mobi/png/160/https://example.org:8080/public/foo.jpg"', $image);
-    }
-
-    public function testUnknownOptionsPassedToHelperMethodAreTreatedAsImageAttributes()
-    {
-        $this->helper->setBaseUrl('http://example.com');
-        $image = $this->helper->tinySrc('foo.jpg', array(
-            'alt'   => 'Alt text for image',
-        ));
-        $this->assertContains('alt="Alt text for image"', $image);
-    }
-
-    public function invalidDimensions()
-    {
-        return array(
-            array('foo'),
-            array(true),
-            array(array()),
-            array(new stdClass),
-        );
-    }
-}
-
-// Call Zend_View_Helper_TinySrcTest::main() if this source file is executed directly.
-if (PHPUnit_MAIN_METHOD == 'Zend_View_Helper_TinySrcTest::main') {
-    Zend_View_Helper_TinySrcTest::main();
-}