コード例 #1
0
ファイル: package.php プロジェクト: staabm/redaxo
 /**
  * Returns if the package exists.
  *
  * @param string $packageId Package ID
  *
  * @return bool
  */
 public static function exists($packageId)
 {
     $package = explode('/', $packageId);
     if (isset($package[1])) {
         return rex_plugin::exists($package[0], $package[1]);
     }
     return rex_addon::exists($package[0]);
 }
コード例 #2
0
ファイル: cronjob.php プロジェクト: skerbis/redaxo
 public function execute()
 {
     $config = rex_plugin::get('cronjob', 'article_status')->getProperty('config');
     $from = $config['from'];
     $to = $config['to'];
     $from['before'] = (array) $from['before'];
     $to['before'] = (array) $to['before'];
     $sql = rex_sql::factory();
     // $sql->setDebug();
     $sql->setQuery('
         SELECT  name
         FROM    ' . rex::getTablePrefix() . 'metainfo_field
         WHERE   name="' . $from['field'] . '" OR name="' . $to['field'] . '"
     ');
     $rows = $sql->getRows();
     if ($rows < 2) {
         if ($rows == 0) {
             $msg = 'Metainfo fields "' . $from['field'] . '" and "' . $to['field'] . '" not found';
         } else {
             $field = $sql->getValue('name') == $from['field'] ? $to['field'] : $from['field'];
             $msg = 'Metainfo field "' . $field . '" not found';
         }
         $this->setMessage($msg);
         return false;
     }
     $time = time();
     $sql->setQuery('
         SELECT  id, clang_id, status
         FROM    ' . rex::getTablePrefix() . 'article
         WHERE
             (     ' . $from['field'] . ' > 0
             AND   ' . $from['field'] . ' < ' . $time . '
             AND   status IN (' . implode(',', $from['before']) . ')
             AND   (' . $to['field'] . ' > ' . $time . ' OR ' . $to['field'] . ' = 0 OR ' . $to['field'] . ' = "")
             )
         OR
             (     ' . $to['field'] . ' > 0
             AND   ' . $to['field'] . ' < ' . $time . '
             AND   status IN (' . implode(',', $to['before']) . ')
             )
     ');
     $rows = $sql->getRows();
     include_once rex_path::addon('structure', 'functions/function_rex_structure.php');
     for ($i = 0; $i < $rows; ++$i) {
         if (in_array($sql->getValue('status'), $from['before'])) {
             $status = $from['after'];
         } else {
             $status = $to['after'];
         }
         rex_article_service::articleStatus($sql->getValue('id'), $sql->getValue('clang_id'), $status);
         $sql->next();
     }
     $this->setMessage('Updated articles: ' . $rows);
     return true;
 }
コード例 #3
0
ファイル: boot.php プロジェクト: DECAF/redaxo
 *
 * @author Design
 * @author ralph.zumkeller[at]yakamara[dot]de Ralph Zumkeller
 * @author <a href="http://www.yakamara.de">www.yakamara.de</a>
 * @author Umsetzung
 * @author thomas[dot]blum[at]redaxo[dot]org Thomas Blum
 *
 * @package redaxo5
 *
 * @var rex_plugin $this
 */
$mypage = 'redaxo';
if (rex::isBackend()) {
    rex_extension::register('BE_STYLE_SCSS_FILES', function (rex_extension_point $ep) use($mypage) {
        $subject = $ep->getSubject();
        $file = rex_plugin::get('be_style', $mypage)->getPath('scss/default.scss');
        array_unshift($subject, $file);
        return $subject;
    }, rex_extension::EARLY);
    if (rex::getUser() && $this->getProperty('compile')) {
        rex_addon::get('be_style')->setProperty('compile', true);
        rex_extension::register('PACKAGES_INCLUDED', function () {
            $compiler = new rex_scss_compiler();
            $compiler->setRootDir($this->getPath('scss/'));
            $compiler->setScssFile($this->getPath('scss/master.scss'));
            // Compile in backend assets dir
            $compiler->setCssFile($this->getPath('assets/css/styles.css'));
            $compiler->compile();
            // Compiled file to copy in frontend assets dir
            rex_file::copy($this->getPath('assets/css/styles.css'), $this->getAssetsPath('css/styles.css'));
        });
コード例 #4
0
ファイル: manager.php プロジェクト: DECAF/redaxo
 /**
  * Synchronizes the packages with the file system.
  */
 public static function synchronizeWithFileSystem()
 {
     $config = rex::getConfig('package-config');
     $addons = self::readPackageFolder(rex_path::src('addons'));
     $registeredAddons = array_keys(rex_addon::getRegisteredAddons());
     foreach (array_diff($registeredAddons, $addons) as $addonName) {
         $manager = rex_addon_manager::factory(rex_addon::get($addonName));
         $manager->_delete(true);
         unset($config[$addonName]);
     }
     foreach ($addons as $addonName) {
         if (!rex_addon::exists($addonName)) {
             $config[$addonName]['install'] = false;
             $config[$addonName]['status'] = false;
             $registeredPlugins = [];
         } else {
             $addon = rex_addon::get($addonName);
             $config[$addonName]['install'] = $addon->isInstalled();
             $config[$addonName]['status'] = $addon->isAvailable();
             $registeredPlugins = array_keys($addon->getRegisteredPlugins());
         }
         $plugins = self::readPackageFolder(rex_path::addon($addonName, 'plugins'));
         foreach (array_diff($registeredPlugins, $plugins) as $pluginName) {
             $manager = rex_plugin_manager::factory(rex_plugin::get($addonName, $pluginName));
             $manager->_delete(true);
             unset($config[$addonName]['plugins'][$pluginName]);
         }
         foreach ($plugins as $pluginName) {
             $plugin = rex_plugin::get($addonName, $pluginName);
             $config[$addonName]['plugins'][$pluginName]['install'] = $plugin->isInstalled();
             $config[$addonName]['plugins'][$pluginName]['status'] = $plugin->getProperty('status');
         }
         if (isset($config[$addonName]['plugins']) && is_array($config[$addonName]['plugins'])) {
             ksort($config[$addonName]['plugins']);
         }
     }
     ksort($config);
     rex::setConfig('package-config', $config);
     rex_addon::initialize();
 }
コード例 #5
0
ファイル: service_category.php プロジェクト: DECAF/redaxo
 /**
  * Erstellt eine neue Kategorie.
  *
  * @param int   $category_id KategorieId in der die neue Kategorie erstellt werden soll
  * @param array $data        Array mit den Daten der Kategorie
  *
  * @throws rex_api_exception
  *
  * @return string Eine Statusmeldung
  */
 public static function addCategory($category_id, array $data)
 {
     $message = '';
     if (!is_array($data)) {
         throw new rex_api_exception('Expecting $data to be an array!');
     }
     self::reqKey($data, 'catpriority');
     self::reqKey($data, 'catname');
     // parent may be null, when adding in the root cat
     $parent = rex_category::get($category_id);
     if ($parent) {
         $path = $parent->getPath();
         $path .= $parent->getId() . '|';
     } else {
         $path = '|';
     }
     if ($data['catpriority'] <= 0) {
         $data['catpriority'] = 1;
     }
     if (!isset($data['name'])) {
         $data['name'] = $data['catname'];
     }
     if (!isset($data['status'])) {
         $data['status'] = 0;
     }
     $contentAvailable = rex_plugin::get('structure', 'content')->isAvailable();
     if ($contentAvailable) {
         $startpageTemplates = [];
         if ($category_id != '') {
             // TemplateId vom Startartikel der jeweiligen Sprache vererben
             $sql = rex_sql::factory();
             // $sql->setDebug();
             $sql->setQuery('select clang_id,template_id from ' . rex::getTablePrefix() . "article where id={$category_id} and startarticle=1");
             for ($i = 0; $i < $sql->getRows(); $i++, $sql->next()) {
                 $startpageTemplates[$sql->getValue('clang_id')] = $sql->getValue('template_id');
             }
         }
         // Alle Templates der Kategorie
         $templates = rex_template::getTemplatesForCategory($category_id);
     }
     $user = rex::isBackend() ? null : 'frontend';
     // Kategorie in allen Sprachen anlegen
     $AART = rex_sql::factory();
     foreach (rex_clang::getAllIds() as $key) {
         if ($contentAvailable) {
             $template_id = rex_template::getDefaultId();
             if (isset($startpageTemplates[$key]) && $startpageTemplates[$key] != '') {
                 $template_id = $startpageTemplates[$key];
             }
             // Wenn Template nicht vorhanden, dann entweder erlaubtes nehmen
             // oder leer setzen.
             if (!isset($templates[$template_id])) {
                 $template_id = 0;
                 if (count($templates) > 0) {
                     $template_id = key($templates);
                 }
             }
         }
         $AART->setTable(rex::getTablePrefix() . 'article');
         if (!isset($id)) {
             $id = $AART->setNewId('id');
         } else {
             $AART->setValue('id', $id);
         }
         $AART->setValue('clang_id', $key);
         $AART->setValue('template_id', $template_id);
         $AART->setValue('name', $data['name']);
         $AART->setValue('catname', $data['catname']);
         $AART->setValue('catpriority', $data['catpriority']);
         $AART->setValue('parent_id', $category_id);
         $AART->setValue('priority', 1);
         $AART->setValue('path', $path);
         $AART->setValue('startarticle', 1);
         $AART->setValue('status', $data['status']);
         $AART->addGlobalUpdateFields($user);
         $AART->addGlobalCreateFields($user);
         try {
             $AART->insert();
             // ----- PRIOR
             if (isset($data['catpriority'])) {
                 self::newCatPrio($category_id, $key, 0, $data['catpriority']);
             }
             $message = rex_i18n::msg('category_added_and_startarticle_created');
             rex_article_cache::delete($id, $key);
             // ----- EXTENSION POINT
             // Objekte clonen, damit diese nicht von der extension veraendert werden koennen
             $message = rex_extension::registerPoint(new rex_extension_point('CAT_ADDED', $message, ['category' => clone $AART, 'id' => $id, 'parent_id' => $category_id, 'clang' => $key, 'name' => $data['catname'], 'priority' => $data['catpriority'], 'path' => $path, 'status' => $data['status'], 'article' => clone $AART, 'data' => $data]));
         } catch (rex_sql_exception $e) {
             throw new rex_api_exception($e);
         }
     }
     return $message;
 }
コード例 #6
0
ファイル: Wildcard.php プロジェクト: VIEWSION/redaxo_sprog
 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;
 }
コード例 #7
0
ファイル: boot.php プロジェクト: eaCe/slice_ui
if (rex::isBackend() && is_object(rex::getUser())) {
    rex_perm::register('copy[]');
    rex_perm::register('slice_ui[]', null, rex_perm::OPTIONS);
    rex_perm::register('slice_ui[settings]', null, rex_perm::OPTIONS);
}
if (strpos(rex_request('page'), 'content/emptyclipboard') !== false) {
    slice_ui::emptyClipboard();
}
rex_view::addCssFile($this->getAssetsUrl('slice_ui.css'));
if (strpos(rex_request('page'), 'content/paste') !== false) {
    slice_ui::addSlice();
}
if (strpos(rex_request('page'), 'content/toggleSlice') !== false) {
    slice_ui::toggleSlice();
}
if (is_object(rex::getUser()) && (!rex::getUser()->hasPerm('editContentOnly[]') && rex::getUser()->hasPerm('slice_ui[]') || rex::getUser()->isAdmin())) {
    rex_extension::register('ART_SLICE_MENU', 'slice_ui::modifySliceEditMenu');
}
if (is_object(rex::getUser()) && (rex_request('page', 'string') === 'content/copy' || rex_request('page', 'string') === 'content/cut')) {
    slice_ui::copySlice();
}
rex_extension::register('SLICE_SHOW', 'slice_ui::isActive');
/* Slice-Menü überschreiben */
if (!empty($_SESSION['slice_ui'])) {
    $Content = rex_plugin::get('structure', 'content');
    $ContentPages = $Content->getProperty('pages');
    $ContentPages['content']['subpages']['paste'] = array('title' => 'Einfügen', 'icon' => 'rex-icon rex-icon-paste');
    $ContentPages['content']['subpages']['emptyclipboard'] = array('title' => 'Clipboard löschen', 'icon' => 'rex-icon rex-icon-emptyclipboard');
    $Content->setProperty('pages', $ContentPages);
}
コード例 #8
0
ファイル: index.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'wartungsarbeiten');
$content = '';
if (rex_post('config-submit', 'boolean')) {
    $plugin->setConfig(rex_post('config', [['url', 'string']]));
    $content .= rex_view::info('Änderung gespeichert');
}
$content .= '
<div class="rex-form">
    <form action="' . rex_url::currentBackendPage() . '" method="post">
        <fieldset>';
$formElements = [];
$n = [];
$n['label'] = '<label for="rex-out5-wartungsarbeiten-url">URL</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-out5-wartungsarbeiten-url" name="config[url]" value="' . $plugin->getConfig('url') . '"/>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');
$content .= '
        </fieldset>

        <fieldset class="rex-form-action">';
$formElements = [];
$n = [];
$n['field'] = '<div class="btn-toolbar"><button id="rex-out5-wartungsarbeiten-save" type="submit" name="config-submit" class="btn btn-save rex-form-aligned" value="1">Einstellungen speichern</button></div>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/submit.php');
コード例 #9
0
ファイル: index.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'border');
$content = '';
if (rex_post('config-submit', 'boolean')) {
    $plugin->setConfig(rex_post('config', [['text', 'string'], ['farbe', 'string']]));
    $content .= rex_view::info('Änderung gespeichert');
}
$content .= '
<div class="rex-form">
    <form action="' . rex_url::currentBackendPage() . '" method="post">
        <fieldset>';
