some modifications for the addWhere parameter
authorfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 31 Oct 2006 08:33:07 +0000 (08:33 +0000)
committerfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 31 Oct 2006 08:33:07 +0000 (08:33 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@3989 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.ext_update.php
pi1/class.tx_staticinfotables_pi1.php
tca.php

index a4c3715..ad46b3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006-10-31  Franz Holzinger  <kontakt@fholzinger.com>
+       * change the param into an addWhere parameter where it is a WHERE clause
+
 2006-10-11  Franz Holzinger  <kontakt@fholzinger.com>
        * additional WHERE clauses to many functions in order to filter the lists
        * call function to load additional TCA to allow fields added from the language specific static_info_tables derivates
index 27f8534..b96fdf9 100644 (file)
@@ -30,7 +30,7 @@
  *
  * $Id$
  *
- * @author      René Fritz <r.fritz@colorcube.de>
+ * @author      René Fritz <r.fritz@colorcube.de>
  */
 class ext_update  {
 
@@ -41,7 +41,7 @@ class ext_update  {
         */
        function main() {
 
-               require_once ('class.tx_staticinfotables_encoding.php');
+               require_once(t3lib_extMgm::extPath(STATIC_INFO_TABLES_EXTkey).'class.tx_staticinfotables_encoding.php');
 
                $tables = array ('static_countries', 'static_country_zones', 'static_languages', 'static_currencies');
 
@@ -75,9 +75,9 @@ class ext_update  {
        }
 
        /**
-        * [Describe function...]
+        * access is always allowed
         *
-        * @return      [type]          ...
+        * @return      boolean         Always returns true
         */
        function access() {
                return true;
index 89d93dc..4e16c86 100644 (file)
  *   64: class tx_staticinfotables_pi1 extends tslib_pibase
  *   92:     function init()
  *  131:     function getStaticInfoName($type='COUNTRIES', $code, $country='', $countrySubdivision='', $self=0)
- *  181:     function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selected='', $country='', $submit=0, $id='', $title='', $where='', $local=FALSE)
- *  247:     function initCountries($param='UN', $lang='', $local=FALSE)
- *  293:     function initCountrySubdivisions($param)
- *  337:     function initCurrencies($param='')
- *  376:     function initLanguages($param='')
- *  415:     function optionsConstructor($names, $selected='')
- *  436:     function loadCurrencyInfo($currencyCode)
- *  479:     function formatAmount($amount, $displayCurrencyCode='')
- *  503:     function formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode='', $countryCode='')
- *  551:     function applyConsumerTaxes($amount, $taxClass=0, $shopCountryCode, $shopCountrySubdivisionCode, $buyerCountryCode, $buyerCountrySubdivisionCode, $EUThreshold=0)
- *  670:     function getCurrentLanguage()
+ *  182:     function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selected='', $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE)
+ *  250:     function initCountries($param='UN', $lang='', $local=FALSE, $addWhere='')
+ *  300:     function initCountrySubdivisions($param, $addWhere='')
+ *  345:     function initCurrencies($addWhere='')
+ *  384:     function initLanguages($addWhere='')
+ *  423:     function optionsConstructor($names, $selected='')
+ *  444:     function loadCurrencyInfo($currencyCode)
+ *  487:     function formatAmount($amount, $displayCurrencyCode='')
+ *  511:     function formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode='', $countryCode='')
+ *  559:     function applyConsumerTaxes($amount, $taxClass=0, $shopCountryCode, $shopCountrySubdivisionCode, $buyerCountryCode, $buyerCountrySubdivisionCode, $EUThreshold=0)
+ *  678:     function getCurrentLanguage()
  *
  * TOTAL FUNCTIONS: 13
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -175,11 +175,14 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         * @param       string          A value for the id attribute of the <select> tag
         * @param       string          A value for the title attribute of the <select> tag
         * @param       string          A where clause for the records
-        * @param       [type]          $local: ...
+        * @param       string          language to be used
+        * @param       boolean         $local: If set, we are looking for the "local" title field
         * @return      string          A set of HTML <select> and <option> tags
         */
-       function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selected='', $country='', $submit=0, $id='', $title='', $where='', $local=FALSE)      {
+       function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selected='', $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE) {
 
+               $selected = trim($selected);
+               $country = trim($country);
                $nameAttribute = (trim($name)) ? 'name="'.htmlspecialchars(trim($name)).'" ' : '';
                $classAttribute = (trim($class)) ? 'class="'.htmlspecialchars(trim($class)).'" ' : '';
                $idAttribute = (trim($id)) ? 'id="'.htmlspecialchars(trim($id)).'" ' : '';
@@ -196,33 +199,32 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
 
                switch($type)   {
                        case 'COUNTRIES':
-                               $names = $this->initCountries($where,$local);
-                               $selected = (trim($selected)) ? trim($selected) : $this->defaultCountry;
+                               $names = $this->initCountries('ALL',$lang,$local,$addWhere);
+                               $selected = ($selected ? $selected : $this->defaultCountry);
                                reset($names);
-                               $selected = ($selected) ? $selected : key($names);
+                               $selected = ($selected ? $selected : key($names));
                                break;
                        case 'SUBDIVISIONS':
-                               $param = (trim($where) ? trim($where) : (trim($country)) ? trim($country) : $this->defaultCountry);
-                               $names = $this->initCountrySubdivisions($param);
-                               $selected = trim($selected);
+                               $param = (trim($country) ? trim($country) : $this->defaultCountry);
+                               $names = $this->initCountrySubdivisions($param,$addWhere);
                                if( $param == $this->defaultCountry ) {
-                                       $selected = ($selected) ? $selected : $this->defaultCountryZone;
+                                       $selected = ($selected ? $selected : $this->defaultCountryZone);
                                } else {
                                        reset($names);
-                                       $selected = ($selected) ? $selected : key($names);
+                                       $selected = ($selected ? $selected : key($names));
                                }
                                break;
                        case 'CURRENCIES':
-                               $names = $this->initCurrencies($where);
-                               $selected = (trim($selected)) ? trim($selected) : $this->currency;
+                               $names = $this->initCurrencies($addWhere);
+                               $selected = ($selected ? $selected : $this->currency);
                                reset($names);
-                               $selected = ($selected) ? $selected : key($names);
+                               $selected = ($selected ? $selected : key($names));
                                break;
                        case 'LANGUAGES':
-                               $names = $this->initLanguages($where);
-                               $selected = (trim($selected)) ? trim($selected) : $this->defaultLanguage;
+                               $names = $this->initLanguages($addWhere);
+                               $selected = ($selected ? $selected : $this->defaultLanguage);
                                reset($names);
-                               $selected = ($selected) ? $selected : key($names);
+                               $selected = ($selected ? $selected : key($names));
                                break;
                }
                if( count($names) > 0 ) {
@@ -242,9 +244,10 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         * @param       string          1: WHERE clause 2: It defines a selection: 'ALL', 'UN', 'EU'
         * @param       string          language to be used
         * @param       boolean         If set, we are looking for the "local" title field
+        * @param       string          additional WHERE clause
         * @return      array           An array of names of countries
         */
-       function initCountries($param='UN', $lang='', $local=FALSE) {
+       function initCountries($param='UN', $lang='', $local=FALSE, $addWhere='') {
                global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
 
                $table = $this->tables['COUNTRIES'];
@@ -263,8 +266,10 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
                } elseif ($param == 'ALL')      {
                        $where = '1=1';
                } else {
-                       $where = '1=1'.($param ? ' AND '.$param : '');
+                       $where = '1=1';
                }
+               $where .= ($addWhere ? ' AND '.$addWhere : '');
+
                $res = $TYPO3_DB->exec_SELECTquery(
                        $table.'.cn_iso_3,'.$labelFields,
                        $table,
@@ -286,11 +291,13 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         * Getting all country subdivisions of a given country into an array
         *      where the key is the code of the subdivision
         *      and where the value is the name of the country subdivision in the current language
+        * You can leave the ISO code empty and use the additional WHERE clause instead of it.
         *
-        * @param       string          1: WHERE clause 2: The ISO alpha-3 code of a country
+        * @param       string          The ISO alpha-3 code of a country
+        * @param       string          additional WHERE clause
         * @return      array           An array of names of country subdivisions
         */
-       function initCountrySubdivisions($param)        {
+       function initCountrySubdivisions($param, $addWhere='')  {
                global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
 
                $table = $this->tables['SUBDIVISIONS'];
@@ -298,8 +305,9 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
                        $country = $param;
                        $where = 'zn_country_iso_3='.$TYPO3_DB->fullQuoteStr($country,$table);
                } else {
-                       $where = '1=1'.($param ? ' AND '.$param : '');
+                       $where = '1=1';
                }
+               $where .= ($addWhere ? ' AND '.$addWhere : '');
                $lang = $this->getCurrentLanguage();
                $names = array();
                $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang);
@@ -331,13 +339,13 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         *      where the key is the ISO alpha-3 code of the currency
         *      and where the value are the name of the currency in the current language
         *
-        * @param       string          WHERE clause
+        * @param       string          additional WHERE clause
         * @return      array           An array of names of currencies
         */
-       function initCurrencies($param='') {
+       function initCurrencies($addWhere='') {
                global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
 
-               $where = '1=1'.($param ? ' AND '.$param : '');
+               $where = '1=1'.($addWhere ? ' AND '.$addWhere : '');
                $table = $this->tables['CURRENCIES'];
                $lang = $this->getCurrentLanguage();
                $names = array();
@@ -370,13 +378,13 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         *      and where the value are the name of the language in the current language
         *      Note: we exclude sacred and constructed languages
         *
-        * @param       string          WHERE clause
+        * @param       string          additional WHERE clause
         * @return      array           An array of names of languages
         */
-       function initLanguages($param='') {
+       function initLanguages($addWhere='') {
                global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
 
-               $where = '1=1'.($param ? ' AND '.$param : '');
+               $where = '1=1'.($addWhere ? ' AND '.$addWhere : '');
                $table = $this->tables['LANGUAGES'];
                $lang = $this->getCurrentLanguage();
                $names = array();
@@ -389,7 +397,7 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
                $res = $TYPO3_DB->exec_SELECTquery(
                        $table.'.lg_iso_2,'.$table.'.lg_country_iso_2,'.$labelFields,
                        $table,
-                       $where.'lg_sacred = 0 and lg_constructed = 0 '.
+                       $where.' AND lg_sacred = 0 AND lg_constructed = 0 '.
                                $TSFE->sys_page->enableFields($table)
                        );
                while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
diff --git a/tca.php b/tca.php
index 7ea753b..e0d083b 100644 (file)
--- a/tca.php
+++ b/tca.php
@@ -624,16 +624,16 @@ $TCA['static_taxes'] = Array (
                'showRecordFieldList' => 'tx_name_en,tx_scope,tx_code,tx_country_iso_3,tx_country_iso_2,tx_country_iso_nr,tx_zn_code,tx_class,tx_rate,tx_priority,crdate,hidden,starttime,endtime'
        ),
        'columns' => Array (
-               'hidden' => Array (             
-                       'exclude' => 0, 
+               'hidden' => Array (
+                       'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
                        'config' => Array (
                                'type' => 'check',
                                'default' => '0'
                        )
                ),
-               'starttime' => Array (          
-                       'exclude' => 0, 
+               'starttime' => Array (
+                       'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
                        'config' => Array (
                                'type' => 'input',
@@ -644,8 +644,8 @@ $TCA['static_taxes'] = Array (
                                'checkbox' => '0'
                        )
                ),
-               'endtime' => Array (            
-                       'exclude' => 0, 
+               'endtime' => Array (
+                       'exclude' => 0,
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
                        'config' => Array (
                                'type' => 'input',
@@ -726,9 +726,9 @@ $TCA['static_taxes'] = Array (
                                'default' => ''
                        )
                ),
-               'tx_scope' => Array (           
-                       'exclude' => 0,         
-                       'label' => 'LLL:EXT:static_info_tables/locallang_db.xml:static_taxes_item.tx_scope',            
+               'tx_scope' => Array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:static_info_tables/locallang_db.xml:static_taxes_item.tx_scope',
                        'config' => Array (
                                'type' => 'select',
                                'items' => Array (
@@ -737,9 +737,9 @@ $TCA['static_taxes'] = Array (
                                ),
                        )
                ),
-               'tx_class' => Array (           
-                       'exclude' => 0,         
-                       'label' => 'LLL:EXT:static_info_tables/locallang_db.xml:static_taxes_item.tx_class',            
+               'tx_class' => Array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:static_info_tables/locallang_db.xml:static_taxes_item.tx_class',
                        'config' => Array (
                                'type' => 'select',
                                'items' => Array (