/**
  * CLASS Function:
  * Return an OORedaxo object based on an id
  */
 function getArticleById($article_id, $clang = false, $OOCategory = false)
 {
     global $REX;
     if ($clang === false) {
         $clang = $REX['CUR_CLANG'];
     } elseif (!isset($REX['CLANG'][$clang])) {
         $clang = 0;
     }
     $article_path = $REX['INCLUDE_PATH'] . '/generated/articles/' . $article_id . '.' . $clang . '.article';
     if (!file_exists($article_path)) {
         include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
         $article_id = (int) $article_id;
         rex_generateArticle($article_id, FALSE);
     }
     if (file_exists($article_path)) {
         include $article_path;
     } else {
         return null;
     }
     if ($OOCategory) {
         return new OOCategory(OORedaxo::convertGeneratedArray($REX['ART'][$article_id], $clang));
     } else {
         return new OOArticle(OORedaxo::convertGeneratedArray($REX['ART'][$article_id], $clang));
     }
 }
function rex_generateAll()
{
    global $REX, $I18N;
    // alles existiert schon
    // -> generiere templates
    // -> generiere article und listen
    // -> generiere file meta
    // -> loesche cache
    // ----------------------------------------------------------- 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 ...
    // **********************
    // ----------------------------------------------------------- delete cache
    $Cache = new Cache();
    $Cache->removeAllCacheFiles();
    // ----------------------------------------------------------- message
    $MSG = $I18N->msg('articles_generated') . " " . $I18N->msg('old_articles_deleted');
    return $MSG;
}
 function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = FALSE)
 {
     global $REX;
     if ($to_revision_delete) {
         $dc = new rex_sql();
         // $dc->debugsql = 1;
         $dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id);
     }
     if ($from_revision_id == $to_revision_id) {
         return false;
     }
     $gc = new rex_sql();
     // $gc->debugsql = 1;
     $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'");
     if ($gc->getRows() == 1) {
         // letzt slice_id des ziels holen ..
         $glid = new rex_sql();
         // $glid->debugsql = 1;
         $glid->setQuery("\n\t\t\t\t\tselect \n\t\t\t\t\t\tr1.id, r1.re_article_slice_id\n\t        from \n\t\t\t\t\t\t" . $REX['TABLE_PREFIX'] . "article_slice as r1\n\t\t\t\t\tleft join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n\t        where \n\t\t\t\t\t\tr1.article_id = {$article_id} and r1.clang = {$clang} and \n\t\t\t\t\t\tr2.id is NULL and \n\t\t\t\t\t\tr1.revision='{$to_revision_id}';");
         if ($glid->getRows() == 1) {
             $to_last_slice_id = $glid->getValue("r1.id");
         } else {
             $to_last_slice_id = 0;
         }
         $ins = new rex_sql();
         // $ins->debugsql = 1;
         $ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
         $cols = new rex_sql();
         $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice");
         for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
             $colname = $cols->getValue("Field");
             if ($colname == "re_article_slice_id") {
                 $value = $to_last_slice_id;
             } elseif ($colname == "revision") {
                 $value = $to_revision_id;
             } elseif ($colname == "createdate") {
                 $value = time();
             } elseif ($colname == "updatedate") {
                 $value = time();
             } elseif ($colname == "createuser") {
                 $value = $REX["USER"]->getValue("login");
             } elseif ($colname == "updateuser") {
                 $value = $REX["USER"]->getValue("login");
             } else {
                 $value = $gc->getValue($colname);
             }
             if ($colname != "id") {
                 $ins->setValue($colname, $ins->escape($value));
             }
         }
         $ins->insert();
         // id holen und als re setzen und weitermachen..
         rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue("id"));
         return true;
     }
     rex_generateArticle($article_id);
     return true;
 }