$formElements = [];
$n = [];
$n['label'] = '<label for="rex-out5-border-text">Text</label>';
$n['field'] = '<input class="form-control"  type="text" id="rex-out5-border-text" name="config[text]" value="' . $plugin->getConfig('text') . '"/>';
$formElements[] = $n;
$n['label'] = '<label for="rex-out5-border-farbe">Farbe</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-out5-border-farbe" name="config[farbe]" value="' . $plugin->getConfig('farbe') . '"/>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');
$content .= '
        </fieldset>

        <fieldset class="rex-form-action">';
$formElements = [];
$n = [];
$n['field'] = '<div class="btn-toolbar"><button id="rex-out5-border-save" type="submit" name="config-submit" class="btn btn-save rex-form-aligned" value="1">Einstellungen speichern</button></div>';
$formElements[] = $n;
コード例 #10
0
ファイル: index.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'min');
$content = "\n<p>combinied.min.css im Frontend einbinden</p>\n<pre>\n\$ str = file_get_contents('main.css');\n\$ str = \$ str.file_get_contents('navigation.css');\n\$ str = \$ str.file_get_contents('content.css');\n\$ str = \$ str.file_get_contents('media/default.css');\n\n\nfile_put_contents('./media/combinied.min.css', minify_css(\$ str));\n</pre>\n\n<br/>\n<p>combinied.min.js im Frontend einbinden</p>\n\n<pre>\n// if (!file_exists('./assets/js/combinied.js')) {\n\n\$ str = file_get_contents('./assets/vendor/jquery/domscript.js');\n\$ str = \$ str.file_get_contents('./assets/vendor/jquery/jquery.cookiebar.js');\nfile_put_contents('./assets/js/domscript.js', minify_js(\$ str));\n\n// }\n</pre>\n(\$ str ohne Leerzeichen)\n";
$fragment = new rex_fragment();
$fragment->setVar('class', 'edit');
$fragment->setVar('title', 'min');
$fragment->setVar('body', $content, false);
echo $fragment->parse('core/page/section.php');
コード例 #11
0
ファイル: install.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'structure_separators');
if (!$plugin->hasConfig()) {
    $plugin->setConfig('sepp', 'sepp: ');
    $plugin->setConfig('cssColor', '#283542');
    $plugin->setConfig('cssBackground', '#dfe3e9');
    $plugin->setConfig('status', 'deaktiviert');
}
コード例 #12
0
ファイル: system.customizer.php プロジェクト: staabm/redaxo
    } else {
        $error[] = rex_i18n::msg('customizer_labelcolor_error');
    }
    $tempConfig['showlink'] = 0;
    if (isset($newConfig['showlink']) && $newConfig['showlink'] == 1) {
        $tempConfig['showlink'] = 1;
    }
    // save config
    if (empty($error) && rex_plugin::get('be_style', 'customizer')->setConfig($tempConfig)) {
        $success = rex_i18n::msg('customizer_config_updated');
    } else {
        $error[] = rex_i18n::msg('customizer_config_update_failed');
    }
}
// load config
$config = rex_plugin::get('be_style', 'customizer')->getConfig();
// build elements
$themes = [];
foreach (glob($curDir . '/assets/vendor/codemirror/theme/*.css') as $filename) {
    $themes[] = substr(basename($filename), 0, -4);
}
$tselect = new rex_select();
$tselect->setId('customizer-codemirror_theme');
$tselect->setName('settings[codemirror_theme]');
$tselect->setSize(1);
$tselect->setAttribute('class', 'form-control');
$tselect->setSelected($config['codemirror_theme']);
foreach ($themes as $theme) {
    $tselect->addOption($theme, $theme);
}
// messages
コード例 #13
0
ファイル: uebersicht.php プロジェクト: FriendsOfREDAXO/out5
<?php

