View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_View_Helper_Currency
{zone-data}

{zone-data:proposer-list}
[~thomas]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 7 April 2009: Initial Draft
{zone-data}

{zone-data:overview}
Zend_View_Helper_Currency is a view helper to use Zend_Currency within a view script.
{zone-data}

{zone-data:references}
* [Zend_Currency|http://framework.zend.com/manual/en/Zend_Currency.html]
* [Zend_Locale|http://framework.zend.com/manual/en/Zend_Locale.html]
{zone-data}

{zone-data:requirements}
* This component *will* display currencies within your view
* It supports having the used currency within the registry
* It supports using the default currency which is detected by the users browser locale when possible
{zone-data}

{zone-data:dependencies}
* Zend_Currency
* Zend_Locale
{zone-data}

{zone-data:operation}
Zend_View_Helper_Currency allows to use defined currencies within your view. It allows to use a registry key (Zend_Currency) which can be set application wide. When giving a numeric input (integer or float) the displayed value will always be a currency notation according to the used settings
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: \[DONE\] Proposal accepted
* Milestone 3: \[DONE\] Working implementation
* Milestone 4: \[DONE\] Unit tests
* Milestone 5: \[DONE\] Documentation
* Milestone 6: \[DONE\] Moved to core
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_Currency
{zone-data}

{zone-data:use-cases}
||UC-01||
Set the currency to use within the registry
{code}
$currency = new Zend_Currency('EUR');
Zend_Registry::set('Zend_Currency', $currency);
{code}
Now you can use the view helper without any initiation or parameter
{code}
$this->view->currency(1234);
// prints 1.234EUR
{code}

||UC-02||
Create the view helper manually
{code}
$helper = new Zend_View_Helper_Currency('en_US');
$helper->currency(1234.56)
// returns $1,234.56
{code}

||UC-03||
Initiate the view on the fly
{code}
$this->currency->setCurrency('en_US');
$this->currency(1234);
// returns $1,234
{code}
PS: Not sure if the first line is correct, but there is a way to call view helper function from within the view
{zone-data}

{zone-data:skeletons}
{code}
class Zend_View_Helper_Currency extends Zend_View_Helper_Abstract {

/**
* @param string|Zend_Locale|Zend_Currency Currency to set
*/
public function __construct($currency = null) {}

/**
* @param string|Zend_Locale|Zend_Currency Currency to set
*/
public function setCurrency($currency) {}

/**
* @return Zend_Currency
*/
public function getCurrency() {}

/**
* @param numeric $value Value to output as currency
* @param mixed $currency Currency to set, overrides the instance settings
* @returns string Currency output
*/
public function currency($value, $currency = null) {}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>