getArray() 공개 메소드

Laedt das komplette Resultset in ein Array und gibt dieses zurueck.
public getArray ( string $query = null, array $params = [], integer $fetchType = PDO::FETCH_ASSOC ) : array
$query string The sql-query
$params array An optional array of statement parameter
$fetchType integer
리턴 array
 function execute()
 {
     $table = $this->action["elements"][2];
     // Tabelle vorhanden ?
     $sql = new rex_sql();
     $sql->debug = 1;
     $sql->setQuery('show tables');
     $table_exists = FALSE;
     foreach ($sql->getArray() as $k => $v) {
         if ($table == $v) {
             $table_exists = TRUE;
             break;
         }
     }
     if (!$table_exists) {
         $sql->setQuery('CREATE TABLE `' . $table . '` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY);');
     }
     // Welche Felder sind vorhanden ?
     $sql->setQuery('show columns from ' . $table);
     $sql_cols = $sql->getArray();
     $cols = array();
     foreach ($sql_cols as $k => $v) {
         $cols[] = $v['Field'];
     }
     // wenn Feld nicht in Datenbank, dann als TEXT anlegen.
     foreach ($this->elements_sql as $key => $value) {
         if (!in_array($key, $cols)) {
             $sql->setQuery('ALTER TABLE `' . $table . '` ADD `' . $key . '` TEXT NOT NULL;');
         }
     }
     return;
 }
function rex_a128_historyHandler($params)
{
    global $page, $subpage, $REX_USER, $REX;
    $mypage = $params['mypage'];
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyManager.inc.php';
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_history.inc.php';
    require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyItem.inc.php';
    $function = rex_request('function', 'string');
    $mode = rex_request('mode', 'string');
    // Alle Histories registrierens
    $articleHistory =& rexHistoryManager::getHistory('articles');
    $templateHistory =& rexHistoryManager::getHistory('templates');
    $moduleHistory =& rexHistoryManager::getHistory('modules');
    $actionHistory =& rexHistoryManager::getHistory('actions');
    $sql = new rex_sql();
    $sql->debugsql = true;
    if ($page == 'module' && $function == 'edit' && ($module_id = rex_get('modul_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'modultyp WHERE id=' . $module_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&function=' . $function . '&modul_id=' . $module_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $module_id . ']';
            }
            $moduleHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'module' && $subpage == 'actions' && $function == 'edit' && ($action_id = rex_get('action_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'action WHERE id=' . $action_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&subpage=' . $subpage . '&function=' . $function . '&modul_id=' . $action_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $action_id . ']';
            }
            $actionHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'template' && $function == 'edit' && ($template_id = rex_get('template_id', 'int')) != 0) {
        $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id=' . $template_id);
        if (isset($result[0])) {
            $link = 'index.php?page=' . $page . '&function=' . $function . '&template_id=' . $template_id;
            $title = $result[0]['name'];
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $template_id . ']';
            }
            $templateHistory->addItem(new rexHistoryItem($title, $link));
        }
    } elseif ($page == 'content' && $mode == 'edit' && ($article_id = rex_get('article_id', 'int')) != 0) {
        $art = OOArticle::getArticleById($article_id);
        if (OOArticle::isValid($art)) {
            $link = 'index.php?page=' . $page . '&mode=' . $mode . '&article_id=' . $article_id;
            $title = $art->getName();
            if ($REX_USER->hasPerm('advancedMode[]')) {
                $title .= ' [' . $article_id . ']';
            }
            $articleHistory->addItem(new rexHistoryItem($title, $link));
        }
    }
}
예제 #3
0
function a587_getCategories($_ignoreoffline = true, $_onlyIDs = false, $_cats = false)
{
    global $REX;
    $return = array();
    if (!empty($_cats)) {
        $whereCats = array();
        $sqlCats = array();
        if (is_array($_cats)) {
            foreach ($_cats as $catID) {
                $whereCats[] = "path LIKE '%|" . intval($catID) . "|%'";
                $sqlCats[] = intval($catID);
            }
        }
        $return = array();
        $query = 'SELECT id,catname,path FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE startpage = 1';
        if (empty($REX['ADDON']['settings']['rexsearch']['indexoffline']) and $_ignoreoffline) {
            $query .= ' AND status = 1';
        }
        if (!empty($whereCats)) {
            $query .= ' AND (' . implode(' OR ', $whereCats) . ' OR (id IN (' . implode(',', $sqlCats) . ')))';
        }
        $query .= ' GROUP BY id ORDER BY id';
        $sql = new rex_sql();
        foreach ($sql->getArray($query) as $cat) {
            if ($_onlyIDs) {
                $return[] = $cat['id'];
            } else {
                $return[$cat['id']] = $cat['catname'];
            }
        }
    } else {
        $query = 'SELECT id,re_id,catname,path FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE startpage = 1 AND re_id=%d';
        if (empty($REX['ADDON']['settings']['rexsearch']['indexoffline']) and $_ignoreoffline) {
            $query .= ' AND status = 1';
        }
        $query .= ' GROUP BY id ORDER BY catprior,id';
        $sql = new rex_sql();
        $cats = $sql->getArray(sprintf($query, 0));
        while (!empty($cats)) {
            $cat = array_shift($cats);
            if ($_onlyIDs) {
                $return[] = $cat['id'];
            } else {
                $return[$cat['id']] = str_repeat(' ', substr_count($cat['path'], '|') * 2 - 2) . $cat['catname'];
            }
            array_splice($cats, 0, 0, $sql->getArray(sprintf($query, $cat['id'])));
        }
    }
    return $return;
}
예제 #4
0
 private function showList($cat)
 {
     $addSql = "";
     $cats = explode("~~", $cat);
     if (!in_array(999, $cats)) {
         $addSql = 'AND category LIKE \'%|';
         $addSql .= implode('|%\' OR category LIKE \'%|', $cats);
         $addSql .= '|%\'';
     }
     $addWhere = ' WHERE (
             ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
             AND
             ((archive_date = "0000-00-00") OR REPLACE(archive_date, "-", "") > CURDATE() + 0)
             AND 
             ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
     )';
     $qry = "\tSELECT * \r\n\t\t\t\t\tFROM " . TBL_NEWS . " \r\n                    " . $addWhere . "\r\n\t\t\t\t\tAND status=1 \r\n                    " . $addSql . "\r\n\t\t\t\t\tORDER BY online_date DESC\r\n\t\t\t\t";
     $sql = new rex_sql();
     #$sql->debugsql = true;
     $data = $sql->getArray($qry);
     /* create one master array of the records */
     $posts = array();
     foreach ($data as $row) {
         $posts[] = array('post' => $row);
     }
     return $posts;
 }
예제 #5
0
/**
 * Vorgehensweise
 * Die install.sql muss bereits ausgeführt worden sein und die Module und
 * Action somit bereits in der Datenbank stehen.
 * Als erstes werden die IDs des Modules "Gästebuch - Eintragsliste" und der
 * Action "Gästebuch - Eintragsliste StatusPerdatei" ausgelesen und dann nachgesehen,
 * ob es dazu schon eine Zuweisung in der Tabelle rex_module_action gibt.
 * Ist das nicht der Fall, werden die IDs entsprechend eingetragen.
 *
 * Die automatische Zuweisung zwischen Action und Modul ist damit erledigt.
 * Im Fehlerfalle muss eine Meldung ausgegeben werden.
 * Die Action könnte dann evtl. per Hand noch zugewiesen werden.
 *
 *
 * @param   string  Name des Modules (auf richtige Schreibweise achten!)
 * @param   string  Name der Action (auf richtige Schreibweise achten!)
 * @return  mixed   TRUE oder ein Fehlertext
 */
