Esempio n. 1
0
 static function factory($query, $rowsPerPage = 30, $listName = null, $debug = false, $class = null)
 {
     if (!$class) {
         $class = rex_extension::registerPoint(new rex_extension_point('REX_LIST_CLASSNAME', 'rex_yform_list', ['query' => $query, 'rowsPerPage' => $rowsPerPage, 'listName' => $listName, 'debug' => $debug]));
     }
     return new $class($query, $rowsPerPage, $listName, $debug);
 }
Esempio n. 2
0
/**
 * Gibt eine Url zu einem Artikel zurück.
 *
 * @param string       $_id
 * @param int|string   $_clang  SprachId des Artikels
 * @param array|string $_params Array von Parametern
 * @param bool         $escape  Flag whether the argument separator "&" should be escaped (&)
 *
 * @return string
 *
 * @package redaxo\structure
 */
function rex_getUrl($_id = '', $_clang = '', $_params = '', $escape = true)
{
    $id = (int) $_id;
    $clang = (int) $_clang;
    // ----- get id
    if ($id == 0) {
        $id = rex::getProperty('article_id');
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if ($_clang === '' && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) {
        $clang = rex_clang::getCurrentId();
    }
    // ----- get params
    $param_string = rex_param_string($_params, $escape ? '&' : '&');
    $name = 'NoName';
    if ($id != 0) {
        $ooa = rex_article::get($id, $clang);
        if ($ooa) {
            $name = rex_parse_article_name($ooa->getName());
        }
    }
    // ----- EXTENSION POINT
    $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string, 'escape' => $escape]));
    if ($url == '') {
        $_clang = '';
        if (rex_clang::count() > 1) {
            $_clang .= ($escape ? '&' : '&') . 'clang=' . $clang;
        }
        $url = rex_url::frontendController() . '?article_id=' . $id . $_clang . $param_string;
    }
    return $url;
}
Esempio n. 3
0
/**
 * Gibt eine Url zu einem Artikel zurück.
 *
 * @param int|null $id
 * @param int|null $clang     SprachId des Artikels
 * @param array    $params    Array von Parametern
 * @param string   $separator
 *
 * @return string
 *
 * @package redaxo\structure
 */
function rex_getUrl($id = null, $clang = null, array $params = [], $separator = '&')
{
    $id = (int) $id;
    $clang = (int) $clang;
    // ----- get id
    if ($id == 0) {
        $id = rex::getProperty('article_id');
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if (!rex_clang::exists($clang) && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) {
        $clang = rex_clang::getCurrentId();
    }
    // ----- EXTENSION POINT
    $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'clang' => $clang, 'params' => $params, 'separator' => $separator]));
    if ($url == '') {
        if (rex_clang::count() > 1) {
            $clang = $separator . 'clang=' . $clang;
        } else {
            $clang = '';
        }
        $params = rex_string::buildQuery($params, $separator);
        $params = $params ? $separator . $params : '';
        $url = rex_url::frontendController() . '?article_id=' . $id . $clang . $params;
    }
    return $url;
}
Esempio n. 4
0
/**
 * Deletes the cache.
 *
 * @package redaxo\core
 */
function rex_delete_cache()
{
    // close logger, so the logfile can also be deleted
    rex_logger::close();
    $finder = rex_finder::factory(rex_path::cache())->recursive()->childFirst()->ignoreFiles(['.htaccess', '.redaxo'], false)->ignoreSystemStuff(false);
    rex_dir::deleteIterator($finder);
    rex_clang::reset();
    // ----- EXTENSION POINT
    return rex_extension::registerPoint(new rex_extension_point('CACHE_DELETED', rex_i18n::msg('delete_cache_message')));
}
Esempio n. 5
0
 public function __construct($tag = '', rex_form $table = null, array $attributes = [])
 {
     parent::__construct('', $table, $attributes);
     $this->labelField = '';
     $this->whereCondition = '';
     $this->primaryKey = 'id';
     $this->firstOptionMsg = 'form_field_first_priority';
     $this->optionMsg = 'form_field_after_priority';
     $this->select->setSize(1);
     rex_extension::register('REX_FORM_SAVED', [$this, 'organizePriorities']);
 }
Esempio n. 6
0
 /**
  * Extends rex_extension::registerPoint() with FirePHP logging.
  */
 public static function registerPoint(rex_extension_point $extensionPoint)
 {
     $coreTimer = rex::getProperty('timer');
     $absDur = $coreTimer->getFormattedDelta();
     // start timer for this extensionPoint
     $timer = new rex_timer();
     $res = parent::registerPoint($extensionPoint);
     $epDur = $timer->getFormattedDelta();
     $memory = rex_formatter::bytes(memory_get_usage(true), [3]);
     self::$log[] = ['type' => 'EP', 'ep' => $extensionPoint->getName(), 'started' => $absDur, 'duration' => $epDur, 'memory' => $memory, 'subject' => $extensionPoint->getSubject(), 'params' => $extensionPoint->getParams(), 'read_only' => $extensionPoint->isReadonly(), 'result' => $res, 'timer' => $epDur];
     return $res;
 }
Esempio n. 7
0
 function executeAction()
 {
     $sql = rex_sql::factory();
     if ($this->params['debug']) {
         $sql->debugsql = true;
     }
     $main_table = '';
     if (!($main_table = $this->getElement(2))) {
         $main_table = $this->params['main_table'];
     }
     if ($main_table == '') {
         $this->params['form_show'] = true;
         $this->params['hasWarnings'] = true;
         $this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
         return false;
     }
     $sql->setTable($main_table);
     $where = '';
     if ($where = $this->getElement(3)) {
         if ($where == 'main_where') {
             $where = $this->params['main_where'];
         }
     }
     foreach ($this->params['value_pool']['sql'] as $key => $value) {
         $sql->setValue($key, $value);
         if ($where != '') {
             $where = str_replace('###' . $key . '###', addslashes($value), $where);
         }
     }
     try {
         if ($where != '') {
             $sql->setWhere($where);
             $saved = $sql->update();
             $flag = 'update';
         } else {
             $saved = $sql->insert();
             $flag = 'insert';
             $id = $sql->getLastId();
             $this->params['main_id'] = $id;
             $this->params['value_pool']['email']['ID'] = $id;
             // $this->params["value_pool"]["sql"]["ID"] = $id;
         }
     } catch (Exception $sql) {
         $this->params['form_show'] = true;
         $this->params['hasWarnings'] = true;
         $this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
         echo $sql->getMessage();
     }
     rex_extension::registerPoint(new rex_extension_point('REX_YFORM_SAVED'), $sql, array('form' => $this, 'sql' => $sql, 'yform' => true));
 }
