bugfixes for SQL
authorfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 3 Nov 2008 07:43:41 +0000 (07:43 +0000)
committerfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 3 Nov 2008 07:43:41 +0000 (07:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@13669 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_staticinfotables_div.php
doc/manual.sxw
ext_emconf.php
ext_localconf.php
ext_tables.php
ext_tables.sql
ext_tables_static+adt.sql
pi1/class.tx_staticinfotables_pi1.php

index b1b0219..bef41f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-03  Franz Holzinger  <contact@fholzinger.com>
+       * Fix bug 9351: Tennessee
+       * fix getTitleFromIsoCode: empty where clause must be '1=1' to allow AND combinations
+       * support for page module
+
 2008-07-15  Franz Holzinger  <contact@fholzinger.com>
        * Add the form tags to the UPDATE! function in EM for TYPO3 4.2.1
        * The versions 2.0.x are the last ones which will work under PHP 4.
index 9eb9366..45da586 100644 (file)
@@ -296,10 +296,13 @@ class tx_staticinfotables_div {
                                        $tmpField = tx_staticinfotables_div::getIsoCodeField($table, $code, TRUE, $index);
                                        $tmpValue = $TYPO3_DB->fullQuoteStr($code,$table);
                                        if ($tmpField && $tmpValue)     {
-                                               $whereClause .= ($index?' AND ':'').$table.'.'.$tmpField.' = '.$tmpValue;
+                                               $whereClause .= ($whereClause!='' ? ' AND ':'').$table.'.'.$tmpField.' = '.$tmpValue;
                                        }
                                }
                        }
+                       if (strpos($whereClause,' AND ')===0)   {
+                               $whereClause = '1=1'.$whereClause;
+                       }
                        if (is_object($TSFE)) {
                                $enableFields = $TSFE->sys_page->enableFields($table);
                        } else {
@@ -489,10 +492,12 @@ class tx_staticinfotables_div {
                                $fields['uid'] = 'uid';
 
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, $indexField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($indexValue,$table).t3lib_BEfunc::deleteClause($table));
-                               if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                       $uid = $row['uid'];
+                               if ($res !== FALSE)     {
+                                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                                               $uid = $row['uid'];
+                                       }
+                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                                }
-                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        }
 
                        if ($uid) {
@@ -517,7 +522,6 @@ class tx_staticinfotables_div {
                                                'sorting' => 1,
                                        );
                                        $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_staticinfotables_hotlist', $row);
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                                }
                        }
                }
index 7609686..a2e84da 100644 (file)
Binary files a/doc/manual.sxw and b/doc/manual.sxw differ
index 396e922..02a4770 100644 (file)
@@ -35,11 +35,12 @@ $EM_CONF[$_EXTKEY] = array(
        'constraints' => array(
                'depends' => array(
                        'typo3' => '4.0-0.0.0',
-                       'php' => '4.1.0-0.0.0',
+                       'php' => '5.1.0-0.0.0',
                ),
                'conflicts' => array(
                ),
                'suggests' => array(
+                       'patch1822' => '0.0.3-',
                ),
        ),
        '_md5_values_when_last_written' => 'a:23:{s:9:"ChangeLog";s:4:"80ff";s:20:"class.ext_update.php";s:4:"09b5";s:33:"class.tx_staticinfotables_div.php";s:4:"aa55";s:38:"class.tx_staticinfotables_encoding.php";s:4:"03fd";s:41:"class.tx_staticinfotables_syslanguage.php";s:4:"4f57";s:16:"contributors.txt";s:4:"9c5b";s:21:"ext_conf_template.txt";s:4:"5f7b";s:12:"ext_icon.gif";s:4:"639f";s:17:"ext_localconf.php";s:4:"5951";s:14:"ext_tables.php";s:4:"dfeb";s:14:"ext_tables.sql";s:4:"be38";s:25:"ext_tables_static+adt.sql";s:4:"c157";s:25:"icon_static_countries.gif";s:4:"2a46";s:26:"icon_static_currencies.gif";s:4:"a1e2";s:25:"icon_static_languages.gif";s:4:"639f";s:23:"icon_static_markets.gif";s:4:"bf06";s:27:"icon_static_territories.gif";s:4:"aab5";s:16:"locallang_db.xml";s:4:"158c";s:7:"tca.php";s:4:"3a72";s:14:"doc/manual.sxw";s:4:"095a";s:37:"pi1/class.tx_staticinfotables_pi1.php";s:4:"5247";s:39:"static/static_info_tables/constants.txt";s:4:"169d";s:35:"static/static_info_tables/setup.txt";s:4:"82b7";}',
index 09d35ec..ad6e57f 100644 (file)
@@ -91,4 +91,57 @@ if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][STATIC_INFO_TABLES_EXTkey]['tab
 
 require_once(t3lib_extMgm::extPath(STATIC_INFO_TABLES_EXTkey).'class.tx_staticinfotables_div.php');
 
+if ($_EXTCONF['usePatch1822'] &&
+!defined($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_countries']['MENU'])) {
+       $tableArray = array('static_territories', 'static_countries', 'static_country_zones', 'static_currencies', 'static_languages');
+
+       foreach ($tableArray as $theTable)      {
+               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['LLFile'][$theTable] = 'EXT:'.STATIC_INFO_TABLES_EXTkey.'/locallang.xml';
+               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['page0'][$theTable] = TRUE;
+       }
+
+       $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_territories'] = array (
+               'default' => array(
+                       'MENU' => 'm_default',
+                       'fList' =>  'tr_iso_nr,tr_parent_iso_nr,tr_name_en',
+                       'icon' => TRUE
+               ),
+       );
+
+       $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_countries'] = array (
+               'default' => array(
+                       'MENU' => 'm_default',
+                       'fList' =>  'uid,cn_iso_2,cn_iso_3,cn_iso_nr,cn_iso_nr,cn_official_name_local,cn_official_name_en,cn_capital',
+                       'icon' => TRUE
+               ),
+               'ext' => array(
+                       'MENU' => 'm_ext',
+                       'fList' =>  'cn_iso_3,cn_tldomain,cn_currency_iso_3,cn_currency_iso_nr,cn_phone,cn_eu_member,cn_uno_member,cn_address_format,cn_zone_flag,cn_short_local,cn_short_en',
+                       'icon' => TRUE
+               )
+       );
+       $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_country_zones'] = array (
+               'default' => array(
+                       'MENU' => 'm_default',
+                       'fList' =>  'uid,zn_country_iso_2,zn_country_iso_3,zn_country_iso_nr,zn_code,zn_name_local,zn_name_en',
+                       'icon' => TRUE
+               )
+       );
+       $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_currencies'] = array (
+               'default' => array(
+                       'MENU' => 'm_default',
+                       'fList' =>  'uid,cu_iso_3,cu_iso_nr,cu_name_en,cu_symbol_left,cu_symbol_right,cu_thousands_point,cu_decimal_digits,cu_sub_name_en,cu_sub_divisor,cu_sub_symbol_left,cu_sub_symbol_right',
+                       'icon' => TRUE
+               )
+       );
+       $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables']['static_languages'] = array (
+               'default' => array(
+                       'MENU' => 'm_default',
+                       'fList' =>  'uid,lg_iso_2,lg_name_local,lg_name_en,lg_typo3,lg_country_iso_2,lg_collate_locale,lg_sacred,lg_constructed',
+                       'icon' => TRUE
+               )
+       );
+}
+
+
 ?>