$func = rex_request('func', 'string');
$status = rex_request('status', 'string');
$plugin_status = rex_request('key', 'string');
if ($func == 'setstatus') {
    $plugin_temp = rex_plugin::get('out5', $plugin_status);
    if ($status == "aktivieren") {
        $plugin_temp->setConfig('status', 'aktiviert');
    } else {
        $plugin_temp->setConfig('status', 'deaktiviert');
    }
    $func = '';
    $status = '';
    $plugin = '';
}
if ($func == '') {
    $content = '
<section class="rex-page-section">
  <div class="panel panel-default">
  <header class="panel-heading"><div class="panel-title">Liste der verfügbaren Filter</div></header>
  <form action="index.php?page=out5/uebersicht" method="post">
    <table class="table">
      <thead>
        <tr>
          <th class="rex-table-icon"></th>
          <th>Name</th>
          <th>Kurzbeschreibung</th>
          <th>Umgebung</th>
          <th>Status</th>          
          <th></th>
コード例 #14
0
ファイル: install.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'login_image');
if (!$plugin->hasConfig()) {
    $plugin->setConfig('bild', 'out5_login_image.jpg');
    $plugin->setConfig('status', 'deaktiviert');
}
コード例 #15
0
ファイル: index.php プロジェクト: FriendsOfREDAXO/out5
<?php

$plugin = rex_plugin::get('out5', 'email_url');
$content = 'Nicht notwendig :-)';
$fragment = new rex_fragment();
$fragment->setVar('class', 'edit');
$fragment->setVar('title', 'E-Mail / externe Links');
$fragment->setVar('body', $content, false);
echo $fragment->parse('core/page/section.php');
コード例 #16
0
ファイル: boot.php プロジェクト: nilsology/slice_ui
<?php