Esempio n. 8
0
 /**
  * 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]));
 }
Esempio n. 9
0
 public function testRegister()
 {
     $EP = 'TEST_EP_LEVELS';
     $callback = function ($str) {
         return function (rex_extension_point $ep) use($str) {
             return $ep->getSubject() . $str . ' ';
         };
     };
     rex_extension::register($EP, $callback('late1'), rex_extension::LATE);
     rex_extension::register($EP, $callback('normal1'));
     rex_extension::register($EP, $callback('early1'), rex_extension::EARLY);
     rex_extension::register($EP, $callback('late2'), rex_extension::LATE);
     rex_extension::register($EP, $callback('normal2'), rex_extension::NORMAL);
     rex_extension::register($EP, $callback('early2'), rex_extension::EARLY);
     $expected = 'early1 early2 normal1 normal2 late1 late2 ';
     $actual = rex_extension::registerPoint(new rex_extension_point($EP, ''));
     $this->assertEquals($expected, $actual);
 }
Esempio n. 10
0
 protected function applyEffects($type)
 {
     $this->type = $type;
     if (!$this->isCached($type)) {
         $set = $this->effectsFromType($type);
         $set = rex_extension::registerPoint(new rex_extension_point('MEDIA_MANAGER_FILTERSET', $set, ['rex_media_type' => $type]));
         if (count($set) == 0) {
             return $this->media;
         }
         // execute effects on image
         foreach ($set as $effect_params) {
             $effect_class = 'rex_effect_' . $effect_params['effect'];
             $effect = new $effect_class();
             $effect->setMedia($this->media);
             $effect->setParams($effect_params['params']);
             $effect->execute();
         }
     }
 }
Esempio n. 11
0
 protected function handleSave(array $params, rex_sql $sqlFields)
 {
     // Nur speichern wenn auch das MetaForm ausgefüllt wurde
     // z.b. nicht speichern wenn über be_search select navigiert wurde
     if (!rex_post('savemeta', 'boolean')) {
         return $params;
     }
     $article = rex_sql::factory();
     // $article->setDebug();
     $article->setTable(rex::getTablePrefix() . 'article');
     $article->setWhere('id=:id AND clang_id=:clang', ['id' => $params['id'], 'clang' => $params['clang']]);
     $article->setValue('name', rex_post('meta_article_name', 'string'));
     parent::fetchRequestValues($params, $article, $sqlFields);
     // do the save only when metafields are defined
     if ($article->hasValues()) {
         $article->update();
     }
     rex_article_cache::deleteMeta($params['id'], $params['clang']);
     rex_extension::registerPoint(new rex_extension_point('ART_META_UPDATED', '', $params));
     return $params;
 }
 public function show_counter()
 {
     $counter = 0;
     $current_user = rex::getUser()->getId();
     $sql_counter = rex_sql::factory();
     //$sql_counter->setDebug();
     $sql_counter->setQuery('SELECT counter FROM rex_aufgaben_user_settings WHERE user = '******'</i> Aufgaben <span class="label label-default">' . $counter . '</span></a>';
         $counter = $sql_counter->getValue('counter');
         if ($counter > 0) {
             $ersetzen = '</i> Aufgaben <span class="label label-danger">' . $counter . '</span></a>';
         } else {
             $ersetzen = '</i> Aufgaben <span class="label label-default">' . $counter . '</span></a>';
         }
         rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) use($ersetzen) {
             $suchmuster = '</i> Aufgaben';
             $ersetzen = $ersetzen;
             $ep->setSubject(str_replace($suchmuster, $ersetzen, $ep->getSubject()));
         });
     }
 }
 static function sendMail($template, $template_name = '')
 {
     $r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_SEND', ['template' => $template, 'template_name' => $template_name, 'status' => false]));
     $template = $r['template'];
     $template_name = $r['template_name'];
     $status = $r['status'];
     if ($status) {
         return true;
     }
     $mail = new rex_mailer();
     $mail->AddAddress($template['mail_to'], $template['mail_to_name']);
     $mail->SetFrom($template['mail_from'], $template['mail_from_name']);
     $mail->Subject = $template['subject'];
     $mail->Body = $template['body'];
     if ($template['body_html'] != '') {
         $mail->AltBody = $template['body'];
         $mail->MsgHTML($template['body_html']);
     } else {
         $mail->Body = strip_tags($template['body']);
     }
     if (is_array($template['attachments'])) {
         foreach ($template['attachments'] as $f) {
             $mail->AddAttachment($f['path'], $f['name']);
         }
     }
     if ($mail->Send()) {
         $template['email_subject'] = $template['subject'];
         rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_SENT', $template_name, $template, true));
         // read only
         return true;
     } else {
         $template['email_subject'] = $template['subject'];
         rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_SENT_FAILED', $template_name, $template, true));
         // read only
         return false;
     }
 }
Esempio n. 14
0
 public function init()
 {
     // ----- EXTENSION POINT
     // IDs aller Feldtypen bei denen das Parameter-Feld eingeblendet werden soll
     $typeFields = rex_extension::registerPoint(new rex_extension_point('METAINFO_TYPE_FIELDS', [REX_METAINFO_FIELD_SELECT, REX_METAINFO_FIELD_RADIO, REX_METAINFO_FIELD_CHECKBOX, REX_METAINFO_FIELD_REX_MEDIA_WIDGET, REX_METAINFO_FIELD_REX_MEDIALIST_WIDGET, REX_METAINFO_FIELD_REX_LINK_WIDGET, REX_METAINFO_FIELD_REX_LINKLIST_WIDGET]));
     $field = $this->addReadOnlyField('prefix', $this->metaPrefix);
     $field->setLabel(rex_i18n::msg('minfo_field_label_prefix'));
     $field = $this->addTextField('name');
     $field->setLabel(rex_i18n::msg('minfo_field_label_name'));
     $field = $this->addSelectField('priority');
     $field->setLabel(rex_i18n::msg('minfo_field_label_priority'));
     $select = $field->getSelect();
     $select->setSize(1);
     $select->addOption(rex_i18n::msg('minfo_field_first_priority'), 1);
     // Im Edit Mode das Feld selbst nicht als Position einf�gen
     $qry = 'SELECT name,priority FROM ' . $this->tableName . ' WHERE `name` LIKE "' . $this->metaPrefix . '%"';
     if ($this->isEditMode()) {
         $qry .= ' AND id != ' . $this->getParam('field_id');
     }
     $qry .= ' ORDER BY priority';
     $sql = rex_sql::factory();
     $sql->setQuery($qry);
     $value = 1;
     for ($i = 0; $i < $sql->getRows(); ++$i) {
         $value = $sql->getValue('priority') + 1;
         $select->addOption(rex_i18n::rawMsg('minfo_field_after_priority', $sql->getValue('name')), $value);
         $sql->next();
     }
     if (!$this->isEditMode()) {
         $select->setSelected($value);
     }
     $field = $this->addTextField('title');
     $field->setLabel(rex_i18n::msg('minfo_field_label_title'));
     $field->setNotice(rex_i18n::msg('minfo_field_notice_title'));
     $gq = rex_sql::factory();
     $gq->setQuery('SELECT dbtype,id FROM ' . rex::getTablePrefix() . 'metainfo_type');
     $textFields = [];
     foreach ($gq->getArray() as $f) {
         if ($f['dbtype'] == 'text') {
             $textFields[$f['id']] = $f['id'];
         }
     }
     $field = $this->addSelectField('type_id');
     $field->setLabel(rex_i18n::msg('minfo_field_label_type'));
     $field->setAttribute('onchange', 'meta_checkConditionalFields(this, new Array(' . implode(',', $typeFields) . '), new Array(' . implode(',', $textFields) . '));');
     $select = $field->getSelect();
     $select->setSize(1);
     $qry = 'SELECT label,id FROM ' . rex::getTablePrefix() . 'metainfo_type';
     $select->addSqlOptions($qry);
     $notices = '';
     for ($i = 1; $i < REX_METAINFO_FIELD_COUNT; ++$i) {
         if (rex_i18n::hasMsg('minfo_field_params_notice_' . $i)) {
             $notices .= '<span id="metainfo-field-params-notice-' . $i . '" style="display:none">' . rex_i18n::msg('minfo_field_params_notice_' . $i) . '</span>' . "\n";
         }
     }
     $notices .= '
     <script type="text/javascript">
         var needle = new getObj("' . $field->getAttribute('id') . '");
         meta_checkConditionalFields(needle.obj, new Array(' . implode(',', $typeFields) . '), new Array(' . implode(',', $textFields) . '));
     </script>';
     $field = $this->addTextAreaField('params');
     $field->setLabel(rex_i18n::msg('minfo_field_label_params'));
     $field->setNotice($notices);
     $field = $this->addTextAreaField('attributes');
     $field->setLabel(rex_i18n::msg('minfo_field_label_attributes'));
     $notice = rex_i18n::msg('minfo_field_attributes_notice') . "\n";
     $field->setNotice($notice);
     $field = $this->addTextAreaField('callback');
     $field->setLabel(rex_i18n::msg('minfo_field_label_callback'));
     $notice = rex_i18n::msg('minfo_field_label_notice') . "\n";
     $field->setNotice($notice);
     $field = $this->addTextField('default');
     $field->setLabel(rex_i18n::msg('minfo_field_label_default'));
     if ('clang_' !== $this->metaPrefix) {
         $attributes = [];
         $attributes['internal::fieldClass'] = 'rex_form_restrictons_element';
         $field = $this->addField('', 'restrictions', null, $attributes);
         $field->setLabel(rex_i18n::msg('minfo_field_label_restrictions'));
         $field->setAttribute('size', 10);
         $field->setAttribute('class', 'form-control');
     }
     parent::init();
 }
Esempio n. 15
0
                $select .= '<option value="' . $version['history_date'] . '">' . $version['history_date'] . '</option>';
            }
            $content1select = '<select id="content-history-select-date-1" class="content-history-select" data-iframe="content-history-iframe-1" style="">' . $select . '</select>';
            $content1iframe = '<iframe id="content-history-iframe-1" class="history-iframe"></iframe>';
            $content2select = '<select id="content-history-select-date-2" class="content-history-select" data-iframe="content-history-iframe-2">' . $select . '</select>';
            $content2iframe = '<iframe id="content-history-iframe-2" class="history-iframe"></iframe>';
            $button_restore = '<a class="btn btn-apply" href="javascript:rex_history_snapVersion(\'content-history-select-date-2\');">' . $this->i18n('snapshot_reactivate') . '</a>';
            // fragment holen und ausgeben
            $fragment = new rex_fragment();
            $fragment->setVar('title', $this->i18n('overview_versions'));
            $fragment->setVar('info', $info, false);
            $fragment->setVar('content1select', $content1select, false);
            $fragment->setVar('content1iframe', $content1iframe, false);
            $fragment->setVar('content2select', $content2select, false);
            $fragment->setVar('content2iframe', $content2iframe, false);
            $fragment->setVar('button_restore', $button_restore, false);
            echo $fragment->parse('history/layer.php');
            exit;
    }
    rex_extension::register('STRUCTURE_CONTENT_HEADER', function (rex_extension_point $ep) {
        if ($ep->getParam('page') == 'content/edit') {
            echo '<script>
                    var history_article_id = ' . rex_article::getCurrentId() . ';
                    var history_clang_id = ' . rex_clang::getCurrentId() . ';
                    var history_ctype_id = ' . rex_request('ctype', 'int', 0) . ';
                    var history_revision = ' . rex_request('rex_set_version', 'int', 0) . ';
                    var history_article_link = "' . rex_getUrl(rex_article::getCurrentId(), rex_clang::getCurrentId(), ['history_revision' => rex_request('rex_set_version', 'int', 0)], '&') . '";
                    </script>';
        }
    });
}
Esempio n. 16
0
 public function testRegisterMultiple()
 {
     $EP1 = 'TEST_EP_MULTIPLE_1';
     $EP2 = 'TEST_EP_MULTIPLE_2';
     rex_extension::register([$EP1, $EP2], function () {
         return 'foo';
     });
     $this->assertSame('foo', rex_extension::registerPoint(new rex_extension_point($EP1)));
     $this->assertSame('foo', rex_extension::registerPoint(new rex_extension_point($EP2)));
 }
Esempio n. 17
0
<?php

rex_extension::register('OUTPUT_FILTER', ['rex_sql_debug', 'doLog']);
/**
 * Class to monitor sql queries.
 *
 * @author staabm
 *
 * @package redaxo\debug
 */