\ No newline at end of file
index 8d48dea..1e1473c 100644 (file)
@@ -144,29 +144,29 @@ $TCA['static_markets']['ctrl']['readOnly'] = 0;
 
 t3lib_div::loadTCA('sys_language');
 $TCA['sys_language']['columns']['static_lang_isocode']['config'] = array(
-                       'type' => 'select',
-                       'items' => array(
-                               array('',0),
-                       ),
-                       #'foreign_table' => 'static_languages',
-                       #'foreign_table_where' => 'AND static_languages.pid=0 ORDER BY static_languages.lg_name_en',
-                       'itemsProcFunc' => 'tx_staticinfotables_div->selectItemsTCA',
-                       'itemsProcFunc_config' => array(
-                               'table' => 'static_languages',
-                               'indexField' => 'uid',
-                               // I think that will make more sense in the future
-                               // 'indexField' => 'lg_iso_2',
-                               'prependHotlist' => 1,
-                               //      defaults:
-                               //'hotlistLimit' => 8,
-                               //'hotlistSort' => 1,
-                               //'hotlistOnly' => 0,
-                               //'hotlistApp' => TYPO3_MODE,
-                       ),
-                       'size' => 1,
-                       'minitems' => 0,
-                       'maxitems' => 1,
-               );
+       'type' => 'select',
+       'items' => array(
+               array('',0),
+       ),
+       #'foreign_table' => 'static_languages',
+       #'foreign_table_where' => 'AND static_languages.pid=0 ORDER BY static_languages.lg_name_en',
+       'itemsProcFunc' => 'tx_staticinfotables_div->selectItemsTCA',
+       'itemsProcFunc_config' => array(
+               'table' => 'static_languages',
+               'indexField' => 'uid',
+               // I think that will make more sense in the future
+               // 'indexField' => 'lg_iso_2',
+               'prependHotlist' => 1,
+               //      defaults:
+               //'hotlistLimit' => 8,
+               //'hotlistSort' => 1,
+               //'hotlistOnly' => 0,
+               //'hotlistApp' => TYPO3_MODE,
+       ),
+       'size' => 1,
+       'minitems' => 0,
+       'maxitems' => 1,
+);
 
 $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:'.STATIC_INFO_TABLES_EXTkey.'/class.tx_staticinfotables_syslanguage.php:&tx_staticinfotables_syslanguage';
 
index 29a2e52..71e8d20 100644 (file)
@@ -11,7 +11,6 @@ CREATE TABLE static_territories (
   UNIQUE uid (uid)
 );
 
-
 #
 # Table structure for table "static_countries"
 #
@@ -128,3 +127,4 @@ CREATE TABLE tx_staticinfotables_hotlist (
   sorting bigint(20) unsigned DEFAULT '0' NOT NULL,
   KEY uid_local (uid_local),
 );
