当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::deleteByKey方法代码示例

本文整理汇总了PHP中Text::deleteByKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::deleteByKey方法的具体用法?PHP Text::deleteByKey怎么用?PHP Text::deleteByKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text的用法示例。


在下文中一共展示了Text::deleteByKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates text fields to the new structure
  * @return  boolean         False.  Always.
  * @static
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Product
     // Fix the Text, Discount, and Manufacturer tables first
     \Text::errorHandler();
     //        Discount::errorHandler(); // Called by Customer::errorHandler();
     Manufacturer::errorHandler();
     $table_name = DBPREFIX . 'module_shop_products';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discount_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'is_special_offer'), 'stock' => array('type' => 'INT(10)', 'default' => '10'), 'stock_visible' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'stock_visibility'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'date_start' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'startdate'), 'date_end' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'enddate'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'category_id' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'catid'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'manufacturer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'manufacturer'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'usergroup_ids' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_order'), 'distribution' => array('type' => 'VARCHAR(16)', 'default' => '', 'renamefrom' => 'handler'), 'picture' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'flags' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'minimum_order_quantity' => array('type' => 'INT(10)', 'unsigned' => false, 'default' => '0'));
     $table_index = array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'));
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) {
             // Migrate all Product strings to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             \Text::deleteByKey('Shop', self::TEXT_SHORT);
             \Text::deleteByKey('Shop', self::TEXT_LONG);
             \Text::deleteByKey('Shop', self::TEXT_CODE);
             \Text::deleteByKey('Shop', self::TEXT_URI);
             \Text::deleteByKey('Shop', self::TEXT_KEYS);
             $query = "\n                    SELECT `id`, `title`, `shortdesc`, `description`,\n                           `product_id`, `external_link`, `keywords`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Product strings", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['title'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product name '{$name}'");
                 }
                 $short = $objResult->fields['shortdesc'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_SHORT, $short)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product short '{$short}'");
                 }
                 $long = $objResult->fields['description'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_LONG, $long)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product long '{$long}'");
                 }
                 $code = $objResult->fields['product_id'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CODE, $code)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product code '{$code}'");
                 }
                 $uri = $objResult->fields['external_link'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product uri '{$uri}'");
                 }
                 $keys = $objResult->fields['keywords'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_KEYS, $keys)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product keys '{$keys}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Also fix Customer and some related tables
     Customer::errorHandler();
     // Always
     return false;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:69,代码来源:Product.class.php

示例2: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old names to the new structure
  * @return  boolean         False.  Always.
  * @static
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Shipment
     static $break = false;
     if ($break) {
         die("\n                Shipment::errorHandler(): Recursion detected while handling an error.<br /><br />\n                This should not happen.  We are very sorry for the inconvenience.<br />\n                Please contact customer support: helpdesk@comvation.com");
     }
     $break = true;
     //die("Shipment::errorHandler(): Disabled!<br />");
     // Fix the Zones table first
     Zones::errorHandler();
     $table_name = DBPREFIX . 'module_shop_shipper';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_shipment_cost';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'cost'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'price_free'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always!
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:49,代码来源:Shipment.class.php

示例3: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old ProductAttribute to new Attribute structures,
  * including Text records.
  * @return  boolean   false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Attribute
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_name';
     $table_name_new = DBPREFIX . 'module_shop_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME);
                 $query = "\n                        SELECT `id`, `name`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['name'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         //DBG::activate(DBG_ADODB);
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_value';
     $table_name_new = DBPREFIX . 'module_shop_option';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME);
                 $query = "\n                        SELECT `id`, `value`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['value'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes';
     $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id'));
         $table_index = array();
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}");
         }
     }
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:90,代码来源:Attribute.class.php

