protected function getOutput()
 {
     $id = $this->getArg('id', 0, true);
     if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
         return false;
     }
     $value = $this->getContextData()->getValue('value' . $id);
     if ($this->hasArg('isset') && $this->getArg('isset')) {
         return $value ? 'true' : 'false';
     }
     if ($this->hasArg('widget') && $this->getArg('widget')) {
         if (!$this->environmentIs(self::ENV_INPUT)) {
             return false;
         }
         $select = new rex_category_select();
         if ($this->hasArg('multiple') && $this->getArg('multiple')) {
             $select->setName('REX_INPUT_VALUE[' . $id . '][]');
             $select->setMultiple();
             $select->setSelected(rex_var::toArray($value));
         } else {
             $select->setName('REX_INPUT_VALUE[' . $id . ']');
             $select->setSelected($value);
         }
         if ($this->hasArg('root') && $this->getArg('root')) {
             $select->setRootId(explode(',', $this->getArg('root')));
         }
         $widget = '<div class="rex-select-style">' . $select->get() . '</div>';
         if ($this->hasArg('output') && $this->getArg('output')) {
             $label = $this->hasArg('label') ? $this->getArg('label') : '';
             $widget = Dao::getForm($widget, $label, $this->getArg('output'));
         }
         return self::quote($widget);
     }
     return self::quote(htmlspecialchars($value));
 }