class rex_sql_debug extends rex_sql
{
    private static $queries = [];
    private static $errors = 0;
    /**
     * {@inheritdoc}.
     */
    public function setQuery($qry, array $params = [])
    {
        try {
            parent::setQuery($qry, $params);
        } catch (rex_exception $e) {
            $trace = debug_backtrace();
            for ($i = 0; $trace && $i < count($trace); ++$i) {
                if (isset($trace[$i]['file']) && strpos($trace[$i]['file'], 'sql.php') === false) {
                    $file = $trace[$i]['file'];
                    $line = $trace[$i]['line'];
                    break;
                }
            }
            $firephp = FirePHP::getInstance(true);
Esempio n. 18
0
/**
 * Menupunkt nur einbinden, falls ein Plugin sich angemeldet hat
 * via BE_STYLE_PAGE_CONTENT inhalt auszugeben.
 *
 * @package redaxo\be-style
 */
function rex_be_add_page()
{
    if (rex_extension::isRegistered('BE_STYLE_PAGE_CONTENT')) {
        rex_addon::get('be_style')->setProperty('name', 'Backend Style');
    }
}
Esempio n. 19
0
    {
        $params = $ep->getParams();
        if (isset($params['category'])) {
            $params['activeItem'] = $params['category'];
            // Hier die category_id setzen, damit beim klick auf den REX_LINK_BUTTON der Medienpool in der aktuellen Kategorie startet
            $params['activeItem']->setValue('category_id', $params['id']);
        }
        $result = '
            <tr id="' . self::CONTAINER . '" class="collapse mark">
                <td colspan="2"></td>
                <td colspan="5">
                    <div class="rex-collapse-content">
                    ' . parent::renderFormAndSave(self::PREFIX, $params) . '
                    </div>
                </td>
            </tr>';
        // Bei CAT_ADDED und CAT_UPDATED nur speichern und kein Formular zurückgeben
        if ('CAT_UPDATED' == $ep->getName() || 'CAT_ADDED' == $ep->getName()) {
            return $ep->getSubject();
        } else {
            return $ep->getSubject() . $result;
        }
    }
}
$catHandler = new rex_metainfo_category_handler();
rex_extension::register('CAT_FORM_ADD', [$catHandler, 'extendForm']);
rex_extension::register('CAT_FORM_EDIT', [$catHandler, 'extendForm']);
rex_extension::register('CAT_ADDED', [$catHandler, 'extendForm']);
rex_extension::register('CAT_UPDATED', [$catHandler, 'extendForm']);
rex_extension::register('CAT_FORM_BUTTONS', [$catHandler, 'renderToggleButton']);
Esempio n. 20
0
     $add_td = '<td></td>';
     if ($PERMALL) {
         $add_td = '<td><input type="checkbox" name="selectedmedia[]" value="' . $file_name . '" /></td>';
     }
     $panel .= '<tr>
                     ' . $add_td . '
                     <td data-title="' . rex_i18n::msg('pool_file_thumbnail') . '"><a href="' . $ilink . '">' . $thumbnail . '</a></td>
                     <td data-title="' . rex_i18n::msg('pool_file_info') . '">
                         <h3><a href="' . $ilink . '">' . htmlspecialchars($file_title) . '</a></h3>
                         ' . $desc . '
                         <p>' . htmlspecialchars($file_name) . ' <span class="rex-filesize">' . $file_size . '</span></p>
                     </td>
                     <td data-title="' . rex_i18n::msg('pool_last_update') . '"><p class="rex-date">' . $file_stamp . '</p><p class="rex-author">' . htmlspecialchars($file_updateuser) . '</p></td>
                     <td class="rex-table-action"><a href="' . $ilink . '">' . rex_i18n::msg('edit') . '</a></td>
                     <td class="rex-table-action">';
     $panel .= rex_extension::registerPoint(new rex_extension_point('MEDIA_LIST_FUNCTIONS', $opener_link, ['file_id' => $files->getValue('id'), 'file_name' => $files->getValue('filename'), 'file_oname' => $files->getValue('originalname'), 'file_title' => $files->getValue('title'), 'file_type' => $files->getValue('filetype'), 'file_size' => $files->getValue('filesize'), 'file_stamp' => $files->getDateTimeValue('updatedate'), 'file_updateuser' => $files->getValue('updateuser')]));
     $panel .= '</td>
              </tr>';
     $files->next();
 }
 // endforeach
 // ----- no items found
 if ($files->getRows() == 0) {
     $panel .= '
         <tr>
             <td></td>
             <td colspan="5">' . rex_i18n::msg('pool_nomediafound') . '</td>
         </tr>';
 }
 $panel .= '
         </tbody>
Esempio n. 21
0
 rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) {
     // Bereite Ausnahmen vor: Templates und Artikel
     // Dort werden E-Mailadressen nicht verschlüsselt
     $whitelistTemplates = rex_addon::get('emailobfuscator')->getConfig('templates', []);
     $whitelistArticles = rex_addon::get('emailobfuscator')->getConfig('articles', '');
     if ($whitelistArticles != '') {
         $whitelistArticles = explode(',', $whitelistArticles);
     } else {
         $whitelistArticles = [];
     }
     if (!is_null(rex_article::getCurrent()) && !in_array(rex_article::getCurrent()->getTemplateId(), $whitelistTemplates) && !in_array(rex_article::getCurrentId(), $whitelistArticles)) {
         $subject = $ep->getSubject();
         // Ersetze mailto-Links (zuerst!)
         // Anmerkung: Attributwerte (hier: href) benötigen nicht zwingend Anführungsstriche drumrum,
         // deshalb prüfen wir zusätzlich noch auf '>' am Ende .
         $subject = preg_replace_callback('/mailto:(.*?)(?=[\'|"|\\>])/', 'emailobfuscator::encodeEmailLinks', $subject);
         // Ersetze E-Mailadressen
         $subject = preg_replace_callback('/([\\w\\-\\+\\.]+)@([\\w\\-\\.]+\\.[\\w]{2,})/', 'emailobfuscator::encodeEmail', $subject);
         // Injiziere CSS vors schließende </head> im Seitenkopf
         if ($this->getConfig('autoload_css')) {
             $cssFile = '<link rel="stylesheet" href="' . $this->getAssetsUrl('emailobfuscator.css?v=' . $this->getVersion()) . '">';
             $subject = str_replace('</head>', $cssFile . '</head>', $subject);
         }
         // Injiziere JavaScript vors schließende </body> der Seite
         if ($this->getConfig('autoload_js')) {
             $jsFile = '<script src="' . $this->getAssetsUrl('emailobfuscator.js?v=' . $this->getVersion()) . '"></script>';
             $subject = str_replace('</body>', $jsFile . '</body>', $subject);
         }
         $ep->setSubject($subject);
     }
 });