rex_extension::register('BE_STYLE_LESS_FILES', function (rex_extension_point $ep) {
    $subject = $ep->getSubject();
    array_unshift($subject, rex_plugin::get('slice_ui', 'slice_json_block')->getPath('less/styles.less|sourceMap|compress'));
    return $subject;
}, rex_extension::EARLY);
if (!rex_plugin::exists('be_style', 'lessphp')) {
    rex_view::addCssFile($this->getPath() . 'less/styles.min.css');
}
rex_view::addJsFile($this->getAssetsUrl('slice_skin.js'));
コード例 #17
0
ファイル: service_article.php プロジェクト: staabm/redaxo
 /**
  * Bearbeitet einen Artikel.
  *
  * @param int   $article_id Id des Artikels der verändert werden soll
  * @param int   $clang      Id der Sprache
  * @param array $data       Array mit den Daten des Artikels
  *
  * @throws rex_api_exception
  *
  * @return string Eine Statusmeldung
  */
 public static function editArticle($article_id, $clang, $data)
 {
     if (!is_array($data)) {
         throw new rex_api_exception('Expecting $data to be an array!');
     }
     self::reqKey($data, 'name');
     // Artikel mit alten Daten selektieren
     $thisArt = rex_sql::factory();
     $thisArt->setQuery('select * from ' . rex::getTablePrefix() . 'article where id=' . $article_id . ' and clang_id=' . $clang);
     if ($thisArt->getRows() != 1) {
         throw new rex_api_exception('Unable to find article with id "' . $article_id . '" and clang "' . $clang . '"!');
     }
     $ooArt = rex_article::get($article_id, $clang);
     $data['category_id'] = $ooArt->getCategoryId();
     if (rex_plugin::get('structure', 'content')->isAvailable()) {
         $templates = rex_template::getTemplatesForCategory($data['category_id']);
         // Wenn Template nicht vorhanden, dann entweder erlaubtes nehmen
         // oder leer setzen.
         if (!isset($templates[$data['template_id']])) {
             $data['template_id'] = 0;
             if (count($templates) > 0) {
                 $data['template_id'] = key($templates);
             }
         }
     }
     if (isset($data['priority'])) {
         if ($data['priority'] <= 0) {
             $data['priority'] = 1;
         }
     }
     // complete remaining optional aprams
     foreach (['path', 'priority'] as $optionalData) {
         if (!isset($data[$optionalData])) {
             $data[$optionalData] = $thisArt->getValue($optionalData);
         }
     }
     $EA = rex_sql::factory();
     $EA->setTable(rex::getTablePrefix() . 'article');
     $EA->setWhere(['id' => $article_id, 'clang_id' => $clang]);
     $EA->setValue('name', $data['name']);
     $EA->setValue('template_id', $data['template_id']);
     $EA->setValue('priority', $data['priority']);
     $EA->addGlobalUpdateFields();
     try {
         $EA->update();
         $message = rex_i18n::msg('article_updated');
         // ----- PRIOR
         rex_sql::factory()->setTable(rex::getTable('article'))->setWhere('id = :id AND clang_id != :clang', ['id' => $article_id, 'clang' => $clang])->setValue('priority', $data['priority'])->addGlobalUpdateFields()->update();
         foreach (rex_clang::getAllIds() as $clangId) {
             self::newArtPrio($data['category_id'], $clangId, $data['priority'], $thisArt->getValue('priority'));
         }
         rex_article_cache::delete($article_id);
         // ----- EXTENSION POINT
         $message = rex_extension::registerPoint(new rex_extension_point('ART_UPDATED', $message, ['id' => $article_id, 'article' => clone $EA, 'article_old' => clone $thisArt, 'status' => $thisArt->getValue('status'), 'name' => $data['name'], 'clang' => $clang, 'parent_id' => $data['category_id'], 'priority' => $data['priority'], 'path' => $data['path'], 'template_id' => $data['template_id'], 'data' => $data]));
     } catch (rex_sql_exception $e) {
         throw new rex_api_exception($e);
     }
     return $message;
 }