function rex_a63_installAction2Modul($modul_name, $action_name)
{
    global $REX;
    if (!isset($modul_name) or $modul_name == '' or !isset($action_name) or $action_name == '') {
        return 'rex_a63_installAction2Modul: Keinen Modul- oder Aktionname übergeben.';
    }
    /**
     * Diese Abfrage gibt zurück
     * - wenn es bereits eine Verküpfung in der Tabelle rex_module_action gibt:
     * m_id  a_id  mod_action_m_id   mod_action_a_id
     *  42     9       true             true
     *
     * - gibt es noch keine Verknüpfung, sieht die Rückgabe so aus:
     * m_id  a_id  mod_action_m_id   mod_action_a_id
     *  42     9       false             false
     *
     * m_id und a_id sind von MySQL vergebene IDs und entsprechen nicht diesem Beispiel hier!
     *
     */
    $qry = 'SELECT `' . $REX['TABLE_PREFIX'] . 'module`.`id` AS m_id, `' . $REX['TABLE_PREFIX'] . 'action`.`id` AS a_id,
            IF(`' . $REX['TABLE_PREFIX'] . 'module_action`.`module_id` != 0, "true", "false") AS mod_action_m_id,
            IF(`' . $REX['TABLE_PREFIX'] . 'module_action`.`action_id` != 0, "true", "false") AS mod_action_a_id
          FROM (`' . $REX['TABLE_PREFIX'] . 'module` , `' . $REX['TABLE_PREFIX'] . 'action`)
          LEFT JOIN `' . $REX['TABLE_PREFIX'] . 'module_action` ON ( `' . $REX['TABLE_PREFIX'] . 'module_action`.`module_id` = `' . $REX['TABLE_PREFIX'] . 'module`.`id`
            AND `' . $REX['TABLE_PREFIX'] . 'module_action`.`action_id` = `' . $REX['TABLE_PREFIX'] . 'action`.`id` )
          WHERE `' . $REX['TABLE_PREFIX'] . 'module`.`name` = "' . $modul_name . '"
            AND `' . $REX['TABLE_PREFIX'] . 'action`.`name` = "' . $action_name . '"
          LIMIT 1';
    $sql = new rex_sql();
    //$sql->debugsql = true;
    $data = $sql->getArray($qry);
    if (is_array($data) and $sql->getRows() == 1) {
        foreach ($data as $row) {
            // prüfe IDs auf vorhandensein
            // sind diese IDs in dieser Kombination noch nicht in der Verknüpfungstabelle
            // dann können sie dort eingetragen werden
            if ($row['mod_action_m_id'] == 'false' and $row['mod_action_a_id'] == 'false') {
                $qry = 'INSERT INTO `' . $REX['TABLE_PREFIX'] . 'module_action` ( `id` , `module_id` , `action_id` )
                VALUES (NULL , "' . $row['m_id'] . '", "' . $row['a_id'] . '")';
                $sql2 = new rex_sql();
                //$sql->debugsql = true;
                $sql2->setQuery($qry);
                if (!$REX['a63_sql_compare']) {
                    $sql2->freeResult();
                }
            } else {
                return 'rex_a63_installAction2Modul: Es exitiert bereits eine Zuweisung zwischen dem Modul "' . $modul_name . '" und der Aktion "' . $action_name . '".';
            }
        }
    } else {
        return 'rex_a63_installAction2Modul: Fehler in der Datenbankabfrage. Ist der Modulname "' . $modul_name . '" und der Aktionname "' . $action_name . '" richtig?';
    }
    if (!$REX['a63_sql_compare']) {
        $sql->freeResult();
    }
    return true;
}
 function execute()
 {
     $subject_key = $this->action["elements"][2];
     $body_key = $this->action["elements"][3];
     $user_id_key = $this->action["elements"][4];
     foreach ($this->elements_sql as $key => $value) {
         if ($subject_key == $key) {
             $subject = $value;
         }
         if ($body_key == $key) {
             $body = $value;
         }
         if ($user_id_key == $key) {
             $from_user_id = $value;
         }
         // echo "<br /> $key => $value";
     }
     if ($subject == "" or $body == "" or $from_user_id == "") {
         return FALSE;
     }
     // User auslesen
     $gu = new rex_sql();
     // $gu->debugsql = 1;
     // $gu->setQuery('select * from rex_com_user where id<>"'.$from_user_id.'" order by id');
     $gu->setQuery('select * from rex_com_user order by id');
     foreach ($gu->getArray() as $user) {
         $user_body = $body;
         $user_subject = $subject;
         $to_user_id = $user["id"];
         // Empfaenger einbauen
         $in = new rex_sql();
         // $in->debugsql = 1;
         $in->setTable("rex_com_message");
         $in->setValue("user_id", $to_user_id);
         $in->setValue("from_user_id", $from_user_id);
         $in->setValue("to_user_id", $to_user_id);
         $in->setValue("subject", $user_subject);
         $in->setValue("body", $user_body);
         $in->setValue("create_datetime", time());
         $in->insert();
         /*
         $in = new rex_sql;
         // $in->debugsql = 1;
         $in->setTable("rex_com_message");
         $in->setValue("user_id",$from_user_id);
         $in->setValue("from_user_id",$from_user_id);
         $in->setValue("to_user_id",$to_user_id);
         $in->setValue("subject",$user_subject);
         $in->setValue("body",$user_body);
         $in->setValue("create_datetime",time());
         $in->insert();
         */
         rex_com_user::exeAction($to_user_id, "sendemail_newmessage", $user);
     }
 }
    function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0)
    {
        // ***** SELECT FESTLEGEN
        $SEL = new rex_select();
        $SEL->setName('FORM[' . $this->params["form_name"] . '][el_' . $this->id . '][]');
        $SEL->setId("el_" . $this->id);
        $SEL->setSize(5);
        $SEL->setMultiple(1);
        // ***** SQL - ROHDATEN ZIEHEN
        $sql = $this->elements[5];
        $teams = new rex_sql();
        $teams->debugsql = $this->params["debug"];
        $teams->setQuery($sql);
        for ($t = 0; $t < $teams->getRows(); $t++) {
            $SEL->addOption($teams->getValue($this->elements[7]), $teams->getValue($this->elements[6]));
            $teams->next();
        }
        $wc = "";
        // if (isset($warning["el_" . $this->getId()])) $wc = $warning["el_" . $this->getId()];
        $SEL->setStyle('class="multipleselect ' . $wc . '"');
        // ***** EINGELOGGT ODER NICHT SETZEN
        if ($send == 0) {
            // erster aufruf
            // Daten ziehen
            if ($this->params["main_id"] > 0) {
                $this->value = array();
                $g = new rex_sql();
                $g->debugsql = $this->params["debug"];
                $g->setQuery('select ' . $this->elements[3] . ' from ' . $this->elements[1] . ' where ' . $this->elements[2] . '=' . $this->params["main_id"]);
                $gg = $g->getArray();
                if (is_array($gg)) {
                    foreach ($gg as $g) {
                        $this->value[] = $g[$this->elements[3]];
                    }
                }
            }
        }
        // ***** AUSWAHL SETZEN
        if (is_array($this->value)) {
            foreach ($this->value as $val) {
                $SEL->setSelected($val);
            }
        }
        // ***** AUSGEBEN
        $form_output[] = '
			<p class="formmultipleselect">
				<label class="multipleselect ' . $wc . '" for="el_' . $this->id . '" >' . $this->elements[4] . '</label>
				' . $SEL->get() . '
			</p>';
    }
 function getContactsAsArray()
 {
     if (is_array($this->contacts)) {
         return $this->contacts;
     }
     $this->contacts = array();
     $gc = new rex_sql();
     // $gc->debugsql = 1;
     $gc->setQuery('select * from rex_com_contact where user_id=' . $this->user_id . ' and accepted=1');
     $res = $gc->getArray();
     foreach ($res as $con) {
         $this->contacts[] = $con["to_user_id"];
     }
     return $this->contacts;
 }
 function execute()
 {
     foreach ($this->elements_email as $k => $v) {
         if ($this->action["elements"][4] == $k) {
             $value = $v;
         }
     }
     $gd = new rex_sql();
     // $gd->debugsql = 1;
     $gd->setQuery('select * from ' . $this->action["elements"][2] . ' where ' . $this->action["elements"][3] . '="' . addslashes($value) . '"');
     if ($gd->getRows() == 1) {
         $ar = $gd->getArray();
         foreach ($ar[0] as $k => $v) {
             $this->elements_email[$k] = $v;
         }
     }
     // $email_elements[$this->elements[1]] = stripslashes($this->value);
     // if ($this->elements[4] != "no_db") $sql_elements[$this->elements[1]] = $this->value;
     return;
 }
 function a724_generatePathnamesFromTable($params)
 {
     $debug = false;
     $sql = new rex_sql();
     $results = $sql->getArray('SELECT article_id, url_table, url_table_parameters FROM rex_a724_frau_schultze WHERE url_table != "" AND url_table_parameters != ""');
     $URLPATH = array();
     if ($sql->getRows() >= 1) {
         a724_deletePathnamesFromTable();
         foreach ($results as $result) {
             if (is_array($result) && count($result) > 0) {
                 $path = rex_getUrl($result['article_id']) . '/';
                 $path = str_replace('.html', '', $path);
                 $table = $result['url_table'];
                 $params = unserialize($result['url_table_parameters']);
                 $col_name = $params[$table][$table . "_name"];
                 $col_id = $params[$table][$table . "_id"];
                 // Daten zum Aufbau der Urls holen
                 $sqlu = new rex_sql();
                 $sqlu->setDebug($debug);
                 $res = $sqlu->getArray('SELECT ' . $col_name . ' AS name, ' . $col_id . ' AS id FROM ' . $table);
                 if ($sqlu->getRows() >= 1) {
                     // Urls in die Datenbank schreiben
                     $sqli = new rex_sql();
                     $sqli->setDebug($debug);
                     foreach ($res as $re) {
                         $table_path = $path . strtolower(rex_parse_article_name($re['name'])) . '.html';
                         $table_id = $re['id'];
                         $URLPATH[$result['url_table']][$table_id] = $table_path;
                         $sqli->setTable('rex_a724_frau_schultze');
                         $sqli->setValue('article_id', $result['article_id']);
                         $sqli->setValue('status', '1');
                         $sqli->setValue('url_table', $result['url_table']);
                         $sqli->setValue('name', $table_path);
                         $sqli->insert();
                     }
                 }
             }
         }
     }
     rex_put_file_contents(A724_URL_TABLE_PATHLIST, "<?php\n\$URLPATH = " . var_export($URLPATH, true) . ";\n");
 }