+
index 2eeb0ee..e4ec0a7 100644 (file)
@@ -390,7 +390,7 @@ INSERT INTO static_country_zones VALUES ('52', '0', 'US', 'USA', '840', 'PR', 'P
 INSERT INTO static_country_zones VALUES ('53', '0', 'US', 'USA', '840', 'RI', 'Rhode Island', '');
 INSERT INTO static_country_zones VALUES ('54', '0', 'US', 'USA', '840', 'SC', 'South Carolina', '');
 INSERT INTO static_country_zones VALUES ('55', '0', 'US', 'USA', '840', 'SD', 'South Dakota', '');
-INSERT INTO static_country_zones VALUES ('56', '0', 'US', 'USA', '840', 'TN', 'Tenessee', '');
+INSERT INTO static_country_zones VALUES ('56', '0', 'US', 'USA', '840', 'TN', 'Tennessee', '');
 INSERT INTO static_country_zones VALUES ('57', '0', 'US', 'USA', '840', 'TX', 'Texas', '');
 INSERT INTO static_country_zones VALUES ('58', '0', 'US', 'USA', '840', 'UT', 'Utah', '');
 INSERT INTO static_country_zones VALUES ('59', '0', 'US', 'USA', '840', 'VT', 'Vermont', '');
index 8528dcd..bb7eb62 100644 (file)
  *   96:     function needsInit ()
  *  106:     function init($conf=array())
  *  163:     function getStaticInfoName($type='COUNTRIES', $code, $country='', $countrySubdivision='', $local=FALSE)
- *  233:     function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selectedArray=array(), $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE, $mergeArray=array(), $size=1)
- *  318:     function initCountries($param='UN', $lang='', $local=FALSE, $addWhere='')
- *  375:     function initCountrySubdivisions($param, $addWhere='')
- *  421:     function initCurrencies($addWhere='')
- *  461:     function initLanguages($addWhere='')
- *  501:     function optionsConstructor($nameArray, $selectedArray=array())
- *  528:     function loadCurrencyInfo($currencyCode)
- *  573:     function formatAmount($amount, $displayCurrencyCode='')
- *  601:     function formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode='', $countryCode='')
- *  645:     function getCurrentLanguage()
+ *  234:     function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selectedArray=array(), $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE, $mergeArray=array(), $size=1, &$outSelectedArray=array())
+ *  319:     function initCountries($param='UN', $lang='', $local=FALSE, $addWhere='')
+ *  376:     function initCountrySubdivisions($param, $addWhere='')
+ *  422:     function initCurrencies($addWhere='')
+ *  462:     function initLanguages($addWhere='')
+ *  503:     function optionsConstructor($nameArray, $selectedArray=array(), &$outSelectedArray=array())
+ *  529:     function loadCurrencyInfo($currencyCode)
+ *  574:     function formatAmount($amount, $displayCurrencyCode='')
+ *  602:     function formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode='', $countryCode='')
+ *  646:     function getCurrentLanguage()
  *
  * TOTAL FUNCTIONS: 13
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -228,9 +228,10 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         * @param       boolean         $local: If set, we are looking for the "local" title field
         * @param       array           additional array to be merged as key => value pair
         * @param       int             max elements that can be selected. Default: 1
+        * @param       array           out: resulting selected array with the ISO alpha-3 code of the countries
         * @return      string          A set of HTML <select> and <option> tags
         */
-       function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selectedArray=array(), $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE, $mergeArray=array(), $size=1) {
+       function buildStaticInfoSelector($type='COUNTRIES', $name='', $class='', $selectedArray=array(), $country='', $submit=0, $id='', $title='', $addWhere='', $lang='', $local=FALSE, $mergeArray=array(), $size=1, &$outSelectedArray=array())     {
                global $TSFE;
 
                if ($size > 1) {
@@ -296,7 +297,7 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
                        uasort($nameArray, 'strcoll');
                }
                if(count($nameArray) > 0)       {
-                       $selector .= $this->optionsConstructor($nameArray, $selectedArray);
+                       $selector .= $this->optionsConstructor($nameArray, $selectedArray, $outSelectedArray);
                        $selector .= '</select>'.chr(10);
                } else {
                        $selector = '';
@@ -496,13 +497,13 @@ class tx_staticinfotables_pi1 extends tslib_pibase {
         *
         * @param       array           An array where the values will be the texts of an <option> tags and keys will be the values of the tags
         * @param       string          A pre-selected value: if the value appears as a key, the <option> tag will bear a 'selected' attribute
+        * @param       array           out: resulting selected array with the ISO alpha-3 code of the countries
         * @return      string          A string of HTML <option> tags
         */
-       function optionsConstructor($nameArray, $selectedArray=array()) {
+       function optionsConstructor($nameArray, $selectedArray=array(), &$outSelectedArray=array()) {
                global $TSFE;
 
                $options = '';
-               $outSelectedArray=array();
                foreach($nameArray as $value => $name)  {
 
                        $options  .= '<option value="'.$value.'"';