From 84145ac24f1d94655dc9a149c60d57f00a813086 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 30 Jul 2012 16:01:30 +1000 Subject: [PATCH] @todo Work --- application/classes/country.php | 7 +++---- application/classes/model/country.php | 3 +++ application/classes/model/currency.php | 15 +++++++++++++++ application/views/yaml/page.php | 6 +----- 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 application/classes/model/currency.php diff --git a/application/classes/country.php b/application/classes/country.php index 6bb86c6e..0ecf449b 100644 --- a/application/classes/country.php +++ b/application/classes/country.php @@ -12,10 +12,9 @@ */ class Country { public static function icon($cid) { - // @todo alt character should be country specific - // @todo This doesnt correctly get the right 3 character country code - it should be obtained from a join with country/currency - return HTML::image(sprintf('media/img/country/%s.png',strtolower(StaticList_Module::record('country','two_code','id',$cid))),array('alt'=>'$','style'=>'border: 0px;')); - return sprintf('media/img/country/%s.png',strtolower(StaticList_Module::record('country','three_code','id',$cid))); + $co = ORM::factory('country',$cid); + + return HTML::image(sprintf('media/img/country/%s.png',strtolower($co->two_code)),array('alt'=>$co->currency()->symbol)); } } ?> diff --git a/application/classes/model/country.php b/application/classes/model/country.php index 2f8c908d..f22cf51c 100644 --- a/application/classes/model/country.php +++ b/application/classes/model/country.php @@ -11,5 +11,8 @@ * @license http://dev.leenooks.net/license.html */ class Model_Country extends ORMOSB { + public function currency() { + return ORM::factory('currency')->where('country_id','=',$this->id)->find(); + } } ?> diff --git a/application/classes/model/currency.php b/application/classes/model/currency.php new file mode 100644 index 00000000..24e68ace --- /dev/null +++ b/application/classes/model/currency.php @@ -0,0 +1,15 @@ + diff --git a/application/views/yaml/page.php b/application/views/yaml/page.php index 7ed4586f..a4c1ab45 100644 --- a/application/views/yaml/page.php +++ b/application/views/yaml/page.php @@ -26,11 +26,7 @@
- - so->country->two_code)),array('alt'=>Config::instance()->so->country->display('name'),'class'=>'flag','title'=>Config::instance()->so->country->display('name'),'width'=>'18','height'=>'12')); ?> + so->country_id); ?> so->country->display('name'); ?>