Esempio n. 22
0
/**
 * Ausgabe des Medienpool Formulars.
 */
function rex_mediapool_Mediaform($form_title, $button_title, $rex_file_category, $file_chooser, $close_form)
{
    global $ftitle, $warning, $info;
    $s = '';
    $cats_sel = new rex_media_category_select();
    $cats_sel->setStyle('class="form-control"');
    $cats_sel->setSize(1);
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex-mediapool-category');
    $cats_sel->addOption(rex_i18n::msg('pool_kats_no'), '0');
    $cats_sel->setAttribute('onchange', 'this.form.submit()');
    $cats_sel->setSelected($rex_file_category);
    if (isset($warning)) {
        if (is_array($warning)) {
            if (count($warning) > 0) {
                $s .= rex_view::error(implode('<br />', $warning));
            }
        } elseif ($warning != '') {
            $s .= rex_view::error($warning);
        }
        $warning = '';
    }
    if (isset($info)) {
        if (is_array($info)) {
            if (count($info) > 0) {
                $s .= rex_view::success(implode('<br />', $info));
            }
        } elseif ($info != '') {
            $s .= rex_view::success($info);
        }
        $info = '';
    }
    if (!isset($ftitle)) {
        $ftitle = '';
    }
    $arg_fields = '';
    foreach (rex_request('args', 'array') as $arg_name => $arg_value) {
        $arg_fields .= '<input type="hidden" name="args[' . $arg_name . ']" value="' . $arg_value . '" />' . "\n";
    }
    $opener_input_field = rex_request('opener_input_field', 'string');
    if ($opener_input_field != '') {
        $arg_fields .= '<input type="hidden" name="opener_input_field" value="' . htmlspecialchars($opener_input_field) . '" />' . "\n";
    }
    $add_submit = '';
    if ($close_form && $opener_input_field != '') {
        $add_submit = '<button class="btn btn-save" type="submit" name="saveandexit" value="' . rex_i18n::msg('pool_file_upload_get') . '"' . rex::getAccesskey(rex_i18n::msg('pool_file_upload_get'), 'save') . '>' . rex_i18n::msg('pool_file_upload_get') . '</button>';
    }
    $panel = '';
    $formElements = [];
    $e = [];
    $e['label'] = '<label for="rex-mediapool-title">' . rex_i18n::msg('pool_file_title') . '</label>';
    $e['field'] = '<input class="form-control" type="text" id="rex-mediapool-title" name="ftitle" value="' . htmlspecialchars($ftitle) . '" />';
    $formElements[] = $e;
    $e = [];
    $e['label'] = '<label for="rex-mediapool-category">' . rex_i18n::msg('pool_file_category') . '</label>';
    $e['field'] = $cats_sel->get();
    $formElements[] = $e;
    $fragment = new rex_fragment();
    $fragment->setVar('elements', $formElements, false);
    $panel .= $fragment->parse('core/form/form.php');
    $panel .= rex_extension::registerPoint(new rex_extension_point('MEDIA_FORM_ADD', ''));
    if ($file_chooser) {
        $e = [];
        $e['label'] = '<label for="rex-mediapool-choose-file">' . rex_i18n::msg('pool_file_file') . '</label>';
        $e['field'] = '<input id="rex-mediapool-choose-file" type="file" name="file_new" />';
        $e['note'] = '<h3>' . rex_i18n::msg('phpini_settings') . '</h3>
                        <dl class="dl-horizontal">
                        ' . (rex_ini_get('file_uploads') == 0 ? '<dt><span class="text-warning">' . rex_i18n::msg('pool_upload') . '</span></dt><dd><span class="text-warning">' . rex_i18n::msg('pool_upload_disabled') . '</span></dd>' : '') . '
                            <dt>' . rex_i18n::msg('pool_max_uploadsize') . ':</dt><dd>' . rex_formatter::bytes(rex_ini_get('upload_max_filesize')) . '</dd>
                            <dt>' . rex_i18n::msg('pool_max_uploadtime') . ':</dt><dd>' . rex_ini_get('max_input_time') . 's</dd>
                        </dl>';
        $fragment = new rex_fragment();
        $fragment->setVar('elements', [$e], false);
        $panel .= $fragment->parse('core/form/form.php');
    }
    $formElements = [];
    $e = [];
    $e['field'] = '<button class="btn btn-save" type="submit" name="save" value="' . $button_title . '"' . rex::getAccesskey($button_title, 'save') . '>' . $button_title . '</button>';
    $formElements[] = $e;
    $e = [];
    $e['field'] = $add_submit;
    $formElements[] = $e;
    $fragment = new rex_fragment();
    $fragment->setVar('elements', $formElements, false);
    $buttons = $fragment->parse('core/form/submit.php');
    $fragment = new rex_fragment();
    $fragment->setVar('title', $form_title, false);
    $fragment->setVar('body', $panel, false);
    $fragment->setVar('buttons', $buttons, false);
    $content = $fragment->parse('core/page/section.php');
    $s .= ' <form action="' . rex_url::currentBackendPage() . '" method="post" enctype="multipart/form-data">
                <fieldset>
                    <input type="hidden" name="media_method" value="add_file" />
                    ' . $arg_fields . '
                    ' . $content . '
                </fieldset>
            ';
    if ($close_form) {
        $s .= '</form>' . "\n";
    }
    return $s;
}
Esempio n. 23
0
 /**
  * Returns the translation for the given key.
  *
  * @param string $key
  * @param bool   $htmlspecialchars
  * @param array  $args
  *
  * @return mixed
  */
 private static function getMsg($key, $htmlspecialchars, array $args)
 {
     if (!self::$loaded) {
         self::loadAll();
     }
     if (self::hasMsg($key)) {
         $msg = self::$msg[$key];
     } else {
         $msg = "[translate:{$key}]";
         $msg = rex_extension::registerPoint(new rex_extension_point('I18N_MISSING_TRANSLATION', $msg, ['key' => $key, 'args' => $args]));
     }
     if ($htmlspecialchars) {
         $msg = htmlspecialchars($msg);
         $msg = preg_replace('@&lt;(/?(?:b|i|code|kbd)|br ?/?)&gt;@i', '<$1>', $msg);
     }
     $patterns = [];
     $replacements = [];
     $argNum = count($args);
     if ($argNum > 1) {
         for ($i = 1; $i < $argNum; ++$i) {
             // zero indexed
             $patterns[] = '/\\{' . ($i - 1) . '\\}/';
             $replacements[] = $args[$i];
         }
     }
     return preg_replace($patterns, $replacements, $msg);
 }