function _rex_a62_metainfo_art_handleSave($params, $sqlFields)
{
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        return $params;
    }
    global $REX;
    $article = rex_sql::getInstance();
    //  $article->debugsql = true;
    $article->setTable($REX['TABLE_PREFIX'] . 'article');
    $article->setWhere('id=' . $params['id'] . ' AND clang=' . $params['clang']);
    _rex_a62_metainfo_handleSave($params, $article, $sqlFields);
    $article->update();
    // Artikel nochmal mit den zusätzlichen Werten neu generieren
    rex_generateArticle($params['id']);
    return $params;
}
/**
 * Kopiert die Inhalte eines Artikels in einen anderen Artikel
 * 
 * @param $from_id           ArtikelId des Artikels, aus dem kopiert werden (Quell ArtikelId)
 * @param $to_id             ArtikelId des Artikel, in den kopiert werden sollen (Ziel ArtikelId)
 * @param [$from_clang]      ClangId des Artikels, aus dem kopiert werden soll (Quell ClangId)
 * @param [$to_clang]        ClangId des Artikels, in den kopiert werden soll (Ziel ClangId)
 * @param [$from_re_sliceid] Id des Slices, bei dem begonnen werden soll
 */
function rex_copyContent($from_id, $to_id, $from_clang = 0, $to_clang = 0, $from_re_sliceid = 0)
{
    global $REX, $REX_USER;
    if ($from_id == $to_id && $from_clang == $to_clang) {
        return false;
    }
    $gc = new sql();
    $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$from_id}' and clang='{$from_clang}'");
    if ($gc->getRows() == 1) {
        // letzt slice_id des ziels holen ..
        $glid = new sql();
        $glid->setQuery("select r1.id, r1.re_article_slice_id\r\n                     from " . $REX['TABLE_PREFIX'] . "article_slice as r1 \r\n                     left join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id=r2.re_article_slice_id \r\n                     where r1.article_id={$to_id} and r1.clang={$to_clang} and r2.id is NULL;");
        if ($glid->getRows() == 1) {
            $to_last_slice_id = $glid->getValue("r1.id");
        } else {
            $to_last_slice_id = 0;
        }
        $ins = new sql();
        // $ins->debugsql = 1;
        $ins->setTable($REX['TABLE_PREFIX'] . "article_slice");
        $cols = new sql();
        // $cols->debugsql = 1;
        $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice");
        for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
            $colname = $cols->getvalue("Field");
            if ($colname == "clang") {
                $value = $to_clang;
            } elseif ($colname == "re_article_slice_id") {
                $value = $to_last_slice_id;
            } elseif ($colname == "article_id") {
                $value = $to_id;
            } elseif ($colname == "createdate") {
                $value = time();
            } elseif ($colname == "updatedate") {
                $value = time();
            } elseif ($colname == "createuser") {
                $value = $REX_USER->getValue("login");
            } elseif ($colname == "updateuser") {
                $value = $REX_USER->getValue("login");
            } else {
                $value = addslashes($gc->getValue("{$colname}"));
            }
            if ($colname != "id") {
                $ins->setValue($colname, $value);
            }
        }
        $ins->insert();
        // id holen und als re setzen und weitermachen..
        rex_copyContent($from_id, $to_id, $from_clang, $to_clang, $gc->getValue("id"));
        return true;
    }
    rex_generateArticle($to_id);
    return true;
}
         $message = $I18N->msg('no_rights_to_this_function');
     }
 }
 // ------------------------------------------ END: MOVE CATEGORY
 // ------------------------------------------ START: SAVE METADATA
 if (rex_post('savemeta', 'string')) {
     $meta_sql = new rex_sql();
     $meta_sql->setTable($REX['TABLE_PREFIX'] . "article");
     // $meta_sql->debugsql = 1;
     $meta_sql->setWhere("id='{$article_id}' AND clang={$clang}");
     $meta_sql->setValue('name', $meta_article_name);
     $meta_sql->addGlobalUpdateFields();
     if ($meta_sql->update()) {
         $article->setQuery("SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE id='{$article_id}' AND clang='{$clang}'");
         $message = $I18N->msg("metadata_updated") . $message;
         rex_generateArticle($article_id);
         // ----- EXTENSION POINT
         $message = rex_register_extension_point('ART_META_UPDATED', $message, array('id' => $article_id, 'clang' => $clang, 'name' => $meta_article_name));
     } else {
         $message .= $meta_sql->getError();
     }
 }
 // ------------------------------------------ END: SAVE METADATA
 // ------------------------------------------ START: CONTENT HEAD MENUE
 $num_ctypes = count($REX['CTYPE']);
 $ctype_menu = '';
 if ($num_ctypes > 0) {
     $listElements = array();
     if ($num_ctypes > 1) {
         $listElements[] = $I18N->msg('content_types') . ': ';
     } else {
 function regenerateArticlesByModultypId($modules)
 {
     global $PHP_SELF, $module_id, $FORM, $REX_USER, $REX, $I18N;
     include_once $REX[INCLUDE_PATH] . "/clang.inc.php";
     $modules = explode("__", $modules);
     array_pop($modules);
     $gc = new rex_sql();
     foreach ($modules as $modul_id) {
         $gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article\n      \t        LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id\n      \t        WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'");
         for ($i = 0; $i < $gc->getRows(); $i++) {
             rex_generateArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id"));
             $gc->next();
         }
     }
 }
 function setArticleId($article_id)
 {
     global $REX;
     $article_id = (int) $article_id;
     $this->article_id = (int) $article_id;
     if (!$REX['GG'] || $this->viasql) {
         // ---------- select article
         $qry = "SELECT * FROM " . $REX['TABLE_PREFIX'] . "article WHERE " . $REX['TABLE_PREFIX'] . "article.id='{$article_id}' AND clang='" . $this->clang . "'";
         $this->ARTICLE = new rex_sql();
         // $this->ARTICLE->debugsql = 1;
         $this->ARTICLE->setQuery($qry);
         if ($this->ARTICLE->getRows() == 1) {
             $this->template_id = $this->ARTICLE->getValue($REX['TABLE_PREFIX'] . "article.template_id");
             $this->category_id = $this->getValue("category_id");
             return TRUE;
         } else {
             $this->article_id = 0;
             $this->template_id = 0;
             $this->category_id = 0;
             return FALSE;
         }
     } else {
         $FX = file_exists($REX['INCLUDE_PATH'] . "/generated/articles/" . $article_id . "." . $this->clang . ".content");
         if ($FX && @(include $REX['INCLUDE_PATH'] . "/generated/articles/" . $article_id . "." . $this->clang . ".article")) {
             $this->category_id = $REX['ART'][$article_id]['re_id'][$this->clang];
             $this->template_id = $REX['ART'][$article_id]['template_id'][$this->clang];
             return TRUE;
         } else {
             $this->ARTICLE = new rex_sql();
             $this->ARTICLE->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where " . $REX['TABLE_PREFIX'] . "article.id='{$article_id}' and clang='" . $this->clang . "'");
             if ($this->ARTICLE->getRows() == 1) {
                 include_once $REX["INCLUDE_PATH"] . "/functions/function_rex_generate.inc.php";
                 rex_generateArticle($article_id);
                 if (@(include $REX['INCLUDE_PATH'] . "/generated/articles/" . $article_id . "." . $this->clang . ".article")) {
                     $this->category_id = $REX['ART'][$article_id]['re_id'][$this->clang];
                     $this->template_id = $REX['ART'][$article_id]['template_id'][$this->clang];
                     return TRUE;
                 } else {
                     return FALSE;
                 }
             } else {
                 return FALSE;
             }
         }
     }
 }
    }
}
if (isset($function) and ($function == 'add' or $function == 'edit')) {
    if (isset($save) and $save == 'ja') {
        $modultyp = new sql();
        if ($function == 'add') {
            $modultyp->query("INSERT INTO rex_modultyp (category_id, name, eingabe, ausgabe) VALUES ('{$category_id}', '{$mname}', '{$eingabe}', '{$ausgabe}')");
            $message = '<p class="warning">' . $I18N->msg("module_added") . '</p>';
        } else {
            $modultyp->query("UPDATE rex_modultyp SET name='{$mname}', eingabe='{$eingabe}', ausgabe='{$ausgabe}' WHERE id='{$modul_id}'");
            $message = '<p class="warning">' . $I18N->msg("module_updated") . ' | ' . $I18N->msg("articel_updated") . '</font></p>';
            // article updaten
            $gc = new sql();
            $gc->setQuery("SELECT DISTINCT(rex_article.id) FROM rex_article \r\n          LEFT JOIN rex_article_slice ON rex_article.id=rex_article_slice.article_id \r\n          WHERE rex_article_slice.modultyp_id='{$modul_id}'");
            for ($i = 0; $i < $gc->getRows(); $i++) {
                rex_generateArticle($gc->getValue("rex_article.id"));
                $gc->next();
            }
        }
        if (isset($goon) and $goon != '') {
            $save = 'nein';
        } else {
            $function = '';
        }
    }
    if (!isset($save) or $save != 'ja') {
        echo '<a name="edit"><table class="rex" style="table-layout:auto;" cellpadding="5" cellspacing="1">';
        if ($function == 'edit') {
            $hole = new sql();
            $hole->setQuery("SELECT * FROM rex_modultyp WHERE id='{$modul_id}'");
            $category_id = $hole->getValue("category_id");
示例#10
0
        // extension point 1
        $params = array();
        $params['id'] = $articleId;
        $params['url_type'] = $newUrlType;
        if ($newUrlData['url_clone']) {
            foreach ($REX['CLANG'] as $theClang => $clang_name) {
                $params['clang'] = $theClang;
                rex_register_extension_point('SEO42_URL_UPDATE', '', $params);
            }
        } else {
            $params['clang'] = $clang;
            rex_register_extension_point('SEO42_URL_UPDATE', '', $params);
        }
        // generate stuff new
        rex_deleteCacheArticleContent($articleId, $clang);
        rex_generateArticle($articleId);
        seo42_generate_pathlist(array());
        // extension point 2
        rex_register_extension_point('SEO42_URL_UPDATED', '', $params);
        // this is for frontend link fix with js
        $dataUpdated = true;
    } else {
        // err msg
        if ($sql->getError() != '') {
            echo rex_warning($sql->getError());
        }
    }
}
$sql = rex_sql::factory();
//$sql->debugsql = 1;
$urlData = $sql->getArray('SELECT seo_custom_url FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE id=' . $articleId . ' AND clang=' . $clang);
 function rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $from_re_sliceid = 0, $to_revision_delete = false)
 {
     global $REX;
     if ($to_revision_delete) {
         $dc = rex_sql::factory();
         // $dc->debugsql = 1;
         $dc->setQuery('delete from ' . $REX['TABLE_PREFIX'] . 'article_slice where article_id=' . $article_id . ' and clang=' . $clang . ' and revision=' . $to_revision_id);
     }
     if ($from_revision_id == $to_revision_id) {
         return false;
     }
     $gc = rex_sql::factory();
     // $gc->debugsql = 1;
     $gc->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$article_id}' and clang='{$clang}' and revision='{$from_revision_id}'");
     if ($gc->getRows() == 1) {
         // letzt slice_id des ziels holen ..
         $glid = rex_sql::factory();
         // $glid->debugsql = 1;
         $glid->setQuery('
                 select
                     r1.id, r1.re_article_slice_id
                 from
                     ' . $REX['TABLE_PREFIX'] . 'article_slice as r1
                 left join ' . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id = r2.re_article_slice_id\n                    where\n                        r1.article_id = {$article_id} and r1.clang = {$clang} and\n                        r2.id is NULL and\n                        r1.revision='{$to_revision_id}';");
         if ($glid->getRows() == 1) {
             $to_last_slice_id = $glid->getValue('r1.id');
         } else {
             $to_last_slice_id = 0;
         }
         $ins = rex_sql::factory();
         // $ins->debugsql = 1;
         $ins->setTable($REX['TABLE_PREFIX'] . 'article_slice');
         $cols = rex_sql::factory();
         $cols->setquery('SHOW COLUMNS FROM ' . $REX['TABLE_PREFIX'] . 'article_slice');
         for ($j = 0; $j < $cols->rows; $j++, $cols->next()) {
             $colname = $cols->getValue('Field');
             if ($colname == 're_article_slice_id') {
                 $value = $to_last_slice_id;
             } elseif ($colname == 'revision') {
                 $value = $to_revision_id;
             } elseif ($colname == 'createdate') {
                 $value = time();
             } elseif ($colname == 'updatedate') {
                 $value = time();
             } elseif ($colname == 'createuser') {
                 $value = $REX['USER']->getValue('login');
             } elseif ($colname == 'updateuser') {
                 $value = $REX['USER']->getValue('login');
             } else {
                 $value = $gc->getValue($colname);
             }
             if ($colname != 'id') {
                 $ins->setValue($colname, $ins->escape($value));
             }
         }
         $ins->insert();
         // id holen und als re setzen und weitermachen..
         rex_copyRevisionContent($article_id, $clang, $from_revision_id, $to_revision_id, $gc->getValue('id'));
         return true;
     }
     rex_generateArticle($article_id);
     return true;
 }