예제 #11
0
function a587_getArticleIds($cats = false)
{
    global $REX;
    $whereCats = array();
    if (is_array($cats)) {
        foreach ($cats as $catID) {
            $whereCats[] = "path LIKE '%|" . $catID . "|%'";
        }
    }
    $return = array();
    $query = 'SELECT id FROM ' . $REX['TABLE_PREFIX'] . 'article';
    if (empty($REX['ADDON']['settings']['rexsearch']['indexoffline'])) {
        $query .= ' WHERE status = 1';
    }
    if (!empty($whereCats)) {
        $query .= ' AND (' . implode(' OR ', $whereCats) . ' OR (id IN (' . implode(',', $cats) . ') AND startpage = 1))';
    }
    $query .= ' GROUP BY id ORDER BY id';
    $sql = new rex_sql();
    foreach ($sql->getArray($query) as $art) {
        $return[] = $art['id'];
    }
    return $return;
}
예제 #12
0
// ---------- Versand an alle
if ($method == "start" && $method_all == "all" && count($error) == 0 && $send) {
    $nl = new rex_sql();
    // $nl->debugsql = 1;
    // $nl->setQuery('select * from rex_com_user where newsletter_last_id<>"'.$nl_id.'" and email<>"" and newsletter=1 LIMIT 50');
    $nl->setQuery('select * from rex_com_user where newsletter_last_id<>"' . $nl_id . '" and email<>"" and newsletter=1 and profile=' . $nl_filter_profile . ' and status=' . $nl_filter_status . ' LIMIT 50');
    if ($nl->getRows() > 0) {
        $i = "" . date("H:i:s") . "h Bitte noch nicht abbrechen. Automatischer Reload. Es werden noch weitere E-Mails versendet";
        ?>
<script>
			function win_reload(){ window.location.reload(); }
			setTimeout("win_reload()",5000); // Millisekunden 1000 = 1 Sek * 80
			</script><?php 
        $i .= "<br />An folgende E-Mails wurde der Newsletter versendet: ";
        $up = new rex_sql();
        foreach ($nl->getArray() as $userinfo) {
            $i .= ", " . $userinfo["email"];
            $up->setQuery('update rex_com_user set newsletter_last_id="' . $nl_id . '" where id=' . $userinfo["id"]);
            $r = rex_newsletter_sendmail($userinfo, $nl_from_email, $nl_from_name, $nl_subject, $nl_body_text, $nl_body_html);
            $nl->next();
        }
        $info[] = $i;
    } else {
        $info[] = "Alle eMails wurden verschickt";
    }
}
// ---------- Fehlermeldungen
if (count($error) > 0) {
    foreach ($error as $e) {
        echo rex_warning($e);
    }
예제 #13
0
<?php

// Ist Modul schon vorhanden ?
$searchtext = '$xform = new rex_xform';
$gm = new rex_sql();
$gm->setQuery('select * from rex_module where ausgabe LIKE "%' . $searchtext . '%"');
$module_id = 0;
$module_name = "";
foreach ($gm->getArray() as $module) {
    $module_id = $module["id"];
    $module_name = $module["name"];
}
if (isset($_REQUEST["install"]) && $_REQUEST["install"] == 1) {
    $xform_module_name = "rex - X-Form";
    // Daten einlesen
    $in = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_in.inc");
    $out = rex_get_file_contents($REX["INCLUDE_PATH"] . "/addons/xform/module/module_out.inc");
    $mi = new rex_sql();
    // $mi->debugsql = 1;
    $mi->setTable("rex_module");
    $mi->setValue("eingabe", addslashes($in));
    $mi->setValue("ausgabe", addslashes($out));
    // altes Module aktualisieren
    if (isset($_REQUEST["module_id"]) && $module_id == $_REQUEST["module_id"]) {
        $mi->setWhere('id="' . $module_id . '"');
        $mi->update();
        echo rex_info('Modul "' . $module_name . '" wurde aktualisiert');
    } else {
        $mi->setValue("name", $xform_module_name);
        $mi->insert();
        echo rex_info('XForm Modul wurde angelegt unter "' . $xform_module_name . '"');
/**
 *
 * @package redaxo4
 * @version svn:$Id$
 */
// *************************************** CONFIG
$thumbs = true;
$thumbsresize = true;
if (!OOAddon::isAvailable('image_resize')) {
    $thumbsresize = false;
}
// *************************************** KATEGORIEN CHECK UND AUSWAHL
// ***** kategorie auswahl
$db = new rex_sql();
$file_cat = $db->getArray('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file_category ORDER BY name ASC');
// ***** select bauen
$sel_media = new rex_select();
$sel_media->setId("rex_file_category");
$sel_media->setName("rex_file_category");
$sel_media->setSize(1);
$sel_media->setStyle('class="rex-form-select"');
$sel_media->setSelected($rex_file_category);
$sel_media->setAttribute('onchange', 'this.form.submit();');
$sel_media->addOption($I18N->msg('pool_kats_no'), "0");
$mediacat_ids = array();
if ($rootCats = OOMediaCategory::getRootCategories()) {
    foreach ($rootCats as $rootCat) {
        rex_mediapool_addMediacatOptions($sel_media, $rootCat, $mediacat_ids);
    }
}
예제 #15
0
 if ($selectedmedia[0] > 0) {
     $msg = "";
     foreach ($selectedmedia as $file_id) {
         $gf = new rex_sql();
         $gf->setQuery("select * from " . $REX['TABLE_PREFIX'] . "file where file_id='{$file_id}'");
         if ($gf->getRows() == 1) {
             $file_name = $gf->getValue("filename");
             // check if file is in an article slice
             $file_search = '';
             for ($c = 1; $c < 11; $c++) {
                 $file_search .= "OR file{$c}='{$file_name}' ";
                 $file_search .= "OR value{$c} LIKE '%{$file_name}%' ";
             }
             $file_search = substr($file_search, 2);
             $sql = "SELECT " . $REX['TABLE_PREFIX'] . "article.name," . $REX['TABLE_PREFIX'] . "article.id FROM " . $REX['TABLE_PREFIX'] . "article_slice LEFT JOIN " . $REX['TABLE_PREFIX'] . "article on " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id WHERE " . $file_search . " AND " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id";
             $res1 = $db->getArray($sql);
             $sql = "SELECT " . $REX['TABLE_PREFIX'] . "article.name," . $REX['TABLE_PREFIX'] . "article.id FROM " . $REX['TABLE_PREFIX'] . "article where file='{$file_name}'";
             $res2 = $db->getArray($sql);
             if (count($res1) == 0 and count($res2) == 0) {
                 $sql = "DELETE FROM " . $REX['TABLE_PREFIX'] . "file WHERE file_id = '{$file_id}'";
                 $db->setQuery($sql);
                 // fehler unterdrücken, falls die Datei nicht mehr vorhanden ist
                 @unlink($REX['MEDIAFOLDER'] . "/" . $file_name);
                 $msg .= "\"{$file_name}\" " . $I18N->msg('pool_file_deleted');
                 $subpage = "";
             } else {
                 $msg .= $I18N->msg('pool_file_delete_error_1', $file_name) . " ";
                 $msg .= $I18N->msg('pool_file_delete_error_2') . "<br>";
                 if (is_array($res1)) {
                     foreach ($res1 as $var) {
                         $msg .= " | <a href=../index.php?article_id={$var['id']} target=_blank>{$var['name']}</a>";
예제 #16
0
<h2 class="rex-hl2" style="position: relative;"><?php 
echo $I18N->Msg('a587_stats_title');
?>
</h2>

<div class="rex-form">
<form method="post" action="index.php?page=rexsearch&amp;subpage=stats" id="a587_stats_form">
<?php 
$stats = new rexsearchStats();
#$stats->createTestData();
#error_reporting(E_ALL);
// general stats
$sql = new rex_sql();
$generalstats = $sql->getArray('SELECT
  ((SELECT COUNT(DISTINCT ftable,fid) as count FROM `' . $REX['TABLE_PREFIX'] . '587_searchindex` WHERE ftable IS NOT NULL) + (SELECT COUNT(DISTINCT fid) as count FROM `' . $REX['TABLE_PREFIX'] . '587_searchindex` WHERE ftable IS NULL)) AS 010_uniquedatasetcount,
  (SELECT AVG(resultcount) FROM `' . $REX['TABLE_PREFIX'] . '587_stats_searchterms`) AS 020_averageresultcount,
  (SELECT COUNT(*) FROM `' . $REX['TABLE_PREFIX'] . '587_stats_searchterms` WHERE resultcount > 0) AS 040_successfullsearchescount,
  (SELECT COUNT(*) FROM `' . $REX['TABLE_PREFIX'] . '587_stats_searchterms` WHERE resultcount = 0) AS 050_failedsearchescount,
  (SELECT COUNT(DISTINCT term) FROM `' . $REX['TABLE_PREFIX'] . '587_stats_searchterms`) AS 060_uniquesearchterms');
$generalstats = $generalstats[0];
$generalstats['030_searchescount'] = $generalstats['040_successfullsearchescount'] + $generalstats['050_failedsearchescount'];
$generalstats['100_datalength'] = 0;
$generalstats['110_indexlength'] = 0;
foreach ($sql->getArray("SHOW TABLE STATUS LIKE '" . $REX['TABLE_PREFIX'] . "587_%'") as $table) {
    $generalstats['100_datalength'] += $table['Data_length'];
    $generalstats['110_indexlength'] += $table['Index_length'];
    if ($table['Name'] == $REX['TABLE_PREFIX'] . '587_searchindex') {
        $generalstats['080_searchindexdatalength'] = a587_stats_bytesize($table['Data_length']);
        $generalstats['090_searchindexindexlength'] = a587_stats_bytesize($table['Index_length']);
        $generalstats['005_datasetcount'] = $table['Rows'];
    }
    if ($table['Name'] == $REX['TABLE_PREFIX'] . '587_keywords') {
 /**
  * Fügt Optionen anhand der Übergeben SQL-Select-Abfrage hinzu.
  */
 function addSqlOptions($qry)
 {
     $sql = new rex_sql();
     $this->addOptions($sql->getArray($qry, MYSQL_NUM));
 }
 function syncTemplates()
 {
     global $REX;
     $templateFiles = $this->getTemplateFiles();
     if (is_array($templateFiles)) {
         foreach ($templateFiles as $templateId) {
             if (file_exists($this->livePath . $this->TemplatePath . $templateId . $this->TemplateExtension)) {
                 $content = file_get_contents($this->livePath . $this->TemplatePath . $templateId . $this->TemplateExtension);
                 $contentDatum = fileatime($this->livePath . $this->TemplatePath . $templateId . $this->TemplateExtension);
                 $db = new rex_sql();
                 $sql = "SELECT * FROM " . $REX['TABLE_PREFIX'] . "template WHERE id='{$templateId}'";
                 $dbResult = $db->getArray($sql);
                 if ($contentDatum > $dbResult[0]['updatedate']) {
                     $sql = "UPDATE " . $REX['TABLE_PREFIX'] . "template SET content='" . mysql_escape_string($content) . "' WHERE id='{$templateId}'";
                     $db->setQuery($sql);
                     if (mysql_affected_rows($db->identifier) > 0) {
                         $this->generateTemplate($templateId, $content);
                         //print "generated template db".$templateId."<br>";
                     }
                 }
             }
         }
     }
 }
 /**
  * @access public
  */
 function getMediaByFileName($name)
 {
     $query = 'SELECT file_id FROM ' . OOMedia::_getTableName() . ' WHERE filename = "' . $name . '"';
     $sql = new rex_sql();
     $result = $sql->getArray($query);
     if (is_array($result)) {
         foreach ($result as $line) {
             return OOMedia::getMediaById($line['file_id']);
         }
     }
     return null;
 }
예제 #20
0
function rex_setup_setUtf8()
{
    global $REX;
    $gt = new rex_sql();
    $gt->setQuery("show tables");
    foreach ($gt->getArray() as $t) {
        $table = $t["Tables_in_" . $REX['DB']['1']['NAME']];
        $gc = new rex_sql();
        $gc->setQuery("show columns from {$table}");
        if (substr($table, 0, strlen($REX['TABLE_PREFIX'])) == $REX['TABLE_PREFIX']) {
            $columns = array();
            $pri = "";
            foreach ($gc->getArray() as $c) {
                $columns[] = $c["Field"];
                if ($pri == "" && $c["Key"] == "PRI") {
                    $pri = $c["Field"];
                }
            }
            if ($pri != "") {
                $gr = new rex_sql();
                $gr->setQuery("select * from {$table}");
                foreach ($gr->getArray() as $r) {
                    reset($columns);
                    $privalue = $r[$pri];
                    $uv = new rex_sql();
                    $uv->setTable($table);
                    $uv->setWhere($pri . '= "' . $privalue . '"');
                    foreach ($columns as $key => $column) {
                        if ($pri != $column) {
                            $value = $r[$column];
                            $newvalue = utf8_decode($value);
                            $uv->setValue($column, addslashes($newvalue));
                        }
                    }
                    $uv->update();
                }
            }
        }
    }
}
예제 #21
0
    $list->setColumnLabel('name', 'Name');
    $list->setColumnLabel('firma', 'Firma');
    $list->setColumnLabel('funktion', 'Funktion');
    */
    $list->setColumnParams("id", array("oid" => "###id###", "func" => "edit"));
    $list->setColumnParams("name", array("oid" => "###id###", "func" => "edit"));
    $list->setColumnParams("email", array("oid" => "###id###", "func" => "edit"));
    $list->addParam("page", $page);
    $list->addParam("subpage", $subpage);
    $list->addParam("csuchtxt", $csuchtxt);
    $list->addParam("cstatus", $cstatus);
    $list->addParam("csuche", $csuche);
    foreach ($csuchfeld as $cs) {
        $list->addParam("csuchfeld[]", $cs);
    }
    $guf = new rex_sql();
    $guf->setQuery("select * from " . $table_field . " where inlist<>1 order by prior");
    $gufa = $guf->getArray();
    foreach ($gufa as $key => $value) {
        $list->removeColumn($value["userfield"]);
    }
    $list->addColumn('lšschen', 'lšschen');
    $list->setColumnParams("lšschen", array("oid" => "###id###", "func" => "delete"));
    /*
    $list->setColumnSortable('name');
    $list->addColumn('testhead','###id### - ###name###',-1);
    $list->addColumn('testhead2','testbody2');
    $list->setCaption('thomas macht das css');
    */
    echo $list->get();
}
예제 #22
0
        if ($func == "edit") {
            $this->generateAll();
            echo rex_info($I18N->msg("thankyouforupdate"));
        } elseif ($func == "add") {
            $this->generateAll();
            echo rex_info($I18N->msg("thankyouforentry"));
        }
        $func = "list";
    }
}
// ********************************************* LOESCHEN
if ($func == "delete") {
    $sf = new rex_sql();
    // $sf->debugsql = 1;
    $sf->setQuery('select * from rex_' . $this->getType() . '_field where table_name="' . $table["table_name"] . '" and id=' . $field_id);
    $sfa = $sf->getArray();
    if (count($sfa) == 1) {
        $query = 'delete from rex_' . $this->getType() . '_field where table_name="' . $table["table_name"] . '" and id=' . $field_id;
        $delsql = new rex_sql();
        // $delsql->debugsql=1;
        $delsql->setQuery($query);
        echo rex_info($I18N->msg("tablefielddeleted"));
    } else {
        echo rex_warning($I18N->msg("tablefieldnotfound"));
    }
    $func = "list";
}
// ********************************************* LIST
if ($func == "list") {
    function rex_xform_list_format($p, $value = "")
    {
예제 #23
0
 //  function factory($tableName, $fieldset, $whereCondition, $method = 'post', $debug = false, $class = null)
 $form = rex_form::factory(TBL_NEWS, $legend, 'id=' . $id, 'post', false, 'rex_form_news_extended2');
 $form->addParam('clang', $clang);
 if ($func == 'edit') {
     $form->addParam('id', $id);
 }
 // kategorie
 $field = $form->addSelectField('category');
 $field->setLabel("Kategorie");
 $select = $field->getSelect();
 $select->setMultiple(true);
 $select->setSize(3);
 $select->addOption("Bitte wählen", 99999);
 $qry = 'SELECT id, name from ' . TBL_NEWS_CATS;
 $sql = new rex_sql();
 $data = $sql->getArray($qry);
 if (is_array($data) && sizeof($data) > 0) {
     foreach ($data as $row) {
         $select->addOption($row['name'], $row['id']);
     }
 }
 // Sprache
 if (sizeof($REX['CLANG']) > 1) {
     $field = $form->addSelectField('clang');
     $field->setLabel("Sprache");
     $select = $field->getSelect();
     $select->setMultiple(false);
     $select->setSize(1);
     foreach ($REX['CLANG'] as $k => $v) {
         $select->addOption($v, $k);
     }
    function getFieldPage()
    {
        global $REX, $I18N;
        // ********************************************* FIELD ADD/EDIT/LIST
        $func = rex_request('func', 'string', 'list');
        $page = rex_request('page', 'string', '');
        $subpage = rex_request('subpage', 'string', '');
        $tripage = rex_request('tripage', 'string', '');
        $type_id = rex_request('type_id', 'string');
        $type_name = rex_request('type_name', 'string');
        $field_id = rex_request('field_id', 'int');
        $show_list = true;
        $link_vars = '';
        foreach ($this->getLinkVars() as $k => $v) {
            $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
        }
        $TYPE = array('value' => $I18N->msg('xform_values'), 'validate' => $I18N->msg('xform_validates'), 'action' => $I18N->msg('xform_action'));
        // ********************************** TABELLE HOLEN
        $table = $this->table;
        $table_info = '<b>' . rex_translate($table->getName()) . ' [' . $table->getTableName() . ']</b> ';
        echo rex_content_block($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 != '') {
            ?>
            <div class="rex-addon-output"><h2 class="rex-hl2">Folgendes Feld wird verwendet: <?php 
            echo $type_real_field;
            ?>
</h2><div class="rex-addon-content"><p class="rex-tx1"><?php 
            $rfields = $this->table->getColumns();
            foreach ($rfields[$type_real_field] as $k => $v) {
                echo '<b>' . $k . ':</b> ' . $v . '<br />';
            }
            ?>
</p></div></div><?php 
        }
        // ********************************************* CHOOSE FIELD
        $types = rex_xform::getTypeArray();
        if ($func == 'choosenadd') {
            // type and choose !!
            $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&';
            if (!$table->hasId()) {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('xform_id_is_missing');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('xform_id_missing_info');
                ?>
</p>
                    </div></div>
            <?php 
            } else {
                ?>
                <div class="rex-addon-output" id="xform-choosenadd"><h2 class="rex-hl2"><?php 
                echo $I18N->msg('xform_choosenadd');
                ?>
</h2><div class="rex-addon-content">
                        <p class="rex-tx1"><?php 
                echo $I18N->msg('xform_choosenadd_description');
                ?>
</p>
                    </div></div>
                <?php 
                if ($type_real_field == '' && count($mfields) > 0) {
                    ?>
                    <div class="rex-addon-output"><h2 class="rex-hl2">Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.</h2><div class="rex-addon-content">
                            <?php 
                    $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';
                        echo '<a href="' . $l . '">' . $k . '</a>, ';
                    }
                    ?>
</div></div>

                <?php 
                }
                ?>


                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a">
                            <h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['value'];
                ?>
</h3>
                            <div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2">beliebte <?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (isset($v['famous']) && $v['famous']) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <div class="rex-addon-output xform-table_field">
                    <div class="rex-area-col-2">

                        <div class="rex-area-col-a"><h3 class="rex-hl2"><?php 
                echo $TYPE['value'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['value'])) {
                    ksort($types['value']);
                    foreach ($types['value'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                        <div class="rex-area-col-b"><h3 class="rex-hl2"><?php 
                echo $TYPE['validate'];
                ?>
</h3><div class="rex-area-content"><p class="rex-tx1"><?php 
                if (isset($types['validate'])) {
                    ksort($types['validate']);
                    foreach ($types['validate'] as $k => $v) {
                        if (!isset($v['famous']) || $v['famous'] !== true) {
                            echo '<p class="rex-button"><a class="rex-button" href="' . $link . 'type_id=validate&type_name=' . $k . '">' . $k . '</a> <span>' . $v['description'] . '</span></p>';
                        }
                    }
                }
                ?>
</p></div></div>

                    </div></div>

                <!--
             <div class="rex-addon-output">
             <h2 class="rex-hl2"><?php 
                echo $TYPE['action'];
                ?>
</h2>
             <div class="rex-addon-content">
             <p class="rex-tx1"><?php 
                if (isset($types['action'])) {
                    ksort($types['action']);
                    foreach ($types['action'] as $k => $v) {
                        echo '<p class="rex-button">"<a href="' . $link . 'type_id=action&type_name=' . $k . '">' . $k . '</a>" - ' . $v['description'] . '</p>';
                    }
                }
                ?>
</p>
             </div>
             </div>
             -->

            <?php 
            }
            $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '"><b>&laquo; ' . $I18N->msg('xform_back_to_overview') . '</b></a>';
            echo rex_content_block($table_echo);
        }
        // ********************************************* FORMULAR
        if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) {
            $xform = new rex_xform();
            $xform->setDebug(false);
            foreach ($this->getLinkVars() as $k => $v) {
                $xform->setHiddenField($k, $v);
            }
            $xform->setHiddenField('func', $func);
            $xform->setHiddenField('table_name', $table->getTableName());
            $xform->setHiddenField('type_real_field', $type_real_field);
            $xform->setHiddenField('list', rex_request('list', 'string'));
            $xform->setHiddenField('sort', rex_request('sort', 'string'));
            $xform->setHiddenField('sorttype', rex_request('sorttype', 'string'));
            $xform->setHiddenField('start', rex_request('start', 'string'));
            $xform->setValueField('hidden', array('table_name', $table->getTableName()));
            $xform->setValueField('hidden', array('type_name', $type_name, 'REQUEST'));
            $xform->setValueField('hidden', array('type_id', $type_id, 'REQUEST'));
            $xform->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') {
                            $xform->setValueField('showvalue', array($field, 'Name'));
                        } else {
                            if (!isset($v['value']) && $type_real_field != '') {
                                $v['value'] = $type_real_field;
                            } elseif (!isset($v['value'])) {
                                $v['value'] = '';
                            }
                            $xform->setValueField('text', array($field, 'Name', $v['value']));
                            $xform->setValidateField('notEmpty', array($field, $I18N->msg('xform_validatenamenotempty')));
                            $xform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", $I18N->msg('xform_validatenamepregmatch')));
                            $xform->setValidateField('customfunction', array($field, 'rex_xform_manager_checkField', array('table_name' => $table->getTableName()), $I18N->msg('xform_validatenamecheck')));
                        }
                        break;
                    case 'no_db':
                        if (!isset($v['default']) || $v['default'] != 1) {
                            $v['default'] = 0;
                        }
                        $xform->setValueField('checkbox', array($field, $I18N->msg('xform_donotsaveindb'), 'no_db', $v['default']));
                        break;
                    case 'boolean':
                        // checkbox|check_design|Bezeichnung|Value|1/0|[no_db]
                        if (!isset($v['default'])) {
                            $v['default'] = '';
                        }
                        $xform->setValueField('checkbox', array($field, $v['label'], '', $v['default']));
                        break;
                    case 'select':
                        // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1
                        $xform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0));
                        break;
                    case 'table':
                        // ist fest eingetragen, damit keine Dinge durcheinandergehen
                        if ($func == 'edit') {
                            $xform->setValueField('showvalue', array($field, $v['label']));
                        } else {
                            $_tables = rex_xform_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_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'] = '';
                            }
                            $xform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0));
                        }
                        break;
                    case 'textarea':
                        $xform->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;
                        }
                        $xform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0));
                        break;
                    case 'select_names':
                        $_fields = array();
                        foreach ($table->getValueFields() as $_k => $_v) {
                            $_fields[] = $_k;
                        }
                        $xform->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'] = '';
                        }
                        $xform->setValueField('text', array($field, $v['label'], $v['value']));
                }
            }
            $xform->setActionField('showtext', array('', '<p>' . $I18N->msg('xform_thankyouforentry') . '</p>'));
            $xform->setObjectparams('main_table', rex_xform_manager_field::table());
            if ($func == 'edit') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_save'));
                $xform->setHiddenField('field_id', $field_id);
                $xform->setActionField('manage_db', array(rex_xform_manager_field::table(), "id={$field_id}"));
                $xform->setObjectparams('main_id', $field_id);
                $xform->setObjectparams('main_where', "id={$field_id}");
                $sql = rex_sql::factory();
                $sql->setQuery('SELECT * FROM ' . rex_xform_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));
                        }
                        $xform->setValueField('hidden', array($alias, ''));
                    }
                }
                $xform->setObjectparams('sql_object', $sql);
                $xform->setObjectparams('getdata', true);
            } elseif ($func == 'add') {
                $xform->setObjectparams('submit_btn_label', $I18N->msg('xform_add'));
                $xform->setActionField('manage_db', array(rex_xform_manager_field::table()));
            }
            if ($type_id == 'value') {
                $xform->setValueField('checkbox', array('list_hidden', $I18N->msg('xform_hideinlist'), 1, '1'));
                $xform->setValueField('checkbox', array('search', $I18N->msg('xform_useassearchfieldalidatenamenotempty'), 1, '1'));
            } elseif ($type_id == 'validate') {
                $xform->setValueField('hidden', array('list_hidden', 1));
            }
            $form = $xform->getForm();
            if ($xform->objparams['form_show']) {
                if ($func == 'add') {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_addfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                } else {
                    echo '<div class="rex-addon-output"><h3 class="rex-hl2">' . $I18N->msg('xform_editfield') . ' "' . $type_name . '"</h3><div class="rex-addon-content">';
                }
                echo $form;
                echo '</div></div>';
                $table_echo = '<a href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '"><b>&laquo; ' . $I18N->msg('xform_back_to_overview') . '</b></a>';
                echo rex_content_block($table_echo);
                $func = '';
            } else {
                if ($func == 'edit') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('xform_thankyouforupdate'));
                } elseif ($func == 'add') {
                    $this->generateAll();
                    echo rex_info($I18N->msg('xform_thankyouforentry'));
                }
                $func = 'list';
            }
        }
        // ********************************************* LOESCHEN
        if ($func == 'delete') {
            $sf = new rex_sql();
            $sf->debugsql = self::$debug;
            $sf->setQuery('select * from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id);
            $sfa = $sf->getArray();
            if (count($sfa) == 1) {
                $query = 'delete from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id;
                $delsql = new rex_sql();
                $delsql->debugsql = self::$debug;
                $delsql->setQuery($query);
                echo rex_info($I18N->msg('xform_tablefielddeleted'));
                $this->generateAll();
            } else {
                echo rex_warning($I18N->msg('xform_tablefieldnotfound'));
            }
            $func = 'list';
        }
        // ********************************************* CREATE/UPDATE FIELDS
        if ($func == 'updatetable') {
            $this->generateAll();
            echo rex_info($I18N->msg('xform_tablesupdated'));
            $func = 'list';
        }
        if ($func == 'updatetablewithdelete') {
            $this->generateAll(array('delete_fields' => true));
            echo rex_info($I18N->msg('xform_tablesupdated'));
            $func = 'list';
        }
        if ($func == 'show_form_notation') {
            $formbuilder_fields = $table->getFields();
            $notation_php = '';
            $notation_pipe = '';
            $notation_email = '';
            $notation_php_pre = array('$xform = new rex_xform();', '$xform->setObjectparams(\'form_skin\', \'default\');', '$xform->setObjectparams(\'form_showformafterupdate\', 0);', '$xform->setObjectparams(\'real_field_names\', true);');
            $notation_php .= implode("\n", $notation_php_pre) . "\n";
            $notation_pipe_pre = array('objparams|form_skin|default', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true');
            $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n";
            foreach ($formbuilder_fields as $field) {
                $classname = rex_xform::includeClass($field['type_id'], $field['type_name']);
                $cl = new $classname();
                $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" . '$xform->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" . '$xform->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" . '$xform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                    $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                }
            }
            $notation_php .= "\n\n" . '$xform->setActionField(\'db2email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));';
            $notation_php .= "\n" . 'echo $xform->getForm();';
            $notation_pipe .= "\n\n" . 'action|db2email|emailtemplate|emaillabel|email@domain.de';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">PHP</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_php . '</code></pre>';
            echo '</div></div>';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">Pipe</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_pipe . '</code></pre>';
            echo '</div></div>';
            echo '<div class="rex-addon-output">';
            echo '<h2 class="rex-hl2">E-Mail</h2>';
            echo '<div class="rex-addon-content">';
            echo '<pre class="rex-code"><code>' . $notation_email . '</code></pre>';
            echo '</div></div>';
            $func = 'list';
        }
        // ********************************************* LIST
        if ($func == 'list') {
            // ****** EP XFORM_MANAGER_TABLE_FIELD_FUNC
            $show_list = true;
            $show_list = rex_register_extension_point('XFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, array('table' => $table, 'link_vars' => $this->getLinkVars()));
            if ($show_list) {
                function rex_xform_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_xform_list_edit_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_edit'), $I18N->msg('xform_edit')));
                }
                function rex_xform_list_delete_format($p)
                {
                    global $REX, $I18N;
                    return rex_xform_list_format($p, $p['list']->getColumnLink($I18N->msg('xform_delete'), $I18N->msg('xform_delete')));
                }
                $table_echo = '
                     <div class="rex-area-col-2">
                             <div class="rex-area-col-a">
                                     <a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd"><b>+ ' . $I18N->msg('xform_addtablefield') . '</b></a>
                             </div>
                             <div class="rex-area-col-b rex-algn-rght">
                                <ul class="rex-navi-piped">
                                    <li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=show_form_notation">' . $I18N->msg('xform_manager_show_form_notation') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetable">' . $I18N->msg('xform_updatetable') . '</a></li><li><a href="index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=updatetablewithdelete" onclick="return confirm(\'' . $I18N->msg('xform_updatetable_with_delete_confirm') . '\')">' . $I18N->msg('xform_updatetable_with_delete') . '</a></li>
                                </ul>
                             </div>
                     </div>
                     <div class="rex-clearer"></div>
                     ';
                echo rex_content_block($table_echo);
                $sql = 'select id, prio, type_id, type_name, name from ' . rex_xform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio';
                $list = rex_list::factory($sql, 30);
                // $list->debug = 1;
                $list->setColumnFormat('id', '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', $I18N->msg('xform_manager_table_prio_short'));
                $list->setColumnLabel('type_id', $I18N->msg('xform_manager_type_id'));
                $list->setColumnLabel('type_name', $I18N->msg('xform_manager_type_name'));
                $list->setColumnLabel('name', $I18N->msg('xform_manager_name'));
                $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('prio', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_id', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat('type_name', 'custom', 'rex_xform_list_format');
                $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###'));
                // ###VALUE###
                $list->setColumnFormat('name', 'custom', 'rex_xform_list_format');
                $list->addColumn($I18N->msg('xform_edit'), $I18N->msg('xform_edit'));
                $list->setColumnParams($I18N->msg('xform_edit'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###'));
                $list->setColumnLayout($I18N->msg('xform_edit'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('xform_edit'), 'custom', 'rex_xform_list_edit_format');
                $list->addColumn($I18N->msg('xform_delete'), $I18N->msg('xform_delete'));
                $list->setColumnParams($I18N->msg('xform_delete'), array('field_id' => '###id###', 'func' => 'delete'));
                $list->setColumnLayout($I18N->msg('xform_delete'), array('<th>###VALUE###</th>', '###VALUE###'));
                $list->setColumnFormat($I18N->msg('xform_delete'), 'custom', 'rex_xform_list_delete_format');
                $list->addLinkAttribute($I18N->msg('xform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . $I18N->msg('xform_delete') . ' ?\')');
                echo $list->get();
            }
        }
    }
예제 #25
0
 /** 
  * Executes the search.
  * 
  * @param string $_search
  * 
  * @return array
  */
 function search($_search)
 {
     $startTime = microtime(true);
     $this->searchString = trim(stripslashes($_search));
     $keywordCount = $this->parseSearchString($this->searchString);
     if (empty($this->searchString) or empty($this->searchArray)) {
         return array('count' => 0, 'hits' => array(), 'keywords' => array(), 'keywords' => '', 'sql' => 'No search performed.', 'blacklisted' => false, 'hash' => '', 'simwordsnewsearch' => '', 'simwords' => array(), 'time' => 0);
     }
     // ask cache
     if ($this->cache and $this->isCached($this->searchString)) {
         $this->cachedArray['time'] = microtime(true) - $startTime;
         if ($this->similarwords and $this->cachedArray['count'] > 0) {
             $this->storeKeywords($this->searchArray);
         }
         // EP registrieren
         rex_register_extension_point('A587_SEARCH_EXECUTED', $this->cachedArray);
         //var_dump($this->cachedArray['sql']);
         return $this->cachedArray;
     }
     $return = array();
     $return['simwordsnewsearch'] = '';
     $return['simwords'] = array();
     if ($this->similarwords) {
         $simwords = array();
         foreach ($this->searchArray as $keyword) {
             $sounds = array();
             if ($this->similarwordsMode & A587_SIMILARWORDS_SOUNDEX) {
                 $sounds[] = "soundex = '" . soundex($keyword['search']) . "'";
             }
             if ($this->similarwordsMode & A587_SIMILARWORDS_METAPHONE) {
                 $sounds[] = "metaphone = '" . metaphone($keyword['search']) . "'";
             }
             if ($this->similarwordsMode & A587_SIMILARWORDS_COLOGNEPHONE) {
                 $sounds[] = "colognephone = '" . $this->cologne_phone($keyword['search']) . "'";
             }
             $simwords[] = sprintf("\n          SELECT\n            GROUP_CONCAT(DISTINCT keyword SEPARATOR ' ') as keyword,\n            '%s' AS typedin,\n            SUM(count) as count\n          FROM `%s`\n          WHERE 1\n            %s\n            AND (%s)", $keyword['search'], $this->tablePrefix . '587_keywords', $this->clang !== false ? 'AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)' : '', implode(' OR ', $sounds));
         }
         // simwords
         $simWordsSQL = new rex_sql();
         foreach ($simWordsSQL->getArray(sprintf("\n        %s\n        GROUP BY %s\n        ORDER BY SUM(count)", implode(' UNION ', $simwords), $this->similarwordsPermanent ? "''" : 'keyword, typedin')) as $simword) {
             $return['simwords'][$simword['typedin']] = array('keyword' => $simword['keyword'], 'typedin' => $simword['typedin'], 'count' => $simword['count']);
         }
         $newsearch = array();
         foreach ($this->searchArray as $keyword) {
             if (preg_match($this->encodeRegex('~\\s~is'), $keyword['search'])) {
                 $quotes = '"';
             } else {
                 $quotes = '';
             }
             if (array_key_exists($keyword['search'], $return['simwords'])) {
                 $newsearch[] = $quotes . $return['simwords'][$keyword['search']]['keyword'] . $quotes;
             } else {
                 $newsearch[] = $quotes . $keyword['search'] . $quotes;
             }
         }
         $return['simwordsnewsearch'] = implode(' ', $newsearch);
     }
     if ($this->similarwordsPermanent) {
         $keywordCount = $this->parseSearchString($this->searchString . ' ' . $return['simwordsnewsearch']);
     }
     $searchColumns = array();
     switch ($this->textMode) {
         case 'unmodified':
             $searchColumns[] = 'unchangedtext';
             break;
         case 'both':
             $searchColumns[] = 'plaintext';
             $searchColumns[] = 'unchangedtext';
             break;
         default:
             $searchColumns[] = 'plaintext';
     }
     $sql = new rex_sql();
     $Awhere = array();
     $Amatch = array();
     foreach ($this->searchArray as $keyword) {
         // build MATCH-Array
         $match = sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`', $searchColumns), $sql->escape($keyword['search']), $keyword['weight']);
         if ($this->searchEntities) {
             $match .= ' + ' . sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`', $searchColumns), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8')), $keyword['weight']);
         }
         $Amatch[] = $match;
         // build WHERE-Array
         if ($this->searchMode == 'match') {
             $AWhere[] = $match;
         } else {
             $tmpWhere = array();
             foreach ($searchColumns as $searchColumn) {
                 $tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%', '_'), array('\\%', '\\_'), $sql->escape($keyword['search'])));
                 if ($this->searchEntities) {
                     $tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%', '_'), array('\\%', '\\_'), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8'))));
                 }
             }
             $AWhere[] = '(' . implode(' OR ', $tmpWhere) . ')';
         }
         /*if($this->logicalMode == ' AND ')
             $Awhere[] = '+*'.$keyword['search'].'*';
           else
             $AWhere[] = '*'.$keyword['search'].'*';*/
     }
     // build MATCH-String
     $match = '(' . implode(' + ', $Amatch) . ' + 1)';
     // build WHERE-String
     $where = '(' . implode($this->logicalMode, $AWhere) . ')';
     #$where = sprintf("( MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)) > 0",implode(',',$searchColumns),implode(' ',$Awhere));
     // language
     if ($this->clang !== false) {
         $where .= ' AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)';
     }
     $AwhereToSearch = array();
     if (array_key_exists('articles', $this->searchInIDs) and count($this->searchInIDs['articles'])) {
         $AwhereToSearch[] = "texttype = 'article'";
         $AwhereToSearch[] = "(fid IN (" . implode(',', $this->searchInIDs['articles']) . "))";
     }
     if (array_key_exists('categories', $this->searchInIDs) and count($this->searchInIDs['categories'])) {
         $AwhereToSearch[] = "(catid IN (" . implode(',', $this->searchInIDs['categories']) . ") AND ftable = '" . $sql->escape($this->tablePrefix) . "article')";
     }
     if (array_key_exists('filecategories', $this->searchInIDs) and count($this->searchInIDs['filecategories'])) {
         $AwhereToSearch[] = "(catid IN (" . implode(',', $this->searchInIDs['filecategories']) . ") AND ftable = '" . $sql->escape($this->tablePrefix) . "file')";
     }
     if (array_key_exists('db_columns', $this->searchInIDs) and count($this->searchInIDs['db_columns'])) {
         $AwhereToSearch[] = "texttype = 'db_column'";
         $Acolumns = array();
         foreach ($this->searchInIDs['db_columns'] as $table => $colArray) {
             foreach ($colArray as $column) {
                 //$Acolumns[] = sprintf("(ftable = '%s' AND fcolumn = '%s' %s)", $table, $column, $strSearchArticles);
                 $Acolumns[] = sprintf("(ftable = '%s' AND fcolumn = '%s')", $table, $column);
             }
         }
         $AwhereToSearch[] = '(' . implode(' OR ', $Acolumns) . ')';
     }
     if (count($AwhereToSearch)) {
         if ($this->searchArticles) {
             $where .= " AND ((texttype = 'article') OR (" . implode(' AND ', $AwhereToSearch) . '))';
         } else {
             $where .= ' AND (' . implode(' AND ', $AwhereToSearch) . ')';
         }
     }
     if (!empty($this->where)) {
         $where .= ' AND (' . $this->where . ')';
     }
     // build ORDER-BY-String
     $Aorder = array();
     foreach ($this->order as $col => $dir) {
         $Aorder[] = $col . ' ' . $dir;
     }
     $selectFields = array();
     if ($this->groupBy) {
         $selectFields[] = sprintf('(SELECT SUM%s FROM `%s` summe WHERE summe.fid = r1.fid AND summe.ftable = r1.ftable) AS RELEVANCE587', $match, $this->tablePrefix . '587_searchindex');
         $selectFields[] = sprintf('(SELECT COUNT(*) FROM `%s` summe WHERE summe.fid = r1.fid AND (summe.ftable IS NULL OR summe.ftable = r1.ftable) AND (summe.fcolumn IS NULL OR summe.fcolumn = r1.fcolumn) AND summe.texttype = r1.texttype) AS COUNT587', $this->tablePrefix . '587_searchindex');
     } else {
         $selectFields[] = $match . ' AS RELEVANCE587';
     }
     $selectFields[] = '`id`';
     $selectFields[] = '`fid`';
     $selectFields[] = '`catid`';
     $selectFields[] = '`ftable`';
     $selectFields[] = '`fcolumn`';
     $selectFields[] = '`texttype`';
     $selectFields[] = '`clang`';
     $selectFields[] = '`unchangedtext`';
     $selectFields[] = '`plaintext`';
     $selectFields[] = '`teaser`';
     $selectFields[] = '`values`';
     $selectFields[] = '`filename`';
     $selectFields[] = '`fileext`';
     if ($this->groupBy) {
         $query = sprintf('
     SELECT SQL_CALC_FOUND_ROWS %s
     FROM `%s` r1
     WHERE (%s) AND (
       (
         %s = (SELECT MAX%s FROM `%s` r2 WHERE r1.ftable = r2.ftable AND r1.fid = r2.fid %s)
         AND fid IS NOT NULL
       ) OR
       ftable IS NULL
     )
     GROUP BY ftable,fid,clang
     ORDER BY %s
     LIMIT %d,%d', implode(",\n", $selectFields), $this->tablePrefix . '587_searchindex', $where, $match, $match, $this->tablePrefix . '587_searchindex', $this->clang !== false ? 'AND (clang = ' . intval($this->clang) . ' OR clang IS NULL)' : '', implode(",\n", $Aorder), $this->limit[0], $this->limit[1]);
     } else {
         $query = sprintf('
     SELECT SQL_CALC_FOUND_ROWS %s
     FROM `%s`
     WHERE %s
     ORDER BY %s
     LIMIT %d,%d', implode(",\n", $selectFields), $this->tablePrefix . '587_searchindex', $where, implode(",\n", $Aorder), $this->limit[0], $this->limit[1]);
     }
     #echo '<pre>'.$query.'</pre>';
     $sqlResult = $sql->getArray($query);
     $indexIds = array();
     $count = 0;
     $sqlResultCount = $sql->getArray('SELECT FOUND_ROWS() as count');
     $return['count'] = intval($sqlResultCount[0]['count']);
     // hits
     $return['hits'] = array();
     $i = 0;
     foreach ($sqlResult as $hit) {
         $indexIds[] = $hit['id'];
         $return['hits'][$i] = array();
         $return['hits'][$i]['id'] = $hit['id'];
         $return['hits'][$i]['fid'] = $hit['fid'];
         if (!is_numeric($hit['fid']) and !is_null($json_decode_fid = json_decode($hit['fid'], true))) {
             $return['hits'][$i]['fid'] = $json_decode_fid;
         }
         $return['hits'][$i]['table'] = $hit['ftable'];
         $return['hits'][$i]['column'] = $hit['fcolumn'];
         $return['hits'][$i]['type'] = $hit['texttype'];
         $return['hits'][$i]['clang'] = $hit['clang'];
         $return['hits'][$i]['unchangedtext'] = $hit['unchangedtext'];
         $return['hits'][$i]['plaintext'] = $hit['plaintext'];
         $return['hits'][$i]['teaser'] = $this->getTeaserText($hit['plaintext']);
         $return['hits'][$i]['highlightedtext'] = $this->getHighlightedText($hit['plaintext']);
         $return['hits'][$i]['article_teaser'] = $hit['teaser'];
         $return['hits'][$i]['values'] = a587_config_unserialize($hit['values']);
         $return['hits'][$i]['filename'] = $hit['filename'];
         $return['hits'][$i]['fileext'] = $hit['fileext'];
         $i++;
         if ($this->groupBy) {
             $count += $hit['COUNT587'];
         }
     }
     if ($this->groupBy) {
         $indexIds = array();
         foreach ($sql->getArray(sprintf('
         SELECT id
         FROM `%s`
         WHERE %s
         LIMIT %d,%d', $this->tablePrefix . '587_searchindex', $where, $this->limit[0], $count)) as $hit) {
             $indexIds[] = $hit['id'];
         }
     }
     // keywords, which were searched for
     $return['keywords'] = $this->searchArray;
     $return['searchterm'] = $this->searchString;
     // sql
     $return['sql'] = $query;
     // was any blacklisted word searched for?
     $return['blacklisted'] = false;
     if (count($this->blacklisted) > 0) {
         $return['blacklisted'] = $this->blacklisted;
     }
     $return['hash'] = $this->cacheHash($this->searchString);
     if ($this->similarwords and $i) {
         $this->storeKeywords($this->searchArray);
     }
     if ($this->cache) {
         $this->cacheSearch(serialize($return), $indexIds);
     }
     // EP registrieren
     rex_register_extension_point('A587_SEARCH_EXECUTED', $return);
     $return['time'] = microtime(true) - $startTime;
     return $return;
 }
/**
 * Importiert den SQL Dump $filename in die Datenbank
 *
 * @param string Pfad + Dateinamen zur SQL-Datei
 *
 * @return array Gibt ein Assoc. Array zurück.
 *               'state' => boolean (Status ob fehler aufgetreten sind)
 *               'message' => Evtl. Status/Fehlermeldung
 */
function rex_a1_import_db($filename)
{
    global $REX, $I18N_IM_EXPORT;
    $return = array();
    $return['state'] = false;
    $return['message'] = '';
    $msg = '';
    $error = '';
    if ($filename == '' || substr($filename, -4, 4) != ".sql") {
        $return['message'] = $I18N_IM_EXPORT->msg('no_import_file_chosen_or_wrong_version') . '<br>';
        return $return;
    }
    $conts = rex_get_file_contents($filename);
    // Versionsstempel prüfen
    // ## Redaxo Database Dump Version x.x
    $version = strpos($conts, '## Redaxo Database Dump Version ' . $REX['VERSION']);
    if ($version === false) {
        $return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Redaxo Database Dump Version ' . $REX['VERSION'] . '] is missing';
        return $return;
    }
    // Versionsstempel entfernen
    $conts = trim(str_replace('## Redaxo Database Dump Version ' . $REX['VERSION'], '', $conts));
    // Prefix prüfen
    // ## Prefix xxx_
    if (preg_match('/^## Prefix ([a-zA-Z0-9\\_]*)/', $conts, $matches) && isset($matches[1])) {
        // prefix entfernen
        $prefix = $matches[1];
        $conts = trim(str_replace('## Prefix ' . $prefix, '', $conts));
    } else {
        // Prefix wurde nicht gefunden
        $return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Prefix ' . $REX['TABLE_PREFIX'] . '] is missing';
        return $return;
    }
    // Prefix im export mit dem der installation angleichen
    if ($REX['TABLE_PREFIX'] != $prefix) {
        // Hier case-insensitiv ersetzen, damit alle möglich Schreibweisen (TABLE TablE, tAblE,..) ersetzt werden
        // Dies ist wichtig, da auch SQLs innerhalb von Ein/Ausgabe der Module vom rex-admin verwendet werden
        $conts = preg_replace('/(TABLE `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
        $conts = preg_replace('/(INTO `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
        $conts = preg_replace('/(EXISTS `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
    }
    // Inhalt der /generated Ordner komplett leeren
    rex_generateAll();
    // ----- EXTENSION POINT
    $filesize = filesize($filename);
    $msg = rex_register_extension_point('A1_BEFORE_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
    // Datei aufteilen
    $lines = explode("\n", $conts);
    $add = new rex_sql();
    $error = '';
    foreach ($lines as $line) {
        $line = trim($line, "\r");
        // Windows spezifische extras
        $line = trim($line, ";");
        // mysql 3.x
        if ($line == '') {
            continue;
        }
        $add->setQuery($line);
        if ($add->hasError()) {
            $error .= "\n" . $add->getError();
        }
    }
    if ($error != '') {
        $return['message'] = trim($error);
        return $return;
    }
    $msg .= $I18N_IM_EXPORT->msg('database_imported') . '. ' . $I18N_IM_EXPORT->msg('entry_count', count($lines)) . '<br />';
    // CLANG Array aktualisieren
    unset($REX['CLANG']);
    $db = new rex_sql();
    $db->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'clang');
    for ($i = 0; $i < $db->getRows(); $i++) {
        $id = $db->getValue('id');
        $name = $db->getValue('name');
        $REX['CLANG'][$id] = $name;
        $db->next();
    }
    // prüfen, ob eine user tabelle angelegt wurde
    $result = $db->getArray('SHOW TABLES');
    $user_table_found = false;
    foreach ($result as $row) {
        if (in_array($REX['TABLE_PREFIX'] . 'user', $row)) {
            $user_table_found = true;
            break;
        }
    }
    if (!$user_table_found) {
        $create_user_table = '
    CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'user
     (
       user_id int(11) NOT NULL auto_increment,
       name varchar(255) NOT NULL,
       description text NOT NULL,
       login varchar(50) NOT NULL,
       psw varchar(50) NOT NULL,
       status varchar(5) NOT NULL,
       rights text NOT NULL,
       login_tries tinyint(4) NOT NULL DEFAULT 0,
       createuser varchar(255) NOT NULL,
       updateuser varchar(255) NOT NULL,
       createdate int(11) NOT NULL DEFAULT 0,
       updatedate int(11) NOT NULL DEFAULT 0,
       lasttrydate int(11) NOT NULL DEFAULT 0,
       session_id varchar(255) NOT NULL,
       PRIMARY KEY(user_id)
     ) TYPE=MyISAM;';
        $db->setQuery($create_user_table);
        $error = $db->getError();
        if ($error != '') {
            // evtl vorhergehende meldungen löschen, damit nur der fehler angezeigt wird
            $msg = '';
            $msg .= $error;
        }
    }
    // generated neu erstellen, wenn kein Fehler aufgetreten ist
    if ($error == '') {
        // ----- EXTENSION POINT
        $msg = rex_register_extension_point('A1_AFTER_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
        $msg .= rex_generateAll();
        $return['state'] = true;
    }
    $return['message'] = $msg;
    return $return;
}
<?php

// Uebersichtsliste
if ($func == '') {
    // Wenn eine Kategorie geloescht wurde koennen die lang-Objekte noch existieren und ...
    $query_to_delete = "SELECT lang.kategorie_id, kategorien.kategorie_id " . "FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kategorien_lang` AS lang " . "LEFT JOIN  `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kategorien` AS kategorien " . "ON lang.kategorie_id = kategorien.kategorie_id " . "WHERE kategorien.kategorie_id IS NULL " . "GROUP BY lang.kategorie_id";
    $result_to_delete = new rex_sql();
    $result_to_delete->setQuery($query_to_delete);
    $num_rows_to_delete = $result_to_delete->getRows();
    for ($i = 0; $i < $num_rows_to_delete; $i++) {
        // ...  muessen zuerst geloescht werden
        $delete_qry = 'DELETE FROM ' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kategorien_lang ' . 'WHERE kategorie_id = ' . $result_to_delete->getValue("lang.kategorie_id");
        $delete_sql = new rex_sql();
        $delete_data = $delete_sql->getArray($delete_qry);
        $result_to_delete->next();
    }
    /*
     *  Liste anlegen 
     */
    $sql = 'SELECT kategorie_id, interne_bezeichnung FROM ' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kategorien AS kategorien ' . 'ORDER BY interne_bezeichnung ASC';
    $list = rex_list::factory($sql, 100);
    // Spalten mit Sortierfunktion
    $list->setColumnSortable('interne_bezeichnung');
    $imgHeader = '<a href="' . $list->getUrl(array('func' => 'add')) . '"><img src="media/metainfo_plus.gif" alt="add" title="add" /></a>';
    // Hinzufuegen Button
    $list->addColumn($imgHeader, '<img src="media/metainfo.gif" alt="field" title="field" />', 0, array('<th class="rex-icon">###VALUE###</th>', '<td class="rex-icon">###VALUE###</td>'));
    // Edit Button unterhalb des hinzufuegen Buttons
    $list->setColumnParams($imgHeader, array('func' => 'edit', 'entry_id' => '###kategorie_id###'));
    // Labels
    $list->setColumnLabel('kategorie_id', $I18N_STELLEN->msg('id'));
    $list->setColumnLabel('interne_bezeichnung', $I18N_STELLEN->msg('interne_bezeichnung'));
    function getArticle($curctype = -1)
    {
        global $REX, $I18N;
        if ($this->content != "") {
            echo $this->content;
            return;
        }
        $this->ctype = $curctype;
        $module_id = rex_request('module_id', 'int');
        $sliceLimit = '';
        if ($this->getSlice) {
            $sliceLimit = " AND " . $REX['TABLE_PREFIX'] . "article_slice.id = '" . $this->getSlice . "' ";
        }
        // ----- start: article caching
        ob_start();
        ob_implicit_flush(0);
        if (!$this->viasql && !$this->getSlice) {
            if ($this->article_id != 0) {
                $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
                if (!file_exists($article_content_file)) {
                    include_once $REX["INCLUDE_PATH"] . "/functions/function_rex_generate.inc.php";
                    $generated = rex_generateArticleContent($this->article_id, $this->clang);
                    if ($generated !== true) {
                        // fehlermeldung ausgeben
                        echo $generated;
                    }
                }
                if (file_exists($article_content_file)) {
                    eval(rex_get_file_contents($article_content_file));
                }
            }
        } else {
            if ($this->article_id != 0) {
                // ---------- alle teile/slices eines artikels auswaehlen
                $sql = "SELECT " . $REX['TABLE_PREFIX'] . "module.id, " . $REX['TABLE_PREFIX'] . "module.name, " . $REX['TABLE_PREFIX'] . "module.ausgabe, " . $REX['TABLE_PREFIX'] . "module.eingabe, " . $REX['TABLE_PREFIX'] . "article_slice.*, " . $REX['TABLE_PREFIX'] . "article.re_id\r\n          FROM\r\n            " . $REX['TABLE_PREFIX'] . "article_slice\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "module ON " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id=" . $REX['TABLE_PREFIX'] . "module.id\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "article ON " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id\r\n          WHERE\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.article_id='" . $this->article_id . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.clang='" . $this->clang . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article.clang='" . $this->clang . "' AND \r\n            " . $REX['TABLE_PREFIX'] . "article_slice.revision='" . $this->slice_revision . "'\r\n            " . $sliceLimit . "\r\n            ORDER BY " . $REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id";
                $this->CONT = new rex_sql();
                if ($this->debug) {
                    $this->CONT->debugsql = 1;
                }
                $this->CONT->setQuery($sql);
                $RE_CONTS = array();
                $RE_CONTS_CTYPE = array();
                $RE_MODUL_OUT = array();
                $RE_MODUL_IN = array();
                $RE_MODUL_ID = array();
                $RE_MODUL_NAME = array();
                $RE_C = array();
                // ---------- SLICE IDS/MODUL SETZEN - speichern der daten
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    $RE_SLICE_ID = $this->CONT->getValue('re_article_slice_id');
                    $RE_CONTS[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.id');
                    $RE_CONTS_CTYPE[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.ctype');
                    $RE_MODUL_IN[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.eingabe');
                    $RE_MODUL_OUT[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.ausgabe');
                    $RE_MODUL_ID[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.id');
                    $RE_MODUL_NAME[$RE_SLICE_ID] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.name');
                    $RE_C[$RE_SLICE_ID] = $i;
                    $this->CONT->next();
                }
                // ---------- moduleselect: nur module nehmen auf die der user rechte hat
                if ($this->mode == 'edit') {
                    $MODULE = new rex_sql();
                    $modules = $MODULE->getArray('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
                    $template_ctypes = rex_getAttributes('ctype', $this->template_attributes, array());
                    // wenn keine ctyes definiert sind, gibt es immer den CTYPE=1
                    if (count($template_ctypes) == 0) {
                        $template_ctypes = array(1 => 'default');
                    }
                    $MODULESELECT = array();
                    foreach ($template_ctypes as $ct_id => $ct_name) {
                        $MODULESELECT[$ct_id] = new rex_select();
                        $MODULESELECT[$ct_id]->setName('module_id');
                        $MODULESELECT[$ct_id]->setSize('1');
                        $MODULESELECT[$ct_id]->setStyle('class="rex-form-select"');
                        $MODULESELECT[$ct_id]->setAttribute('onchange', 'this.form.submit();');
                        $MODULESELECT[$ct_id]->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
                        foreach ($modules as $m) {
                            if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('module[' . $m['id'] . ']')) {
                                if (rex_template::hasModule($this->template_attributes, $ct_id, $m['id'])) {
                                    $MODULESELECT[$ct_id]->addOption(rex_translate($m['name'], NULL, FALSE), $m['id']);
                                }
                            }
                        }
                    }
                }
                // ---------- SLICE IDS SORTIEREN UND AUSGEBEN
                $I_ID = 0;
                $PRE_ID = 0;
                $LCTSL_ID = 0;
                $this->CONT->reset();
                $this->content = "";
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    // ----- ctype unterscheidung
                    if ($this->mode != "edit" && $i == 0) {
                        $this->content = "<?php if (\$this->ctype == '" . $RE_CONTS_CTYPE[$I_ID] . "' || (\$this->ctype == '-1')) { ?>";
                    }
                    // ------------- EINZELNER SLICE - AUSGABE
                    $this->CONT->counter = $RE_C[$I_ID];
                    $slice_content = "";
                    $SLICE_SHOW = TRUE;
                    if ($this->mode == "edit") {
                        $form_url = 'index.php';
                        $this->ViewSliceId = $RE_CONTS[$I_ID];
                        // ----- add select box einbauen
                        if ($this->function == "add" && $this->slice_id == $I_ID) {
                            $slice_content = $this->addSlice($I_ID, $module_id);
                        } else {
                            // ----- BLOCKAUSWAHL - SELECT
                            $MODULESELECT[$this->ctype]->setId("module_id" . $I_ID);
                            $slice_content = '
              <div class="rex-form rex-form-content-editmode">
              <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                <fieldset class="rex-form-col-1">
                  <legend><span>' . $I18N->msg("add_block") . '</span></legend>
                  <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                  <input type="hidden" name="page" value="content" />
                  <input type="hidden" name="mode" value="' . $this->mode . '" />
                  <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                  <input type="hidden" name="function" value="add" />
                  <input type="hidden" name="clang" value="' . $this->clang . '" />
                  <input type="hidden" name="ctype" value="' . $this->ctype . '" />
                  
                  <div class="rex-form-wrapper">
                    <div class="rex-form-row">
                      <p class="rex-form-col-a rex-form-select">
                        ' . $MODULESELECT[$this->ctype]->get() . '
                        <noscript><input class="rex-form-submit" type="submit" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                      </p>
                    </div>
                  </div>
                </fieldset>
              </form>
              </div>';
                        }
                        // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
                        if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm("module[" . $RE_MODUL_ID[$I_ID] . "]")) {
                            $msg = '';
                            if ($this->slice_id == $RE_CONTS[$I_ID]) {
                                if ($this->warning != '') {
                                    $msg .= rex_warning($this->warning);
                                }
                                if ($this->info != '') {
                                    $msg .= rex_info($this->info);
                                }
                            }
                            $sliceUrl = 'index.php?page=content&amp;article_id=' . $this->article_id . '&amp;mode=edit&amp;slice_id=' . $RE_CONTS[$I_ID] . '&amp;clang=' . $this->clang . '&amp;ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID];
                            $listElements = array();
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=edit') . '" class="rex-tx3">' . $I18N->msg('edit') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-tx2" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            if ($REX['USER']->hasPerm('moveSlice[]')) {
                                $moveUp = $I18N->msg('move_slice_up');
                                $moveDown = $I18N->msg('move_slice_down');
                                // upd stamp übergeben, da sonst ein block nicht mehrfach hintereindander verschoben werden kann
                                // (Links wären sonst gleich und der Browser lässt das klicken auf den gleichen Link nicht zu)
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=moveup') . '" title="' . $moveUp . '" class="rex-slice-move-up"><span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '" class="rex-slice-move-down"><span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            }
                            // ----- EXTENSION POINT
                            $listElements = rex_register_extension_point('ART_SLICE_MENU', $listElements, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID]));
                            $mne = $msg;
                            if ($this->function == "edit" && $this->slice_id == $RE_CONTS[$I_ID]) {
                                $mne .= '<div class="rex-content-editmode-module-name rex-form-content-editmode-edit-slice">';
                            } else {
                                $mne .= '<div class="rex-content-editmode-module-name">';
                            }
                            $mne .= '
                <h3 class="rex-hl4">' . htmlspecialchars($RE_MODUL_NAME[$I_ID]) . '</h3>
                <div class="rex-navi-slice">
                  <ul>
              ';
                            $listElementFlag = true;
                            foreach ($listElements as $listElement) {
                                $class = '';
                                if ($listElementFlag) {
                                    $class = ' class="rex-navi-first"';
                                    $listElementFlag = false;
                                }
                                $mne .= '<li' . $class . '>' . $listElement . '</li>';
                            }
                            $mne .= '</ul></div></div>';
                            $slice_content .= $mne;
                            if ($this->function == "edit" && $this->slice_id == $RE_CONTS[$I_ID]) {
                                // **************** Aktueller Slice
                                // ----- PRE VIEW ACTION [EDIT]
                                $REX_ACTION = array();
                                // nach klick auf den übernehmen button,
                                // die POST werte übernehmen
                                if (rex_var::isEditEvent()) {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
                                    }
                                } else {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACDatabaseValues($REX_ACTION, $this->CONT);
                                    }
                                }
                                if ($this->function == 'edit') {
                                    $modebit = '2';
                                } elseif ($this->function == 'delete') {
                                    $modebit = '4';
                                } else {
                                    $modebit = '1';
                                }
                                // pre-action and add
                                $ga = new rex_sql();
                                if ($this->debug) {
                                    $ga->debugsql = 1;
                                }
                                $ga->setQuery('SELECT preview FROM ' . $REX['TABLE_PREFIX'] . 'module_action ma,' . $REX['TABLE_PREFIX'] . 'action a WHERE preview != "" AND ma.action_id=a.id AND module_id=' . $RE_MODUL_ID[$I_ID] . ' AND ((a.previewmode & ' . $modebit . ') = ' . $modebit . ')');
                                for ($t = 0; $t < $ga->getRows(); $t++) {
                                    $iaction = $ga->getValue('preview');
                                    // ****************** VARIABLEN ERSETZEN
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $iaction = $obj->getACOutput($REX_ACTION, $iaction);
                                    }
                                    eval('?>' . $iaction);
                                    // ****************** SPEICHERN FALLS NOETIG
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $obj->setACValues($this->CONT, $REX_ACTION);
                                    }
                                    $ga->next();
                                }
                                // ----- / PRE VIEW ACTION
                                $slice_content .= $this->editSlice($RE_CONTS[$I_ID], $RE_MODUL_IN[$I_ID], $RE_CONTS_CTYPE[$I_ID], $RE_MODUL_ID[$I_ID]);
                            } else {
                                // Modulinhalt ausgeben
                                $slice_content .= '
                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                <div class="rex-content-editmode-slice-output">
                <div class="rex-content-editmode-slice-output-2">
                  ' . $RE_MODUL_OUT[$I_ID] . '
                </div>
                </div>
                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                ';
                                $slice_content = $this->replaceVars($this->CONT, $slice_content);
                            }
                        } else {
                            // ----- hat keine rechte an diesem modul
                            $mne = '
           <div class="rex-content-editmode-module-name">
                <h3 class="rex-hl4" id="slice' . $RE_CONTS[$I_ID] . '">' . $RE_MODUL_NAME[$I_ID] . '</h3>
                <div class="rex-navi-slice">
                  <ul>
                    <li>' . $I18N->msg('no_editing_rights') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></li>
                  </ul>
                </div>
          </div>';
                            $slice_content .= $mne . $RE_MODUL_OUT[$I_ID];
                            $slice_content = $this->replaceVars($this->CONT, $slice_content);
                        }
                    } else {
                        // ----- wenn mode nicht edit
                        if ($this->getSlice) {
                            while (list($k, $v) = each($RE_CONTS)) {
                                $I_ID = $k;
                            }
                        }
                        $slice_content .= $RE_MODUL_OUT[$I_ID];
                        $slice_content = $this->replaceVars($this->CONT, $slice_content);
                    }
                    // --------------- ENDE EINZELNER SLICE
                    // --------------- EP: SLICE_SHOW
                    $slice_content = rex_register_extension_point('SLICE_SHOW', $slice_content, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID], 'function' => $this->function, 'function_slice_id' => $this->slice_id));
                    // ---------- slice in ausgabe speichern wenn ctype richtig
                    if ($this->ctype == -1 or $this->ctype == $RE_CONTS_CTYPE[$I_ID]) {
                        $this->content .= $slice_content;
                        // last content type slice id
                        $LCTSL_ID = $RE_CONTS[$I_ID];
                    }
                    // ----- zwischenstand: ctype .. wenn ctype neu dann if
                    if ($this->mode != "edit" && isset($RE_CONTS_CTYPE[$RE_CONTS[$I_ID]]) && $RE_CONTS_CTYPE[$I_ID] != $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] && $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] != "") {
                        $this->content .= "<?php } if(\$this->ctype == '" . $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] . "' || \$this->ctype == '-1'){ ?>";
                    }
                    // zum nachsten slice
                    $I_ID = $RE_CONTS[$I_ID];
                    $PRE_ID = $I_ID;
                }
                // ----- end: ctype unterscheidung
                if ($this->mode != "edit" && $i > 0) {
                    $this->content .= "<?php } ?>";
                }
                // ----- add module im edit mode
                if ($this->mode == "edit") {
                    $form_url = 'index.php';
                    if ($this->function == "add" && $this->slice_id == $LCTSL_ID) {
                        $slice_content = $this->addSlice($LCTSL_ID, $module_id);
                    } else {
                        // ----- BLOCKAUSWAHL - SELECT
                        $MODULESELECT[$this->ctype]->setId("module_id" . $LCTSL_ID);
                        // $slice_content = $add_select_box;
                        $slice_content = '
            <div class="rex-form rex-form-content-editmode">
            <form action="' . $form_url . '" method="get">
              <fieldset class="rex-form-col-1">
                <legend><span>' . $I18N->msg("add_block") . '</span></legend>
                <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                <input type="hidden" name="page" value="content" />
                <input type="hidden" name="mode" value="' . $this->mode . '" />
                <input type="hidden" name="slice_id" value="' . $LCTSL_ID . '" />
                <input type="hidden" name="function" value="add" />
                <input type="hidden" name="clang" value="' . $this->clang . '" />
                <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                  
                  <div class="rex-form-wrapper">
                    <div class="rex-form-row">
                      <p class="rex-form-col-a rex-form-select">
                        ' . $MODULESELECT[$this->ctype]->get() . '
                        <noscript><input class="rex-form-submit" type="submit" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                      </p>
                    </div>
                  </div>
              </fieldset>
            </form>
            </div>';
                    }
                    $this->content .= $slice_content;
                }
                // -------------------------- schreibe content
                if ($this->eval === FALSE) {
                    echo $this->replaceLinks($this->content);
                } else {
                    eval("?>" . $this->content);
                }
            } else {
                echo $I18N->msg('no_article_available');
            }
        }
        // ----- end: article caching
        $CONTENT = ob_get_contents();
        ob_end_clean();
        return $CONTENT;
    }
 /**
  * @access public
  */
 function getFiles()
 {
     if ($this->_files === null) {
         $this->_files = array();
         $qry = 'SELECT file_id FROM ' . OOMedia::_getTableName() . ' WHERE category_id = ' . $this->getId();
         $sql = new rex_sql();
         $sql->setQuery($qry);
         $result = $sql->getArray();
         if (is_array($result)) {
             foreach ($result as $line) {
                 $this->_files[] =& OOMedia::getMediaById($line['file_id']);
             }
         }
     }
     return $this->_files;
 }