示例4: errorHandler

 /**
  * Handles any kind of database errors
  *
  * Includes updating the payments table (I guess from version 1.2.0(?),
  * note that this is unconfirmed) to the current structure
  * @return  boolean               False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Payment
     // Fix the Text and Zones tables first
     \Text::errorHandler();
     Zones::errorHandler();
     \Yellowpay::errorHandler();
     $table_name = DBPREFIX . 'module_shop_payment';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             // Migrate all Payment names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Payment names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Payment name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Update Payments that use obsolete PSPs:
     //  - 05, 'Internal_CreditCard'
     //  - 06, 'Internal_Debit',
     // Uses 04, Internal
     \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n                SET `processor_id`=4 WHERE `processor_id` IN (5, 6)");
     // - 07, 'Saferpay_Mastercard_Multipay_CAR',
     // - 08, 'Saferpay_Visa_Multipay_CAR',
     // Uses 01, Saferpay
     \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n                SET `processor_id`=1 WHERE `processor_id` IN (7, 8)");
     $table_name = DBPREFIX . 'module_shop_rel_payment';
     $table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:55,代码来源:Payment.class.php

示例5: errorHandler

 /**
  * Tries to fix any database problems
  * @return  boolean           False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     //die("Discount::errorHandler(): Disabled!<br />");
     // Discount
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_article_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     //\DBG::activate(DBG_DB);
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_ARTICLE);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query article group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_ARTICLE, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate article group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_customer_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_CUSTOMER);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query customer group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_CUSTOMER, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate customer group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_rel_discount_group';
     $table_structure = array('customer_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'article_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'rate' => array('type' => 'decimal(9,2)', 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_name';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_COUNT);
         \Text::deleteByKey('Shop', self::TEXT_UNIT_GROUP_COUNT);
         $query = "\n                SELECT `id`, `name`, `unit`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query count group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             $unit = $objResult->fields['unit'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_COUNT, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group names");
             }
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_UNIT_GROUP_COUNT, $unit)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group units");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate';
     $table_structure = array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:99,代码来源:Discount.class.php

示例6: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old Currency names to the Text class,
  * and inserts default Currencyes if necessary
  * @return  boolean     false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $objDatabase;
     // Currency
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_currencies';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'increment' => array('type' => 'DECIMAL(6,5)', 'unsigned' => true, 'notnull' => true, 'default' => '0.01'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'), 'default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'is_default'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             // Migrate all Currency names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `code`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Currency names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Currency name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
         return false;
     }
     // If the table did not exist, insert defaults
     $arrCurrencies = array('Schweizer Franken' => array('CHF', 'sFr.', 1.0, '0.05', 1, 1, 1), 'Euro' => array('EUR', html_entity_decode("&euro;"), 1.18, '0.01', 2, 1, 0), 'United States Dollars' => array('USD', '$', 0.88, '0.01', 3, 1, 0));
     // There is no previous version of this table!
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     // And there aren't even records to migrate, so
     foreach ($arrCurrencies as $name => $arrCurrency) {
         $query = "\n                INSERT INTO `contrexx_module_shop_currencies` (\n                    `code`, `symbol`, `rate`, `increment`,\n                    `ord`, `active`, `default`\n                ) VALUES (\n                    '" . join("','", $arrCurrency) . "'\n                )";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to insert default Currencies");
         }
         $id = $objDatabase->Insert_ID();
         if (!\Text::replace($id, FRONTEND_LANG_ID, 'Shop', self::TEXT_NAME, $name)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to add Text for default Currency name '{$name}'");
         }
     }
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:57,代码来源:Currency.class.php

示例7: errorHandler

 /**
  * Tries to fix database problems
  *
  * Also migrates text fields to the new structure.
  * Note that no VAT classes are added here (yet), so neither the old
  * nor the new table exists to begin with, the new structure will be
  * created with no records.
  * @return  boolean               False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Vat
     $table_name = DBPREFIX . 'module_shop_vat';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00', 'renamefrom' => 'percent'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name, 'class')) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'class')) {
             // Migrate all Vat classes to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_CLASS);
             $query = "\n                    SELECT `id`, `class`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $class = $objResult->fields['class'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CLASS, $class)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate VAT class '{$class}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:37,代码来源:Vat.class.php

示例8: errorHandler

 /**
  * Handle any error occurring in this class.
  *
  * Tries to fix known problems with the database table.
  * @global  mixed     $objDatabase    Database object
  * @return  boolean                   False.  Always.
  * @author  Reto Kohli <reto.kohli@comvation.com>
  */
 function errorHandler()
 {
     global $objDatabase;
     //die("ImageType::errorHandler(): Disabled!<br />");
     $arrTables = $objDatabase->MetaTables('TABLES');
     if (in_array(DBPREFIX . "core_imagetype", $arrTables)) {
         $objResult = $objDatabase->Execute("\n                DROP TABLE `" . DBPREFIX . "core_imagetype`");
         if (!$objResult) {
             return false;
         }
         echo "ImageType::errorHandler(): Created table core_imagetype<br />";
     }
     $objResult = $objDatabase->Execute("\n            CREATE TABLE IF NOT EXISTS `" . DBPREFIX . "core_imagetype` (\n              `module_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The ID of the module this image type occurs in',\n              `key` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'The key unique for each module ID that identifies the image type',\n              `text_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Relates to core_text.id',\n              `width` INT UNSIGNED NULL DEFAULT NULL,\n              `height` INT UNSIGNED NULL DEFAULT NULL,\n              `quality` INT UNSIGNED NULL DEFAULT NULL,\n              `width_thumb` INT UNSIGNED NULL DEFAULT NULL,\n              `height_thumb` INT UNSIGNED NULL DEFAULT NULL,\n              `quality_thumb` INT UNSIGNED NULL DEFAULT NULL,\n              PRIMARY KEY (`module_id`, `key`),\n              UNIQUE (`text_id`)\n            ) ENGINE=MYISAM");
     if (!$objResult) {
         return false;
     }
     echo "ImageType::errorHandler(): Created table core_imagetype<br />";
     $arrImagetypes = array(array('module_id' => 10013, 'key' => 'hotelcard_hotel_title', 'text' => array(1 => 'Titelbild', 2 => 'Title', 3 => 'Title', 4 => 'Title'), 'width' => 320, 'height' => 240, 'quality' => 90, 'width_thumb' => 160, 'height_thumb' => 120, 'quality_thumb' => 90), array('module_id' => 10013, 'key' => 'hotelcard_hotel_room', 'text' => array(1 => 'Zimmer', 2 => 'Room', 3 => 'Room', 4 => 'Room'), 'width' => 320, 'height' => 240, 'quality' => 90, 'width_thumb' => 160, 'height_thumb' => 120, 'quality_thumb' => 90), array('module_id' => 10013, 'key' => 'hotelcard_hotel_vicinity', 'text' => array(1 => 'Umbgebung', 2 => 'Vicinity', 3 => 'Vicinity', 4 => 'Vicinity'), 'width' => 320, 'height' => 240, 'quality' => 90, 'width_thumb' => 160, 'height_thumb' => 120, 'quality_thumb' => 90), array('module_id' => 10013, 'key' => 'hotelcard_hotel_lobby', 'text' => array(1 => 'Lobby', 2 => 'Lobby', 3 => 'Lobby', 4 => 'Lobby'), 'width' => 320, 'height' => 240, 'quality' => 90, 'width_thumb' => 160, 'height_thumb' => 120, 'quality_thumb' => 90));
     \Text::deleteByKey(self::TEXT_IMAGETYPE);
     foreach ($arrImagetypes as $arrImagetype) {
         $text_id = 0;
         foreach ($arrImagetype['text'] as $lang_id => $text) {
             $text_id = \Text::replace($text_id, $lang_id, $text, $arrImagetype['module_id'], self::TEXT_IMAGETYPE);
             if (!$text_id) {
                 die("ImageType::errorHandler(): Error storing Text");
             }
         }
         $objResult = $objDatabase->Execute("\n                INSERT INTO `" . DBPREFIX . "core_imagetype` (\n                  `module_id`, `key`, `text_id`,\n                  `width`, `height`, `quality`,\n                  `width_thumb`, `height_thumb`, `quality_thumb`\n                ) VALUES (\n                  " . $arrImagetype['module_id'] . ",\n                  '" . addslashes($arrImagetype['key']) . "',\n                  {$text_id},\n                  " . $arrImagetype['width'] . ",\n                  " . $arrImagetype['height'] . ",\n                  " . $arrImagetype['quality'] . ",\n                  " . $arrImagetype['width_thumb'] . ",\n                  " . $arrImagetype['height_thumb'] . ",\n                  " . $arrImagetype['quality_thumb'] . "\n                )");
         if (!$objResult) {
             die("ImageType::errorHandler(): Error adding Imagetype");
         }
         echo "ImageType::errorHandler(): Inserted image type " . var_export($arrImagetype, true) . "<br />";
     }
     // More to come...
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:44,代码来源:ImageType.class.php

示例9: errorHandler

 /**
  * Handles any kind of database error
  * @throws  Cx\Lib\Update_DatabaseException
  * @return  boolean                 False.  Always.
  */
 static function errorHandler()
 {
     // ShopCategory
     // Fix the Text and Settings table first
     \Text::errorHandler();
     ShopSettings::errorHandler();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name = DBPREFIX . 'module_shop_categories';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'catid'), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'parentid'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'catsorting'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'catstatus'), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'default' => ''));
     $table_index = array('flags' => array('fields' => 'flags', 'type' => 'FULLTEXT'));
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'catname')) {
             // Migrate all ShopCategory names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             \Text::deleteByKey('Shop', self::TEXT_DESCRIPTION);
             $query = "\n                    SELECT `catid`, `catname`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query ShopCategory names");
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['catid'];
                 $name = $objResult->fields['catname'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate ShopCategory name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:39,代码来源:ShopCategory.class.php

示例10: errorHandler

 /**
  * Tries to recreate the database table(s) for the class
  *
  * Should be called whenever there's a problem with the database table.
  * @return  boolean             False.  Always.
  */
 static function errorHandler()
 {
     $table_name = DBPREFIX . 'core_country';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'alpha2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'alpha3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'is_active'));
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         \Text::deleteByKey('core', self::TEXT_NAME);
         // Copy the Countries from the Shop module if possible
         if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . "module_shop_countries")) {
             $query = "\n                    SELECT `countries_id`, `countries_name`,\n                           `countries_iso_code_2`, `countries_iso_code_3`,\n                           `activation_status`\n                      FROM " . DBPREFIX . "module_shop_countries";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to to query Country names", $query);
             }
             $default_lang_id = \FWLanguage::getDefaultLangId();
             while (!$objResult->EOF) {
                 $id = $objResult->fields['countries_id'];
                 $name = $objResult->fields['countries_name'];
                 $alpha2 = $objResult->fields['countries_iso_code_2'];
                 $alpha3 = $objResult->fields['countries_iso_code_3'];
                 $active = $objResult->fields['activation_status'];
                 $ord = 0;
                 if ($id == 14) {
                     // fixing missing name
                     $name = 'Österreich';
                 }
                 if (!self::store($alpha2, $alpha3, $default_lang_id, $name, $ord, $active, $id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate Country '{$name}'");
                 }
                 $objResult->MoveNext();
             }
             \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_countries');
         }
     }
     // USE FOR NEW INSTALLATIONS ONLY!
     // These records will lead to inconsistencies with Country references in
     // other tables otherwise.
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         // Add new Country records if available
         if (file_exists(ASCMS_CORE_PATH . '/countries_iso_3166-2.php') && (include_once ASCMS_CORE_PATH . '/countries_iso_3166-2.php')) {
             //DBG::log("Country::errorHandler(): Included ISO file");
             $arrCountries = null;
             $ord = 0;
             foreach ($arrCountries as $country_id => $arrCountry) {
                 $name = $arrCountry[0];
                 $alpha2 = $arrCountry[1];
                 $alpha3 = $arrCountry[2];
                 // Not currently in use:
                 //                    $numeric = $arrCountry[3];
                 //                    $iso_full = $arrCountry[4];
                 // English (language ID 2) only!
                 if (!self::store($alpha2, $alpha3, 2, $name, ++$ord, true, $country_id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to add Country '{$name}' from ISO file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: '$name'");
             }
         }
     }
     //DBG::activate(DBG_ADODB);
     // Add more languages from the countries_languages.php file,
     // if present
     $arrCountries = array();
     // $arrCountries is redefined in the file
     if (file_exists(ASCMS_CORE_PATH . '/countries_languages.php') && (include_once ASCMS_CORE_PATH . '/countries_languages.php')) {
         foreach ($arrCountries as $alpha2 => $arrLanguage) {
             //DBG::log("errorHandler: Looking for Alpha-2 $alpha2");
             $country_id = self::getIdByAlpha2($alpha2);
             if (!$country_id) {
                 // TODO: Fail or not?
                 continue;
             }
             foreach ($arrLanguage as $lang_id => $name) {
                 if (!\Text::replace($country_id, $lang_id, 'core', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to update Country '{$name}' from languages file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: language ID $lang_id");
             }
         }
     }
     \Cx\Core\Setting\Controller\Setting::init('core', 'country');
     \Cx\Core\Setting\Controller\Setting::add('numof_countries_per_page_backend', 30, 101);
     // More to come...
     // Always!
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:91,代码来源:Country.class.php

示例11: errorHandler

 /**
  * Handle any error occurring in this class.
  *
  * Tries to fix known problems with the database table.
  * If the table exists, it is dropped.
  * After that, the table is created anew.
  * Finally, the mime types known are inserted.
  * @global  mixed     $objDatabase    Database object
  * @return  boolean                   False.  Always.
  * @author  Reto Kohli <reto.kohli@comvation.com>
  */
 function errorHandler()
 {
     global $objDatabase;
     die("Filetype::errorHandler(): Disabled!<br />");
     $objResult = $objDatabase->Execute("\n            ALTER TABLE `" . DBPREFIX . "core_filetype`\n            CHANGE `name_text_id` `text_name_id` INT(10) UNSIGNED NOT NULL DEFAULT 0");
     if (!$objResult) {
         return false;
     }
     $objResult = $objDatabase->Execute("\n            ALTER TABLE `" . DBPREFIX . "core_filetype`\n            ADD `ord` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `id`");
     if (!$objResult) {
         return false;
     }
     die("Filetype::errorHandler(): Fixed Filetype table");
     $arrTables = $objDatabase->MetaTables('TABLES');
     if (in_array(DBPREFIX . "core_filetype", $arrTables)) {
         // The table does exist, but causes errors!  So...
         $objResult = $objDatabase->Execute("\n                DROP TABLE `" . DBPREFIX . "core_filetype`");
         if (!$objResult) {
             return false;
         }
     }
     $objResult = $objDatabase->Execute("\n            CREATE TABLE `" . DBPREFIX . "core_filetype` (\n              `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n              `ord` INT(10) UNSIGNED NOT NULL DEFAULT 0,\n              `text_name_id` INT(10) UNSIGNED NOT NULL DEFAULT 0,\n              `extension` VARCHAR(16) NULL COMMENT 'Extension without the leading dot',\n              `mimetype` VARCHAR(32) NULL COMMENT 'Mime type',\n              PRIMARY KEY (`id`),\n              UNIQUE INDEX `type` USING BTREE (`extension`(16) ASC, `mimetype`(32) ASC)\n            ) ENGINE=InnoDB");
     if (!$objResult) {
         return false;
     }
     /**
      * Known extensions and corresponding MIME types.
      *
      * Note that these associations are arbitrary!
      * @var     array
      */
     $arrExtensions2Mimetypes = array('3dm' => 'x-world/x-3dmf', '3dmf' => 'x-world/x-3dmf', 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'au' => 'audio/basic', 'avi' => 'video/x-msvideo', 'bin' => 'application/octet-stream', 'cab' => 'application/x-shockwave-flash', 'chm' => 'application/mshelp', 'class' => 'application/octet-stream', 'com' => 'application/octet-stream', 'csh' => 'application/x-csh', 'css' => 'text/css', 'csv' => 'text/comma-separated-values', 'dll' => 'application/octet-stream', 'doc' => 'application/msword', 'dot' => 'application/msword', 'eps' => 'application/postscript', 'exe' => 'application/octet-stream', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'fif' => 'image/fif', 'gif' => 'image/gif', 'gtar' => 'application/x-gtar', 'gz ' => 'application/gzip', 'hlp' => 'application/mshelp', 'hqx' => 'application/mac-binhex40', 'htm' => 'text/html', 'html' => 'text/html', 'ico' => 'image/x-icon', 'ief' => 'image/ief', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'js' => 'application/x-javascript', 'js' => 'text/javascript', 'latex' => 'application/x-latex', 'mcf' => 'image/vasa', 'mid' => 'audio/x-midi', 'midi' => 'audio/x-midi', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/x-mpeg', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'pbm' => 'image/x-portable-bitmap', 'pdf' => 'application/pdf', 'pgm' => 'image/x-portable-graymap', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'pot' => 'application/mspowerpoint', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/mspowerpoint', 'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'ps' => 'application/postscript', 'qd3' => 'x-world/x-3dmf', 'qd3d' => 'x-world/x-3dmf', 'qt' => 'video/quicktime', 'ra' => 'audio/x-pn-realaudio', 'ram' => 'audio/x-pn-realaudio', 'rgb' => 'image/x-rgb', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'sgm' => 'text/x-sgml', 'sgml' => 'text/x-sgml', 'sh' => 'application/x-sh', 'shtml' => 'text/html', 'sit' => 'application/x-stuffit', 'snd' => 'audio/basic', 'stream' => 'audio/x-qt-stream', 'swf' => 'application/x-shockwave-flash', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain', 'viv' => 'video/vnd.vivo', 'vivo' => 'video/vnd.vivo', 'wav' => 'audio/x-wav', 'wbmp' => 'image/vnd.wap.wbmp', 'wml' => 'text/vnd.wap.wml', 'wrl' => 'model/vrml', 'xbm' => 'image/x-xbitmap', 'xhtml' => 'application/xhtml+xml', 'xla' => 'application/msexcel', 'xls' => 'application/msexcel', 'xml' => 'text/xml', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-windowdump', 'z' => 'application/x-compress', 'zip' => 'application/zip');
     Text::deleteByKey(self::TEXT_NAME);
     foreach ($arrExtensions2Mimetypes as $extension => $mimetype) {
         $text_id = 0;
         // TODO:  Add proper names for the file types
         $text_id = Text::replace($text_id, FRONTEND_LANG_ID, $mimetype, MODULE_ID, self::TEXT_NAME);
         if (!$text_id) {
             echo "Filetype::errorHandler(): Failed to store Text for type {$mimetype}<br />";
             continue;
         }
         $objResult = $objDatabase->Execute("\n                INSERT INTO `" . DBPREFIX . "core_filetype` (\n                    `text_name_id`, `extension`, `mimetype`\n                ) VALUES (\n                    {$text_id}, '" . addslashes($extension) . "', '" . addslashes($mimetype) . "'\n                )");
         if (!$objResult) {
             echo "Filetype::errorHandler(): Failed to store file type {$mimetype}<br />";
             continue;
         }
     }
     // More to come...
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:61,代码来源:Filetype.class.php

示例12: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates text fields to the new structure
  * @return  boolean           False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Zones
     // Fix the Zone-Payment relation table
     $table_name = DBPREFIX . 'module_shop_rel_payment';
     $table_structure = array('zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Fix the Text table
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_zones';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'zones_id'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'activation_status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'zones_name')) {
             // Migrate all Zone names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `zones_id`, `zones_name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Zone names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['zones_id'];
                 $name = $objResult->fields['zones_name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Zone name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name_old = DBPREFIX . 'module_shop_rel_shipment';
     $table_name_new = DBPREFIX . 'module_shop_rel_shipper';
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name_new) && \Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new);
     }
     $table_structure = array('shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'shipment_id'), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name_new, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_rel_countries';
     $table_structure = array('country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'countries_id'), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:56,代码来源:Zones.class.php

示例13: errorHandler

 /**
  * Migrates existing old Shop mailtemplates to the new MailTemplate class
  * @return  boolean         False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     if (!(include_once \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseFrameworkPath() . '/UpdateUtil')) {
         return false;
     }
     if (\Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'core_mail_template')) {
         // Make sure there are no bodies lying around
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_NAME);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_FROM);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SENDER);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_REPLY);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_TO);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_CC);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_BCC);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SUBJECT);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE_HTML);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_ATTACHMENTS);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_INLINE);
     }
     // Migrate existing templates from the shop to the MailTemplate.
     // These are the keys replacing the IDs.
     // TODO: Migrate the old template using the original IDs, make them unprotected
     // TODO: Add the new default templates with the new keys
     // and have the user migrate changes herself!
     $arrKey = array(1 => 'order_confirmation', 2 => 'order_complete', 3 => 'customer_login', 4 => 'order_confirmation_login');
     $arrLanguageId = \FWLanguage::getIdArray();
     if (empty($arrLanguageId)) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to get frontend language IDs");
     }
     foreach ($arrLanguageId as $lang_id) {
         // Mind that the template name is single language yet!
         $arrTemplates = self::getTemplateArray($lang_id);
         if (empty($arrTemplates)) {
             continue;
         }
         foreach ($arrTemplates as $id => $arrTemplate) {
             // TODO: utf8_encode() may not be necessary in all cases.
             // It worked without it for me earlier, but was necessary for verkehrstheorie.ch
             $arrTemplate = array_map("utf8_encode", $arrTemplate);
             if (isset($arrKey[$id])) {
                 // System templates get their default key
                 $arrTemplate['key'] = $arrKey[$id];
                 if ($id == 4) {
                     // Clear the protected flag, so the obsolete template
                     // #4 may be removed at will
                     $arrTemplate['protected'] = false;
                 }
             } else {
                 // Custom templates:
                 // Make the name lowercase and replace any non-letter
                 $new_key = preg_replace('/[^a-z]/', '_', strtolower($arrTemplate['name']));
                 // Keep it unique!  Use the ID if the key is taken
                 if (in_array($new_key, $arrKey)) {
                     $new_key = $id;
                 }
                 // Remember used keys, and replace the former ID
                 $arrKey[$id] = $new_key;
                 $arrTemplate['key'] = $new_key;
             }
             foreach ($arrTemplate as &$string) {
                 // Replace old <PLACEHOLDERS> with new [PLACEHOLDERS].
                 $string = preg_replace('/\\<([A-Z_]+)\\>/', '[$1]', $string);
                 // TODO: This is completely unreliable.
                 // Use the process as described above, not replacing the old templates,
                 // but adding the new ones instead.
                 //                    $string = str_replace('[ORDER_DATA]', $order_data, $string);
                 //                    $string = preg_replace('/[\\w\\s\\:]+\\[USERNAME\\](?:\\n|<br\\s?\\/?
                 //                          >)*[\\w\\s\\:]+\\[PASSWORD\\]/',
                 //                        $login_data, $string);
             }
             //                $arrTemplate['message_html'] = preg_replace(
             //                    '/(?:\r|\n|\r\n)/', "<br />\n", $arrTemplate['message']);
             $arrTemplate['lang_id'] = $lang_id;
             if (!\Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', $arrTemplate)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to store Mailtemplate");
             }
         }
     }
     // Drop old Mail tables after successful migration
     \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail_content');
     \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail');
     // Always!
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:90,代码来源:Mail.class.php

示例14: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates the old Manufacturers to the new structure
  * @return  boolean             False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Manufacturer
     // Fix the Text table first
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_manufacturer';
     // Note:  As this table uses a single column, the primary key will
     // have to be added separately below.  Otherwise, UpdateUtil::table()
     // will drop the id column first, then try to drop all the others,
     // which obviously won't work.
     // In that context, the "AUTO_INCREMENT" has to be dropped as well,
     // for that only applies to a primary key column.
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name) && \Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         // Get rid of bodies
         \Text::deleteByKey('Shop', self::TEXT_NAME);
         \Text::deleteByKey('Shop', self::TEXT_URI);
         // Migrate all Manufacturer text fields to the Text table
         $query = "\n                SELECT `id`, `name`, `url`\n                  FROM `" . DBPREFIX . "module_shop_manufacturer`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         while (!$objResult->EOF) {
             $id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             $uri = $objResult->fields['url'];
             if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Manufacturer name '{$name}'");
             }
             if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Manufacturer URI '{$uri}'");
             }
             $objResult->MoveNext();
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     \Cx\Lib\UpdateUtil::sql("\n            ALTER TABLE `{$table_name}`\n              ADD PRIMARY KEY (`id`)");
     \Cx\Lib\UpdateUtil::sql("\n            ALTER TABLE `{$table_name}`\n           CHANGE `id` `id` int(10) unsigned NOT NULL AUTO_INCREMENT");
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:48,代码来源:Manufacturer.class.php

示例15: errorHandler

    /**
     * Migrates existing old Shop mailtemplates to the new MailTemplate class
     * @return  boolean         False.  Always.
     * @throws  Cx\Lib\Update_DatabaseException
     */
    static function errorHandler()
    {
        // Mail
        \Cx\Core\MailTemplate\Controller\MailTemplate::errorHandler();
        if (\Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'core_mail_template')) {
            // Make sure there are no bodies lying around
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_NAME);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_FROM);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SENDER);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_REPLY);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_TO);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_CC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_BCC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SUBJECT);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE_HTML);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_ATTACHMENTS);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_INLINE);
        }
        $arrFrom = $arrSender = $arrSubject = array();
        $arrLanguageId = \FWLanguage::getIdArray();
        if (empty($arrLanguageId)) {
            throw new \Cx\Lib\Update_DatabaseException("Failed to get frontend language IDs");
        }
        if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_shop_mail')) {
            // Migrate existing templates from the shop to the MailTemplate,
            // appending "_backup_by_update" to the respective keys.
            // Make them unprotected.
            // These are the keys replacing the IDs:
            $arrKey = array(1 => 'order_confirmation', 2 => 'order_complete', 3 => 'customer_login', 4 => 'order_confirmation_login');
            foreach ($arrLanguageId as $lang_id) {
                // Mind that the template name is single language yet!
                $arrTemplates = self::getTemplateArray($lang_id);
                if (empty($arrTemplates)) {
                    continue;
                }
                foreach ($arrTemplates as $id => $arrTemplate) {
                    // NOTE: utf8_encode() may be necessary in some cases.
                    // It usually works without it, but was necessary on a few installations.
                    //                    $arrTemplate = array_map("utf8_encode", $arrTemplate);
                    if (!empty($arrTemplate['from']) && empty($arrFrom[$id])) {
                        $arrFrom[$id] = $arrTemplate['from'];
                    }
                    if (!empty($arrTemplate['sender']) && empty($arrSender[$id])) {
                        $arrSender[$id] = $arrTemplate['sender'];
                    }
                    if (!empty($arrTemplate['subject']) && empty($arrSubject[$id])) {
                        $arrSubject[$id] = str_replace('<DATE>', '[ORDER_DATE]', $arrTemplate['subject']);
                    }
                    if (isset($arrKey[$id])) {
                        // System templates get their default key
                        $arrTemplate['key'] = $arrKey[$id] . '_backup_by_update';
                        // Clear the protected flag, so the old templates
                        // may be removed at will
                        $arrTemplate['protected'] = false;
                    } else {
                        // Custom templates:
                        // Make the name lowercase and replace any non-letter
                        $new_key = preg_replace('/[^a-z]/', '_', strtolower($arrTemplate['name']));
                        // Keep it unique!  Use the ID if the key is taken
                        if (in_array($new_key, $arrKey)) {
                            $new_key = $id;
                        }
                        // Remember used keys, and replace the former ID
                        $arrKey[$id] = $new_key;
                        $arrTemplate['key'] = $new_key;
                    }
                    // Some installations may contain corrupt templates
                    // causing empty (0 or "") keys.  Those would make
                    // MailTemplate::store() fail!
                    if (empty($arrTemplate['key'])) {
                        $arrTemplate['key'] = uniqid() . '_backup_by_update)';
                    }
                    foreach ($arrTemplate as &$string) {
                        // Replace old <PLACEHOLDERS> with new [PLACEHOLDERS].
                        $string = preg_replace('/\\<([A-Z_]+)\\>/', '[$1]', $string);
                        // This is completely unreliable.
                        // Use the process as described above, not replacing the old templates,
                        // but adding the new ones instead.
                        //                    $string = str_replace('[ORDER_DATA]', $order_data, $string);
                        //                    $string = preg_replace('/[\\w\\s\\:]+\\[USERNAME\\](?:\\n|<br\\s?\\/?
                        //                          >)*[\\w\\s\\:]+\\[PASSWORD\\]/',
                        //                        $login_data, $string);
                    }
                    //                $arrTemplate['message_html'] = preg_replace(
                    //                    '/(?:\r|\n|\r\n)/', "<br />\n", $arrTemplate['message']);
                    $arrTemplate['lang_id'] = $lang_id;
                    if (!\Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', $arrTemplate)) {
                        throw new \Cx\Lib\Update_DatabaseException("Failed to store Mailtemplate");
                    }
                }
            }
            // Drop old Mail tables after successful migration
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail_content');
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail');
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:ShopMail.class.php


注:本文中的Text::deleteByKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。