示例#12
0
    }
    // no index
    $noIndex = rex_post('seo_noindex');
    if (is_array($noIndex)) {
        $sql->setValue('seo_noindex', '1');
    } else {
        $sql->setValue('seo_noindex', '');
    }
    // update updatedate of article
    $sql->setValue('updatedate', time());
    // do db update
    if ($sql->update()) {
        // info msg
        echo rex_info($I18N->msg('seo42_seopage_updated'));
        // delete cached article
        rex_generateArticle($articleID);
        // reinit article to get correct values after possible update
        seo42::initArticle($REX['ARTICLE_ID']);
    } else {
        // err msg
        echo rex_warning($sql->getError());
    }
}
$sql = rex_sql::factory();
//$sql->debugsql = 1;
$seoData = $sql->getArray('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE id=' . $articleID . ' AND clang=' . $clang);
$seoData = $seoData[0];
if ($REX['ADDON']['seo42']['settings']['title_preview']) {
    $titleBoxClass = '';
} else {
    $titleBoxClass = 'no-title-preview';
     if ($function == 'add') {
         $modultyp->query("INSERT INTO " . $REX['TABLE_PREFIX'] . "modultyp (category_id, name, eingabe, ausgabe) VALUES ('{$category_id}', '{$mname}', '{$eingabe}', '{$ausgabe}')");
         $message = '<p class="warning">' . $I18N->msg("module_added") . '</p>';
     } else {
         $modultyp->setQuery("select * from " . $REX['TABLE_PREFIX'] . "modultyp where id='{$modul_id}'");
         if ($modultyp->getRows() == 1) {
             $old_ausgabe = $modultyp->getValue("ausgabe");
             $modultyp->query("UPDATE " . $REX['TABLE_PREFIX'] . "modultyp SET name='{$mname}', eingabe='{$eingabe}', ausgabe='{$ausgabe}' WHERE id='{$modul_id}'");
             $message = '<p class="warning">' . $I18N->msg("module_updated") . ' | ' . $I18N->msg("articel_updated") . '</font></p>';
             $new_ausgabe = stripslashes($ausgabe);
             if ($old_ausgabe != $new_ausgabe) {
                 // article updaten - nur wenn ausgabe sich veraendert hat
                 $gc = new sql();
                 $gc->setQuery("SELECT DISTINCT(" . $REX['TABLE_PREFIX'] . "article.id) FROM " . $REX['TABLE_PREFIX'] . "article \r\n              LEFT JOIN " . $REX['TABLE_PREFIX'] . "article_slice ON " . $REX['TABLE_PREFIX'] . "article.id=" . $REX['TABLE_PREFIX'] . "article_slice.article_id \r\n              WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}'");
                 for ($i = 0; $i < $gc->getRows(); $i++) {
                     rex_generateArticle($gc->getValue($REX['TABLE_PREFIX'] . "article.id"));
                     $gc->next();
                 }
             }
         }
     }
     if (isset($goon) and $goon != '') {
         $save = 'nein';
     } else {
         $function = '';
     }
 }
 if (!isset($save) or $save != 'ja') {
     echo '<a name="edit"><table class="rex" style="table-layout:auto;" cellpadding="5" cellspacing="1">';
     if ($function == 'edit') {
         $hole = new sql();