本文整理汇总了PHP中Cx\Lib\UpdateUtil::table_empty方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdateUtil::table_empty方法的具体用法?PHP UpdateUtil::table_empty怎么用?PHP UpdateUtil::table_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Lib\UpdateUtil
的用法示例。
在下文中一共展示了UpdateUtil::table_empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertMailDemoData
/**
* insert demo data to mail tables
* @return bool|string
*/
protected function insertMailDemoData()
{
try {
if (\Cx\Lib\UpdateUtil::table_empty(CALENDAR_NEW_MAIL_TABLE)) {
\Cx\Lib\UpdateUtil::sql("\r\n INSERT IGNORE INTO `" . CALENDAR_NEW_MAIL_TABLE . "` (`id`, `title`, `content_text`, `content_html`, `recipients`, `lang_id`, `action_id`, `is_default`, `status`)\r\n VALUES\r\n (1, '[[URL]] - Einladung zu [[TITLE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]] \r\n\r\nSie wurden auf [[URL]] zum Event \"[[TITLE]]\" eingeladen.\r\nDetails: [[LINK_EVENT]]\r\n\r\nFolgen Sie dem unten stehenden Link um sich für diesen Event an- oder abzumelden.\r\nHinweis: Sollte der Link nicht funktionieren, kopieren Sie die komplette Adresse ohne Zeilenumbrüche in die Adresszeile Ihres Browsers und drücken Sie anschliessend \"Enter\".\r\n\r\n[[LINK_REGISTRATION]]\r\n\r\n\r\n--\r\nDiese Nachricht wurde automatisch generiert\r\n[[DATE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]]<br />\r\n<br />\r\nSie wurden auf <a href=\"http://[[URL]]\" title=\"[[URL]]\">[[URL]]</a> zum Event <a href=\"[[LINK_EVENT]]\" title=\"Event Details\">"[[TITLE]]"</a> eingeladen. <br />\r\nKlicken Sie <a href=\"[[LINK_REGISTRATION]]\" title=\"Anmeldung\">hier</a>, um sich an diesem Event an- oder abzumelden.<br />\r\n<br />\r\n<br />\r\n--<br />\r\n<em>Diese Nachricht wurde automatisch generiert</em><br />\r\n<em>[[DATE]]</em>', '', 1, 1, 1, 1),\r\n (15, '[[URL]] - Neue [[REGISTRATION_TYPE]] für [[TITLE]]', 'Hallo\r\n\r\nAuf [[URL]] wurde eine neue [[REGISTRATION_TYPE]] für den Termin \"[[TITLE]]\" eingetragen.\r\n\r\nInformationen zur [[REGISTRATION_TYPE]]\r\n[[REGISTRATION_DATA]]\r\n\r\n-- \r\nDiese Nachricht wurde automatisch generiert [[DATE]]', 'Hallo<br />\r\n<br />\r\nAuf [[URL]] wurde eine neue [[REGISTRATION_TYPE]] für den Termin "[[TITLE]]" eingetragen.<br />\r\n<br />\r\n<h2>Informationen zur [[REGISTRATION_TYPE]]</h2>\r\n[[REGISTRATION_DATA]] <br />\r\n<br />\r\n-- <br />\r\nDiese Nachricht wurde automatisch generiert [[DATE]]', '', 1, 3, 1, 1),\r\n (14, '[[URL]] - Erfolgreiche [[REGISTRATION_TYPE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]]\r\n\r\nIhre [[REGISTRATION_TYPE]] zum Event \"[[TITLE]]\" vom [[START_DATE]] wurde erfolgreich in unserem System eingetragen.\r\n\r\n\r\n--\r\nDiese Nachricht wurde automatisch generiert\r\n[[DATE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]]<br />\r\n<br />\r\nIhre [[REGISTRATION_TYPE]] zum Event <a title=\"[[TITLE]]\" href=\"[[LINK_EVENT]]\">[[TITLE]]</a> vom [[START_DATE]] wurde erfolgreich in unserem System eingetragen.<br />\r\n<br />\r\n--<br />\r\n<em>Diese Nachricht wurde automatisch generiert<br />\r\n[[DATE]]</em>', '', 1, 2, 1, 1),\r\n (16, '[[URL]] - Neuer Termin: [[TITLE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]] \r\n\r\nUnter [[URL]] finden Sie den neuen Event \"[[TITLE]]\".\r\nDetails: [[LINK_EVENT]]\r\n\r\n\r\n--\r\nDiese Nachricht wurde automatisch generiert\r\n[[DATE]]', 'Hallo [[FIRSTNAME]] [[LASTNAME]]<br />\r\n<br />\r\nUnter <a title=\"[[URL]]\" href=\"http://[[URL]]\">[[URL]]</a> finden Sie den neuen Event <a title=\"Event Details\" href=\"[[LINK_EVENT]]\">"[[TITLE]]"</a>. <br />\r\n<br />\r\n<br />\r\n--<br />\r\n<em>Diese Nachricht wurde automatisch generiert</em><br />\r\n<em>[[DATE]]</em>', '', 1, 4, 1, 1)\r\n ");
}
if (!checkMemoryLimit() || !checkTimeoutLimit()) {
return 'timeout';
}
if (\Cx\Lib\UpdateUtil::table_empty(CALENDAR_NEW_MAIL_ACTION_TABLE)) {
\Cx\Lib\UpdateUtil::sql("\r\n INSERT IGNORE INTO `" . CALENDAR_NEW_MAIL_ACTION_TABLE . "`\r\n VALUES\r\n (1, 'invitationTemplate', 'empty', 0),\r\n (2, 'confirmationRegistration', 'author', 0),\r\n (3, 'notificationRegistration', 'empty', 0),\r\n (4, 'notificationNewEntryFE', 'admin', 0)\r\n ");
}
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例2: 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;
}
示例3: 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;
}
示例4: str_replace
<label>[[TXT_FILESHARING_FILE_NAME]]</label>[[FILESHARING_FILE_NAME]]
</p>
<p>
<input name="delete" type="submit" value="[[TXT_FILESHARING_CONFIRM_DELETE]]" />
</p>
</form>
<!-- END confirm_delete -->
HTMLCODE;
if (!preg_match('/<!--\\s+BEGIN\\s+confirm_delete\\s+-->.*<!--\\s+END\\s+confirm_delete\\s+-->/ms', $matches[0])) {
return str_replace('<!-- END upload_form -->', $newHtmlCode, $matches[0]);
} else {
return $matches[0];
}
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'filesharing', 'cmd' => ''), $search, $callback, array('content'), '3.1.0');
if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0') && (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_news_categories_catid') || \Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'module_news_categories_catid'))) {
try {
/************************************************
* EXTENSION: Categories as NestedSet *
* ADDED: Contrexx v3.1.0 *
************************************************/
$nestedSetRootId = null;
$count = null;
$leftAndRight = 2;
$sorting = 1;
$level = 2;
// add nested set columns
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories', array('catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(11)', 'after' => 'catid'), 'left_id' => array('type' => 'INT(11)', 'after' => 'parent_id'), 'right_id' => array('type' => 'INT(11)', 'after' => 'left_id'), 'sorting' => array('type' => 'INT(11)', 'after' => 'right_id'), 'level' => array('type' => 'INT(11)', 'after' => 'sorting')));
// add nested set root node and select its id
$objResultRoot = \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories` (`catid`, `parent_id`, `left_id`, `right_id`, `sorting`, `level`) VALUES (0, 0, 0, 0, 0, 0)');
if ($objResultRoot) {
示例5: 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');
//.........这里部分代码省略.........