function OORedaxo($params = false, $clang = false) { //var_dump($params); if ($params) { foreach (OORedaxo::getClassVars() as $key => $var) { $this->{$key} = $params[$key]; } } }
function OORedaxo($params = false, $clang = false) { // var_dump($params); if ($params !== false) { foreach (OORedaxo::getClassVars() as $var) { $class_var = '_' . $var; $this->{$class_var} = $params[$var]; } } if ($clang === false && isset($params['clang'])) { $clang = $params['clang']; } if ($clang !== false) { $this->clang = $clang; } }
function getArticlesByType($article_type_id, $ignore_offlines = false, $clang = false) { global $REX; if ($clang === false) { $clang = $REX[CUR_CLANG]; } $offline = $ignore_offlines ? " and status = 1 " : ""; $artlist = array(); $sql = new sql(); $sql->setQuery("select " . implode(',', OORedaxo::getClassVars()) . " FROM rex_article WHERE type_id = '{$article_type_id}' AND clang='{$clang}' {$offline}"); for ($i = 0; $i < $sql->getRows(); $i++) { foreach (OORedaxo::getClassVars() as $var) { $article_data['_' . $var] = $sql->getValue($var); } $artlist[] = new OOArticle($article_data); $sql->next(); } return $artlist; }
function OOCategory($params = false, $clang = false) { parent::OORedaxo($params, $clang); }
function hasValue($value) { return parent::hasValue($value, array('art_')); }
/** * Generiert den Artikel-Cache der Metainformationen. * * @param $article_id Id des zu generierenden Artikels * @param [$clang ClangId des Artikels] * * @return TRUE bei Erfolg, FALSE wenn eine ungütlige article_id übergeben wird, sonst eine Fehlermeldung */ function rex_generateArticleMeta($article_id, $clang = null) { global $REX, $I18N; foreach ($REX['CLANG'] as $_clang => $clang_name) { if ($clang !== null && $clang != $_clang) { continue; } $CONT = new rex_article_base(); $CONT->setCLang($_clang); $CONT->setEval(false); // Content nicht ausfŸhren, damit in Cachedatei gespeichert werden kann if (!$CONT->setArticleId($article_id)) { return false; } // --------------------------------------------------- Artikelparameter speichern $params = array('article_id' => $article_id, 'last_update_stamp' => time()); $class_vars = OORedaxo::getClassVars(); unset($class_vars[array_search('id', $class_vars)]); $db_fields = $class_vars; foreach ($db_fields as $field) { $params[$field] = $CONT->getValue($field); } $content = '<?php' . "\n"; foreach ($params as $name => $value) { $content .= '$REX[\'ART\'][' . $article_id . '][\'' . $name . '\'][' . $_clang . '] = \'' . rex_addslashes($value, '\\\'') . '\';' . "\n"; } $content .= '?>'; $article_file = $REX['GENERATED_PATH'] . "/articles/{$article_id}.{$_clang}.article"; if (rex_file::put($article_file, $content) === false) { return $I18N->msg('article_could_not_be_generated') . ' ' . $I18N->msg('check_rights_in_directory') . $REX['GENERATED_PATH'] . '/articles/'; } // damit die aktuellen änderungen sofort wirksam werden, einbinden! require $article_file; } return true; }
function getValue($value) { // alias für re_id -> category_id if (in_array($value, array('re_id', '_re_id', 'category_id', '_category_id'))) { // für die CatId hier den Getter verwenden, // da dort je nach ArtikelTyp unterscheidungen getroffen werden müssen return $this->getCategoryId(); } return parent::getValue($value); }
/** * Macht einen Artikel zum Startartikel der eigenen Kategorie * * @param $aid Artikel ID */ function rex_article2startpage($neu_id) { global $REX; $GAID = array(); // neuen startartikel holen und schauen ob da $neu = new rex_sql(); $neu->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id={$neu_id} and startpage=0 and clang=0"); if ($neu->getRows() != 1) { return false; } $neu_path = $neu->getValue("path"); $neu_cat_id = $neu->getValue("re_id"); // in oberster kategorie dann return if ($neu_cat_id == 0) { return false; } // alten startartikel $alt = new rex_sql(); $alt->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id={$neu_cat_id} and startpage=1 and clang=0"); if ($alt->getRows() != 1) { return false; } $alt_path = $alt->getValue('path'); $alt_id = $alt->getValue('id'); // cat felder sammeln. + $params = array('path', 'prior', 'catname', 'startpage', 'catprior', 'status'); $db_fields = OORedaxo::getClassVars(); foreach ($db_fields as $field) { if (substr($field, 0, 4) == 'cat_') { $params[] = $field; } } // LANG SCHLEIFE foreach ($REX['CLANG'] as $clang => $clang_name) { // alter startartikel $alt->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id={$neu_cat_id} and startpage=1 and clang={$clang}"); // neuer startartikel $neu->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id={$neu_id} and startpage=0 and clang={$clang}"); // alter startartikel updaten $alt2 = new rex_sql(); $alt2->setTable($REX['TABLE_PREFIX'] . "article"); $alt2->setWhere("id={$alt_id} and clang=" . $clang); $alt2->setValue("re_id", $neu_id); // neuer startartikel updaten $neu2 = new rex_sql(); $neu2->setTable($REX['TABLE_PREFIX'] . "article"); $neu2->setWhere("id={$neu_id} and clang=" . $clang); $neu2->setValue("re_id", $alt->getValue("re_id")); // austauschen der definierten paramater foreach ($params as $param) { $neu_value = $neu->getValue($param); $alt_value = $alt->getValue($param); $alt2->setValue($param, $neu_value); $neu2->setValue($param, $alt_value); } $alt2->update(); $neu2->update(); } // alle artikel suchen nach |art_id| und pfade ersetzen // alles artikel mit re_id alt_id suchen und ersetzen $articles = new rex_sql(); $ia = new rex_sql(); $articles->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where path like '%|{$alt_id}|%'"); for ($i = 0; $i < $articles->getRows(); $i++) { $iid = $articles->getValue("id"); $ipath = str_replace("|{$alt_id}|", "|{$neu_id}|", $articles->getValue("path")); $ia->setTable($REX['TABLE_PREFIX'] . "article"); $ia->setWhere('id=' . $iid); $ia->setValue("path", $ipath); if ($articles->getValue("re_id") == $alt_id) { $ia->setValue("re_id", $neu_id); } $ia->update(); $GAID[$iid] = $iid; $articles->next(); } $GAID[$neu_id] = $neu_id; $GAID[$alt_id] = $alt_id; foreach ($GAID as $gid) { rex_generateArticle($gid); } return true; }
static function hasValue($value) { return parent::hasValueWithPrefixes($value, array('art_')); }
/** * CLASS Function: * Returns an Array containing article field names */ function getClassVars() { static $vars = array(); if (empty($vars)) { global $REX; $vars = array(); $file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $REX['START_ARTICLE_ID'] . '.0.article'; if ($REX['GG'] && file_exists($file)) { // Im GetGenerated Modus, die Spaltennamen aus den generated Dateien holen include_once $file; // da getClassVars() eine statische Methode ist, können wir hier nicht mit $this->getId() arbeiten! $genVars = OORedaxo::convertGeneratedArray($REX['ART'][$REX['START_ARTICLE_ID']], 0); unset($genVars['article_id']); unset($genVars['last_update_stamp']); foreach ($genVars as $name => $value) { $vars[] = $name; } } else { // Im Backend die Spalten aus der DB auslesen / via EP holen $sql = new rex_sql(); $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'article LIMIT 0'); foreach ($sql->getFieldnames() as $field) { $vars[] = $field; } } } return $vars; }
/** * Konvertiert einen Artikel zum Startartikel der eigenen Kategorie * * @param int $neu_id Artikel ID des Artikels, der Startartikel werden soll * * @return boolean TRUE bei Erfolg, sonst FALSE */ function rex_article2startpage($neu_id) { global $REX; $GAID = array(); // neuen startartikel holen und schauen ob da $neu = rex_sql::factory(); $neu->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where id={$neu_id} and startpage=0 and clang=0"); if ($neu->getRows() != 1) { return false; } $neu_path = $neu->getValue('path'); $neu_cat_id = $neu->getValue('re_id'); // in oberster kategorie dann return if ($neu_cat_id == 0) { return false; } // alten startartikel $alt = rex_sql::factory(); $alt->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where id={$neu_cat_id} and startpage=1 and clang=0"); if ($alt->getRows() != 1) { return false; } $alt_path = $alt->getValue('path'); $alt_id = $alt->getValue('id'); $parent_id = $alt->getValue('re_id'); // cat felder sammeln. + $params = array('path', 'prior', 'catname', 'startpage', 'catprior', 'status'); $db_fields = OORedaxo::getClassVars(); foreach ($db_fields as $field) { if (substr($field, 0, 4) == 'cat_') { $params[] = $field; } } // LANG SCHLEIFE foreach ($REX['CLANG'] as $clang => $clang_name) { // alter startartikel $alt->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where id={$neu_cat_id} and startpage=1 and clang={$clang}"); // neuer startartikel $neu->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where id={$neu_id} and startpage=0 and clang={$clang}"); // alter startartikel updaten $alt2 = rex_sql::factory(); $alt2->setTable($REX['TABLE_PREFIX'] . 'article'); $alt2->setWhere("id={$alt_id} and clang=" . $clang); $alt2->setValue('re_id', $neu_id); // neuer startartikel updaten $neu2 = rex_sql::factory(); $neu2->setTable($REX['TABLE_PREFIX'] . 'article'); $neu2->setWhere("id={$neu_id} and clang=" . $clang); $neu2->setValue('re_id', $alt->getValue('re_id')); // austauschen der definierten paramater foreach ($params as $param) { $neu_value = $neu->escape($neu->getValue($param)); $alt_value = $alt->escape($alt->getValue($param)); $alt2->setValue($param, $neu_value); $neu2->setValue($param, $alt_value); } $alt2->update(); $neu2->update(); } // alle artikel suchen nach |art_id| und pfade ersetzen // alles artikel mit re_id alt_id suchen und ersetzen $articles = rex_sql::factory(); $ia = rex_sql::factory(); $articles->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where path like '%|{$alt_id}|%'"); for ($i = 0; $i < $articles->getRows(); $i++) { $iid = $articles->getValue('id'); $ipath = str_replace("|{$alt_id}|", "|{$neu_id}|", $articles->getValue('path')); $ia->setTable($REX['TABLE_PREFIX'] . 'article'); $ia->setWhere('id=' . $iid); $ia->setValue('path', $ipath); if ($articles->getValue('re_id') == $alt_id) { $ia->setValue('re_id', $neu_id); } $ia->update(); $GAID[$iid] = $iid; $articles->next(); } $GAID[$neu_id] = $neu_id; $GAID[$alt_id] = $alt_id; $GAID[$parent_id] = $parent_id; foreach ($GAID as $gid) { rex_deleteCacheArticle($gid); } $users = rex_sql::factory(); $users->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'user SET rights = REPLACE(rights, "#csw[' . $alt_id . ']#", "#csw[' . $neu_id . ']#")'); foreach ($REX['CLANG'] as $clang => $clang_name) { rex_register_extension_point('ART_TO_STARTPAGE', '', array('id' => $neu_id, 'id_old' => $alt_id, 'clang' => $clang)); } return true; }
function save() { $fieldName = $this->elementPostValue($this->getFieldsetName(), 'name'); // Den alten Wert aus der DB holen // Dies muss hier geschehen, da in parent::save() die Werte für die DB mit den // POST werten überschrieben werden! $fieldOldName = ''; $fieldOldPrior = 9999999999999.0; // dirty, damit die prio richtig läuft... $fieldOldDefault = ''; if ($this->sql->getRows() == 1) { $fieldOldName = $this->sql->getValue('name'); $fieldOldPrior = $this->sql->getValue('prior'); $fieldOldDefault = $this->sql->getValue('default'); } if (parent::save()) { global $REX, $I18N; $this->organizePriorities($this->elementPostValue($this->getFieldsetName(), 'prior'), $fieldOldPrior); $fieldName = $this->addPrefix($fieldName); $fieldType = $this->elementPostValue($this->getFieldsetName(), 'type'); $fieldDefault = $this->elementPostValue($this->getFieldsetName(), 'default'); $sql = rex_sql::factory(); $sql->debugsql =& $this->debug; $result = $sql->getArray('SELECT `dbtype`, `dblength` FROM `' . $REX['TABLE_PREFIX'] . '62_type` WHERE id=' . $fieldType); $fieldDbType = $result[0]['dbtype']; $fieldDbLength = $result[0]['dblength']; // TEXT Spalten dürfen in MySQL keine Defaultwerte haben if ($fieldDbType == 'text') { $fieldDefault = null; } if ($this->isEditMode()) { // Spalte in der Tabelle verändern $tmRes = $this->tableManager->editColumn($fieldOldName, $fieldName, $fieldDbType, $fieldDbLength, $fieldDefault); } else { // Spalte in der Tabelle anlegen $tmRes = $this->tableManager->addColumn($fieldName, $fieldDbType, $fieldDbLength, $fieldDefault); } OORedaxo::$vars = array(); rex_generateAll(); if ($tmRes) { // DefaultWerte setzen if ($fieldDefault != $fieldOldDefault) { $upd = rex_sql::factory(); $upd->debugsql =& $this->debug; $upd->setTable($this->tableManager->getTableName()); $upd->setWhere('`' . $fieldName . '`="' . addSlashes($fieldOldDefault) . '"'); $upd->setValue($fieldName, addSlashes($fieldDefault)); return $upd->update(); } // Default werte haben schon zuvor gepasst, daher true zurückgeben return true; } } return false; }