Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into markup
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Markup/Parser/Textile.php
	library/Zend/Markup/Renderer/AbstractRenderer.php
	library/Zend/Markup/Renderer/Html.php
  • Loading branch information
kokx committed Oct 30, 2010
2 parents 95c9d8d + 1b8822c commit 8b3028a
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
abstract class AbstractAdapter extends \Zend\Validator\AbstractValidator implements Adapter
{
Expand Down
1 change: 0 additions & 1 deletion src/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
interface Adapter extends \Zend\Validator\Validator
{
Expand Down
1 change: 0 additions & 1 deletion src/Dumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Dumb extends Word
{
Expand Down
5 changes: 2 additions & 3 deletions src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

Expand All @@ -27,12 +26,12 @@
/**
* Exception for Zend_Form component.
*
* @uses \Zend\Exception
* @uses Zend\Exception
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Exception
interface Exception
{
}
41 changes: 41 additions & 0 deletions src/Exception/ExtensionNotLoadedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Captcha\Exception;
use Zend\Captcha\Exception;

/**
* Exception for Zend_Form component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ExtensionNotLoadedException
extends \RuntimeException
implements Exception
{
}
41 changes: 41 additions & 0 deletions src/Exception/ImageNotLoadableException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Captcha\Exception;
use Zend\Captcha\Exception;

/**
* Exception for Zend_Form component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ImageNotLoadableException
extends \RuntimeException
implements Exception
{
}
41 changes: 41 additions & 0 deletions src/Exception/NoFontProvidedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Captcha\Exception;
use Zend\Captcha\Exception;

/**
* Exception for Zend_Form component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Captcha
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class NoFontProvidedException
extends \InvalidArgumentException
implements Exception
{
}
1 change: 0 additions & 1 deletion src/Figlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Figlet extends Word
{
Expand Down
64 changes: 46 additions & 18 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Captcha;
use Zend\Captcha\Exception\NoFontProvidedException,
Zend\Captcha\Exception\ExtensionNotLoadedException,
Zend\Captcha\Exception\ImageNotLoadableException;

/**
* Image-based captcha element
Expand Down Expand Up @@ -103,6 +105,7 @@ class Image extends Word
* @var string
*/
protected $_startImage;

/**
* How frequently to execute garbage collection
*
Expand All @@ -124,41 +127,70 @@ class Image extends Word
* @var int
*/
protected $_dotNoiseLevel = 100;

/**
* Number of noise lines on image
* Used twice - before and after transform
*
* @var int
*/
protected $_lineNoiseLevel = 5;

/**
* Constructor
*
* @param array|Zend\Config\Config $options
* @return void
*/
public function __construct($options = null)
{
if (!extension_loaded("gd")) {
throw new ExtensionNotLoadedException("Image CAPTCHA requires GD extension");
}

if (!function_exists("imagepng")) {
throw new ExtensionNotLoadedException("Image CAPTCHA requires PNG support");
}

if (!function_exists("imageftbbox")) {
throw new ExtensionNotLoadedException("Image CAPTCHA requires FT fonts support");
}

parent::__construct($options);
}

/**
* @return string
*/
public function getImgAlt ()
{
return $this->_imgAlt;
}

/**
* @return string
*/
public function getStartImage ()
{
return $this->_startImage;
}

/**
* @return int
*/
public function getDotNoiseLevel ()
{
return $this->_dotNoiseLevel;
}

/**
* @return int
*/
public function getLineNoiseLevel ()
{
return $this->_lineNoiseLevel;
}

/**
* Get captcha expiration
*
Expand All @@ -178,6 +210,7 @@ public function getGcFreq()
{
return $this->_gcFreq;
}

/**
* Get font to use when generating captcha
*
Expand Down Expand Up @@ -217,6 +250,7 @@ public function getImgDir()
{
return $this->_imgDir;
}

/**
* Get captcha image base URL
*
Expand All @@ -226,6 +260,7 @@ public function getImgUrl()
{
return $this->_imgUrl;
}

/**
* Get captcha image file suffix
*
Expand All @@ -235,6 +270,7 @@ public function getSuffix()
{
return $this->_suffix;
}

/**
* Get captcha image width
*
Expand All @@ -244,6 +280,7 @@ public function getWidth()
{
return $this->_width;
}

/**
* @param string $startImage
*/
Expand All @@ -252,6 +289,7 @@ public function setStartImage ($startImage)
$this->_startImage = $startImage;
return $this;
}

/**
* @param int $dotNoiseLevel
*/
Expand All @@ -260,7 +298,8 @@ public function setDotNoiseLevel ($dotNoiseLevel)
$this->_dotNoiseLevel = $dotNoiseLevel;
return $this;
}
/**

/**
* @param int $lineNoiseLevel
*/
public function setLineNoiseLevel ($lineNoiseLevel)
Expand Down Expand Up @@ -449,22 +488,10 @@ public function generate()
*/
protected function _generateImage($id, $word)
{
if (!extension_loaded("gd")) {
throw new Exception("Image CAPTCHA requires GD extension");
}

if (!function_exists("imagepng")) {
throw new Exception("Image CAPTCHA requires PNG support");
}

if (!function_exists("imageftbbox")) {
throw new Exception("Image CAPTCHA requires FT fonts support");
}

$font = $this->getFont();

if (empty($font)) {
throw new Exception("Image CAPTCHA requires font");
throw new NoFontProvidedException("Image CAPTCHA requires font");
}

$w = $this->getWidth();
Expand All @@ -473,11 +500,12 @@ protected function _generateImage($id, $word)

$img_file = $this->getImgDir() . $id . $this->getSuffix();
if(empty($this->_startImage)) {
$img = imagecreatetruecolor($w, $h);
$img = imagecreatetruecolor($w, $h);
} else {
$img = imagecreatefrompng($this->_startImage);
// Potential error is change to exception
$img = @imagecreatefrompng($this->_startImage);
if(!$img) {
throw new Exception("Can not load start image");
throw new ImageNotLoadableException("Can not load start image");
}
$w = imagesx($img);
$h = imagesy($img);
Expand Down
1 change: 0 additions & 1 deletion src/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class ReCaptcha extends AbstractAdapter
{
Expand Down
1 change: 0 additions & 1 deletion src/Word.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @subpackage Adapter
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
abstract class Word extends AbstractAdapter
{
Expand Down
Loading

0 comments on commit 8b3028a

Please sign in to comment.