コード例 #18
0
ファイル: manager.php プロジェクト: VIEWSION/redaxo_yform
 public function getDataPage()
 {
     rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_DATA_PAGE', $this));
     // ********************************************* DATA ADD/EDIT/LIST
     $func = rex_request('func', 'string', '');
     $data_id = rex_request('data_id', 'int', '');
     $show_list = true;
     // -------------- rex_yform_manager_filter and sets
     $rex_yform_filter = rex_request('rex_yform_filter', 'array');
     $rex_yform_set = rex_request('rex_yform_set', 'array');
     // -------------- opener - popup for selection
     $popup = false;
     $rex_yform_manager_opener = rex_request('rex_yform_manager_opener', 'array');
     if (count($rex_yform_manager_opener) > 0) {
         if (isset($rex_yform_manager_opener['id']) && $rex_yform_manager_opener['id'] != '') {
             $popup = true;
             // id, field, multiple
         }
     }
     // -------------- filter - popup for selection
     if (count($rex_yform_filter) > 0) {
         $popup = true;
     }
     if (is_bool($p = rex_request('popup', 'bool', null))) {
         $popup = $p;
         $this->setLinkVars(array('popup' => $p ? 1 : 0));
     }
     // SearchObject
     $searchObject = new rex_yform_manager_search($this->table);
     $searchObject->setLinkVars(array("list" => rex_request('list', 'string', '')));
     $searchObject->setLinkVars(array("start" => rex_request('start', 'string', '')));
     $searchObject->setLinkVars(array("sort" => rex_request('sort', 'string', '')));
     $searchObject->setLinkVars(array("sorttype" => rex_request('sorttype', 'string', '')));
     $searchObject->setLinkVars($this->getLinkVars());
     if (count($rex_yform_filter) > 0) {
         foreach ($rex_yform_filter as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k2 => $v2) {
                     $searchObject->setLinkVars(array('rex_yform_filter[' . $k . '][' . $k2 . ']' => $v2));
                 }
             } else {
                 $searchObject->setLinkVars(array('rex_yform_filter[' . $k . ']' => $v));
             }
         }
     }
     if (count($rex_yform_set) > 0) {
         foreach ($rex_yform_set as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k2 => $v2) {
                     $searchObject->setLinkVars(array('rex_yform_set[' . $k . '][' . $k2 . ']' => $v2));
                 }
             } else {
                 $searchObject->setLinkVars(array('rex_yform_set[' . $k . ']' => $v));
             }
         }
     }
     if (count($rex_yform_manager_opener) > 0) {
         foreach ($rex_yform_manager_opener as $k => $v) {
             $searchObject->setLinkVars(array('rex_yform_manager_opener[' . $k . ']' => $v));
         }
     }
     $searchform = '';
     if ($this->hasDataPageFunction('search')) {
         $searchform = '<div class="rex-addon-output">
                          <h3 class="rex-hl2">' . rex_i18n::msg('yform_manager_search') . '</h3>
                          <div class="rex-addon-content">
                         <div class="yform" id="rex-yform">' . $searchObject->getForm() . '</div>
                       </div>
                       </div>';
     }
     // -------------- DEFAULT - LISTE AUSGEBEN
     $link_vars = '';
     foreach ($this->getLinkVars() as $k => $v) {
         $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
     }
     echo rex_view::title(rex_i18n::msg('yform_table') . ': ' . rex_i18n::translate($this->table->getName()) . ' <small>[' . $this->table->getTablename() . ']</small>', '');
     echo rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_REX_INFO', ''));
     $show_editpage = true;
     $show_editpage = rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_DATA_EDIT_FUNC', $show_editpage, ['table' => $this->table, 'link_vars' => $this->getLinkVars()]));
     if ($show_editpage) {
         // -------------- DB FELDER HOLEN
         $field_names = array();
         foreach ($this->table->getValueFields() as $field) {
             $field_names[] = $field->getName();
         }
         // -------------- DB DATA HOLEN
         $data = array();
         if ($data_id != '') {
             $gd = rex_sql::factory();
             $gd->setQuery('select * from ' . $this->table->getTableName() . ' where id=' . $data_id);
             if ($gd->getRows() == 1) {
                 $datas = $gd->getArray();
                 $data = current($datas);
             } else {
                 $data_id = '';
             }
         }
         // -------------- Opener
         foreach ($rex_yform_manager_opener as $k => $v) {
             $link_vars .= '&rex_yform_manager_opener[' . $k . ']=' . urlencode($v);
         }
         // -------------- Searchfields / Searchtext
         $link_vars .= '&' . http_build_query($searchObject->getSearchVars());
         // -------------- FILTER UND SETS PR†FEN
         $em_url_filter = '';
         if (count($rex_yform_filter) > 0) {
             foreach ($rex_yform_filter as $k => $v) {
                 if (!in_array($k, $field_names)) {
                     unset($rex_yform_filter[$k]);
                 }
             }
             $em_url_filter .= '&' . http_build_query(compact('rex_yform_filter'));
         }
         $em_url_set = '';
         if (count($rex_yform_set) > 0) {
             foreach ($rex_yform_set as $k => $v) {
                 if (!in_array($k, $field_names)) {
                     unset($rex_yform_set[$k]);
                 }
             }
             $em_url_filter .= '&' . http_build_query(compact('rex_yform_set'));
         }
         $em_url = $em_url_filter . $em_url_set;
         $em_rex_list = '';
         $em_rex_list .= '&list=' . urlencode(rex_request('list', 'string'));
         $em_rex_list .= '&sort=' . urlencode(rex_request('sort', 'string'));
         $em_rex_list .= '&sorttype=' . urlencode(rex_request('sorttype', 'string'));
         $em_rex_list .= '&start=' . urlencode(rex_request('start', 'string'));
         // ---------- Popup - no menue, header ...
         if ($popup) {
             echo '<link rel="stylesheet" type="text/css" href="' . rex_plugin::get('yform', 'manager')->getAssetsUrl('popup.css') . '" />';
         }
         // -------------- Import
         if (!$popup && $func == 'import' && $this->hasDataPageFunction('import')) {
             include rex_path::plugin('yform', 'manager', 'pages/data_import.php');
             echo rex_view::info('<a href="index.php?' . $link_vars . $em_url . $em_rex_list . '"><b>&laquo; ' . rex_i18n::msg('yform_back_to_overview') . '</b></a>');
         }
         // -------------- delete entry
         if ($func == 'delete' && $data_id != '' && $this->hasDataPageFunction('delete')) {
             $delete = true;
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DELETE', $delete, array('id' => $data_id, 'value' => $data, 'table' => $this->table)))) {
                 $query = 'delete from ' . $this->table->getTablename() . ' where id=' . $data_id;
                 $delsql = rex_sql::factory();
                 $delsql->debugsql = self::$debug;
                 $delsql->setQuery($query);
                 echo rex_view::success(rex_i18n::msg('yform_datadeleted'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DELETED', '', array('id' => $data_id, 'value' => $data, 'table' => $this->table)));
             }
         }
         // -------------- delete dataset
         if ($func == 'dataset_delete' && $this->hasDataPageFunction('truncate_table')) {
             $delete = true;
             $query = 'delete from `' . $this->table->getTablename() . '` ' . $this->getDataListQueryWhere($rex_yform_filter, $searchObject);
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DATASET_DELETE', $delete, array('table' => $this->table, 'query' => &$query)))) {
                 $delsql = rex_sql::factory();
                 $delsql->debugsql = self::$debug;
                 $delsql->setQuery($query);
                 echo rex_view::success(rex_i18n::msg('yform_dataset_deleted'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DATASET_DELETED', '', array('table' => $this->table)));
             }
         }
         // -------------- truncate table
         if ($func == 'truncate_table' && $this->hasDataPageFunction('truncate_table')) {
             $truncate = true;
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_TRUNCATE', $truncate, array('table' => $this->table)))) {
                 $query = 'truncate table ' . $this->table->getTablename();
                 $trunsql = rex_sql::factory();
                 $trunsql->setQuery($query);
                 echo rex_view::info(rex_i18n::msg('yform_table_truncated'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_TRUNCATED', '', array('table' => $this->table)));
             }
         }
         // -------------- export dataset
         if ($func == 'dataset_export' && $this->hasDataPageFunction('export')) {
             ob_end_clean();
             $sql = $this->getDataListQuery($rex_yform_filter, $searchObject);
             $data = '';
             $fields = array();
             $g = rex_sql::factory();
             $g->setQuery($sql);
             $array = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_EXPORT', $g->getArray(), array('table' => $this->table)));
             foreach ($array as $d) {
                 if ($data == '') {
                     foreach ($d as $a => $b) {
                         $fields[] = '"' . $a . '"';
                     }
                     $data = implode(';', $fields);
                 }
                 foreach ($d as $a => $b) {
                     $d[$a] = '"' . str_replace('"', '""', $b) . '"';
                 }
                 $data .= "\n" . implode(';', $d);
             }
             // ----- download - save as
             $filename = 'export_data_' . date('YmdHis') . '.csv';
             $filesize = strlen($data);
             $filetype = 'application/octetstream';
             $expires = 'Mon, 01 Jan 2000 01:01:01 GMT';
             $last_modified = 'Mon, 01 Jan 2000 01:01:01 GMT';
             header('Expires: ' . $expires);
             // Date in the past
             header('Last-Modified: ' . $last_modified);
             // always modified
             header('Cache-Control: no-store, no-cache, must-revalidate');
             // HTTP/1.1
             header('Cache-Control: post-check=0, pre-check=0', false);
             header('Pragma: no-cache');
             header('Pragma: private');
             header('Cache-control: private, must-revalidate');
             header('Content-Type: ' . $filetype . '; name="' . $filename . '"');
             header('Content-Disposition: attachment; filename="' . $filename . '"');
             header('Content-Description: "' . $filename . '"');
             header('Content-Length: ' . $filesize);
             echo $data;
             exit;
         }
         // -------------- form
         if ($func == 'add' && $this->hasDataPageFunction('add') || $func == 'edit') {
             $back = rex_view::info('<a href="index.php?' . $link_vars . $em_url . $em_rex_list . '"><b>&laquo; ' . rex_i18n::msg('yform_back_to_overview') . '</b></a>');
             $yform = new rex_yform();
             $yform->setDebug(self::$debug);
             foreach ($this->getLinkVars() as $k => $v) {
                 $yform->setHiddenField($k, $v);
             }
             if (count($rex_yform_manager_opener) > 0) {
                 foreach ($rex_yform_manager_opener as $k => $v) {
                     $yform->setHiddenField('rex_yform_manager_opener[' . $k . ']', $v);
                 }
             }
             if (count($rex_yform_filter) > 0) {
                 foreach ($rex_yform_filter as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $yform->setHiddenField('rex_yform_filter[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $yform->setHiddenField('rex_yform_filter[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_set) > 0) {
                 foreach ($rex_yform_set as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $yform->setHiddenField('rex_yform_set[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $yform->setHiddenField('rex_yform_set[' . $k . ']', $v);
                     }
                 }
             }
             foreach ($searchObject->getSearchVars() as $s_var => $values) {
                 foreach ($values as $k => $v) {
                     $yform->setHiddenField($s_var . '[' . $k . ']', $v);
                 }
             }
             // for rexlist
             $yform->setHiddenField('list', rex_request('list', 'string'));
             $yform->setHiddenField('sort', rex_request('sort', 'string'));
             $yform->setHiddenField('sorttype', rex_request('sorttype', 'string'));
             $yform->setHiddenField('start', rex_request('start', 'string'));
             foreach ($this->table->getFields() as $field) {
                 $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName();
                 $cl = new $class();
                 $definitions = $cl->getDefinitions();
                 $values = array();
                 $i = 1;
                 foreach ($definitions['values'] as $key => $_) {
                     $key = $this->getFieldName($key, $field->getType());
                     /*if ($field->getElement($key)) {
                           $values[] = $field->getElement($key);
                       } elseif ($field->getElement('f' . $i)) {
                           $values[] = $field->getElement('f' . $i);
                       } else {
                           $values[] = '';
                       }*/
                     $values[] = $field->getElement($key);
                     $i++;
                 }
                 if ($field->getType() == 'value') {
                     if (in_array($values[1], $this->getFilterFields())) {
                         // Feld vorhanden -> ignorieren -> hidden feld machen
                         // TODO: Feld trotzdem noch aufnehmen, damit validierungen etc noch funktionieren
                     } else {
                         $yform->setValueField($field->getTypeName(), $values);
                     }
                 } elseif ($field->getType() == 'validate') {
                     $yform->setValidateField($field->getTypeName(), $values);
                 } elseif ($field->getType() == 'action') {
                     $yform->setActionField($field->getTypeName(), $values);
                 }
             }
             if (rex_request('rex_yform_show_formularblock', 'string') != '') {
                 // Optional .. kann auch geloescht werden. Dient nur zu Hilfe beim Aufbau
                 // von yform-Formularen über php
                 // Textblock gibt den formalarblock als text aus, um diesen in das yform modul einsetzen zu können.
                 //  rex_yform_show_formularblock=1
                 $text_block = '';
                 foreach ($this->table->getFields() as $field) {
                     $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName();
                     $cl = new $class();
                     $definitions = $cl->getDefinitions();
                     $values = array();
                     $i = 1;
                     foreach ($definitions['values'] as $key => $_) {
                         $key = $this->getFieldName($key, $field->getType());
                         if (isset($field[$key])) {
                             $values[] = $field[$key];
                         } elseif (isset($field['f' . $i])) {
                             $values[] = $field['f' . $i];
                         } else {
                             $values[] = '';
                         }
                         $i++;
                     }
                     if ($field->getType() == 'value') {
                         $text_block .= "\n" . '$yform->setValueField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                     } else {
                         if ($field->getType() == 'validate') {
                             $text_block .= "\n" . '$yform->setValidateField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                         } else {
                             if ($field->getType() == 'action') {
                                 $text_block .= "\n" . '$yform->setActionField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                             }
                         }
                     }
                     // $text_block .= "\n".$field["type_name"].'|'.implode("|",$values);
                 }
                 echo '<pre>' . $text_block . '</pre>';
             }
             $yform->setObjectparams('main_table', $this->table->getTablename());
             // für db speicherungen und unique abfragen
             $yform->setObjectparams('rex_yform_set', $rex_yform_set);
             $yform_clone = clone $yform;
             $yform->setHiddenField('func', $func);
             // damit es neu im clone gesetzt werden kann
             if ($func == 'edit') {
                 $yform->setHiddenField('data_id', $data_id);
                 $yform->setActionField('db', array($this->table->getTablename(), "id={$data_id}"));
                 $yform->setObjectparams('main_id', $data_id);
                 $yform->setObjectparams('main_where', "id={$data_id}");
                 $yform->setObjectparams('getdata', true);
                 $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_save') . "," . rex_i18n::msg('yform_save_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
             } elseif ($func == 'add') {
                 $yform->setActionField('db', array($this->table->getTablename()));
                 $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_add') . "," . rex_i18n::msg('yform_add_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
             }
             if ($func == 'edit') {
                 $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_UPDATE', $yform, array('table' => $this->table, 'data_id' => $data_id, 'data' => $data)));
             } elseif ($func == 'add') {
                 $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_ADD', $yform, array('table' => $this->table)));
             }
             $yform->executeFields();
             $submit_type = 1;
             // normal, 2=apply
             foreach ($yform->objparams["values"] as $f) {
                 if ($f->getName() == "submit") {
                     if ($f->getValue() == 2) {
                         // apply
                         $yform->setObjectparams('form_showformafterupdate', 1);
                         $yform->executeFields();
                         $submit_type = 2;
                     }
                 }
             }
             $form = $yform->executeActions();
             if ($yform->objparams['actions_executed']) {
                 if ($func == 'edit') {
                     echo rex_view::info(rex_i18n::msg('yform_thankyouforupdate'));
                     $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_UPDATED', $yform, array('table' => $this->table, 'data_id' => $data_id, 'data' => $data)));
                 } elseif ($func == 'add') {
                     echo rex_view::info(rex_i18n::msg('yform_thankyouforentry'));
                     $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_ADDED', $yform, array('table' => $this->table)));
                     if ($submit_type == 2) {
                         $data_id = $yform->objparams['main_id'];
                         $func = "edit";
                         $yform = $yform_clone;
                         $yform->setHiddenField('func', $func);
                         $yform->setHiddenField('data_id', $data_id);
                         $yform->setActionField('db', array($this->table->getTablename(), "id={$data_id}"));
                         $yform->setObjectparams('main_id', $data_id);
                         $yform->setObjectparams('main_where', "id={$data_id}");
                         $yform->setObjectparams('getdata', true);
                         $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_save') . "," . rex_i18n::msg('yform_save_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
                         $yform->setObjectparams('form_showformafterupdate', 1);
                         $yform->executeFields();
                         $form = $yform->executeActions();
                     }
                 }
             }
             if ($yform->objparams['form_show'] || $yform->objparams['form_showformafterupdate']) {
                 if ($func == 'add') {
                     $title = rex_i18n::msg('yform_adddata');
                 } else {
                     $title = rex_i18n::msg('yform_editdata');
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('class', 'edit', false);
                 $fragment->setVar('title', $title);
                 $fragment->setVar('body', $form, false);
                 // $fragment->setVar('buttons', $buttons, false);
                 $form = $fragment->parse('core/page/section.php');
                 echo $form;
                 echo rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_FORM', '', array('form' => $form, 'func' => $func, 'this' => $this, 'table' => $this->table)));
                 echo $back;
                 $show_list = false;
             }
         }
         // ********************************************* LIST
         if ($show_list) {
             $sql = $this->getDataListQuery($rex_yform_filter, $searchObject);
             // ---------- LISTE AUSGEBEN
             /** @type rex_list $list */
             $list = rex_list::factory($sql, $this->table->getListAmount());
             if ($this->hasDataPageFunction('add')) {
                 $tdIcon = '<i class="rex-icon rex-icon-table"></i>';
                 $thIcon = '<a href="index.php?' . $link_vars . '&func=add&' . $em_url . $em_rex_list . '"' . rex::getAccesskey(rex_i18n::msg('add'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>';
                 $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']);
                 if (!isset($rex_yform_manager_opener['id'])) {
                     $list->setColumnParams($thIcon, ['data_id' => '###id###', 'func' => 'edit', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')]);
                 }
             }
             // $list->setColumnFormat('id', 'Id');
             foreach ($this->getLinkVars() as $k => $v) {
                 $list->addParam($k, $v);
             }
             $list->addParam('table_name', $this->table->getTablename());
             if (count($rex_yform_filter) > 0) {
                 foreach ($rex_yform_filter as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $list->addParam('rex_yform_filter[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $list->addParam('rex_yform_filter[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_set) > 0) {
                 foreach ($rex_yform_set as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $list->addParam('rex_yform_set[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $list->addParam('rex_yform_set[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_manager_opener) > 0) {
                 foreach ($rex_yform_manager_opener as $k => $v) {
                     $list->addParam('rex_yform_manager_opener[' . $k . ']', $v);
                 }
             }
             foreach ($searchObject->getSearchVars() as $s_var => $values) {
                 foreach ($values as $k => $v) {
                     $list->addParam($s_var . '[' . $k . ']', $v);
                 }
             }
             $list->setColumnLabel('id', rex_i18n::msg('yform_id'));
             $list->setColumnLayout('id', ['<th class="rex-table-id">###VALUE###</th>', '<td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">###VALUE###</td>']);
             $list->setColumnParams('id', array('data_id' => '###id###', 'func' => 'edit'));
             $list->setColumnSortable('id');
             foreach ($this->table->getFields() as $field) {
                 if (!$field->isHiddenInList() && $field->getTypeName()) {
                     if (method_exists('rex_yform_value_' . $field->getTypeName(), 'getListValue')) {
                         $list->setColumnFormat($field->getName(), 'custom', array('rex_yform_value_' . $field->getTypeName(), 'getListValue'), array('field' => $field->toArray(), 'fields' => $this->table->getFields()));
                     }
                 }
                 if ($field->getType() == 'value') {
                     if ($field->isHiddenInList()) {
                         $list->removeColumn($field->getName());
                     } else {
                         $list->setColumnSortable($field->getName());
                         $list->setColumnLabel($field->getName(), $field->getLabel());
                     }
                 }
             }
             if (isset($rex_yform_manager_opener['id'])) {
                 $list->addColumn(rex_i18n::msg('yform_data_select'), '');
                 $list->setColumnFormat(rex_i18n::msg('yform_data_select'), 'custom', function ($params) {
                     $value = '';
                     list($table_name, $field_name) = explode(".", $params["params"]["opener_field"]);
                     $table = rex_yform_manager_table::get($table_name);
                     if ($table) {
                         $fields = $table->getValueFields(array("name" => $field_name));
                         if (isset($fields[$field_name])) {
                             $target_table = $fields[$field_name]->getElement('table');
                             $target_field = $fields[$field_name]->getElement('field');
                             $values = rex_yform_value_be_manager_relation::getListValues($target_table, $target_field);
                             $value = $values[$params['list']->getValue('id')];
                         }
                     }
                     return '<a href="javascript:yform_manager_setData(' . $params["params"]["opener_id"] . ',###id###,\'' . htmlspecialchars($value) . ' [id=###id###]\',' . $params["params"]["opener_multiple"] . ')">' . rex_i18n::msg('yform_data_select') . '</a>';
                 }, array("opener_id" => $rex_yform_manager_opener["id"], "opener_field" => $rex_yform_manager_opener["field"], "opener_multiple" => $rex_yform_manager_opener["multiple"]));
             } else {
                 $list->addColumn(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit'));
                 $list->setColumnLayout(rex_i18n::msg('yform_function'), ['<th class="rex-table-action">###VALUE###</th>', '<td class="rex-table-action">###VALUE###</td>']);
                 $list->setColumnParams(rex_i18n::msg('yform_function'), array('data_id' => '###id###', 'func' => 'edit', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')));
                 if ($this->hasDataPageFunction('delete')) {
                     // Column layout fuer edit neu setzen
                     $list->setColumnLayout(rex_i18n::msg('yform_function'), ['<th class="rex-table-action" colspan="2">###VALUE###</th>', '<td class="rex-table-action">###VALUE###</td>']);
                     $list->addColumn(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete'));
                     $list->setColumnLayout(rex_i18n::msg('yform_delete'), ['', '<td class="rex-table-action">###VALUE###</td>']);
                     $list->setColumnParams(rex_i18n::msg('yform_delete'), array('data_id' => '###id###', 'func' => 'delete', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')));
                     $list->addLinkAttribute(rex_i18n::msg('yform_delete'), 'onclick', 'return confirm(\' id=###id### ' . rex_i18n::msg('yform_delete') . ' ?\')');
                 }
             }
             // *********************************************
             $list = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_LIST', $list, array('table' => $this->table)));
             if ($rex_yform_filter) {
                 $filter = array();
                 $getFilter = function (rex_yform_manager_field $field, $value) {
                     if ('be_manager_relation' == $field->getTypeName()) {
                         $listValues = rex_yform_value_be_manager_relation::getListValues($field->getElement('table'), $field->getElement('field'), array('id' => $value));
                         if (isset($listValues[$value])) {
                             $value = $listValues[$value];
                         }
                     }
                     return '<b>' . rex_i18n::translate($field->getLabel()) . ':</b> ' . $value;
                 };
                 foreach ($rex_yform_filter as $key => $value) {
                     if (is_array($value)) {
                         $relTable = rex_yform_manager_table::get($this->table->getValueField($key)->getElement('table'));
                         foreach ($value as $k => $v) {
                             $filter[] = $getFilter($relTable->getValueField($k), $v);
                         }
                     } else {
                         $filter[] = $getFilter($this->table->getValueField($key), $value);
                     }
                 }
                 echo rex_view::info(implode('<br>', $filter));
             }
             $panel_options = '';
             $data_links = [];
             if ($this->table->isSearchable() && $this->hasDataPageFunction('search')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_search');
                 $item['attributes']['class'][] = 'btn-search';
                 $item['attributes']['id'] = 'searchtoggler';
                 $data_links[] = $item;
             }
             if (count($data_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $data_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_data') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             // INFO LINK
             $dataset_links = [];
             if ($this->table->isExportable() == 1 && $this->hasDataPageFunction('export')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_export');
                 $item['url'] = 'index.php?' . $link_vars . '&func=dataset_export&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-default';
                 $dataset_links[] = $item;
             }
             if ($this->hasDataPageFunction('truncate_table')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_delete');
                 $item['url'] = 'index.php?' . $link_vars . '&func=dataset_delete&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-delete';
                 $item['attributes']['id'] = 'dataset-delete';
                 $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_dataset_delete_confirm') . '\');';
                 $dataset_links[] = $item;
             }
             if (count($dataset_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $dataset_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_dataset') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             $table_links = array();
             if (!$popup && $this->table->isImportable() && $this->hasDataPageFunction('import')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_import');
                 $item['url'] = 'index.php?' . htmlspecialchars($link_vars) . '&amp;func=import';
                 $item['attributes']['class'][] = 'btn-default';
                 $table_links[] = $item;
             }
             if (rex::getUser()->isAdmin()) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_edit');
                 $item['url'] = 'index.php?page=yform/manager&table_id=' . $this->table->getId() . '&func=edit';
                 $item['attributes']['class'][] = 'btn-default';
                 $table_links[] = $item;
             }
             if ($this->hasDataPageFunction('truncate_table')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_truncate_table');
                 $item['url'] = 'index.php?' . $link_vars . '&func=truncate_table&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-delete';
                 $item['attributes']['id'] = 'truncate-table';
                 $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_truncate_table_confirm') . '\');';
                 $table_links[] = $item;
             }
             if (count($table_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $table_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_table') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             $field_links = array();
             if (rex::getUser()->isAdmin()) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_edit');
                 $item['url'] = 'index.php?page=yform/manager/table_field&table_name=' . $this->table->getTableName();
                 $item['attributes']['class'][] = 'btn-default';
                 $field_links[] = $item;
             }
             if (count($field_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $field_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_manager_fields') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             // SEARCHBLOCK
             $searchVars = $searchObject->getSearchVars();
             $display = count($searchVars["rex_yform_searchvars"]) > 0 ? 'block' : 'none';
             echo '<div id="searchblock" style="display:' . $display . ';">' . $searchform . '</div>';
             $content = $list->get();
             $fragment = new rex_fragment();
             $fragment->setVar('title', rex_i18n::msg('yform_tabledata_overview'));
             $fragment->setVar('options', $panel_options, false);
             $fragment->setVar('content', $content, false);
             $content = $fragment->parse('core/page/section.php');
             $content .= '
              <script type="text/javascript">/* <![CDATA[ */
                  jQuery("#searchtoggler").click(function(){jQuery("#searchblock").slideToggle("fast");});
                  jQuery("#yform_help_empty_toggler").click(function(){jQuery("#yform_help_empty").slideToggle("fast");});
                  jQuery("#yform_search_reset").click(function(){window.location.href = "index.php?page=yform/manager/data_edit&table_name=' . $this->table->getTableName() . '";});
                  jQuery("#truncate-table").click(function(){if(confirm("' . rex_i18n::msg('yform_truncate_table_confirm') . '")){return true;} else {return false;}});
                  jQuery("#dataset-delete").click(function(){if(confirm("' . rex_i18n::msg('yform_dataset_delete_confirm') . '")){return true;} else {return false;}});
              /* ]]> */</script>';
             echo $content;
         }
     }
     // end: $show_editpage
 }
コード例 #19
0
ファイル: slice_ui.php プロジェクト: nilsology/slice_ui
 public function extendSliceButtons()
 {
     // ----- EXTENSION POINT
     $hideButtons = rex_extension::registerPoint(new rex_extension_point('HIDE_COPY_BUTTONS', '', []));
     if (!$hideButtons && (rex_get('page_buttons') == '' || strpos(rex_get('page_buttons'), __CLASS__) !== false)) {
         $Content = rex_plugin::get('structure', 'content');
         $ContentPages = $Content->getProperty('pages');
         $ContentPages['content']['subpages']['paste'] = array('title' => 'Einfügen', 'icon' => 'rex-icon rex-icon-paste');
         $ContentPages['content']['subpages']['emptyclipboard'] = array('title' => 'Clipboard löschen', 'icon' => 'rex-icon rex-icon-emptyclipboard');
         $Content->setProperty('pages', $ContentPages);
     }
 }