예제 #30
0
    function showList($eingeloggt = FALSE, $msg = "", $returnUrl = false)
    {
        $I18N_NEWS_DB = new i18n(REX_LANG, REX_INCLUDE_PATH . '/addons/' . MY_PAGE . '/lang');
        if (!empty($msg)) {
            print "<div class=\"msg\">{$msg}</div>\n";
        }
        $conf['max'] = $this->num == "" ? $conf['max'] = 10 : $this->num;
        $conf['page'] = $_GET['page'] ? $_GET['page'] : 1;
        if ($this->pagination == 0) {
            $conf['page'] = 1;
        }
        $conf['page'] = (int) $conf['page'];
        if ($this->archive == "" or $this->archive == "0") {
            $addWhere = 'WHERE (
                    ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
                    AND
                    ((archive_date = "0000-00-00") OR REPLACE(archive_date, "-", "") > CURDATE() + 0)
                    AND 
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
            )';
        } elseif ($this->archive == "1") {
            $addWhere = 'WHERE (
                    (
                        (offline_date != "0000-00-00") AND (REPLACE(offline_date, "-", "") > CURDATE() + 0)
                        OR (offline_date = "0000-00-00")
                    )
                    AND
                    ((archive_date != "0000-00-00") AND REPLACE(archive_date, "-", "") <= CURDATE() + 0)
                    AND 
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
             )';
        } else {
            $addWhere = 'WHERE (
                    ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
                    AND
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
            )';
        }
        $_cat = $_GET['cat'];
        if (isset($_cat)) {
            $addSQL = 'AND category LIKE "%|' . $_cat . '|%" ';
        }
        if ($this->category > 0 and $this->category != 999) {
            $addSQL = 'AND category LIKE "%|' . $this->category . '|%" ';
        }
        if ($this->active == 0) {
            $addSQL .= 'AND status = "0" ';
        }
        if ($this->active == 1) {
            $addSQL .= 'AND status = "1" ';
        }
        if ($this->language != "") {
            $addSQL .= 'AND clang = ' . $this->language;
        }
        if ($this->view == 1) {
            $addSQL .= ' AND flag = 1';
        } else {
            if ($this->view == 2) {
                $addSQL .= ' AND flag = 0';
            }
        }
        // 21.04.2013: StickyNews auf Startseite priorisiert
        $addSticky = $addOrderBy = "";
        if ($this->id == $this->start_article_id) {
            $addSticky = ',
				CASE 
				WHEN REPLACE(stickyUntil, "-", "") > CURDATE() + 0 THEN true
				ELSE false
				END as st		
			';
            $addOrderBy = 'st DESC, ';
        }
        $qry = 'SELECT * ' . $addSticky . '
				FROM ' . TBL_NEWS . ' 
				' . $addWhere . '
				' . $addSQL . '
				ORDER BY ' . $addOrderBy . 'online_date ' . $this->sort;
        if ($result = mysql_query($qry)) {
            $total = mysql_num_rows($result);
        }
        $pnum = round(ceil($total / $conf['max']), $conf['max']);
        $limitStart = ($conf['page'] - 1) * $conf['max'];
        $limitEnd = $conf['max'];
        $qry .= ' LIMIT ' . $limitStart . ',' . $limitEnd;
        $sql = new rex_sql();
        if ($this->debug == 1) {
            $sql->debugsql = true;
        }
        $data = $sql->getArray($qry);
        if ($this->pagination == 1 and $total > $conf['max']) {
            $pager['jumplist'] = self::drawJumplist(rex_getUrl('', '', array("page" => 'SEITENZAHL'), '&amp;'), "&lt;", " ", "&gt;", $conf['page'], $pnum);
        }
        // http://www.redaxo.org/de/forum/addons-f30/news-addon-d-mind-t18730.html
        if (!class_exists('Smarty')) {
            include 'redaxo/include/addons/news/libs/Smarty.class.php';
        }
        $t = new Smarty();
        $t->debugging = false;
        $t->caching = false;
        $t->cache_lifetime = 120;
        $t->config_dir = 'redaxo/include/addons/news/view/configs/';
        $t->compile_dir = 'redaxo/include/addons/news/view/templates_c/';
        $t->cache_dir = 'redaxo/include/addons/news/view/cache/';
        $t->template_dir = 'redaxo/include/addons/news/view/templates/';
        if (is_array($data) && sizeof($data) > 0) {
            $i = 1;
            foreach ($data as $row) {
                // Selbe News ausschliessen, falls in rechter Spalte Liste
                if ($row['id'] == rex_request('newsid')) {
                    continue;
                }
                include "redaxo/include/addons/" . MY_PAGE . "/conf/conf.php";
                if ($this->detailArticle) {
                    if ($REX_NEWS_CONF['rewrite'] == 1) {
                        $url = self::rewriteNewsUrls($row['name'], $row['id']);
                    } else {
                        $url = rex_getUrl($this->detailArticle, $this->language, array('newsid' => $row['id']), '&amp;');
                    }
                }
                $item[$i]['id'] = $row['id'];
                $item[$i]['name'] = $row['name'];
                $item[$i]['url'] = $url;
                $item[$i]['date'] = $this->rex_news_format_date($row['online_date'], $this->language);
                $item[$i]['source'] = $row["source"];
                $teaser = "";
                if ($row['teaser'] != "") {
                    $teaser = $row['teaser'];
                    $item[$i]['teaser'] = $teaser;
                } else {
                    $teaser2 = htmlspecialchars_decode($row["article"]);
                    $teaser2 = str_replace("<br />", "", $teaser);
                    $teaser2 = rex_a79_textile($teaser);
                    $teaser2 = str_replace("###", "&#x20;", $teaser);
                    $teaser2 = strip_tags($teaser);
                    $item[$i]['teaser'] = substr($teaser2, 0, strpos($teaser2, ".", 80) + 1);
                }
                $text = htmlspecialchars_decode($row["article"]);
                $text = str_replace("<br />", "", $text);
                $text = rex_a79_textile($text);
                $text = str_replace("###", "&#x20;", $text);
                $text = strip_tags($text);
                $item[$i]['text'] = $text;
                if ($row["thumb"] != "" and $this->images == true) {
                    // Bildausgabe
                    $images = explode(",", $row["thumb"]);
                    if (file_exists($REX['HTDOCS_PATH'] . 'files/' . $images[0])) {
                        $media = OOMedia::getMediaByName($images[0]);
                        if (is_array($media) and sizeof($media) > 0) {
                            $mediaTitle = $media->getValue('title');
                            $MediaDesc = $media->getValue('med_description');
                        }
                    }
                    $item[$i]['image'] = '<a href="' . $url . '" title="' . $row['name'] . '"><img src="index.php?rex_img_type=' . $REX_NEWS_CONF['image_list_type'] . '&amp;rex_img_file=' . $images[0] . '" title="' . $mediaTitle . '" alt="' . $MediaDesc . '" /></a>';
                }
                $i++;
            }
        }
        $t->assign("pager", $pager);
        $t->assign("data", $item);
        $t->display($this->template);
    }