Esempio n. 24
0
<?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();
        }
    });
}
Esempio n. 25
0
 /**
  * Returns whether the element is permitted.
  *
  * @return bool
  */
 public function isPermitted()
 {
     return (bool) rex_extension::registerPoint(new rex_extension_point('MEDIA_IS_PERMITTED', true, ['element' => $this]));
 }
Esempio n. 26
0
 /**
  * Erstellt den nötigen HTML Code um ein Formular zu erweitern.
  *
  * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
  * @param array   $epParams  Array of all EP parameters
  *
  * @return string
  */
 public function renderMetaFields(rex_sql $sqlFields, array $epParams)
 {
     $s = '';
     // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
     $media_id = 1;
     $mlist_id = 1;
     $link_id = 1;
     $llist_id = 1;
     $activeItem = isset($epParams['activeItem']) ? $epParams['activeItem'] : null;
     $sqlFields->reset();
     for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) {
         // Umschliessendes Tag von Label und Formularelement
         $tag = 'p';
         $tag_attr = '';
         $name = $sqlFields->getValue('name');
         $title = $sqlFields->getValue('title');
         $params = $sqlFields->getValue('params');
         $typeLabel = $sqlFields->getValue('label');
         $attr = $sqlFields->getValue('attributes');
         $dblength = $sqlFields->getValue('dblength');
         $attrArray = rex_string::split($attr);
         if (isset($attrArray['perm'])) {
             if (!rex::getUser()->hasPerm($attrArray['perm'])) {
                 continue;
             }
             unset($attrArray['perm']);
         }
         $defaultValue = $sqlFields->getValue('default');
         if ($activeItem) {
             $itemValue = $activeItem->getValue($name);
             if (strpos($itemValue, '|+|') !== false) {
                 // Alte notation mit |+| als Trenner
                 $dbvalues = explode('|+|', $activeItem->getValue($name));
             } else {
                 // Neue Notation mit | als Trenner
                 $dbvalues = explode('|', $activeItem->getValue($name));
             }
         } else {
             $dbvalues = (array) $sqlFields->getValue('default');
         }
         if ($title != '') {
             $label = rex_i18n::translate($title);
         } else {
             $label = htmlspecialchars($name);
         }
         $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
         $labelIt = true;
         $label = '<label for="' . $id . '">' . $label . '</label>';
         $field = '';
         switch ($typeLabel) {
             case 'text':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($dblength > 0) {
                     $rexInput->setAttribute('maxlength', $dblength);
                 }
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'checkbox':
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if (!$activeItem) {
                     $defaultValue = explode('|', $defaultValue);
                 }
                 $name .= '[]';
             case 'radio':
                 $formElements = [];
                 $values = [];
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     $sql = rex_sql::factory();
                     $value_groups = $sql->getDBArray($params, [], PDO::FETCH_NUM);
                     foreach ($value_groups as $value_group) {
                         if (isset($value_group[1])) {
                             $values[$value_group[1]] = $value_group[0];
                         } else {
                             $values[$value_group[0]] = $value_group[0];
                         }
                     }
                 } else {
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                 }
                 $oneValue = count($values) == 1;
                 $attrStr = '';
                 $classAdd = '';
                 $inline = false;
                 if (false !== ($key = array_search('inline', $attrArray))) {
                     $inline = true;
                     unset($attrArray[$key]);
                 }
                 foreach ($attrArray as $key => $value) {
                     if ($key == 'class') {
                         $classAdd = ' ' . $value;
                     } else {
                         $attrStr = ' ' . $key . '="' . $value . '"';
                     }
                 }
                 if (!$activeItem) {
                     $dbvalues = (array) $defaultValue;
                 }
                 foreach ($values as $key => $value) {
                     $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                     // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                     // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                     if ($oneValue && $key == '') {
                         $key = 'true';
                     }
                     $selected = '';
                     if (in_array($key, $dbvalues)) {
                         $selected = ' checked="checked"';
                     }
                     $e = [];
                     if ($oneValue) {
                         $e['label'] = $label;
                     } else {
                         $e['label'] = '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>';
                     }
                     $e['field'] = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />';
                     $formElements[] = $e;
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', $formElements, false);
                 $fragment->setVar('inline', $inline);
                 if ($typeLabel == 'radio') {
                     $field = $fragment->parse('core/form/radio.php');
                 } else {
                     if (!$oneValue) {
                         $fragment->setVar('grouped', true);
                     }
                     $field = $fragment->parse('core/form/checkbox.php');
                 }
                 if (!$oneValue) {
                     $e = [];
                     $e['label'] = $label;
                     $e['field'] = $field;
                     $fragment = new rex_fragment();
                     $fragment->setVar('elements', [$e], false);
                     $field = $fragment->parse('core/form/form.php');
                 }
                 break;
             case 'select':
                 $tag_attr = ' class="form-control"';
                 $select = new rex_select();
                 $select->setStyle('class="form-control"');
                 $select->setName($name);
                 $select->setId($id);
                 $multiple = false;
                 foreach ($attrArray as $attr_name => $attr_value) {
                     if (empty($attr_name)) {
                         continue;
                     }
                     $select->setAttribute($attr_name, $attr_value);
                     if ($attr_name == 'multiple') {
                         $multiple = true;
                         $select->setName($name . '[]');
                         $select->setMultiple();
                     }
                 }
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if ($multiple && !$activeItem) {
                     $dbvalues = explode('|', $defaultValue);
                 }
                 // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                 $select->setSelected($dbvalues);
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     // Werte via SQL Laden
                     $select->addDBSqlOptions($params);
                 } else {
                     // Optionen mit | separiert
                     // eine einzelne Option kann mit key:value separiert werden
                     $values = [];
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                     $select->addOptions($values);
                 }
                 $field .= $select->get();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'date':
             case 'time':
             case 'datetime':
                 $tag_attr = ' class="form-control-date"';
                 $active = $dbvalues[0] != 0;
                 if ($dbvalues[0] == '') {
                     $dbvalues[0] = time();
                 }
                 $inputValue = [];
                 $inputValue['year'] = date('Y', $dbvalues[0]);
                 $inputValue['month'] = date('n', $dbvalues[0]);
                 $inputValue['day'] = date('j', $dbvalues[0]);
                 $inputValue['hour'] = date('G', $dbvalues[0]);
                 $inputValue['minute'] = date('i', $dbvalues[0]);
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($inputValue);
                 $field = $rexInput->getHtml();
                 $checked = $active ? ' checked="checked"' : '';
                 $field .= '<input class="rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'textarea':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'legend':
                 $tag = '';
                 $tag_attr = '';
                 $labelIt = false;
                 // tabindex entfernen, macht bei einer legend wenig sinn
                 $attr = preg_replace('@tabindex="[^"]*"@', '', $attr);
                 $field = '</fieldset><fieldset><legend id="' . $id . '"' . $attr . '>' . $label . '</legend>';
                 break;
             case 'REX_MEDIA_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $rexInput = rex_input::factory('mediabutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($media_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$media_id;
                 break;
             case 'REX_MEDIALIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $name .= '[]';
                 $rexInput = rex_input::factory('medialistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($mlist_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$mlist_id;
                 break;
             case 'REX_LINK_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $rexInput = rex_input::factory('linkbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($link_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$link_id;
                 break;
             case 'REX_LINKLIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $name .= '[]';
                 $rexInput = rex_input::factory('linklistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($llist_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue(implode(',', $dbvalues));
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$llist_id;
                 break;
             default:
                 // ----- EXTENSION POINT
                 list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_extension::registerPoint(new rex_extension_point('METAINFO_CUSTOM_FIELD', [$field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields]));
         }
         $s .= $this->renderFormItem($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel);
     }
     return $s;
 }
Esempio n. 27
0
 /**
  * @return bool
  */
 protected function delete()
 {
     $deleteSql = rex_sql::factory();
     $deleteSql->setDebug($this->debug);
     $deleteSql->setTable($this->tableName);
     $deleteSql->setWhere($this->whereCondition);
     try {
         $deleteSql->delete();
         $deleted = true;
     } catch (rex_sql_exception $e) {
         $deleted = false;
     }
     // ----- EXTENSION POINT
     if ($deleted) {
         $deleted = rex_extension::registerPoint(new rex_extension_point('REX_FORM_DELETED', $deleted, ['form' => $this, 'sql' => $deleteSql]));
     } else {
         $deleted = $deleteSql->getErrno();
     }
     return $deleted;
 }
Esempio n. 28
0
            $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'));
        });
    }
    rex_view::addCssFile($this->getAssetsUrl('css/styles.css'));
    rex_view::addJsFile($this->getAssetsUrl('javascripts/redaxo.js'));
    rex_extension::register('PAGE_HEADER', function (rex_extension_point $ep) {
        $icons = [];
        foreach (['57', '60', '72', '76', '114', '120', '144', '152'] as $size) {
            $size = $size . 'x' . $size;
            $icons[] = '<link rel="apple-touch-icon-precomposed" sizes="' . $size . '" href="' . $this->getAssetsUrl('images/apple-touch-icon-' . $size . '.png') . '" />';
        }
        foreach (['16', '32', '96', '128', '196'] as $size) {
            $size = $size . 'x' . $size;
            $icons[] = '<link rel="icon" type="image/png" href="' . $this->getAssetsUrl('images/favicon-' . $size . '.png') . '" sizes="' . $size . '" />';
        }
        $icons[] = '<meta name="msapplication-TileColor" content="#FFFFFF" />';
        $icons[] = '<meta name="msapplication-TileImage" content="' . $this->getAssetsUrl('images/mstile-144x144.png') . '" />';
        foreach (['70', '150', '310'] as $size) {
            $size = $size . 'x' . $size;
            $icons[] = '<meta name="msapplication-square' . $size . 'logo" content="' . $this->getAssetsUrl('images/mstile-' . $size . '.png') . '" />';
        }
        $icons[] = '<meta name="msapplication-wide310x150logo" content="' . $this->getAssetsUrl('images/mstile-310x150.png') . '" />';
        $icons = implode("\n    ", $icons);
        $ep->setSubject($icons . $ep->getSubject());
    });
}
Esempio n. 29
0
 function getFieldPage()
 {
     // ********************************************* FIELD ADD/EDIT/LIST
     $func = rex_request('func', 'string', 'list');
     $type_id = rex_request('type_id', 'string');
     $type_name = rex_request('type_name', 'string');
     $field_id = rex_request('field_id', 'int');
     $link_vars = '';
     foreach ($this->getLinkVars() as $k => $v) {
         $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
     }
     $TYPE = array('value' => rex_i18n::msg('yform_values'), 'validate' => rex_i18n::msg('yform_validates'), 'action' => rex_i18n::msg('yform_action'));
     // ********************************** TABELLE HOLEN
     $table = $this->table;
     $table_info = '<b>' . rex_i18n::translate($table->getName()) . ' [' . $table->getTableName() . ']</b> ';
     echo rex_view::info($table_info);
     // ********************************************* Missing Fields
     $mfields = $table->getMissingFields();
     // ksort($mfields);
     $type_real_field = rex_request('type_real_field', 'string');
     if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) {
         $type_real_field = '';
     }
     if ($type_real_field != '') {
         $panel = '';
         $panel .= '<dl class="dl-horizontal text-left">';
         $rfields = $this->table->getColumns();
         foreach ($rfields[$type_real_field] as $k => $v) {
             $panel .= '<dt>' . ucfirst($k) . ':</dt><dd>' . $v . '</dd>';
         }
         $panel .= '</dl>';
         $fragment = new rex_fragment();
         $fragment->setVar('class', 'info');
         $fragment->setVar('title', 'Folgendes Feld wird verwendet: ' . $type_real_field);
         $fragment->setVar('body', $panel, false);
         echo $fragment->parse('core/page/section.php');
     }
     // ********************************************* CHOOSE FIELD
     $types = rex_yform::getTypeArray();
     if ($func == 'choosenadd') {
         $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&';
         $content = [];
         $panels = [];
         if (!$table->hasId()) {
             $content[] = rex_i18n::msg('yform_id_is_missing') . '' . rex_i18n::msg('yform_id_missing_info');
         } else {
             if ($type_real_field == '' && count($mfields) > 0) {
                 $tmp = '';
                 $d = 0;
                 foreach ($mfields as $k => $v) {
                     $d++;
                     $l = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t';
                     $tmp .= '<a class="btn btn-default" href="' . $l . '">' . $k . '</a> ';
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('class', 'info');
                 $fragment->setVar('title', 'Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.');
                 $fragment->setVar('body', $tmp, false);
                 echo $fragment->parse('core/page/section.php');
             }
             $tmp = '';
             if (isset($types['value'])) {
                 ksort($types['value']);
                 $tmp .= '<table class="table table-hover">';
                 foreach ($types['value'] as $k => $v) {
                     $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>';
                 }
                 $tmp .= '</table>';
             }
             $fragment = new rex_fragment();
             $fragment->setVar('title', $TYPE['value']);
             $fragment->setVar('content', $tmp, false);
             $panels[] = $fragment->parse('core/page/section.php');
             $tmp = '';
             if (isset($types['validate'])) {
                 ksort($types['validate']);
                 $tmp .= '<table class="table table-hover">';
                 foreach ($types['validate'] as $k => $v) {
                     $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=validate&type_name=' . $k . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>';
                 }
                 $tmp .= '</table>';
             }
             $fragment = new rex_fragment();
             $fragment->setVar('title', $TYPE['validate']);
             $fragment->setVar('content', $tmp, false);
             $panels[] = $fragment->parse('core/page/section.php');
         }
         $fragment = new rex_fragment();
         $fragment->setVar('title', rex_i18n::msg('yform_choosenadd'));
         $fragment->setVar('body', rex_i18n::msg('yform_choosenadd_description'), false);
         echo $fragment->parse('core/page/section.php');
         $fragment = new rex_fragment();
         $fragment->setVar('content', $panels, false);
         echo $fragment->parse('core/page/grid.php');
         $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>';
         $fragment = new rex_fragment();
         $fragment->setVar('footer', $table_echo, false);
         echo $fragment->parse('core/page/section.php');
     }
     // ********************************************* FORMULAR
     if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) {
         $yform = new rex_yform();
         $yform->setDebug(false);
         foreach ($this->getLinkVars() as $k => $v) {
             $yform->setHiddenField($k, $v);
         }
         $yform->setHiddenField('func', $func);
         $yform->setHiddenField('table_name', $table->getTableName());
         $yform->setHiddenField('type_real_field', $type_real_field);
         $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'));
         $yform->setValueField('hidden', array('table_name', $table->getTableName()));
         $yform->setValueField('hidden', array('type_name', $type_name, 'REQUEST'));
         $yform->setValueField('hidden', array('type_id', $type_id, 'REQUEST'));
         $yform->setValueField('prio', array('prio', 'Prioritaet', array('name', 'type_id', 'type_name'), array('table_name')));
         $selectFields = array();
         $i = 1;
         foreach ($types[$type_id][$type_name]['values'] as $k => $v) {
             $field = $this->getFieldName($k, $type_id);
             $selectFields['f' . $i] = $field;
             $i++;
             switch ($v['type']) {
                 case 'name':
                     if ($func == 'edit') {
                         $yform->setValueField('showvalue', array($field, 'Name'));
                     } else {
                         if (!isset($v['value']) && $type_real_field != '') {
                             $v['value'] = $type_real_field;
                         } elseif (!isset($v['value'])) {
                             $v['value'] = '';
                         }
                         $yform->setValueField('text', array($field, 'Name', $v['value']));
                         $yform->setValidateField('empty', array($field, rex_i18n::msg('yform_validatenamenotempty')));
                         $yform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", rex_i18n::msg('yform_validatenamepregmatch')));
                         $yform->setValidateField('customfunction', array($field, 'rex_yform_manager_checkField', array('table_name' => $table->getTableName()), rex_i18n::msg('yform_validatenamecheck')));
                     }
                     break;
                 case 'no_db':
                     if (!isset($v['default']) || $v['default'] != 1) {
                         $v['default'] = 0;
                     }
                     $yform->setValueField('checkbox', array($field, rex_i18n::msg('yform_donotsaveindb'), 'no_db', $v['default']));
                     break;
                 case 'boolean':
                     // checkbox|check_design|Bezeichnung|Value|1/0|[no_db]
                     if (!isset($v['default'])) {
                         $v['default'] = '';
                     }
                     $yform->setValueField('checkbox', array($field, $v['label'], '', $v['default']));
                     break;
                 case 'select':
                     // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1
                     $yform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0));
                     break;
                 case 'table':
                     // ist fest eingetragen, damit keine Dinge durcheinandergehen
                     if ($func == 'edit') {
                         $yform->setValueField('showvalue', array($field, $v['label']));
                     } else {
                         $_tables = rex_yform_manager_table::getAll();
                         $_options = array();
                         if (isset($v['empty_option']) && $v['empty_option']) {
                             $_options[0] = '–=';
                         }
                         foreach ($_tables as $_table) {
                             $_options[$_table['table_name']] = str_replace('=', '-', rex_i18n::translate($_table['name']) . ' [' . $_table['table_name'] . ']') . '=' . $_table['table_name'];
                             $_options[$_table['table_name']] = str_replace(',', '.', $_options[$_table['table_name']]);
                         }
                         if (!isset($v['default'])) {
                             $v['default'] = '';
                         }
                         $yform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0));
                     }
                     break;
                 case 'textarea':
                     $yform->setValueField('textarea', array($field, $v['label']));
                     break;
                 case 'table.field':
                     // Todo:
                 // Todo:
                 case 'select_name':
                     $_fields = array();
                     foreach ($table->getValueFields() as $_k => $_v) {
                         $_fields[] = $_k;
                     }
                     $yform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0));
                     break;
                 case 'select_names':
                     $_fields = array();
                     foreach ($table->getValueFields() as $_k => $_v) {
                         $_fields[] = $_k;
                     }
                     $yform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5));
                     break;
                 default:
                     // nur beim "Bezeichnungsfeld"
                     if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) {
                         $v['value'] = $type_real_field;
                     } elseif (!isset($v['value'])) {
                         $v['value'] = '';
                     }
                     $yform->setValueField('text', array($field, $v['label'], $v['value']));
             }
         }
         $yform->setActionField('showtext', array('', '<p>' . rex_i18n::msg('yform_thankyouforentry') . '</p>'));
         $yform->setObjectparams('main_table', rex_yform_manager_field::table());
         if ($func == 'edit') {
             $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_save'));
             $yform->setHiddenField('field_id', $field_id);
             $yform->setActionField('manage_db', array(rex_yform_manager_field::table(), "id={$field_id}"));
             $yform->setObjectparams('main_id', $field_id);
             $yform->setObjectparams('main_where', "id={$field_id}");
             $sql = rex_sql::factory();
             $sql->setQuery('SELECT * FROM ' . rex_yform_manager_field::table() . " WHERE id={$field_id}");
             foreach ($selectFields as $alias => $field) {
                 if ($alias != $field) {
                     if ((!$sql->hasValue($field) || null === $sql->getValue($field) || '' === $sql->getValue($field)) && $sql->hasValue($alias)) {
                         $sql->setValue($field, $sql->getValue($alias));
                     }
                     $yform->setValueField('hidden', array($alias, ''));
                 }
             }
             $yform->setObjectparams('sql_object', $sql);
             $yform->setObjectparams('getdata', true);
         } elseif ($func == 'add') {
             $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_add'));
             $yform->setActionField('manage_db', array(rex_yform_manager_field::table()));
         }
         if ($type_id == 'value') {
             $yform->setValueField('checkbox', array('list_hidden', rex_i18n::msg('yform_hideinlist'), 1, '1'));
             $yform->setValueField('checkbox', array('search', rex_i18n::msg('yform_useassearchfieldalidatenamenotempty'), 1, '1'));
         } elseif ($type_id == 'validate') {
             $yform->setValueField('hidden', array('list_hidden', 1));
         }
         $form = $yform->getForm();
         if ($yform->objparams['form_show']) {
             if ($func == 'add') {
                 $title = rex_i18n::msg('yform_addfield') . ' "' . $type_name . '"';
             } else {
                 $title = rex_i18n::msg('yform_editfield') . ' "' . $type_name . '"';
             }
             $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;
             $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>';
             $fragment = new rex_fragment();
             $fragment->setVar('footer', $table_echo, false);
             echo $fragment->parse('core/page/section.php');
             $func = '';
         } else {
             if ($func == 'edit') {
                 $this->generateAll();
                 echo rex_view::success(rex_i18n::msg('yform_thankyouforupdate'));
             } elseif ($func == 'add') {
                 $this->generateAll();
                 echo rex_view::success(rex_i18n::msg('yform_thankyouforentry'));
             }
             $func = 'list';
         }
     }
     // ********************************************* LOESCHEN
     if ($func == 'delete') {
         $sf = rex_sql::factory();
         $sf->debugsql = self::$debug;
         $sf->setQuery('select * from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id);
         $sfa = $sf->getArray();
         if (count($sfa) == 1) {
             $query = 'delete from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id;
             $delsql = rex_sql::factory();
             $delsql->debugsql = self::$debug;
             $delsql->setQuery($query);
             echo rex_view::success(rex_i18n::msg('yform_tablefielddeleted'));
             $this->generateAll();
         } else {
             echo rex_view::warning(rex_i18n::msg('yform_tablefieldnotfound'));
         }
         $func = 'list';
     }
     // ********************************************* CREATE/UPDATE FIELDS
     if ($func == 'updatetable') {
         $this->generateAll();
         echo rex_view::info(rex_i18n::msg('yform_tablesupdated'));
         $func = 'list';
     }
     if ($func == 'updatetablewithdelete') {
         $this->generateAll(array('delete_fields' => true));
         echo rex_view::info(rex_i18n::msg('yform_tablesupdated'));
         $func = 'list';
     }
     if ($func == 'show_form_notation') {
         $formbuilder_fields = $table->getFields();
         $notation_php = '';
         $notation_pipe = '';
         $notation_email = '';
         $notation_php_pre = array('$yform = new rex_yform();', '$yform->setObjectparams(\'form_skin\', \'default\');', '$yform->setObjectparams(\'form_showformafterupdate\', 0);', '$yform->setObjectparams(\'real_field_names\', true);');
         $notation_php .= implode("\n", $notation_php_pre) . "\n";
         $notation_pipe_pre = array('objparams|form_skin|bootstrap', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true');
         $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n";
         foreach ($formbuilder_fields 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['type_id']);
                 if (isset($field[$key])) {
                     $values[] = $field[$key];
                 } elseif (isset($field['f' . $i])) {
                     $values[] = $field['f' . $i];
                 } else {
                     $values[] = '';
                 }
                 $i++;
             }
             if ($field['type_id'] == 'value') {
                 $notation_php .= "\n" . '$yform->setValueField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                 $notation_email .= "\n" . $field['label'] . ': ###' . $field['name'] . '###';
             } elseif ($field['type_id'] == 'validate') {
                 $notation_php .= "\n" . '$yform->setValidateField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
             } elseif ($field['type_id'] == 'action') {
                 $notation_php .= "\n" . '$yform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
             }
         }
         $notation_php .= "\n\n" . '$yform->setActionField(\'email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));';
         $notation_php .= "\n" . 'echo $yform->getForm();';
         $notation_pipe .= "\n\n" . 'action|email|emailtemplate|emaillabel|email@domain.de';
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'PHP');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_php . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'Pipe');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_pipe . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'E-Mail');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_email . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $func = 'list';
     }
     // ********************************************* LIST
     if ($func == 'list') {
         $show_list = true;
         $show_list = rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, ['table' => $table, 'link_vars' => $this->getLinkVars()]));
         if ($show_list) {
             function rex_yform_list_format($p, $value = '')
             {
                 if ($value != '') {
                     $p['value'] = $value;
                 }
                 switch ($p['list']->getValue('type_id')) {
                     case 'validate':
                         $style = 'color:#aaa;';
                         // background-color:#cfd9d9;
                         break;
                     case 'action':
                         $style = 'background-color:#cfd9d9;';
                         break;
                     default:
                         $style = 'background-color:#eff9f9;';
                         break;
                 }
                 return '<td style="' . $style . '">' . $p['value'] . '</td>';
             }
             function rex_yform_list_edit_format($p)
             {
                 return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit')));
             }
             function rex_yform_list_delete_format($p)
             {
                 return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete')));
             }
             $context = new rex_context($this->getLinkVars());
             $items = [];
             $item = [];
             $item['label'] = rex_i18n::msg('yform_manager_show_form_notation');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'show_form_notation']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'show_form_notation') {
                 $item['attributes']['class'][] = 'active';
             }
             $items[] = $item;
             $item = [];
             $item['label'] = rex_i18n::msg('yform_updatetable');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetable']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'updatetable') {
                 $item['attributes']['class'][] = 'active';
             }
             $items[] = $item;
             $item = [];
             $item['label'] = rex_i18n::msg('yform_updatetable_with_delete');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetablewithdelete']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'updatetablewithdelete') {
                 $item['attributes']['class'][] = 'active';
             }
             $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_updatetable_with_delete_confirm') . '\')';
             $items[] = $item;
             $fragment = new rex_fragment();
             $fragment->setVar('buttons', $items, false);
             $fragment->setVar('size', 'xs', false);
             $panel_options = $fragment->parse('core/buttons/button_group.php');
             $sql = 'select id, prio, type_id, type_name, name from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio';
             $list = rex_list::factory($sql, 30);
             // $list->debug = 1;
             // $list->setColumnFormat('id', 'Id');
             $tdIcon = '<i class="rex-icon rex-icon-table"></i>';
             $thIcon = '<a href="' . $list->getUrl(['table_name' => $table->getTableName(), 'func' => 'choosenadd']) . '"' . 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>']);
             $list->setColumnParams($thIcon, ['field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###']);
             foreach ($this->getLinkVars() as $k => $v) {
                 $list->addParam($k, $v);
             }
             $list->addParam('start', rex_request('start', 'int'));
             $list->addParam('table_name', $table->getTableName());
             $list->removeColumn('id');
             $list->setColumnLabel('prio', rex_i18n::msg('yform_manager_table_prio_short'));
             //$list->setColumnLayout('prio', ['<th class="rex-table-priority">###VALUE###</th>', '<td class="rex-table-priority" data-title="' . rex_i18n::msg('yform_manager_table_prio_short') . '">###VALUE###</td>']);
             $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('prio', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('type_id', rex_i18n::msg('yform_manager_type_id'));
             $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('type_id', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('type_name', rex_i18n::msg('yform_manager_type_name'));
             $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('type_name', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('name', rex_i18n::msg('yform_manager_name'));
             $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###'));
             // ###VALUE###
             $list->setColumnFormat('name', 'custom', 'rex_yform_list_format');
             $list->addColumn(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit'));
             $list->setColumnParams(rex_i18n::msg('yform_function'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###'));
             $list->setColumnLayout(rex_i18n::msg('yform_function'), array('<th class="rex-table-action" colspan="2">###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat(rex_i18n::msg('yform_function'), 'custom', 'rex_yform_list_edit_format');
             $list->addColumn(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete'));
             $list->setColumnParams(rex_i18n::msg('yform_delete'), array('field_id' => '###id###', 'func' => 'delete'));
             $list->setColumnLayout(rex_i18n::msg('yform_delete'), array('', '###VALUE###'));
             $list->setColumnFormat(rex_i18n::msg('yform_delete'), 'custom', 'rex_yform_list_delete_format');
             $list->addLinkAttribute(rex_i18n::msg('yform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . rex_i18n::msg('yform_delete') . ' ?\')');
             $content = $list->get();
             $fragment = new rex_fragment();
             $fragment->setVar('title', rex_i18n::msg('yform_manager_tablefield_overview'));
             $fragment->setVar('options', $panel_options, false);
             $fragment->setVar('content', $content, false);
             $content = $fragment->parse('core/page/section.php');
             echo $content;
         }
     }
 }
Esempio n. 30
0
        return $field;
    }
    public function extendForm(rex_extension_point $ep)
    {
        $params = $ep->getParams();
        // Nur beim EDIT gibts auch ein Medium zum bearbeiten
        if ($ep->getName() == 'MEDIA_FORM_EDIT') {
            $params['activeItem'] = $params['media'];
            unset($params['media']);
            // Hier die category_id setzen, damit keine Warnung entsteht (REX_LINK_BUTTON)
            // $params['activeItem']->setValue('category_id', 0);
        } elseif ($ep->getName() == 'MEDIA_ADDED') {
            $sql = rex_sql::factory();
            $qry = 'SELECT id FROM ' . rex::getTablePrefix() . 'media WHERE filename="' . $params['filename'] . '"';
            $sql->setQuery($qry);
            if ($sql->getRows() == 1) {
                $params['id'] = $sql->getValue('id');
            } else {
                throw new rex_exception('Error occured during file upload!');
            }
        }
        return parent::renderFormAndSave(self::PREFIX, $params);
    }
}
$mediaHandler = new rex_metainfo_media_handler();
rex_extension::register('MEDIA_FORM_EDIT', [$mediaHandler, 'extendForm']);
rex_extension::register('MEDIA_FORM_ADD', [$mediaHandler, 'extendForm']);
rex_extension::register('MEDIA_ADDED', [$mediaHandler, 'extendForm']);
rex_extension::register('MEDIA_UPDATED', [$mediaHandler, 'extendForm']);
rex_extension::register('MEDIA_IS_IN_USE', ['rex_metainfo_media_handler', 'isMediaInUse']);