本文整理汇总了PHP中rex::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP rex::getTable方法的具体用法?PHP rex::getTable怎么用?PHP rex::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex
的用法示例。
在下文中一共展示了rex::getTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (!rex::getUser()->isAdmin()) {
throw new rex_api_exception('user has no permission for this operation!');
}
$type = rex_get('type', 'string');
switch ($type) {
case 'articles':
$prefix = 'art\\_%';
$defaultFields = [['translate:online_from', 'art_online_from', '1', '', '10', ''], ['translate:online_to', 'art_online_to', '2', '', '10', ''], ['translate:description', 'art_description', '3', '', '2', '']];
break;
case 'media':
$prefix = 'med\\_%';
$defaultFields = [['translate:pool_file_description', 'med_description', '1', '', '2', ''], ['translate:pool_file_copyright', 'med_copyright', '2', '', '1', '']];
break;
default:
throw new rex_api_exception(sprintf('metainfo type "%s" does not have default field.', $type));
}
$existing = rex_sql::factory()->getArray('SELECT name FROM ' . rex::getTable('metainfo_field') . ' WHERE name LIKE ?', [$prefix]);
$existing = array_column($existing, 'name', 'name');
foreach ($defaultFields as $field) {
if (!isset($existing[$field[1]])) {
$return = call_user_func_array('rex_metainfo_add_field', $field);
if (is_string($return)) {
throw new rex_api_exception($return);
}
}
}
return new rex_api_result(true, rex_i18n::msg('minfo_default_fields_created'));
}
示例2: checkTables
private static function checkTables()
{
$slices_table = rex_sql_table::get(rex::getTable('article_slice'));
$history_table = rex_sql_table::get(self::getTable());
foreach ($slices_table->getColumns() as $column) {
if (strtolower($column->getName()) != 'id') {
$history_table->ensureColumn($column)->alter();
}
}
}
示例3: exec
public function exec($type)
{
if (!in_array($type, [self::PREVIEW, self::PRESAVE, self::POSTSAVE])) {
throw new InvalidArgumentException('$type musst be rex_article_action::PREVIEW, ::PRESAVE or ::POSTSAVE');
}
$this->messages = [];
$this->save = true;
$ga = rex_sql::factory();
$ga->setQuery('SELECT a.id, `' . $type . '` as code FROM ' . rex::getTable('module_action') . ' ma,' . rex::getTable('action') . ' a WHERE `' . $type . '` != "" AND ma.action_id=a.id AND module_id=? AND (a.' . $type . 'mode & ?)', [$this->moduleId, $this->mode]);
foreach ($ga as $row) {
$action = $row->getValue('code');
$action = str_replace($this->vars['search'], $this->vars['replace'], $action);
$action = rex_var::parse($action, rex_var::ENV_BACKEND | rex_var::ENV_INPUT, 'action', $this->sql);
require rex_stream::factory('action/' . $row->getValue('id') . '/' . $type, $action);
}
}
示例4: deleteCLang
/**
* Löscht eine Clang.
*
* @param int $id Zu löschende ClangId
*
* @throws rex_exception
*/
public static function deleteCLang($id)
{
$startClang = rex_clang::getStartId();
if ($id == $startClang) {
throw new rex_functional_exception(rex_i18n::msg('clang_error_startidcanotbedeleted', $startClang));
}
if (!rex_clang::exists($id)) {
throw new rex_functional_exception(rex_i18n::msg('clang_error_idcanotbedeleted', $id));
}
$clang = rex_clang::get($id);
$del = rex_sql::factory();
$del->setQuery('delete from ' . rex::getTablePrefix() . 'clang where id=?', [$id]);
rex_sql_util::organizePriorities(rex::getTable('clang'), 'priority', '', 'priority');
rex_delete_cache();
// ----- EXTENSION POINT
rex_extension::registerPoint(new rex_extension_point('CLANG_DELETED', '', ['id' => $clang->getId(), 'name' => $clang->getName(), 'clang' => $clang]));
}
示例5: rex_fragment
$n = [];
$n['label'] = rex_i18n::msg('backup_export_select');
$n['field'] = $radios;
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');
$tableSelect = new rex_select();
$tableSelect->setMultiple();
$tableSelect->setId('rex-form-exporttables');
$tableSelect->setName('EXPTABLES[]');
$tableSelect->setAttribute('class', 'form-control');
$tables = rex_sql::showTables();
foreach ($tables as $table) {
$tableSelect->addOption($table, $table);
if ($table != rex::getTable('user') && 0 === strpos($table, rex::getTablePrefix()) && 0 !== strpos($table, rex::getTablePrefix() . rex::getTempPrefix())) {
$tableSelect->setSelected($table);
}
}
$formElements = [];
$n = [];
$n['header'] = '<div id="rex-js-exporttype-sql-div">';
$n['label'] = '<label for="rex-form-exporttables">' . rex_i18n::msg('backup_export_select_tables') . '</label>';
$n['field'] = $tableSelect->get();
$n['footer'] = '</div>';
$formElements[] = $n;
// Vorhandene Exporte auslesen
$sel_dirs = new rex_select();
$sel_dirs->setId('rex-form-exportdir');
$sel_dirs->setName('EXPDIR[]');
$sel_dirs->setMultiple();
示例6: addSlice
public static function addSlice()
{
$article_id = rex_request('article_id', 'int');
$function = rex_request('page', 'string');
$cut_slice_id = $slice_id = $_SESSION['slice_ui']['slice_id'];
$module_id = $_SESSION['slice_ui']['module_id'];
$clang = rex_get('clang');
$ctype = rex_get('ctype');
if (!self::checkPermissions(array('article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype, 'module_id' => $module_id))) {
// Alle OBs schließen
while (@ob_end_clean()) {
}
header("Location: " . rex_url::backendController() . '?article_id=' . $article_id . '&clang=' . $clang . '&page=content/edit&ctype=' . $ctype);
exit;
}
$slice_revision = 0;
$template_attributes = [];
$newsql = rex_sql::factory();
// $newsql->setDebug();
$sliceTable = rex::getTablePrefix() . 'article_slice';
$newsql->setTable($sliceTable);
if (strpos($function, 'content/paste') !== false && !empty($_SESSION['slice_ui'])) {
// determine priority value to get the new slice into the right order
$priority = '0';
// $prevSlice->setDebug();
if ($function === 'content/paste') {
$priority = 1;
} else {
$prevSlice = rex_sql::factory();
$prevSlice->setQuery('SELECT * FROM ' . $sliceTable . ' WHERE id=' . rex_get('slice_id'));
$priority = $prevSlice->getValue('priority') + 1;
}
$newsql->setValue('article_id', $article_id);
$newsql->setValue('module_id', $module_id);
$newsql->setValue('clang_id', $clang);
$newsql->setValue('ctype_id', $ctype);
$newsql->setValue('revision', $slice_revision);
$newsql->setValue('priority', $priority);
$newsql->addGlobalUpdateFields();
$newsql->addGlobalCreateFields();
try {
$newsql->insert();
$info = $action_message . rex_i18n::msg('block_added');
$slice_id = $newsql->getLastId();
if ($slice_id !== 0) {
$_SESSION['slice_ui']['slice_id'] = $slice_id;
}
rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $article_id . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
$function = '';
// ----- EXTENSION POINT
rex_extension::registerPoint(new rex_extension_point('SLICE_PASTED', '', ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
if ($_SESSION['slice_ui']['cut'] == 1) {
$curr = rex_sql::factory();
$curr->setDebug();
$curr->setTable($sliceTable);
$curr->setWhere(array('id' => $cut_slice_id));
$curr->delete();
rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $_SESSION['slice_ui']['article_id'] . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
}
} catch (rex_sql_exception $e) {
// echo rex_view::warning($e->getMessage());
}
// Alle OBs schließen
while (@ob_end_clean()) {
}
header("Location: " . rex_url::backendController() . '?article_id=' . $article_id . '&clang=' . $clang . '&page=content/edit&ctype=' . $ctype);
exit;
}
}
示例7:
<?php
/**
* YREWRITE Addon.
*
* @author jan.kristinus@yakamara.de
*
* @package redaxo\yrewrite
*
* @var rex_addon $this
*/
rex_sql_table::get(rex::getTable('article'))->removeColumn('yrewrite_url')->removeColumn('yrewrite_priority')->removeColumn('yrewrite_changefreq')->removeColumn('yrewrite_title')->removeColumn('yrewrite_description')->removeColumn('yrewrite_index')->alter();
$sql = rex_sql::factory();
$sql->setQuery(sprintf('DROP TABLE IF EXISTS `%s`;', rex::getTable('yrewrite_domain')));
$sql->setQuery(sprintf('DROP TABLE IF EXISTS `%s`;', rex::getTable('yrewrite_forward')));
rex_delete_cache();
示例8: rex_sql_column
*/
rex_sql_table::get(rex::getTable('article'))->ensureColumn(new rex_sql_column('yrewrite_url', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_canonical_url', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_priority', 'varchar(5)'))->ensureColumn(new rex_sql_column('yrewrite_changefreq', 'varchar(10)'))->ensureColumn(new rex_sql_column('yrewrite_title', 'varchar(255)'))->ensureColumn(new rex_sql_column('yrewrite_description', 'text'))->ensureColumn(new rex_sql_column('yrewrite_index', 'tinyint(1)'))->alter();
$sql = rex_sql::factory();
$sql->setQuery('CREATE TABLE IF NOT EXISTS `' . rex::getTable('yrewrite_domain') . '` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(255) NOT NULL,
`mount_id` int(11) NOT NULL,
`start_id` int(11) NOT NULL,
`notfound_id` int(11) NOT NULL,
`alias_domain` varchar(255) NOT NULL,
`clangs` varchar(255) NOT NULL,
`clang_start` int(11) NOT NULL,
`robots` TEXT NOT NULL,
`title_scheme` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
$sql->setQuery('CREATE TABLE IF NOT EXISTS `' . rex::getTable('yrewrite_forward') . '` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(255) NOT NULL,
`status` int(11) NOT NULL,
`url` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`article_id` int(11) NOT NULL,
`clang` int(11) NOT NULL,
`extern` varchar(255) NOT NULL,
`media` varchar(255) NOT NULL,
`movetype` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
rex_delete_cache();
示例9: rex_mediapool_deleteMedia
/**
* @param string $filename
*
* @return bool
*/
function rex_mediapool_deleteMedia($filename)
{
if ($uses = rex_mediapool_mediaIsInUse($filename)) {
$msg = '<strong>' . rex_i18n::msg('pool_file_delete_error_1', $filename) . ' ' . rex_i18n::msg('pool_file_delete_error_2') . '</strong><br />' . $uses;
return ['ok' => false, 'msg' => $msg];
}
$sql = rex_sql::factory();
$sql->setQuery('DELETE FROM ' . rex::getTable('media') . ' WHERE filename = ? LIMIT 1', [$filename]);
rex_file::delete(rex_path::media($filename));
rex_media_cache::delete($filename);
rex_extension::registerPoint(new rex_extension_point('MEDIA_DELETED', '', ['filename' => $filename]));
return ['ok' => true, 'msg' => rex_i18n::msg('pool_file_deleted')];
}
示例10: define
<?php
/**
* Cronjob Addon.
*
* @author gharlan[at]web[dot]de Gregor Harlan
*
* @package redaxo5
*
* @var rex_addon $this
*/
define('REX_CRONJOB_LOG_FOLDER', $this->getDataPath());
define('REX_CRONJOB_TABLE', rex::getTable('cronjob'));
rex_extension::register('PACKAGES_INCLUDED', function () {
foreach ($this->getAvailablePlugins() as $plugin) {
if (($type = $plugin->getProperty('cronjob_type')) != '') {
rex_cronjob_manager::registerType($type);
}
}
});
$nexttime = $this->getConfig('nexttime', 0);
if ($nexttime != 0 && time() >= $nexttime) {
$EP = rex::isBackend() ? 'PAGE_CHECKED' : 'PACKAGES_INCLUDED';
rex_extension::register($EP, function () {
if (!rex::isBackend() || !in_array(rex_be_controller::getCurrentPagePart(1), ['setup', 'login', 'cronjob'])) {
rex_cronjob_manager_sql::factory()->check();
}
});
}
示例11: newCatPrio
/**
* Berechnet die Prios der Kategorien in einer Kategorie neu.
*
* @param int $parent_id KategorieId der Kategorie, die erneuert werden soll
* @param int $clang ClangId der Kategorie, die erneuert werden soll
* @param int $new_prio Neue PrioNr der Kategorie
* @param int $old_prio Alte PrioNr der Kategorie
*/
public static function newCatPrio($parent_id, $clang, $new_prio, $old_prio)
{
if ($new_prio != $old_prio) {
if ($new_prio < $old_prio) {
$addsql = 'desc';
} else {
$addsql = 'asc';
}
rex_sql_util::organizePriorities(rex::getTable('article'), 'catpriority', 'clang_id=' . $clang . ' AND parent_id=' . $parent_id . ' AND startarticle=1', 'catpriority,updatedate ' . $addsql);
rex_article_cache::deleteLists($parent_id);
}
}
示例12: getMissingWildcards
public static function getMissingWildcards()
{
$wildcards = [];
if (\rex_addon::get('structure')->isAvailable() && \rex_plugin::get('structure', 'content')->isAvailable()) {
$sql = \rex_sql::factory();
// Slices der Artikel durchsuchen
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$fields = ['s.value' => range('1', '20')];
$searchFields = [];
$selectFields = [];
foreach ($fields as $field => $numbers) {
$concatFields = [];
foreach ($numbers as $number) {
$concatFields[] = $field . $number;
$searchFields[] = $field . $number . ' RLIKE ' . $sql->escape(preg_quote(trim(self::getOpenTag())) . '.*' . preg_quote(trim(self::getCloseTag())));
}
$selectFields[] = 'CONCAT_WS("|", ' . implode(',', $concatFields) . ') AS subject';
}
$fields = $searchFields;
$sql_query = ' SELECT s.article_id AS id,
s.clang_id,
s.ctype_id,
' . implode(', ', $selectFields) . '
FROM ' . \rex::getTable('article_slice') . ' AS s
LEFT JOIN
' . \rex::getTable('article') . ' AS a
ON (s.article_id = a.id AND s.clang_id = a.clang_id)
WHERE ' . implode(' OR ', $fields) . '
';
$sql->setDebug(false);
$sql->setQuery($sql_query);
if ($sql->getRows() >= 1) {
$items = $sql->getArray();
foreach ($items as $item) {
preg_match_all(self::getRegexp(), $item['subject'], $matchesSubject, PREG_SET_ORDER);
foreach ($matchesSubject as $match) {
$wildcards[$match[0]]['wildcard'] = str_replace([self::getOpenTag(), self::getCloseTag()], '', $match[0]);
$wildcards[$match[0]]['url'] = \rex_url::backendController(['page' => 'content/edit', 'article_id' => $item['id'], 'mode' => 'edit', 'clang' => $item['clang_id'], 'ctype' => $item['ctype_id']]);
}
}
}
// Alle bereits angelegten Platzhalter entfernen
if (count($wildcards)) {
$sql = \rex_sql::factory();
$sql_query = '
SELECT CONCAT("' . self::getOpenTag() . '", wildcard, "' . self::getCloseTag() . '") AS wildcard
FROM ' . \rex::getTable('sprog_wildcard') . '
WHERE clang_id = "' . \rex_clang::getStartId() . '"';
$sql->setDebug(false);
$sql->setQuery($sql_query);
if ($sql->getRows() >= 1) {
$items = $sql->getArray();
foreach ($items as $item) {
if (isset($wildcards[$item['wildcard']])) {
unset($wildcards[$item['wildcard']]);
}
}
}
}
return $wildcards;
}
return false;
}
示例13: rex_extension_point
if ($function == 'edit') {
$newsql->addGlobalUpdateFields();
try {
$newsql->update();
$info = $action_message . rex_i18n::msg('block_updated');
// ----- EXTENSION POINT
$info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_UPDATED', $info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
} catch (rex_sql_exception $e) {
$warning = $action_message . $e->getMessage();
}
} elseif ($function == 'add') {
$newsql->addGlobalUpdateFields();
$newsql->addGlobalCreateFields();
try {
$newsql->insert();
rex_sql_util::organizePriorities(rex::getTable('article_slice'), 'priority', 'article_id=' . $article_id . ' AND clang_id=' . $clang . ' AND ctype_id=' . $ctype . ' AND revision=' . $slice_revision, 'priority, updatedate DESC');
$info = $action_message . rex_i18n::msg('block_added');
$slice_id = $newsql->getLastId();
$function = '';
// ----- EXTENSION POINT
$info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_ADDED', $info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
} catch (rex_sql_exception $e) {
$warning = $action_message . $e->getMessage();
}
}
} else {
// make delete
if (rex_content_service::deleteSlice($slice_id)) {
$global_info = rex_i18n::msg('block_deleted');
// ----- EXTENSION POINT
$global_info = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SLICE_DELETED', $global_info, ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'module_id' => $module_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
示例14: rex_sql_column
<?php
if (rex_string::versionCompare(rex::getVersion(), '5.1.0-beta1', '<')) {
rex_sql_table::get(rex::getTable('user'))->ensureColumn(new rex_sql_column('email', 'varchar(255)', true))->ensureColumn(new rex_sql_column('lastlogin', 'datetime', true))->alter();
rex_sql_table::get(rex::getTable('clang'))->ensureColumn(new rex_sql_column('status', 'tinyint(1)'))->alter();
rex_sql::factory()->setQuery('UPDATE ' . rex::getTable('clang') . ' SET `status` = 1');
}
if (PHP_VERSION_ID < 50509) {
throw new rex_functional_exception(rex_i18n::msg('setup_301', PHP_VERSION, '5.5.9'));
}
示例15: checkLogin
public function checkLogin()
{
$sql = rex_sql::factory();
$userId = $this->getSessionVar('UID');
$cookiename = 'rex_user_' . sha1(rex::getProperty('instname'));
if ($cookiekey = rex_cookie($cookiename, 'string')) {
if (!$userId) {
$sql->setQuery('SELECT id FROM ' . rex::getTable('user') . ' WHERE cookiekey = ? LIMIT 1', [$cookiekey]);
if ($sql->getRows() == 1) {
$this->setSessionVar('UID', $sql->getValue('id'));
setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
} else {
setcookie($cookiename, '', time() - 3600);
}
}
$this->setSessionVar('STAMP', time());
}
$check = parent::checkLogin();
if ($check) {
// gelungenen versuch speichern | login_tries = 0
if ($this->userLogin != '' || !$userId) {
$this->regenerateSessionId();
$params = [];
$add = '';
if ($this->stayLoggedIn || $cookiekey) {
$cookiekey = sha1($this->systemId . time() . $this->userLogin);
$add = 'cookiekey = ?, ';
$params[] = $cookiekey;
setcookie($cookiename, $cookiekey, time() + 60 * 60 * 24 * 365);
}
if (self::passwordNeedsRehash($this->user->getValue('password'))) {
$add .= 'password = ?, ';
$params[] = self::passwordHash($this->userPassword, true);
}
array_push($params, rex_sql::datetime(), session_id(), $this->userLogin);
$sql->setQuery('UPDATE ' . $this->tableName . ' SET ' . $add . 'login_tries=0, lasttrydate=?, session_id=? WHERE login=? LIMIT 1', $params);
}
$this->user = new rex_user($this->user);
} else {
// fehlversuch speichern | login_tries++
if ($this->userLogin != '') {
$sql->setQuery('SELECT login_tries FROM ' . $this->tableName . ' WHERE login=? LIMIT 1', [$this->userLogin]);
if ($sql->getRows() > 0) {
$login_tries = $sql->getValue('login_tries');
$sql->setQuery('UPDATE ' . $this->tableName . ' SET login_tries=login_tries+1,session_id="",cookiekey="",lasttrydate=? WHERE login=? LIMIT 1', [rex_sql::datetime(), $this->userLogin]);
if ($login_tries >= self::LOGIN_TRIES_1 - 1) {
$time = $login_tries < self::LOGIN_TRIES_2 ? self::RELOGIN_DELAY_1 : self::RELOGIN_DELAY_2;
$hours = floor($time / 3600);
$mins = floor(($time - $hours * 3600) / 60);
$secs = $time % 60;
$formatted = ($hours ? $hours . 'h ' : '') . ($hours || $mins ? $mins . 'min ' : '') . $secs . 's';
$this->message .= ' ' . rex_i18n::msg('login_wait', '<strong data-time="' . $time . '">' . $formatted . '</strong>');
}
}
}
}
if ($this->isLoggedOut() && $userId != '') {
$sql->setQuery('UPDATE ' . $this->tableName . ' SET session_id="", cookiekey="" WHERE id=? LIMIT 1', [$userId]);
setcookie($cookiename, '', time() - 3600);
}
return $check;
}