/**
 * Ausgabe des Seitentitels
 *
 *
 * Beispiel für einen Seitentitel
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'),
 *  array( 'lang'  , 'Sprachen'),
 *  array( 'groups', 'Gruppen')
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 *
 *
 * Beispiel für einen Seitentitel mit Rechteprüfung
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'   , 'index_perm'),
 *  array( 'lang'  , 'Sprachen', 'lang_perm'),
 *  array( 'groups', 'Gruppen' , 'group_perm')
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 *
 *
 * Beispiel für einen Seitentitel eigenen Parametern
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'   , '', array('a' => 'b')),
 *  array( 'lang'  , 'Sprachen', '', 'a=z&x=12'),
 *  array( 'groups', 'Gruppen' , '', array('clang' => $REX['CUR_CLANG']))
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 */
function rex_title($head, $subtitle = '')
{
    global $article_id, $category_id, $page, $I18N;
    if (empty($subtitle)) {
        $subtitle = '<div class="rex-title-row rex-title-row-sub rex-title-row-empty"><p>&nbsp;</p></div>';
    } else {
        if (is_array($subtitle) && rex_be_page_container::isValid($subtitle[0])) {
            $nav = rex_be_navigation::factory();
            $nav->setHeadline('default', $I18N->msg('subnavigation', $head));
            foreach ($subtitle as $pageObj) {
                $nav->addPage($pageObj);
            }
            $nav->setActiveElements();
            $subtitle = '<div class="rex-title-row rex-title-row-sub rex-navi-page">' . $nav->getNavigation() . '</div>';
        } else {
            // REDAXO <= 4.2 compat
            $subtitle = '<div class="rex-title-row rex-title-row-sub">' . rex_get_subtitle($subtitle) . '</div>';
        }
    }
    // ----- EXTENSION POINT
    $head = rex_register_extension_point('PAGE_TITLE', $head, array('category_id' => $category_id, 'article_id' => $article_id, 'page' => $page));
    print '
	<div id="rex-title">
  		<div class="rex-title-row"><h1>' . $head . '</h1></div>
  		' . $subtitle . '
	</div>';
    rex_register_extension_point('PAGE_TITLE_SHOWN', $subtitle, array('category_id' => $category_id, 'article_id' => $article_id, 'page' => $page));
    print '
<!-- *** OUTPUT OF CONTENT - START *** -->
	<div id="rex-output">
	';
}
 public static function init($params)
 {
     global $REX, $SEO42_IDS, $SEO42_IDS_CLONE, $SEO42_URLS, $SEO42_URLS_CLONE;
     if ($REX['MOD_REWRITE']) {
         // includes
         require_once $REX['INCLUDE_PATH'] . '/addons/seo42/classes/class.seo42_rewrite.inc.php';
         if ($REX['REDAXO']) {
             // this is only necessary for backend
             $extensionPoints = array('CAT_ADDED', 'CAT_UPDATED', 'CAT_DELETED', 'ART_ADDED', 'ART_UPDATED', 'ART_DELETED', 'ART_META_FORM_SECTION', 'ART_TO_CAT', 'CAT_TO_ART', 'ART_TO_STARTPAGE', 'CLANG_ADDED', 'CLANG_UPDATED', 'CLANG_DELETED', 'ALL_GENERATED');
             // generate pathlist on each extension point
             foreach ($extensionPoints as $extensionPoint) {
                 rex_register_extension($extensionPoint, 'seo42_generate_pathlist');
             }
         }
         // init rewriter
         $rewriter = new SEO42Rewrite();
         // rewrite ep
         rex_register_extension('URL_REWRITE', array($rewriter, 'rewrite'));
         $rewriter->resolve();
         // clone urls for later usage with sync redirects
         if ($REX['ADDON']['seo42']['settings']['sync_redirects']) {
             $SEO42_IDS_CLONE = $SEO42_IDS;
             $SEO42_URLS_CLONE = $SEO42_URLS;
         }
     }
     // init current article
     seo42::initArticle($REX['ARTICLE_ID']);
     // controller
     include $REX['INCLUDE_PATH'] . '/addons/seo42/controller.inc.php';
     // seo42 post init
     rex_register_extension_point('SEO42_INCLUDED');
 }
 public function applyEffects(rex_image $image, $type)
 {
     global $REX;
     if (!$this->image_cacher->isCached($image, $type)) {
         $set = $this->effectsFromType($type);
         // REGISTER EXTENSION POINT
         $set = rex_register_extension_point('IMAGE_MANAGER_FILTERSET', $set, array('rex_image_type' => $type, 'img' => $image));
         $image->prepare();
         // execute effects on image
         $effect = array();
         $c = 1;
         foreach ($set as $effect_params) {
             $effect_class = 'rex_effect_' . $effect_params['effect'];
             require_once dirname(__FILE__) . '/effects/class.' . $effect_class . '.inc.php';
             $effect[$c] = new $effect_class();
             $effect[$c]->setImage($image);
             $effect[$c]->setParams($effect_params['params']);
             if (!$effect[$c]->execute()) {
             } else {
             }
         }
         if (!rex_image::isValid($image) || !$image->isImage()) {
             // Given image is not a valid rex_image
             $image->sendErrorImage();
         }
     }
     return $image;
 }
 static function factory($query, $rowsPerPage = 30, $listName = null, $debug = false, $class = null)
 {
     if (!$class) {
         // ----- EXTENSION POINT
         $class = rex_register_extension_point('REX_LIST_CLASSNAME', 'rex_xform_list', array('query' => $query, 'rowsPerPage' => $rowsPerPage, 'listName' => $listName, 'debug' => $debug));
     }
     return new $class($query, $rowsPerPage, $listName, $debug);
 }
 function factory($query, $rowsPerPage = 30, $listName = null, $debug = false, $class = null)
 {
     // keine spezielle klasse angegeben -> default klasse verwenden?
     if (!$class) {
         // ----- EXTENSION POINT
         $class = rex_register_extension_point('REX_LIST_CLASSNAME', 'rex_xform_list', array('query' => $query, 'rowsPerPage' => $rowsPerPage, 'listName' => $listName, 'debug' => $debug));
     }
     return new $class($query, $rowsPerPage, $listName, $debug);
 }
 function factory()
 {
     static $class = null;
     if (!$class) {
         // ----- EXTENSION POINT
         $class = rex_register_extension_point('REX_NAVI_CLASSNAME', 'rex_navigation');
     }
     return new $class();
 }
function rex_generateAll()
{
    global $REX, $I18N;
    // alles existiert schon
    // -> generiere templates
    // -> generiere article und listen
    // -> generiere file meta
    // ----------------------------------------------------------- generiere templates
    rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0);
    // mkdir($REX['INCLUDE_PATH']."/generated/templates",$REX['FILEPERM']);
    $gt = new sql();
    $gt->setQuery("select * from rex_template");
    for ($i = 0; $i < $gt->getRows(); $i++) {
        $fp = fopen($REX['INCLUDE_PATH'] . "/generated/templates/" . $gt->getValue("rex_template.id") . ".template", "w");
        fputs($fp, $gt->getValue("rex_template.content"));
        fclose($fp);
        @chmod($REX['INCLUDE_PATH'] . "/generated/templates/" . $gt->getValue("rex_template.id") . ".template", 0777);
        $gt->next();
    }
    // ----------------------------------------------------------- generiere artikel
    rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/articles", 0);
    // mkdir($REX['INCLUDE_PATH']."/generated/articles",$REX['FILEPERM']);
    $gc = new sql();
    $gc->setQuery("select distinct id from rex_article");
    for ($i = 0; $i < $gc->getRows(); $i++) {
        rex_generateArticle($gc->getValue("id"));
        $gc->next();
    }
    // ----------------------------------------------------------- generiere clang
    $lg = new sql();
    $lg->setQuery("select * from rex_clang order by id");
    $content = "// --- DYN\n\r";
    for ($i = 0; $i < $lg->getRows(); $i++) {
        $id = $lg->getValue("id");
        $name = $lg->getValue("name");
        $content .= "\n\r\$REX['CLANG']['{$id}'] = \"{$name}\";";
        $lg->next();
    }
    $content .= "\n\r// --- /DYN";
    $file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
    $h = fopen($file, "r");
    $fcontent = fread($h, filesize($file));
    $fcontent = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $content, $fcontent);
    fclose($h);
    $h = fopen($file, "w+");
    fwrite($h, $fcontent, strlen($fcontent));
    fclose($h);
    @chmod($file, 0777);
    // ----------------------------------------------------------- generiere filemetas ...
    // **********************
    // ----------------------------------------------------------- message
    $MSG = $I18N->msg('articles_generated') . " " . $I18N->msg('old_articles_deleted');
    // ----- EXTENSION POINT
    $MSG = rex_register_extension_point('ALL_GENERATED', $MSG);
    return $MSG;
}
 function read()
 {
     $config =& $this->getConfig();
     $config->readCache();
     if ($cache = file($config->getFileName())) {
         ob_clean();
         $content = implode('', $cache);
         // ----- EXTENSION POINT
         $content = rex_register_extension_point('OUTPUT_CACHE', $content);
         return $content;
     }
     return false;
 }
 function execute()
 {
     // echo "DB EXECUTE";
     // return;
     $sql = rex_sql::factory();
     if ($this->params["debug"]) {
         $sql->debugsql = TRUE;
     }
     $main_table = "";
     if (!($main_table = $this->action["elements"][2])) {
         $main_table = $this->params["main_table"];
     }
     if ($main_table == "") {
         $this->params["form_show"] = TRUE;
         $this->params["hasWarnings"] = TRUE;
         $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         return FALSE;
     }
     $sql->setTable($main_table);
     $where = "";
     if ($where = $this->getElement(3)) {
         if ($where == "main_where") {
             $where = $this->params["main_where"];
         }
     }
     // SQL Objekt mit Werten füllen
     foreach ($this->elements_sql as $key => $value) {
         $sql->setValue($key, $value);
         if ($where != "") {
             $where = str_replace('###' . $key . '###', addslashes($value), $where);
         }
     }
     if ($where != "") {
         $sql->setWhere($where);
         $saved = $sql->update();
         $flag = "update";
     } else {
         $saved = $sql->insert();
         $flag = "insert";
         $id = $sql->getLastId();
         $this->params["main_id"] = $id;
         $this->elements_email["ID"] = $id;
         // $this->elements_sql["ID"] = $id;
         if ($id == 0) {
             $this->params["form_show"] = TRUE;
             $this->params["hasWarnings"] = TRUE;
             $this->params["warning_messages"][] = $this->params["Error-Code-InsertQueryError"];
         }
         rex_register_extension_point('REX_XFORM_SAVED', $saved, array('form' => $this, 'sql' => $sql, 'xform' => true));
     }
 }