예제 #2
0
									  <p class="rex-form-col-a rex-form-submit">
											<input class="rex-form-submit" type="submit" name="copyarticle" value="' . $I18N->msg('content_submitcopyarticle') . '"' . rex_tabindex() . ' onclick="return confirm(\'' . $I18N->msg('content_submitcopyarticle') . '?\')" />
									  </p>
								  </div>
								  
								  <div class="rex-clearer"></div>
								</div>
              </fieldset>';
            }
            // --------------------------------------------------- ARTIKEL KOPIEREN ENDE
            // --------------------------------------------------- KATEGORIE/STARTARTIKEL VERSCHIEBEN START
            if ($isStartpage && ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('moveCategory[]') && $REX['USER']->hasCategoryPerm($article->getValue('re_id')))) {
                $move_a = new rex_category_select(false, false, true, !$REX['USER']->hasMountPoints());
                $move_a->setStyle('class="rex-form-select"');
                $move_a->setId('category_id_new');
                $move_a->setName('category_id_new');
                $move_a->setSize('1');
                $move_a->setSelected($article_id);
                $move_a->setAttribute('tabindex', rex_tabindex(false));
                $out .= '
              <fieldset class="rex-form-col-1">
                <legend>' . $I18N->msg('content_submitmovecategory') . '</legend>

					      <div class="rex-form-wrapper">
					      
					      	<div class="rex-form-row">
								  	<p class="rex-form-col-a rex-form-select">
											<label for="category_id_new">' . $I18N->msg('move_category') . '</label>
											' . $move_a->get() . '
									  </p>
									</div>
예제 #3
0
 // Module ...
 $modul_select = new rex_select();
 $modul_select->setMultiple(true);
 $modul_select->setStyle('class="rex-form-select"');
 $modul_select->setSize(10);
 $m_sql = rex_sql::factory();
 $m_sql->setQuery('SELECT id, name FROM ' . $REX['TABLE_PREFIX'] . 'module ORDER BY name');
 foreach ($m_sql->getArray() as $m) {
     $modul_select->addOption(rex_translate($m['name'], $I18N, false), $m['id']);
 }
 // Kategorien
 $cat_select = new rex_category_select(false, false, false, false);
 $cat_select->setMultiple(true);
 $cat_select->setStyle('class="rex-form-select"');
 $cat_select->setSize(10);
 $cat_select->setName('categories[]');
 $cat_select->setId('categories');
 if (count($categories) > 0) {
     foreach ($categories as $c => $cc) {
         // typsicherer vergleich, weil (0 != "all") => false
         if ($c !== 'all') {
             $cat_select->setSelected($cc);
         }
     }
 }
 $ctypes_out = '';
 $i = 1;
 $ctypes[] = '';
 // Extra, fŸr Neue Spalte
 if (is_array($ctypes)) {
     foreach ($ctypes as $id => $name) {
/**
 * Backend Search Addon
 *
 * @author markus[dot]staab[at]redaxo[dot]de Markus Staab
 *
 * @package redaxo4
 * @version $Id: extension_search_structure.inc.php,v 1.2 2008/04/12 10:22:30 kills Exp $
 */
function rex_a256_search_structure($params)
{
    global $REX, $REX_USER, $I18N_BE_SEARCH;
    if (!($REX_USER->isAdmin() || $REX_USER->hasPerm('be_search[structure]'))) {
        return $params['subject'];
    }
    $message = '';
    $search_result = '';
    $editUrl = 'index.php?page=content&article_id=%s&mode=edit&clang=%s&a256_article_name=%s';
    $structureUrl = 'index.php?page=structure&category_id=%s&clang=%s&a256_article_name=%s';
    // ------------ globale Parameter
    $page = rex_request('page', 'string');
    $mode = rex_request('mode', 'string');
    $category_id = rex_request('category_id', 'int');
    $article_id = rex_request('article_id', 'int');
    $clang = rex_request('clang', 'int');
    $ctype = rex_request('ctype', 'int');
    // ------------ Parameter
    $a256_article_id = rex_request('a256_article_id', 'int');
    $a256_clang = rex_request('a256_clang', 'int');
    $a256_article_name = rex_request('a256_article_name', 'string');
    $a256_article_name_post = rex_post('a256_article_name', 'string');
    $mode = rex_request('mode', 'string');
    // ------------ Suche via ArtikelId
    if ($a256_article_id != 0) {
        $OOArt = OOArticle::getArticleById($a256_article_id, $a256_clang);
        if (OOArticle::isValid($OOArt)) {
            header('Location:' . sprintf($editUrl, $a256_article_id, $a256_clang, urlencode($a256_article_name)));
            exit;
        }
    }
    // Auswahl eines normalen Artikels => category holen
    if ($article_id != 0) {
        $OOArt = OOArticle::getArticleById($article_id, $clang);
        $category_id = $OOArt->getCategoryId();
    }
    // ------------ Suche via ArtikelName
    // hier nur dne post artikel namen abfragen,
    // da sonst bei vorherigen headerweiterleitungen
    // auch gesucht wuerde
    if ($a256_article_name_post != '') {
        $qry = '
    SELECT id
    FROM ' . $REX['TABLE_PREFIX'] . 'article
    WHERE
      clang = ' . $a256_clang . ' AND
      (
        name LIKE "%' . $a256_article_name . '%" OR
        catname LIKE "%' . $a256_article_name . '%"
      )';
        if ($category_id != 0) {
            $qry .= ' AND path LIKE "%|' . $category_id . '|%"';
        }
        $search = new rex_sql();
        //    $search->debugsql = true;
        $search->setQuery($qry);
        $foundRows = $search->getRows();
        // Suche ergab nur einen Treffer => Direkt auf den Treffer weiterleiten
        if ($foundRows == 1) {
            $OOArt = OOArticle::getArticleById($search->getValue('id'), $a256_clang);
            if ($REX_USER->hasCategoryPerm($OOArt->getCategoryId())) {
                header('Location:' . sprintf($editUrl, $search->getValue('id'), $a256_clang, urlencode($a256_article_name)));
                exit;
            }
        } else {
            if ($foundRows > 0) {
                $search_result .= '<ul class="a256-search-result">';
                for ($i = 0; $i < $foundRows; $i++) {
                    $OOArt = OOArticle::getArticleById($search->getValue('id'), $a256_clang);
                    $label = $OOArt->getName();
                    if ($REX_USER->hasCategoryPerm($OOArt->getCategoryId())) {
                        if ($REX_USER->hasPerm('advancedMode[]')) {
                            $label .= ' [' . $search->getValue('id') . ']';
                        }
                        $s = '';
                        $first = true;
                        foreach ($OOArt->getParentTree() as $treeItem) {
                            $treeLabel = $treeItem->getName();
                            if ($REX_USER->hasPerm('advancedMode[]')) {
                                $treeLabel .= ' [' . $treeItem->getId() . ']';
                            }
                            $prefix = ': ';
                            if ($first) {
                                $prefix = '';
                                $first = false;
                            }
                            $s .= '<li>' . $prefix . '<a href="' . sprintf($structureUrl, $treeItem->getId(), $a256_clang, urlencode($a256_article_name)) . '">' . htmlspecialchars($treeLabel) . ' </a></li>';
                        }
                        $prefix = ': ';
                        if ($first) {
                            $prefix = '';
                            $first = false;
                        }
                        $s .= '<li>' . $prefix . '<a href="' . sprintf($editUrl, $search->getValue('id'), $a256_clang, urlencode($a256_article_name)) . '">' . htmlspecialchars($label) . ' </a></li>';
                        $search_result .= '<li><ul class="a256-search-hit">' . $s . '</ul></li>';
                    }
                    $search->next();
                }
                $search_result .= '</ul>';
            } else {
                $message = rex_warning($I18N_BE_SEARCH->msg('search_no_results'));
            }
        }
    }
    $select_name = 'category_id';
    $add_homepage = true;
    if ($mode == 'edit' || $mode == 'meta') {
        $select_name = 'article_id';
        $add_homepage = false;
    }
    $category_select = new rex_category_select(false, false, true, $add_homepage);
    $category_select->setName($select_name);
    $category_select->setId('rex-a256-category-id');
    $category_select->setSize('1');
    $category_select->setAttribute('onchange', 'this.form.submit();');
    $category_select->setSelected($category_id);
    $form = '  <form action="index.php" method="post">
        <input type="hidden" name="page" id="rex-a256-article-clang" value="' . $page . '" />
        <input type="hidden" name="mode" id="rex-a256-article-clang" value="' . $mode . '" />
        <input type="hidden" name="category_id" id="rex-a256-article-clang" value="' . $category_id . '" />
        <input type="hidden" name="article_id" id="rex-a256-article-clang" value="' . $article_id . '" />
        <input type="hidden" name="clang" id="rex-a256-article-clang" value="' . $clang . '" />
        <input type="hidden" name="ctype" id="rex-a256-article-clang" value="' . $ctype . '" />
        <input type="hidden" name="a256_clang" id="rex-a256-article-clang" value="' . $clang . '" />

		    <div class="rex-f-lft">
	        <label for="rex-a256-article-name">' . $I18N_BE_SEARCH->msg('search_article_name') . '</label>
    	    <input type="text" name="a256_article_name" id="rex-a256-article-name" value="' . htmlspecialchars(stripslashes($a256_article_name)) . '"' . rex_tabindex() . ' />

        	<label for="rex-a256-article-id">' . $I18N_BE_SEARCH->msg('search_article_id') . '</label>
	        <input type="text" name="a256_article_id" id="rex-a256-article-id"' . rex_tabindex() . ' />
    	    <input class="rex-sbmt" type="submit" name="a256_start_search" value="' . $I18N_BE_SEARCH->msg('search_start') . '"' . rex_tabindex() . ' />
		    </div>

    		<div class="rex-f-rght">
    			<label for="rex-a256-category-id">' . $I18N_BE_SEARCH->msg('search_quick_navi') . '</label>';
    $category_select->setAttribute('tabindex', rex_tabindex(false));
    $form .= $category_select->get() . '
    			<noscript>
    			  <input type="submit" name="a256_start_jump" value="' . $I18N_BE_SEARCH->msg('search_jump_to_category') . '" />
    			</noscript>
        </div>
      </form>';
    $search_bar = $message . '<div id="rex-a256-searchbar">
     ' . $form . '
     ' . $search_result . '
   </div>
   <div class="rex-clearer"></div>';
    return $search_bar . $params['subject'];
}
예제 #5
0
/**
 * @param rex_context $context
 *
 * @return string
 *
 * @package redaxo\structure
 */
function rex_structure_searchbar(rex_context $context)
{
    $message = '';
    $search_result = '';
    // ------------ Parameter
    $clang = $context->getParam('clang', 1);
    $category_id = $context->getParam('category_id', 0);
    $article_id = $context->getParam('article_id', 0);
    $search_article_name = rex_request('search_article_name', 'string');
    // ------------ Suche via ArtikelId
    if (preg_match('/^[0-9]+$/', $search_article_name, $matches)) {
        if ($OOArt = rex_article::get($matches[0], $clang)) {
            rex_response::sendRedirect($context->getUrl(['page' => 'content/edit', 'article_id' => $OOArt->getId()], false));
        }
    }
    // Auswahl eines normalen Artikels => category holen
    if ($article_id != 0) {
        $OOArt = rex_article::get($article_id, $clang);
        // Falls Artikel gerade geloescht wird, gibts keinen rex_article
        if ($OOArt) {
            $category_id = $OOArt->getCategoryId();
        }
    }
    // ------------ Suche via ArtikelName
    if (rex_request('search_start', 'bool')) {
        // replace LIKE wildcards
        $search_article_name_like = str_replace(['_', '%'], ['\\_', '\\%'], $search_article_name);
        $qry = '
        SELECT id
        FROM ' . rex::getTablePrefix() . 'article
        WHERE
            clang_id = ' . $clang . ' AND
            (
                name LIKE "%' . $search_article_name_like . '%" OR
                catname LIKE "%' . $search_article_name_like . '%"
            )';
        if (rex_addon::get('structure')->getConfig('searchmode', 'local') != 'global') {
            // Suche auf aktuellen Kontext eingrenzen
            if ($category_id != 0) {
                $qry .= ' AND path LIKE "%|' . $category_id . '|%"';
            }
        }
        $search = rex_sql::factory();
        //    $search->setDebug();
        $search->setQuery($qry);
        $foundRows = $search->getRows();
        // Suche ergab nur einen Treffer => Direkt auf den Treffer weiterleiten
        if ($foundRows == 1) {
            $OOArt = rex_article::get($search->getValue('id'), $clang);
            if (rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($OOArt->getCategoryId())) {
                rex_response::sendRedirect($context->getUrl(['page' => 'content/edit', 'article_id' => $search->getValue('id')], false));
            }
        } elseif ($foundRows > 0) {
            $needle = htmlspecialchars($search_article_name);
            $search_result .= '<div class="list-group">';
            for ($i = 0; $i < $foundRows; ++$i) {
                $breadcrumb = [];
                $OOArt = rex_article::get($search->getValue('id'), $clang);
                $label = $OOArt->getName();
                if (rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($OOArt->getCategoryId())) {
                    $label .= ' [' . $search->getValue('id') . ']';
                    $highlightHit = function ($string, $needle) {
                        return preg_replace('/(.*)(' . preg_quote($needle, '/') . ')(.*)/i', '\\1<mark>\\2</mark>\\3', $string);
                    };
                    foreach ($OOArt->getParentTree() as $treeItem) {
                        $treeLabel = $treeItem->getName();
                        if (rex::getUser()->hasPerm('advancedMode[]')) {
                            $treeLabel .= ' [' . $treeItem->getId() . ']';
                        }
                        $treeLabel = htmlspecialchars($treeLabel);
                        $treeLabel = $highlightHit($treeLabel, $needle);
                        $e = [];
                        $e['title'] = $treeLabel;
                        $e['href'] = $context->getUrl(['page' => 'structure', 'category_id' => $treeItem->getId()]);
                        $breadcrumb[] = $e;
                    }
                    $label = htmlspecialchars($label);
                    $label = $highlightHit($label, $needle);
                    $e = [];
                    $e['title'] = $label;
                    $e['href'] = $context->getUrl(['page' => 'content/edit', 'article_id' => $treeItem->getId()]);
                    $breadcrumb[] = $e;
                    $fragment = new rex_fragment();
                    $fragment->setVar('items', $breadcrumb, false);
                    $search_result .= '<div class="list-group-item">' . $fragment->parse('core/navigations/breadcrumb.php') . '</div>';
                }
                $search->next();
            }
            $search_result .= '</div>';
            $fragment = new rex_fragment();
            $fragment->setVar('title', rex_i18n::msg('be_search_result'), false);
            $fragment->setVar('content', $search_result, false);
            $search_result = $fragment->parse('core/page/section.php');
        } else {
            $message = rex_view::info(rex_i18n::msg('be_search_no_results'));
        }
    }
    $select_name = 'category_id';
    $add_homepage = true;
    if (rex_be_controller::getCurrentPagePart(1) == 'content') {
        $select_name = 'article_id';
        $add_homepage = false;
    }
    $category_select = new rex_category_select(false, false, true, $add_homepage);
    $category_select->setName($select_name);
    $category_select->setSize('1');
    $category_select->setAttribute('onchange', 'this.form.submit();');
    $category_select->setSelected($category_id);
    $select = $category_select->get();
    $doc = new DOMDocument();
    $doc->loadHTML('<?xml encoding="UTF-8">' . $select);
    $options = $doc->getElementsByTagName('option');
    $droplistContext = new rex_context(['page' => 'structure', 'category_id' => 0]);
    $button_label = '';
    $items = [];
    foreach ($options as $option) {
        $value = '';
        $item = [];
        if ($option->hasAttributes()) {
            foreach ($option->attributes as $attribute) {
                if ($attribute->name == 'value') {
                    $value = $attribute->value;
                    $droplistContext->setParam('category_id', $value);
                    if ($attribute->value == $category_id) {
                        $button_label = str_replace(" ", '', $option->nodeValue);
                        $item['active'] = true;
                    }
                }
            }
        }
        $item['title'] = preg_replace('/\\[([0-9]+)\\]$/', '<small class="rex-primary-id">$1</small>', $option->nodeValue);
        $item['href'] = $droplistContext->getUrl();
        $items[] = $item;
    }
    $fragment = new rex_fragment();
    $fragment->setVar('button_prefix', rex_i18n::msg('be_search_quick_navi'));
    $fragment->setVar('button_label', $button_label);
    $fragment->setVar('items', $items, false);
    $droplist = '<div class="navbar-btn navbar-right">' . $fragment->parse('core/dropdowns/dropdown.php');
    $formElements = [];
    $n = [];
    $n['field'] = '<input class="form-control" type="text" name="search_article_name" value="' . htmlspecialchars($search_article_name) . '" placeholder="' . htmlspecialchars(rex_i18n::msg('be_search_article_name') . '/' . rex_i18n::msg('be_search_article_id')) . '" />';
    $n['right'] = '<button class="btn btn-search" type="submit" name="search_start" value="1">' . rex_i18n::msg('be_search_start') . '</button>';
    $formElements[] = $n;
    $fragment = new rex_fragment();
    $fragment->setVar('elements', $formElements, false);
    $toolbar = $fragment->parse('core/form/input_group.php');
    $toolbar = '
    <form action="' . rex_url::currentBackendPage() . '" method="post">
    ' . $context->getHiddenInputFields() . '
    <div class="navbar-form navbar-left">
        <div class="form-group">
            ' . $toolbar . '
        </div>
    </div>
    </form>';
    $toolbar = rex_view::toolbar($toolbar . $droplist, rex_i18n::msg('be_search_search'));
    return $toolbar . $search_result;
}
예제 #6
0
$sel_ext = new rex_select();
$sel_ext->setMultiple(1);
$sel_ext->setStyle('class="rex-form-select"');
$sel_ext->setSize(10);
$sel_ext->setName('userperm_ext[]');
$sel_ext->setId('userperm-ext');
sort($REX['EXTPERM']);
$sel_ext->addArrayOptions($REX['EXTPERM'], false);
$userperm_ext = rex_request('userperm_ext', 'array');
$allcats = rex_request('allcats', 'int');
// zugriff auf categorien
$sel_cat = new rex_category_select(false, false, false, false);
$sel_cat->setMultiple(1);
$sel_cat->setStyle('class="rex-form-select"');
$sel_cat->setSize(20);
$sel_cat->setName('userperm_cat[]');
$sel_cat->setId('userperm-cat');
$userperm_cat = rex_request('userperm_cat', 'array');
$allmcats = rex_request('allmcats', 'int');
$userperm_cat_read = rex_request('userperm_cat_read', 'array');
// zugriff auf mediacategorien
$sel_media = new rex_mediacategory_select(false);
$sel_media->setMultiple(1);
$sel_media->setStyle('class="rex-form-select"');
$sel_media->setSize(20);
$sel_media->setName('userperm_media[]');
$sel_media->setId('userperm-media');
$userperm_media = rex_request('userperm_media', 'array');
// zugriff auf sprachen
$sel_sprachen = new rex_select();
$sel_sprachen->setMultiple(1);