/**
 * Sendet einen rex_article zum Client,
 * fügt ggf. HTTP1.1 cache headers hinzu
 *
 * @param $REX_ARTICLE rex_article Den zu sendenen Artikel
 * @param $content string Inhalt des Artikels
 * @param $environment string Die Umgebung aus der der Inhalt gesendet wird
 * (frontend/backend)
 */
function rex_send_article($REX_ARTICLE, $content, $environment)
{
    // ----- EXTENSION POINT
    $content = rex_register_extension_point('OUTPUT_FILTER', $content);
    // ----- EXTENSION POINT - keine Manipulation der Ausgaben ab hier (read only)
    rex_register_extension_point('OUTPUT_FILTER_CACHE', $content, '', true);
    $contentMd5 = md5($content);
    if ($REX_ARTICLE) {
        $lastModified = $REX_ARTICLE->getValue('updatedate');
        $contentMd5 .= $REX_ARTICLE->getValue('pid');
    } else {
        $lastModified = time();
    }
    rex_send_content($content, $lastModified, $contentMd5, $environment);
}
 function executeAction()
 {
     $sql = rex_sql::factory();
     if ($this->params['debug']) {
         $sql->debugsql = true;
     }
     $main_table = '';
     if (!($main_table = $this->getElement(2))) {
         $main_table = $this->params['main_table'];
     }
     if ($main_table == '') {
         $this->params['form_show'] = true;
         $this->params['hasWarnings'] = true;
         $this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
         return false;
     }
     $sql->setTable($main_table);
     $where = '';
     if ($where = $this->getElement(3)) {
         if ($where == 'main_where') {
             $where = $this->params['main_where'];
         }
     }
     foreach ($this->params['value_pool']['sql'] as $key => $value) {
         $sql->setValue($key, $value);
         if ($where != '') {
             $where = str_replace('###' . $key . '###', addslashes($value), $where);
         }
     }
     if ($where != '') {
         $sql->setWhere($where);
         $saved = $sql->update();
         $flag = 'update';
     } else {
         $saved = $sql->insert();
         $flag = 'insert';
         $id = $sql->getLastId();
         $this->params['main_id'] = $id;
         $this->params['value_pool']['email']['ID'] = $id;
         // $this->params["value_pool"]["sql"]["ID"] = $id;
         if ($id == 0) {
             $this->params['form_show'] = true;
             $this->params['hasWarnings'] = true;
             $this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
         }
     }
     rex_register_extension_point('REX_XFORM_SAVED', $saved, array('form' => $this, 'sql' => $sql, 'xform' => true));
 }
 function prepare()
 {
     // ----- EXTENSION POINT
     $dashboard_notifications = array();
     $dashboard_notifications = rex_register_extension_point('DASHBOARD_NOTIFICATION', $dashboard_notifications);
     $content = '';
     if (count($dashboard_notifications) > 0) {
         foreach ($dashboard_notifications as $notification) {
             if (rex_dashboard_notification::isValid($notification) && $notification->checkPermission()) {
                 $content .= $notification->_get();
             }
         }
         unset($dashboard_notifications);
     }
     $this->setContent($content);
 }
/**
 * Object Helper Function:
 * Returns a url for linking to this article
 * This url respects the setting for mod_rewrite
 * support!
 *
 * If you pass an associative array for $params,
 * then these parameters will be attached to the URL.
 * e.g.:
 *   $param = array("order" => "123", "name" => "horst");
 *   $article->getUrl($param);
 * will return:
 *   index.php?article_id=1&order=123&name=horst
 * or if mod_rewrite support is activated:
 *   /1-The_Article_Name?order=123&name=horst
 */
function rex_getUrl($id = '', $clang = '', $params = '')
{
    global $REX, $article_id;
    // ----- get id
    if (strlen($id) == 0 || $id == 0) {
        $id = $article_id;
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if (strlen($clang) == 0 && (count($REX['CLANG']) > 1 || rex_extension_is_registered('URL_REWRITE'))) {
        $clang = $REX['CUR_CLANG'];
    }
    // ----- get params
    $param_string = '';
    if (is_array($params)) {
        foreach ($params as $key => $value) {
            $param_string .= '&amp;' . $key . '=' . $value;
        }
    } elseif ($params != '') {
        $param_string = str_replace('&', '&amp;', $params);
    }
    // ----- get article name
    $id = (int) $id;
    if ($id != 0) {
        $ooa = OOArticle::getArticleById($id);
        if ($ooa) {
            $name = rex_parseArticleName($ooa->getName());
        }
    }
    if (!isset($name) or $name == '') {
        $name = 'NoName';
    }
    // ----- EXTENSION POINT
    $url = rex_register_extension_point('URL_REWRITE', '', array('id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string));
    if ($url == '') {
        // ----- get rewrite function
        if ($REX['MOD_REWRITE'] === true || $REX['MOD_REWRITE'] == 'true') {
            $rewrite_fn = 'rexrewrite_apache_rewrite';
        } else {
            $rewrite_fn = 'rexrewrite_no_rewrite';
        }
        $url = call_user_func($rewrite_fn, $id, $name, $clang, $param_string);
    }
    return $url;
}
/**
 * Sendet einen rex_article zum Client,
 * fügt ggf. HTTP1.1 cache headers hinzu
 *
 * @param $REX_ARTICLE rex_article Den zu sendenen Artikel
 * @param $content string Inhalt des Artikels
 * @param $environment string Die Umgebung aus der der Inhalt gesendet wird
 * (frontend/backend)
 */
function rex_send_article($REX_ARTICLE, $content, $environment, $sendcharset = FALSE)
{
    global $REX;
    // ----- EXTENSION POINT
    $content = rex_register_extension_point('OUTPUT_FILTER', $content, array('environment' => $environment, 'sendcharset' => $sendcharset));
    // ----- EXTENSION POINT - keine Manipulation der Ausgaben ab hier (read only)
    rex_register_extension_point('OUTPUT_FILTER_CACHE', $content, '', true);
    // dynamische teile sollen die md5 summe nicht beeinflussen
    $etag = md5(preg_replace('@<!--DYN-->.*<!--/DYN-->@', '', $content));
    if ($REX_ARTICLE) {
        $lastModified = $REX_ARTICLE->getValue('updatedate');
        $etag .= $REX_ARTICLE->getValue('pid');
        if ($REX_ARTICLE->getArticleId() == $REX['NOTFOUND_ARTICLE_ID'] && $REX_ARTICLE->getArticleId() != $REX['START_ARTICLE_ID']) {
            header("HTTP/1.0 404 Not Found");
        }
    } else {
        $lastModified = time();
    }
    rex_send_content($content, $lastModified, $etag, $environment, $sendcharset);
}
/**
 * Ausgabe des Seitentitels
 *
 *
 * Beispiel für einen Seitentitel
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'),
 *  array( 'lang'  , 'Sprachen'),
 *  array( 'groups', 'Gruppen')
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 *
 *
 * Beispiel für einen Seitentitel mit Rechteprüfung
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'   , 'index_perm'),
 *  array( 'lang'  , 'Sprachen', 'lang_perm'),
 *  array( 'groups', 'Gruppen' , 'group_perm')
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 *
 *
 * Beispiel für einen Seitentitel eigenen Parametern
 *
 * <code>
 * $subpages = array(
 *  array( ''      , 'Index'   , '', array('a' => 'b')),
 *  array( 'lang'  , 'Sprachen', '', 'a=z&x=12'),
 *  array( 'groups', 'Gruppen' , '', array('clang' => $REX['CUR_CLANG']))
 * );
 *
 * rex_title( 'Headline', $subpages)
 * </code>
 */
function rex_title($head, $subtitle = '')
{
    global $article_id, $category_id, $page;
    if ($subtitle == '') {
        $subtitle = '<p>&nbsp;</p>';
    } else {
        $subtitle = '<div class="rex-title-row">' . rex_get_subtitle($subtitle) . '</div>';
    }
    // ----- EXTENSION POINT
    $head = rex_register_extension_point('PAGE_TITLE', $head, array('category_id' => $category_id, 'article_id' => $article_id, 'page' => $page));
    print '
	<div id="rex-title">
  		<div class="rex-title-row"><h1>' . $head . '</h1></div>
  		' . $subtitle . '
	</div>';
    rex_register_extension_point('PAGE_TITLE_SHOWN', $subtitle, array('category_id' => $category_id, 'article_id' => $article_id, 'page' => $page));
    print '
<!-- *** OUTPUT OF CONTENT - START *** -->
	<div id="rex-output">
	';
}
/**
 * Gibt eine Url zu einem Artikel zurück
 *
 * @param [$_id] ArtikelId des Artikels
 * @param [$_clang] SprachId des Artikels
 * @param [$_params] Array von Parametern
 * @param [$_divider] Trennzeichen für Parameter
 * (z.B. &amp; für HTML, & für Javascript)
 */
function rex_getUrl($_id = '', $_clang = '', $_params = '', $_divider = '&amp;')
{
    global $REX, $article_id;
    $id = (int) $_id;
    $clang = (int) $_clang;
    // ----- get id
    if ($id == 0) {
        $id = $article_id;
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if ($_clang === '' && (count($REX['CLANG']) > 1 || rex_extension_is_registered('URL_REWRITE'))) {
        $clang = $REX['CUR_CLANG'];
    }
    // ----- get params
    $param_string = rex_param_string($_params, $_divider);
    if ($id != 0) {
        $ooa = OOArticle::getArticleById($id, $clang);
        if ($ooa) {
            $name = rex_parse_article_name($ooa->getName());
        }
    }
    if (!isset($name) or $name == '') {
        $name = 'NoName';
    }
    // ----- EXTENSION POINT
    $url = rex_register_extension_point('URL_REWRITE', '', array('id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string, 'divider' => $_divider));
    if ($url == '') {
        // ----- get rewrite function
        if ($REX['MOD_REWRITE'] === true || $REX['MOD_REWRITE'] == 'true') {
            $rewrite_fn = 'rex_apache_rewrite';
        } else {
            $rewrite_fn = 'rex_no_rewrite';
        }
        $url = call_user_func($rewrite_fn, $id, $name, $clang, $param_string, $_divider);
    }
    return $url;
}
/**
 * Sendet den Content zum Client,
 * fügt ggf. HTTP1.1 cache headers hinzu
 *
 * @param $REX_ARTICLE rex_article Den zu sendenen Artikel
 * @param $content string Inhalt des Artikels
 * @param $environment string Die Umgebung aus der der Inhalt gesendet wird
 * (frontend/backend)
 */
function rex_send_content($REX_ARTICLE, $content, $environment)
{
    global $REX;
    // ----- EXTENSION POINT
    $content = rex_register_extension_point('OUTPUT_FILTER', $content);
    // ----- EXTENSION POINT - keine Manipulation der Ausgaben ab hier (read only)
    rex_register_extension_point('OUTPUT_FILTER_CACHE', $content, '', true);
    // ----- Last-Modified
    if ($REX['USE_LAST_MODIFIED'] === 'true' || $REX['USE_LAST_MODIFIED'] == $environment) {
        rex_send_last_modified($REX_ARTICLE);
    }
    // ----- ETAG
    if ($REX['USE_ETAG'] === 'true' || $REX['USE_ETAG'] == $environment) {
        rex_send_etag($REX_ARTICLE, $content);
    }
    // ----- GZIP
    if ($REX['USE_GZIP'] === 'true' || $REX['USE_GZIP'] == $environment) {
        $content = rex_send_gzip($content);
    }
    // Evtl offene Db Verbindungen schließen
    rex_sql::disconnect(null);
    echo $content;
}
function rex_a256_search_mpool_query($params)
{
    global $REX, $REX_USER;
    if (!($REX_USER->isAdmin() || $REX_USER->hasPerm('be_search[medienpool]'))) {
        return $params['subject'];
    }
    $media_name = rex_request('a256_media_name', 'string');
    if ($media_name == '') {
        return $params['subject'];
    }
    $category_id = $params['category_id'];
    $qry = "SELECT *\n          FROM " . $REX['TABLE_PREFIX'] . "file f, " . $REX['TABLE_PREFIX'] . "file_category c\n          WHERE f.category_id = c.id AND (filename LIKE '%" . $media_name . "%' OR title LIKE '%" . $media_name . "%')";
    switch (OOAddon::getProperty('be_search', 'searchmode', 'local')) {
        case 'local':
            // Suche auf aktuellen Kontext eingrenzen
            if ($category_id != 0) {
                $qry .= " AND (c.path LIKE '%|" . $params['category_id'] . "|%' OR c.id=" . $params['category_id'] . ") ";
            }
    }
    $qry .= 'ORDER BY f.updatedate desc';
    $qry = rex_register_extension_point('A256_MEDIENPOOL_QUERY', $qry);
    return $qry;
}
 static function sendMail($template, $template_name = '')
 {
     $r = rex_register_extension_point('XFORM_EMAIL_BEFORE_SEND', array('template' => $template, 'template_name' => $template_name, 'status' => false));
     $template = $r['template'];
     $template_name = $r['template_name'];
     $status = $r['status'];
     if ($status) {
         return true;
     }
     $mail = new rex_mailer();
     $mail->AddAddress($template['mail_to'], $template['mail_to_name']);
     $mail->SetFrom($template['mail_from'], $template['mail_from_name']);
     $mail->Subject = $template['subject'];
     $mail->Body = $template['body'];
     if ($template['body_html'] != '') {
         $mail->AltBody = $template['body'];
         $mail->MsgHTML($template['body_html']);
     } else {
         $mail->Body = strip_tags($template['body']);
     }
     if (is_array($template['attachments'])) {
         foreach ($template['attachments'] as $f) {
             $mail->AddAttachment($f['path'], $f['name']);
         }
     }
     if ($mail->Send()) {
         $template['email_subject'] = $template['subject'];
         rex_register_extension_point('XFORM_EMAIL_SENT', $template_name, $template, true);
         // read only
         return true;
     } else {
         $template['email_subject'] = $template['subject'];
         rex_register_extension_point('XFORM_EMAIL_SENT_FAILED', $template_name, $template, true);
         // read only
         return false;
     }
 }
Beispiel #20
0
 function image_manager_init()
 {
     global $REX;
     //--- handle image request
     $rex_img_file = rex_get('rex_img_file', 'string');
     $rex_img_type = rex_get('rex_img_type', 'string');
     $rex_img_init = false;
     if ($rex_img_file != '' && $rex_img_type != '') {
         $rex_img_init = true;
     }
     $imagepath = $REX['HTDOCS_PATH'] . $REX['MEDIA_DIR'] . '/' . $rex_img_file;
     $cachepath = $REX['GENERATED_PATH'] . '/files/';
     // REGISTER EXTENSION POINT
     $subject = array('rex_img_type' => $rex_img_type, 'rex_img_file' => $rex_img_file, 'rex_img_init' => $rex_img_init, 'imagepath' => $imagepath, 'cachepath' => $cachepath);
     $subject = rex_register_extension_point('IMAGE_MANAGER_INIT', $subject);
     if (isset($subject['rex_img_file'])) {
         $rex_img_file = $subject['rex_img_file'];
     }
     if (isset($subject['rex_img_type'])) {
         $rex_img_type = $subject['rex_img_type'];
     }
     if (isset($subject['imagepath'])) {
         $imagepath = $subject['imagepath'];
     }
     if (isset($subject['cachepath'])) {
         $cachepath = $subject['cachepath'];
     }
     if ($subject['rex_img_init']) {
         $image = new rex_image($imagepath);
         $image_cacher = new rex_image_cacher($cachepath);
         $image_manager = new rex_image_manager($image_cacher);
         $image = $image_manager->applyEffects($image, $rex_img_type);
         $image_manager->sendImage($image, $rex_img_type);
         exit;
     }
 }
									</div>
									<div class="rex-clearer"></div>';
            // ----- EXTENSION POINT
            echo rex_register_extension_point('ART_META_FORM', '', array('id' => $article_id, 'clang' => $clang, 'article' => $article));
            echo '

									<div class="rex-form-row">
										<p class="rex-form-col-a rex-form-submit">
								  		<input class="rex-form-submit" type="submit" name="savemeta" value="' . $I18N->msg("update_metadata") . '"' . rex_accesskey($I18N->msg('update_metadata'), $REX['ACKEY']['SAVE']) . rex_tabindex() . ' />
										</p>
									</div>
									<div class="rex-clearer"></div>
								</div>
	           </fieldset>';
            // ----- EXTENSION POINT
            echo rex_register_extension_point('ART_META_FORM_SECTION', '', array('id' => $article_id, 'clang' => $clang));
            echo '</div>';
            $isStartpage = $article->getValue('startpage') == 1;
            // ------------------------------------------------------------- SONSTIGES START
            $out = '';
            // --------------------------------------------------- ZUM STARTARTICLE MACHEN START
            if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('article2startpage[]')) {
                $out .= '
         		<fieldset class="rex-form-col-1">
         			<legend>' . $I18N->msg('content_startarticle') . '</legend>
         			<div class="rex-form-wrapper">
         				
         				<div class="rex-form-row">
         					<p class="rex-form-col-a';
                if (!$isStartpage && $article->getValue('re_id') == 0) {
                    $out .= ' rex-form-read"><span class="rex-form-read">' . $I18N->msg('content_nottostartarticle') . '</span>';
/**
 * Erstellt den nötigen HTML Code um ein Formular zu erweitern
 *
 * @param $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
 * @param $activeItem objekt, dass mit getValue() die Werte des akuellen Eintrags zurückgibt
 * @param $formatCallback callback, dem die infos als Array übergeben werden und den formatierten HTML Text zurückgibt
 */
function rex_a62_metaFields($sqlFields, $activeItem, $formatCallback, $epParams)
{
    global $I18N;
    $s = '';
    // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
    $media_id = 1;
    $mlist_id = 1;
    $link_id = 1;
    $llist_id = 1;
    $sqlFields->reset();
    for ($i = 0; $i < $sqlFields->getRows(); $i++) {
        // Umschliessendes Tag von Label und Formularelement
        $tag = 'p';
        $tag_attr = '';
        $name = $sqlFields->getValue('name');
        $title = $sqlFields->getValue('title');
        $params = $sqlFields->getValue('params');
        $typeLabel = $sqlFields->getValue('label');
        $attr = $sqlFields->getValue('attributes');
        $dblength = $sqlFields->getValue('dblength');
        $dbvalues = array(htmlspecialchars($sqlFields->getValue('default')));
        $dbvalues_esc = $dbvalues;
        if ($activeItem) {
            $itemValue = $activeItem->getValue($name);
            if (strpos($itemValue, '|+|') !== false) {
                // Alte notation mit |+| als Trenner
                $dbvalues = explode('|+|', $activeItem->getValue($name));
            } else {
                // Neue Notation mit | als Trenner
                $dbvalues = explode('|', $activeItem->getValue($name));
            }
            $dbvalues_esc = array_map('htmlspecialchars', $dbvalues);
        }
        if ($title != '') {
            $label = htmlspecialchars(rex_translate($title));
        } else {
            $label = htmlspecialchars($name);
        }
        $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
        $attr .= rex_tabindex();
        $labelIt = true;
        $field = '';
        switch ($typeLabel) {
            case 'text':
                $field = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $dbvalues_esc[0] . '" id="' . $id . ' "maxlength="' . $dblength . '" ' . $attr . ' />';
                break;
            case 'checkbox':
                $name .= '[]';
            case 'radio':
                $values = array();
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    $sql = new rex_sql();
                    $value_groups = $sql->getDBArray($params, MYSQL_NUM);
                    foreach ($value_groups as $value_group) {
                        if (isset($value_group[1])) {
                            $values[$value_group[1]] = $value_group[0];
                        } else {
                            $values[$value_group[0]] = $value_group[0];
                        }
                    }
                } else {
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                }
                $class = $typeLabel == 'radio' ? 'rex-rdo' : 'rex-chckbx';
                $oneValue = count($values) == 1;
                if (!$oneValue) {
                    $tag = '';
                    $labelIt = false;
                    $tag = 'div';
                    $tag_attr = ' class="rex-chckbxs rex-ptag"';
                    $field .= '<p>' . $label . '</p>';
                }
                foreach ($values as $key => $value) {
                    $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                    $key = htmlspecialchars($key);
                    // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                    // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                    if ($oneValue && $key == '') {
                        $key = 'true';
                    }
                    $selected = '';
                    if (in_array($key, $dbvalues_esc)) {
                        $selected = ' checked="checked"';
                    }
                    if ($oneValue) {
                        $tag_attr = ' class="' . $class . '"';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                    } else {
                        $field .= '<p class="' . $class . '">' . "\n";
                        $field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
                        $field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
                        $field .= '</p>' . "\n";
                    }
                }
                break;
            case 'select':
                $select = new rex_select();
                $select->setName($name);
                $select->setId($id);
                // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                $select->setSelected($dbvalues);
                foreach (rex_split_string($attr) as $attr_name => $attr_value) {
                    if (empty($attr_name)) {
                        continue;
                    }
                    $select->setAttribute($attr_name, $attr_value);
                    if ($attr_name == 'multiple') {
                        $select->setName($name . '[]');
                    }
                }
                if (rex_sql::getQueryType($params) == 'SELECT') {
                    // Werte via SQL Laden
                    $select->addDBSqlOptions($params);
                } else {
                    // Optionen mit | separiert
                    // eine einzelne Option kann mit key:value separiert werden
                    $values = array();
                    $value_groups = explode('|', $params);
                    foreach ($value_groups as $value_group) {
                        if (strpos($value_group, ':') !== false) {
                            $temp = explode(':', $value_group);
                            $values[$temp[0]] = $temp[1];
                        } else {
                            $values[$value_group] = $value_group;
                        }
                    }
                    $select->addOptions($values);
                }
                $field .= $select->get();
                break;
            case 'datetime':
            case 'date':
                if ($dbvalues_esc[0] == '') {
                    $dbvalues_esc[0] = time();
                }
                $style = 'class="rex-fdate"';
                $yearStyle = 'class="rex-fdatey"';
                $yearSelect = new rex_select();
                $yearSelect->addOptions(range(2005, date('Y') + 10), true);
                $yearSelect->setName($name . '[year]');
                $yearSelect->setSize(1);
                $yearSelect->setId($id);
                $yearSelect->setStyle($yearStyle);
                $yearSelect->setSelected(date('Y', $dbvalues_esc[0]));
                $monthSelect = new rex_select();
                $monthSelect->addOptions(range(1, 12), true);
                $monthSelect->setName($name . '[month]');
                $monthSelect->setSize(1);
                $monthSelect->setStyle($style);
                $monthSelect->setSelected(date('m', $dbvalues_esc[0]));
                $daySelect = new rex_select();
                $daySelect->addOptions(range(1, 31), true);
                $daySelect->setName($name . '[day]');
                $daySelect->setSize(1);
                $daySelect->setStyle($style);
                $daySelect->setSelected(date('j', $dbvalues_esc[0]));
                if ($typeLabel == 'datetime') {
                    $hourSelect = new rex_select();
                    $hourSelect->addOptions(range(1, 23), true);
                    $hourSelect->setName($name . '[hour]');
                    $hourSelect->setSize(1);
                    $hourSelect->setStyle($style);
                    $hourSelect->setSelected(date('G', $dbvalues_esc[0]));
                    $minuteSelect = new rex_select();
                    $minuteSelect->addOptions(range(0, 59), true);
                    $minuteSelect->setName($name . '[minute]');
                    $minuteSelect->setSize(1);
                    $minuteSelect->setStyle($style);
                    $minuteSelect->setSelected(date('i', $dbvalues_esc[0]));
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get() . '-' . $hourSelect->get() . $minuteSelect->get();
                } else {
                    $field = $daySelect->get() . $monthSelect->get() . $yearSelect->get();
                }
                break;
            case 'textarea':
                $field = '<textarea name="' . $name . '" id="' . $id . '" cols="50" rows="6" ' . $attr . '>' . $dbvalues_esc[0] . '</textarea>';
                break;
            case 'REX_MEDIA_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $field = rex_var_media::getMediaButton($media_id);
                $field = str_replace('REX_MEDIA[' . $media_id . ']', $dbvalues_esc[0], $field);
                $field = str_replace('MEDIA[' . $media_id . ']', $name, $field);
                $id = 'REX_MEDIA_' . $media_id;
                $media_id++;
                break;
            case 'REX_MEDIALIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $name .= '[]';
                $field = rex_var_media::getMediaListButton($mlist_id, implode(',', $dbvalues_esc));
                $field = str_replace('MEDIALIST[' . $mlist_id . ']', $name, $field);
                $id = 'REX_MEDIALIST_' . $mlist_id;
                $mlist_id++;
                break;
            case 'REX_LINK_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $field = rex_var_link::getLinkButton($link_id, $dbvalues_esc[0], $category);
                $field = str_replace('LINK[' . $link_id . ']', $name, $field);
                $id = 'LINK_' . $link_id;
                $link_id++;
                break;
            case 'REX_LINKLIST_BUTTON':
                $tag = 'div';
                $tag_attr = ' class="rex-ptag"';
                $category = '';
                if ($activeItem) {
                    $category = $activeItem->getValue('category_id');
                }
                $name .= '[]';
                $field = rex_var_link::getLinklistButton($llist_id, implode(',', $dbvalues), $category);
                $field = str_replace('LINKLIST[' . $llist_id . ']', $name, $field);
                $id = 'REX_LINKLIST_' . $llist_id;
                $llist_id++;
                break;
            default:
                // ----- EXTENSION POINT
                list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_register_extension_point('A62_CUSTOM_FIELD', array($field, $tag, $tag_attr, $id, $label, $labelIt, 'type' => $typeLabel, 'sql' => $sqlFields));
        }
        $s .= rex_call_func($formatCallback, array($field, $tag, $tag_attr, $id, $label, $labelIt), false);
        $sqlFields->next();
    }
    return $s;
}
/**
 * Ändert eine Clang
 * 
 * @param $id   Id der Clang 
 * @param $name Name der Clang 
 */
function rex_editCLang($id, $name)
{
    global $REX;
    $REX['CLANG'][$id] = $name;
    $file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
    $h = fopen($file, "r");
    $cont = fread($h, filesize($file));
    $cont = ereg_replace("(REX\\['CLANG'\\]\\['{$id}\\'].?\\=.?)[^;]*", "\\1\"" . $name . "\"", $cont);
    fclose($h);
    $h = fopen($REX['INCLUDE_PATH'] . "/clang.inc.php", "w+");
    fwrite($h, $cont, strlen($cont));
    fclose($h);
    @chmod($REX['INCLUDE_PATH'] . "/clang.inc.php", 0777);
    $edit = new sql();
    $edit->query("update " . $REX['TABLE_PREFIX'] . "clang set name='{$name}' where id='{$id}'");
    // ----- EXTENSION POINT
    rex_register_extension_point('CLANG_UPDATED', '', array('id' => $id, 'name' => $name));
}
/**
 * Addonlist
 * @package redaxo4
 * @version $Id: addons.inc.php,v 1.12 2007/10/13 21:44:39 kills Exp $
 */
// ----------------- addons
if (isset($REX['ADDON']['status'])) {
    unset($REX['ADDON']['status']);
}
// ----------------- DONT EDIT BELOW THIS
// --- DYN
$REX['ADDON']['install']['image_resize'] = 1;
$REX['ADDON']['status']['image_resize'] = 1;
$REX['ADDON']['install']['textile'] = 1;
$REX['ADDON']['status']['textile'] = 1;
// --- /DYN
// ----------------- /DONT EDIT BELOW THIS
if (!isset($REX['ADDON']) || !is_array($REX['ADDON'])) {
    $REX['ADDON'] = array();
    $REX['ADDON']['install'] = array();
    $REX['ADDON']['status'] = array();
}
foreach ($REX['ADDON']['status'] as $addonName => $addonStatus) {
    // Warnungen unterdrücken ist schneller als ein file_exists
    if ($addonStatus == 1) {
        @(include $REX['INCLUDE_PATH'] . '/addons/' . $addonName . '/config.inc.php');
    }
}
// ----- all addons configs included
rex_register_extension_point('ADDONS_INCLUDED');
 /**
  * Speichert das Formular
  *
  * Gibt true zurück wenn alles ok war, false bei einem allgemeinen Fehler oder
  * einen String mit einer Fehlermeldung.
  */
 function save()
 {
     // trigger extensions point
     // Entscheiden zwischen UPDATE <-> CREATE via editMode möglich
     // Falls die Extension FALSE zurückgibt, nicht speicher,
     // um hier die Möglichkeit offen zu haben eigene Validierungen/Speichermechanismen zu implementieren
     if (rex_register_extension_point('REX_FORM_' . strtoupper($this->getName()) . '_SAVE', '', array('form' => $this)) === false) {
         return;
     }
     $sql = rex_sql::getInstance();
     $sql->debugsql =& $this->debug;
     $sql->setTable($this->tableName);
     foreach ($this->getFieldsets() as $fieldsetName) {
         // POST-Werte ermitteln
         $fieldValues = $this->fieldsetPostValues($fieldsetName);
         foreach ($fieldValues as $fieldName => $fieldValue) {
             // Callback, um die Values vor dem Speichern noch beeinflussen zu können
             $fieldValue = $this->preSave($fieldsetName, $fieldName, $fieldValue, $sql);
             if (is_array($fieldValue)) {
                 $fieldValue = implode('|+|', $fieldValue);
             }
             // Element heraussuchen
             $element =& $this->getElement($fieldsetName, $fieldName);
             // Den POST-Wert als Value in das Feld speichern
             // Da generell alles von REDAXO escaped wird, hier slashes entfernen
             $element->setValue(stripslashes($fieldValue));
             // Den POST-Wert in die DB speichern (inkl. slahes)
             $sql->setValue($fieldName, $fieldValue);
         }
     }
     if ($this->isEditMode()) {
         $sql->setWhere($this->whereCondition);
         return $sql->update();
     } else {
         return $sql->insert();
     }
 }
                         $FILESQL->setValue("filetype", $ffiletype);
                         $FILESQL->setValue("originalname", $ffilename);
                         $FILESQL->setValue("filesize", $ffilesize);
                         $uploaded = true;
                     }
                 } else {
                     $FILESQL->setValue("filetype", $ffiletype);
                     $FILESQL->setValue("originalname", $ffilename);
                     $FILESQL->setValue("filesize", $ffilesize);
                     $uploaded = true;
                 }
                 if (isset($uploaded) and $uploaded) {
                     $msg .= "<br>" . $I18N->msg('pool_file_changed');
                     chmod($REX['MEDIAFOLDER'] . "/{$filename}", $REX['FILEPERM']);
                     // ----- EXTENSION POINT
                     rex_register_extension_point('MEDIA_UPDATED', '', array("id" => $file_id, "type" => $ffiletype, "filename" => $filename));
                 }
             } else {
                 $msg .= "<br>" . $I18N->msg('pool_file_upload_errortype');
             }
         }
         $size = @getimagesize($REX['INCLUDE_PATH'] . "/../../files/{$filename}");
         $FILESQL->setValue("updatedate", time());
         $FILESQL->setValue("updateuser", $REX_USER->getValue("login"));
         $FILESQL->update();
     } else {
         $msg = $I18N->msg('no_permission');
     }
 } else {
     $msg = $I18N->msg('pool_file_not_found');
     $subpage = "";
function rex_com_showUserProfil($user_id, $aid = 0, $params = array())
{
    global $REX, $FORM;
    $u = new rex_sql();
    $u->setQuery("select * from rex_com_user where id=" . $user_id);
    if ($u->getRows() == 1) {
        $datetime = time();
        $show_basis = (int) $u->getValue("show_basisinfo");
        $show_kontakt = (int) $u->getValue("show_contactinfo");
        $show_personal = (int) $u->getValue("show_personalinfo");
        $ST = FALSE;
        $SK = FALSE;
        $SP = FALSE;
        // ***** Kontakt ?
        $KT = FALSE;
        // Kontakt nicht gestartet
        $KTA = FALSE;
        // Kontakt nicht bestaetigt
        $KTR = FALSE;
        // Kontakt nicht angefragt
        if (is_object($REX['COM_USER'])) {
            $k = new rex_sql();
            $k->setQuery('select * from rex_com_contact where user_id="' . $user_id . '" and to_user_id="' . $REX['COM_USER']->getValue('rex_com_user.id') . '"');
            if ($k->getRows() == 1) {
                if ($_REQUEST["delete_contact"] == 1) {
                    $msg = "Kontakt wurde gelöscht.";
                    $k->setQuery('delete from rex_com_contact where user_id="' . $user_id . '" and to_user_id="' . $REX['COM_USER']->getValue('rex_com_user.id') . '"');
                    $k->setQuery('delete from rex_com_contact where user_id="' . $REX['COM_USER']->getValue('rex_com_user.id') . '" and to_user_id="' . $user_id . '"');
                } elseif ($_REQUEST["contact_accepted"] == 1 && $k->getValue("accepted") == 0) {
                    $msg = "Kontakt wurde bestätigt.";
                    $k->setQuery('update rex_com_contact set accepted=1 where user_id="' . $user_id . '" and to_user_id="' . $REX['COM_USER']->getValue('rex_com_user.id') . '"');
                    $k->setQuery('update rex_com_contact set accepted=1 where user_id="' . $REX['COM_USER']->getValue('rex_com_user.id') . '" and to_user_id="' . $user_id . '"');
                    $KT = TRUE;
                    // $KTR = TRUE;
                    // $KTA = TRUE;
                    if ($show_basis == 1) {
                        $ST = TRUE;
                    }
                    if ($show_kontakt == 1) {
                        $SK = TRUE;
                    }
                    if ($show_personal == 1) {
                        $SP = TRUE;
                    }
                } else {
                    $KT = TRUE;
                    if ($k->getValue("requested") == 1) {
                        $KTR = TRUE;
                    }
                    // d.h. schwesterndatensatz ist request -> daten sind freigegeben
                    if ($k->getValue("accepted") == 1) {
                        $KTA = TRUE;
                    }
                    if ($show_basis == 1 && ($KTR || $KTA)) {
                        $ST = TRUE;
                    }
                    if ($show_kontakt == 1 && ($KTR || $KTA)) {
                        $SK = TRUE;
                    }
                    if ($show_personal == 1 && ($KTR || $KTA)) {
                        $SP = TRUE;
                    }
                }
            } else {
                // Kontaktanfrage
                if ($_REQUEST["add_contact"] == 1) {
                    $msg = "Kontakt wurde angefragt.";
                    $k = new rex_sql();
                    $k->setTable("rex_com_contact");
                    $k->setValue("user_id", $user_id);
                    $k->setValue("to_user_id", $REX['COM_USER']->getValue('rex_com_user.id'));
                    $k->setValue("create_datetime", $datetime);
                    $k->insert();
                    $k = new rex_sql();
                    $k->setTable("rex_com_contact");
                    $k->setValue("user_id", $REX['COM_USER']->getValue('rex_com_user.id'));
                    $k->setValue("to_user_id", $user_id);
                    $k->setValue("requested", 1);
                    $k->setValue("create_datetime", $datetime);
                    $k->insert();
                    if ($user_id != $REX['COM_USER']->getValue('rex_com_user.id')) {
                        rex_com_user::exeAction($user_id, "sendemail_contactrequest", array("user_id" => $REX['COM_USER']->getValue('rex_com_user.id'), "firstname" => $REX['COM_USER']->getValue('rex_com_user.firstname'), "name" => $REX['COM_USER']->getValue('rex_com_user.name'), "login" => $REX['COM_USER']->getValue('rex_com_user.login'), "to_user_id" => $u->getValue('rex_com_user.id'), "to_firstname" => $u->getValue('rex_com_user.firstname'), "to_name" => $u->getValue('rex_com_user.name'), "to_login" => $u->getValue('rex_com_user.login')));
                    }
                    $KT = TRUE;
                }
            }
        }
        // ***** für alle sichtbar
        if ($show_basis == 0) {
            $ST = FALSE;
        }
        if ($show_kontakt == 0) {
            $SK = FALSE;
        }
        if ($show_personal == 0) {
            $SP = FALSE;
        }
        if ($show_basis == 2) {
            $ST = TRUE;
        }
        if ($show_kontakt == 2) {
            $SK = TRUE;
        }
        if ($show_personal == 2) {
            $SP = TRUE;
        }
        // ***** user hat eigenes profil aufgerufen
        $MY = FALSE;
        if (is_object($REX['COM_USER']) && $REX['COM_USER']->getValue("rex_com_user.id") == $user_id) {
            $ST = TRUE;
            $SK = TRUE;
            $SP = TRUE;
            $MY = TRUE;
        }
        // ***** MSG AUSAGBE
        if ($msg != "") {
            echo '<p class="warning">' . $msg . '</p>';
        }
        // ***** AUSGABE USERPROFIL BASIS
        echo '
		<div class="rex-com-profile">
			<div class="image">' . rex_com_showUser($u, "image_big", "", FALSE) . '</div>
			<div class="text">
			<h2 class="noclear">';
        if ($ST) {
            echo rex_com_showUser($u, "login", "", FALSE) . " [ " . rex_com_showUser($u, "name", "", FALSE) . "]";
        } else {
            echo rex_com_showUser($u, "login", "", FALSE);
        }
        echo '</h2>
			<ul class="navi com-navi-myprofile">
			';
        $buttons = array();
        rex_register_extension_point('ADDON_COM_USER_BUTTONS_PRE', "", array("userobj" => &$u, "buttons" => &$buttons, "user_id" => $user_id));
        // Kontakt
        if (!$KT && !$MY) {
            $buttons[] = '<a href="' . rex_getUrl($aid, 0, array("user_id" => $user_id, "add_contact" => 1)) . '"><span>Als Kontakt hinzufügen</span></a>';
        }
        if ($KT) {
            $buttons[] = '<a href="' . rex_getUrl($aid, 0, array("user_id" => $user_id, "delete_contact" => 1)) . '"><span>Kontakt löschen</span></a>';
        }
        if (!$KTA && $KTR && $KT) {
            $buttons[] = '<a href="' . rex_getUrl($aid, 0, array("user_id" => $user_id, "contact_accepted" => 1)) . '"><span>Kontakt bestätigen</span></a>';
        }
        // Eigene Daten bearbeiten
        if ($MY) {
            $buttons[] = '<a href="' . rex_getUrl(REX_COM_PAGE_MYPROFIL_ID, 0, array("tab" => 0)) . '"><span>Basisdaten bearbeiten</span></a>';
            $buttons[] = '<a href="' . rex_getUrl(REX_COM_PAGE_MYPROFIL_ID, 0, array("tab" => 1)) . '"><span>Kontaktdaten bearbeiten</span></a>';
            $buttons[] = '<a href="' . rex_getUrl(REX_COM_PAGE_MYPROFIL_ID, 0, array("tab" => 2)) . '"><span>Persönliches bearbeiten</span></a>';
            $buttons[] = '<a href="' . rex_getUrl(REX_COM_PAGE_MYPROFIL_ID, 0, array("tab" => 3)) . '"><span>Einstellungen</span></a>';
            $buttons[] = '<a href="' . rex_getUrl(REX_COM_PAGE_MYPROFIL_ID, 0, array("tab" => 4)) . '"><span>Passwort ändern</span></a>';
        }
        rex_register_extension_point('ADDON_COM_USER_BUTTONS_POST', "", array("userobj" => &$u, "buttons" => &$buttons, "user_id" => $user_id));
        foreach ($buttons as $k => $button) {
            echo '<li class="no-' . $k . '">' . $button . '</li>';
        }
        echo '
			</ul>
			</div>
			<div class="clearer"> </div>
		</div>';
        // ***** AUSGABE USERPROFIL STAMMDATEN,PERSÖNLICHES; ... GÄSTEBUCH
        $tab_arr_in = array('Basisdaten' => 'REX_LINK_ID[1]', 'Kontaktdaten' => 'REX_LINK_ID[2]', 'Persönliches' => 'REX_LINK_ID[3]', 'Gästebuch' => 'REX_LINK_ID[4]');
        $tab_arr = array();
        foreach ($tab_arr_in as $k => $v) {
            if ($k != "" && $v != "") {
                $tab_arr[$k] = $v;
            }
        }
        $tab_g = 0;
        if (isset($_REQUEST['tab']) and $_REQUEST['tab'] != '') {
            $tab_g = (int) $_REQUEST['tab'];
        }
        if ($tab_g < 0 || $tab_g >= count($tab_arr)) {
            $tab_g = 0;
        }
        $tab_cnt = '';
        $tab_list = '';
        $tab_c = 0;
        // Counter
        // $tab_g -> active tab
        foreach ($tab_arr as $key => $val) {
            $link = rex_getUrl('', '', array('tab' => $tab_c));
            $tab_class = '';
            if ($tab_g == $tab_c) {
                $tab_cnt = $val;
                $tab_class = 'active ';
            }
            if ($tab_c == 0) {
                $tab_class = 'tab-frst ';
            }
            if ($tab_c == 0 and $tab_g == $tab_c) {
                $tab_class = 'tab-frst-active ';
            }
            if ($tab_c + 1 == count($tab_arr)) {
                $tab_class = 'tab-lst ';
            }
            if ($tab_c + 1 == count($tab_arr) and $tab_g == $tab_c) {
                $tab_class = 'tab-lst-active ';
            }
            $tab_c_active_nxt = $tab_g - 1;
            if ($tab_c == $tab_c_active_nxt) {
                $tab_class .= 'active-nxt ';
            }
            trim($tab_class);
            if ($tab_class != '') {
                $tab_class = ' class="' . $tab_class . '"';
            }
            $tab_list .= '<li' . $tab_class . '><a href="' . rex_getUrl($aid, '', array('user_id' => $user_id, 'tab' => $tab_c)) . '"><span>' . $key . '</span></a></li>';
            $tab_c++;
        }
        print '
			<div class="com-tab">
			<div class="com-tab2">
				<div class="com-tab-navi">
					<ul class="navi">
						' . $tab_list . '
					</ul>
				</div>
				
				<div class="com-tab-cntnt">
				<div class="com-tab-cntnt-2">
				<div class="com-tab-cntnt-3">';
        $current = "";
        function wechsel(&$current)
        {
            if ($current != 'class="alternative"') {
                $current = 'class="alternative"';
            } else {
                $current = "";
            }
            return $current;
        }
        switch ($tab_g) {
            case "0":
                // Stammdaten
                $G = array();
                $G["m"] = "Herr";
                $G["1"] = "Herr";
                $G["f"] = "Frau";
                $G["2"] = "Frau";
                $gender = $G[$u->getValue("gender")];
                if (!$ST) {
                    echo "Daten sind nicht freigeschaltet";
                } else {
                    echo '<table class="profiledata">';
                    if ($u->getValue("gender") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Anrede: </td><td>' . $gender . '</td></tr>';
                    }
                    if ($u->getValue("firstname") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Vorname: </td><td>' . htmlspecialchars($u->getValue("firstname")) . '</td></tr>';
                    }
                    if ($u->getValue("name") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Name: </td><td>' . htmlspecialchars($u->getValue("name")) . '</td></tr>';
                    }
                    if ($u->getValue("motto") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Motto: </td><td>' . htmlspecialchars($u->getValue("motto")) . '</td></tr>';
                    }
                    echo '</table>';
                }
                break;
            case "1":
                // Kontaktdaten
                if (!$SK) {
                    echo "Daten sind nicht freigeschaltet";
                } else {
                    $current = "";
                    echo '<table class="profiledata">';
                    if ($u->getValue("email") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">E-Mail: </td><td>' . htmlspecialchars($u->getValue("email")) . '</td></tr>';
                    }
                    if ($u->getValue("street") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Straße: </td><td>' . htmlspecialchars($u->getValue("street")) . '</td></tr>';
                    }
                    if ($u->getValue("zip") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">PLZ: </td><td>' . htmlspecialchars($u->getValue("zip")) . '</td></tr>';
                    }
                    if ($u->getValue("city") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Ort: </td><td>' . htmlspecialchars($u->getValue("city")) . '</td></tr>';
                    }
                    if ($u->getValue("phone") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Telefon: </td><td>' . htmlspecialchars($u->getValue("phone")) . '</td></tr>';
                    }
                    if ($u->getValue("fax") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Fax: </td><td>' . htmlspecialchars($u->getValue("fax")) . '</td></tr>';
                    }
                    if ($u->getValue("icq") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">ICQ: </td><td>' . htmlspecialchars($u->getValue("icq")) . '</td></tr>';
                    }
                    echo '</table>';
                }
                break;
            case "2":
                // Persönliches
                if (!$SP) {
                    echo "Daten sind nicht freigeschaltet";
                } else {
                    $FS = array();
                    $current = "";
                    echo '<table class="profiledata">';
                    if ($u->getValue("birthday") != "0000-00-00") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Geburtstag: </td><td>' . $u->getValue("birthday") . '</td></tr>';
                    }
                    if ($u->getValue("hobby") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Hobbies: </td><td>' . nl2br(htmlspecialchars($u->getValue("hobby"))) . '</td></tr>';
                    }
                    if ($u->getValue("interests") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Interessen: </td><td>' . nl2br(htmlspecialchars($u->getValue("interests"))) . '</td></tr>';
                    }
                    if ($u->getValue("more") != "") {
                        echo '<tr ' . wechsel($current) . '><td class="label">Mehr über mich: </td><td>' . nl2br(htmlspecialchars($u->getValue("more"))) . '</td></tr>';
                    }
                    // echo '<tr><td>Über mich</td><td>'.$u->getValue("description").'</td></tr>';
                    echo '</table>';
                }
                break;
            case "3":
                // Gästebuch
                echo rex_com_user::getGuestbook($user_id, $aid, array("tab" => $tab_g));
                break;
        }
        print '
				<div class="clearer"> </div>
				</div>
				</div>
				</div>
			</div>
			</div>';
    }
}
Beispiel #28
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;
 }
    function getArticle($curctype = -1)
    {
        global $module_id, $REX_USER, $REX, $I18N;
        $this->ctype = $curctype;
        $sliceLimit = '';
        if ($this->getSlice) {
            //$REX['GG'] = 0;
            $sliceLimit = " AND " . $REX['TABLE_PREFIX'] . "article_slice.id = '" . $this->getSlice . "' ";
        }
        // ----- start: article caching
        ob_start();
        ob_implicit_flush(0);
        if ($REX['GG'] && !$this->viasql && !$this->getSlice) {
            if ($this->article_id != 0) {
                $this->contents = '';
                $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
                if ($cont = rex_get_file_contents($article_content_file)) {
                    $this->contents = $cont;
                    eval($this->contents);
                }
            }
        } 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 . "'\r\n            " . $sliceLimit . "\r\n            ORDER BY " . $REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id";
                $this->CONT = new rex_sql();
                $this->CONT->debugsql = 0;
                $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_CONTS[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.id');
                    $RE_CONTS_CTYPE[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.ctype');
                    $RE_MODUL_IN[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.eingabe');
                    $RE_MODUL_OUT[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.ausgabe');
                    $RE_MODUL_ID[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.id');
                    $RE_MODUL_NAME[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.name');
                    $RE_C[$this->CONT->getValue('re_article_slice_id')] = $i;
                    $this->CONT->next();
                }
                // ---------- moduleselect: nur module nehmen auf die der user rechte hat
                if ($this->mode == 'edit') {
                    $MODULE = new rex_sql();
                    $MODULE->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
                    $MODULESELECT = new rex_select();
                    $MODULESELECT->setName('module_id');
                    $MODULESELECT->setSize('1');
                    $MODULESELECT->setAttribute('onchange', 'this.form.submit();');
                    $MODULESELECT->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
                    for ($i = 0; $i < $MODULE->getRows(); $i++) {
                        if ($REX_USER->hasPerm('module[' . $MODULE->getValue('id') . ']') || $REX_USER->hasPerm('admin[]')) {
                            $MODULESELECT->addOption(rex_translate($MODULE->getValue('name'), NULL, FALSE), $MODULE->getValue('id'));
                        }
                        $MODULE->next();
                    }
                }
                // ---------- SLICE IDS SORTIEREN UND AUSGEBEN
                $I_ID = 0;
                $PRE_ID = 0;
                $LCTSL_ID = 0;
                $this->CONT->reset();
                $this->article_content = "";
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    // ----- ctype unterscheidung
                    if ($this->mode != "edit" && $i == 0) {
                        $this->article_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';
                        if ($this->setanker) {
                            $form_url .= '#addslice';
                        }
                        $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->setId("module_id" . $I_ID);
                            $slice_content = '
              <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                <fieldset>
                  <legend class="rex-lgnd"><span class="rex-hide">' . $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 . '" />

                  <p class="rex-slct">
                    ' . $MODULESELECT->get() . '
                    <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                  </p>

                </fieldset>
              </form>';
                        }
                        // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
                        if ($REX_USER->hasPerm("module[" . $RE_MODUL_ID[$I_ID] . "]") || $REX_USER->hasPerm("admin[]")) {
                            $msg = '';
                            if ($this->slice_id == $RE_CONTS[$I_ID] && $this->message != '') {
                                $msg = rex_warning($this->message);
                            }
                            $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-clr-grn">' . $I18N->msg('edit') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-clr-red" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span class="rex-hide">' . $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 . '"><img src="media/file_up.gif" width="16" height="16" alt="' . $moveUp . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '"><img src="media/file_down.gif" width="16" height="16" alt="' . $moveDown . '" /> <span class="rex-hide">' . $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 . '
			       	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft">' . htmlspecialchars($RE_MODUL_NAME[$I_ID]) . '</p>
                <ul class="rex-flRight" id="rex-slc-mnu">
              ';
                            foreach ($listElements as $listElement) {
                                $mne .= '<li>' . $listElement . '</li>';
                            }
                            $mne .= '</ul></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);
                                    }
                                }
                                // TODO: PreviewActions gibts nur im EditMode...?
                                if ($this->function == 'edit') {
                                    $modebit = '2';
                                } elseif ($this->function == 'delete') {
                                    $modebit = '4';
                                } else {
                                    $modebit = '1';
                                }
                                // pre-action and add
                                $ga = new rex_sql();
                                $ga->debugsql = 0;
                                $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-cnt-slc-otp"><div class="rex-cnt-slc-otp2">
                  ' . $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-cnt-editmode-slc">
                <p class="rex-flLeft" id="slice' . $RE_CONTS[$I_ID] . '">' . $RE_MODUL_NAME[$I_ID] . '</p>
                <ul class="rex-flRight">
                  <li>' . $I18N->msg('no_editing_rights') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></li>
                </ul>
				  </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->article_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->article_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->article_content .= "<?php } ?>";
                }
                // ----- add module im edit mode
                if ($this->mode == "edit") {
                    $form_url = 'index.php';
                    if ($this->setanker) {
                        $form_url .= '#addslice';
                    }
                    if ($this->function == "add" && $this->slice_id == $LCTSL_ID) {
                        $slice_content = $this->addSlice($LCTSL_ID, $module_id);
                    } else {
                        // ----- BLOCKAUSWAHL - SELECT
                        $MODULESELECT->setId("module_id" . $LCTSL_ID);
                        // $slice_content = $add_select_box;
                        $slice_content = '
            <form action="' . $form_url . '" method="get">
              <fieldset>
                <legend class="rex-lgnd"><span class="rex-hide">' . $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 . '" />

                <p class="rex-slct">
                  ' . $MODULESELECT->get() . '
                  <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                </p>

              </fieldset>
            </form>';
                    }
                    $this->article_content .= $slice_content;
                }
                // -------------------------- schreibe content
                if ($this->mode == "generate" || $this->viasql) {
                    echo $this->replaceLinks($this->article_content);
                } else {
                    eval("?>" . $this->article_content);
                }
            } else {
                echo $I18N->msg('no_article_available');
            }
        }
        // ----- end: article caching
        $CONTENT = ob_get_contents();
        ob_end_clean();
        return $CONTENT;
    }
 /**
  * Gibt die gerenderte Liste zurück
  * 
  * @param bool [Flag, ob die Standardtoolbars hinzugefügt werden sollen - 
  *             true => ja/ false => nein; default:true]
  * @access public
  */
 function get($addDefaultToolbars = true)
 {
     global $REX;
     $s = '';
     // Default Toolbars hinzufügen
     if ($addDefaultToolbars) {
         $this->addDefaultToolbars();
     }
     $this->prepareToolbars();
     // Benötigte Variablen definieren
     $rows = $this->getCurrentRows();
     $s .= '<!-- rexList start -->' . "\n";
     $s .= '<div class="a22-rexlist">' . "\n";
     $s .= $this->getVar(LIST_VAR_TOP);
     // Platzhalter
     $s .= '  <form action="index.php" method="post">' . "\n";
     $s .= '    <fieldset>' . "\n";
     $label = $this->getLabel();
     if ($label != '') {
         $s .= '      <legend>' . $label . '</legend>' . "\n";
     }
     // Alle Parameter für einen Post als hidden übergeben
     foreach ($this->params as $_name => $_value) {
         if ($_name != '' && $_value != '') {
             $s .= '      <input type="hidden" name="' . $_name . '" value="' . $_value . '" />' . "\n";
         }
     }
     // ------------ Kopfleisten
     $s .= $this->getVar(LIST_VAR_BEFORE_HEAD);
     // Platzhalter
     $s .= '      <div class="a22-rexlist-toolbars-top">' . "\n";
     $s .= $this->_getToolbars($this->toolbars['top']['full']);
     $s .= $this->_getHalfToolbars($this->toolbars['top']['half']);
     $s .= '      </div>' . "\n";
     $s .= $this->getVar(LIST_VAR_AFTER_HEAD);
     // Platzhalter
     // ------------ Datenbereich
     $s .= $this->getVar(LIST_VAR_BEFORE_DATAHEAD);
     // Platzhalter
     $s .= '      <div class="a22-rexlist-data">' . "\n";
     if ($this->numCurrentRows() != 0) {
         // ------------ Tabellenkopf
         $s .= '        <table' . $this->getAttributes() . '>' . "\n";
         $s .= $this->_getColGroup();
         $caption = $this->getCaption();
         if ($caption != '') {
             $s .= '        <caption>' . $caption . '</caption>' . "\n";
         }
         $s .= '          <thead>' . "\n";
         $s .= '            <tr>' . "\n";
         for ($i = 0; $i < $this->numColumns(); $i++) {
             $column =& $this->columns[$i];
             $s .= sprintf('              <th%s>%s</th>' . "\n", $column->getHeadAttributes(), $column->getLabel());
         }
         $s .= '            </tr>' . "\n";
         $s .= '          </thead>' . "\n";
         $s .= $this->getVar(LIST_VAR_AFTER_DATAHEAD);
         // Platzhalter
         // ------------ Tabellendaten
         $s .= $this->getVar(LIST_VAR_BEFORE_DATA);
         // Platzhalter
         if (is_array($rows)) {
             $extension_point = 'REX_LIST_' . strtoupper($this->getName()) . '_ROW_ATTR';
             $extension_is_registered = rex_extension_is_registered($extension_point);
             $s .= '          <tbody>' . "\n";
             for ($t = 0; $t < count($rows); $t++) {
                 $row =& $rows[$t];
                 $rowAttributes = '';
                 if ($extension_is_registered) {
                     $rowAttributes = rex_register_extension_point($extension_point, '', array('row' => $row, 'line_number' => $t));
                 }
                 $s .= '            <tr' . $rowAttributes . '>' . "\n";
                 for ($i = 0; $i < count($this->columns); $i++) {
                     $column =& $this->columns[$i];
                     $s .= '              <td' . $column->getBodyAttributes() . '>' . $column->format($row) . '</td>' . "\n";
                 }
                 $s .= '            </tr>' . "\n";
             }
         }
         $s .= '          </tbody>' . "\n";
         $s .= '        </table>' . "\n";
     } else {
         // keine Daten vorhanden
         $def_message = 'Ihr Abfrage ergab keine Ergebnisse';
         $s .= '        <p class="a22-rexlist-norows">' . $this->getVar(LIST_VAR_NO_DATA, $def_message) . '</p>' . "\n";
         // Platzhalter
     }
     $s .= '      </div>' . "\n";
     $s .= $this->getVar(LIST_VAR_AFTER_DATA);
     // Platzhalter
     // ------------ Fußleisten
     $s .= $this->getVar(LIST_VAR_BEFORE_FOOT);
     // Platzhalter
     $s .= '      <div class="a22-rexlist-toolbars-btm">' . "\n";
     $s .= $this->_getHalfToolbars($this->toolbars['bottom']['half']);
     $s .= $this->_getToolbars($this->toolbars['bottom']['full']);
     $s .= '      </div>' . "\n";
     $s .= $this->getVar(LIST_VAR_AFTER_FOOT);
     // Platzhalter
     $s .= '    </fieldset>' . "\n";
     $s .= '  </form>' . "\n";
     $s .= $this->getVar(LIST_VAR_BOTTOM);
     // Platzhalter
     $s .= '</div>' . "\n";
     $s .= '<!-- rexList end -->' . "\n";
     return $s;
 }