コード例 #1
0
 function getBreadcrumb($startPageLabel, $includeCurrent = FALSE, $category_id = 0)
 {
     if (!$this->_setActivePath()) {
         return FALSE;
     }
     global $REX;
     $path = $this->path;
     $i = 1;
     $lis = '';
     if ($startPageLabel) {
         $lis .= '<li class="rex-lvl' . $i . '"><a href="' . rex_getUrl($REX['START_ARTICLE_ID']) . '">' . htmlspecialchars($startPageLabel) . '</a></li>';
         $i++;
         // StartArticle nicht doppelt anzeigen
         if (isset($path[0]) && $path[0] == $REX['START_ARTICLE_ID']) {
             unset($path[0]);
         }
     }
     foreach ($path as $pathItem) {
         if ($cat = OOCategory::getCategoryById($pathItem) && $this->_check($cat, $i)) {
             $lis .= '<li class="rex-lvl' . $i . '"><a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a></li>';
             $i++;
         }
     }
     if ($includeCurrent) {
         if ($art = OOArticle::getArticleById($this->current_article_id) && $this->_check($art, $i)) {
             if (!$art->isStartpage()) {
                 $lis .= '<li class="rex-lvl' . $i . '">' . htmlspecialchars($art->getName()) . '</li>';
             } else {
                 $cat = OOCategory::getCategoryById($this->current_article_id);
                 $lis .= '<li class="rex-lvl' . $i . '">' . htmlspecialchars($cat->getName()) . '</li>';
             }
         }
     }
     return '<ul class="rex-breadcrumb">' . $lis . '</ul>';
 }
コード例 #2
0
function rex_a62_metainfo_button($params)
{
    global $REX, $I18N;
    $s = '';
    $restrictionsCondition = '';
    if (isset($params['id']) && $params['id'] != '') {
        $OOCat = OOCategory::getCategoryById($params['id']);
        // Alle Metafelder des Pfades sind erlaubt
        foreach (explode('|', $OOCat->getPath()) as $pathElement) {
            if ($pathElement != '') {
                $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
            }
        }
        // Auch die Kategorie selbst kann Metafelder haben
        $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"';
    }
    $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
    $fields = _rex_a62_metainfo_sqlfields('cat_', $restrictionsCondition);
    if ($fields->getRows() >= 1) {
        $return = '<p class="rex-button-add"><script type="text/javascript"><!--

    function rex_metainfo_toggle()
    {
        jQuery("#rex-form-structure-category .rex-metainfo-cat").toggle();
        metacat = jQuery("#rex-i-meta-category");
        if(metacat.hasClass("rex-i-generic-open"))
        {
            metacat.removeClass("rex-i-generic-open");
            metacat.addClass("rex-i-generic-close");
        }
        else
        {
            metacat.removeClass("rex-i-generic-close");
            metacat.addClass("rex-i-generic-open");
        }
    }

    //--></script><a id="rex-i-meta-category" class="rex-i-generic-open" href="javascript:rex_metainfo_toggle();">' . $I18N->msg('minfo_edit_metadata') . '</a></p>';
        return $params['subject'] . $return;
    }
    return $params['subject'];
}
コード例 #3
0
 function hasCategoryPerm($category_id, $depricatedSecondParam = null)
 {
     // 1. Volle Rechte auf direkte Kategorie, csw
     // 2. Leserechte, bei Kategorien "zwischen" main und eigener navi, aber nicht sichtbar, csr
     // 3. Volle Rechte, wenn Kategorie unterhalb eine vollen Rechte Kat
     if ($this->isAdmin() || $this->hasPerm('csw[0]') || $this->hasPerm('csw[' . $category_id . ']')) {
         return true;
     }
     if ($c = OOCategory::getCategoryById($category_id)) {
         foreach ($c->getPathAsArray() as $k) {
             if ($this->hasPerm('csw[' . $k . ']')) {
                 return true;
             }
         }
     }
     /*if(!$rw)
       {
            if( $this->hasPerm('csr[' . $category_id . ']') )
               return TRUE;
       } */
     return false;
 }
コード例 #4
0
ファイル: linkmap.inc.php プロジェクト: Barnhiac/MTW_REDAXO
<div id="rex-linkmap">
    <div class="rex-area-col-2">
        <div class="rex-area-col-a">
            <h3 class="rex-hl2"><?php 
echo $I18N->msg('lmap_categories');
?>
</h3>
            <div class="rex-area-content">
            <?php 
$roots = OOCategory::getRootCategories();
$mountpoints = $REX['USER']->getMountpoints();
if (count($mountpoints) > 0) {
    $roots = array();
    foreach ($mountpoints as $mp) {
        if (OOCategory::getCategoryById($mp)) {
            $roots[] = OOCategory::getCategoryById($mp);
        }
    }
}
echo rex_linkmap_tree($tree, $category_id, $roots, $GlobalParams);
?>
            </div>
        </div>

        <div class="rex-area-col-b">
            <h3 class="rex-hl2"><?php 
echo $I18N->msg('lmap_articles');
?>
</h3>
            <div class="rex-area-content">
            <ul>
コード例 #5
0
          <col width="40" />
          <col width="315" />
          <col width="153" />
        </colgroup>
        <thead>
          <tr>
            <th class="rex-icon">' . $add_category . '</th>
            ' . $add_header . '
            <th>' . $I18N->msg('header_category') . '</th>
            <th>' . $I18N->msg('header_priority') . '</th>
            <th>' . $I18N->msg('header_edit_category') . '</th>
            <th>' . $I18N->msg('header_status') . '</th>
          </tr>
        </thead>
        <tbody>';
if ($category_id != 0 && ($category = OOCategory::getCategoryById($category_id))) {
    echo '<tr>
          <td></td>
          <td colspan="' . $data_colspan . '"><a href="index.php?page=structure&category_id=' . $category->getParentId() . '&clang=' . $clang . '">..</a></td>
        </tr>';
}
// --------------------- KATEGORIE ADD FORM
if ($function == 'add_cat' && $KATPERM && !$REX_USER->hasPerm('editContentOnly[]')) {
    $add_td = '';
    if ($REX_USER->hasPerm('advancedMode[]')) {
        $add_td = '<td class="rex-icon">-</td>';
    }
    $add_buttons = rex_register_extension_point('CAT_FORM_BUTTONS', "");
    $add_buttons .= '<input type="submit" class="rex-fsubmit" name="catadd_function" value="' . $I18N->msg('add_category') . '"' . rex_accesskey($I18N->msg('add_category'), $REX['ACKEY']['SAVE']) . ' />';
    echo '
        <tr class="rex-trow-actv">
コード例 #6
0
 static function getListValue($params)
 {
     $return = array();
     foreach (explode(',', $params['value']) as $id) {
         if ($cat = OOCategory::getCategoryById($id, (int) $params['params']['field']['clang'])) {
             $return[] = $cat->getName();
         }
     }
     return implode('<br />', $return);
 }
コード例 #7
0
/**
 * Erstellt einen neuen Artikel
 *
 * @param array $data Array mit den Daten des Artikels
 *
 * @return array Ein Array welches den status sowie eine Fehlermeldung beinhaltet
 */
function rex_addArticle($data)
{
    global $REX, $I18N;
    $success = true;
    $message = '';
    if (!is_array($data)) {
        trigger_error('Expecting $data to be an array!', E_USER_ERROR);
    }
    if (isset($data['prior'])) {
        if ($data['prior'] <= 0) {
            $data['prior'] = 1;
        }
    }
    $templates = OOCategory::getTemplates($data['category_id']);
    // Wenn Template nicht vorhanden, dann entweder erlaubtes nehmen
    // oder leer setzen.
    if (!isset($templates[$data['template_id']])) {
        $data['template_id'] = 0;
        if (count($templates) > 0) {
            $data['template_id'] = key($templates);
        }
    }
    $message = $I18N->msg('article_added');
    $AART = rex_sql::factory();
    foreach ($REX['CLANG'] as $key => $val) {
        // ------- Kategorienamen holen
        $category = OOCategory::getCategoryById($data['category_id'], $key);
        $category_name = '';
        if ($category) {
            $category_name = addslashes($category->getName());
        }
        $AART->setTable($REX['TABLE_PREFIX'] . 'article');
        if (!isset($id) or !$id) {
            $id = $AART->setNewId('id');
        } else {
            $AART->setValue('id', $id);
        }
        $AART->setValue('name', $data['name']);
        $AART->setValue('catname', $category_name);
        $AART->setValue('attributes', '');
        $AART->setValue('clang', $key);
        $AART->setValue('re_id', $data['category_id']);
        $AART->setValue('prior', $data['prior']);
        $AART->setValue('path', $data['path']);
        $AART->setValue('startpage', 0);
        $AART->setValue('status', 0);
        $AART->setValue('template_id', $data['template_id']);
        $AART->addGlobalCreateFields();
        $AART->addGlobalUpdateFields();
        if ($AART->insert()) {
            // ----- PRIOR
            rex_newArtPrio($data['category_id'], $key, 0, $data['prior']);
        } else {
            $success = false;
            $message = $AART->getError();
        }
        // ----- EXTENSION POINT
        $message = rex_register_extension_point('ART_ADDED', $message, array('id' => $id, 'clang' => $key, 'status' => 0, 'name' => $data['name'], 're_id' => $data['category_id'], 'prior' => $data['prior'], 'path' => $data['path'], 'template_id' => $data['template_id'], 'data' => $data));
    }
    return array($success, $message);
}
コード例 #8
0
// ------------------------ Print JS Functions
?>
<script type="text/javascript">
  function insertLink(link,name){
    <?php 
echo $func_body . "\n";
?>
    self.close();
  }
</script>

<div class="rex-lmp-pth">
<ul>
<?php 
$isRoot = $category_id === 0;
$category = OOCategory::getCategoryById($category_id);
$link = rex_linkmap_url(array('category_id' => 0), $GlobalParams);
echo '<li>' . $I18N->msg('path') . ' </li>';
echo '<li>: <a href="' . $link . '">Homepage</a> </li>';
$tree = array();
if ($category) {
    foreach ($category->getParentTree() as $cat) {
        $tree[] = $cat->getId();
        $link = rex_linkmap_url(array('category_id' => $cat->getId()), $GlobalParams);
        echo '<li> : <a href="' . $link . '">' . htmlspecialchars($cat->getName()) . '</a></li>';
    }
}
?>
</ul>
</div>
コード例 #9
0
 function getParent()
 {
     return OOCategory::getCategoryById($this->re_id);
 }
コード例 #10
0
ファイル: article_list.inc.php プロジェクト: crono/_rex_ajax
<?php

// title: Liste aller REDAXO-Artikel einer Kategorie
/**
 * Beispielmodul Liste aller REDAXO-Artikel einer Kategorie
 */
// Artikel-ID
$catid = rex_request('cat', 'int');
$content = '';
if ($catid != 0) {
    $cat = OOCategory::getCategoryById($catid);
    if ($cat) {
        $article = $cat->getArticles();
        if (is_array($article)) {
            $content = '<ul>';
            foreach ($article as $var) {
                $articleId = $var->getId();
                $articleName = $var->getName();
                $articleDescription = $var->getDescription();
                if (!$var->isStartpage() and $var->isOnline()) {
                    $content .= '<li><a href="' . rex_getUrl($articleId) . '" class="faq">' . $articleName . '</a></li>';
                }
            }
            $content .= '</ul>';
        }
    }
}
// Ausgabe, evtl. mit Header / Fehlermeldung
header('Content-Type: text/html; charset=utf-8');
if (trim($content) == '' or trim($content) == '<ul></ul>') {
    echo 'Keine Artikel gefunden!';
コード例 #11
0
/**
 * rex_rewriter_generate_pathnames
 * generiert die Pathlist, abhŠngig von Aktion
 * @author markus.staab[at]redaxo[dot]de Markus Staab
 * @package redaxo4.2
 */
function rex_rewriter_generate_pathnames($params)
{
    global $REX, $REXPATH;
    if (file_exists(FULLNAMES_PATHLIST)) {
        require_once FULLNAMES_PATHLIST;
    }
    if (!isset($REXPATH)) {
        $REXPATH = array();
    }
    if (!isset($params['extension_point'])) {
        $params['extension_point'] = '';
    }
    $where = '';
    switch ($params['extension_point']) {
        // ------- sprachabhängig, einen artikel aktualisieren
        case 'CAT_DELETED':
        case 'ART_DELETED':
            unset($REXPATH[$params['id']]);
            break;
        case 'CAT_ADDED':
        case 'CAT_UPDATED':
        case 'ART_ADDED':
        case 'ART_UPDATED':
            $where = '(id=' . $params['id'] . ' AND clang=' . $params['clang'] . ') OR (path LIKE "%|' . $params['id'] . '|%" AND clang=' . $params['clang'] . ')';
            break;
            // ------- alles aktualisieren
        // ------- alles aktualisieren
        case 'ALL_GENERATED':
        default:
            $where = '1=1';
            break;
    }
    if ($where != '') {
        $db = new rex_sql();
        // $db->debugsql=true;
        $db->setQuery('SELECT id,clang,path,startpage FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE ' . $where . ' and revision=0');
        while ($db->hasNext()) {
            $clang = $db->getValue('clang');
            $pathname = '';
            if (count($REX['CLANG']) > 1) {
                $pathname = $REX['CLANG'][$clang] . '/';
            }
            // pfad über kategorien bauen
            $path = trim($db->getValue('path'), '|');
            if ($path != '') {
                $path = explode('|', $path);
                foreach ($path as $p) {
                    $ooc = OOCategory::getCategoryById($p, $clang);
                    $name = $ooc->getName();
                    unset($ooc);
                    // speicher freigeben
                    $pathname = rex_rewriter_appendToPath($pathname, $name);
                }
            }
            $ooa = OOArticle::getArticleById($db->getValue('id'), $clang);
            if ($ooa->isStartArticle()) {
                $ooc = $ooa->getCategory();
                $catname = $ooc->getName();
                unset($ooc);
                // speicher freigeben
                $pathname = rex_rewriter_appendToPath($pathname, $catname);
            }
            // eigentlicher artikel anhängen
            $name = $ooa->getName();
            unset($ooa);
            // speicher freigeben
            $pathname = rex_rewriter_appendToPath($pathname, $name);
            $pathname = substr($pathname, 0, strlen($pathname) - 1) . '.html';
            $REXPATH[$db->getValue('id')][$db->getValue('clang')] = $pathname;
            $db->next();
        }
    }
    rex_put_file_contents(FULLNAMES_PATHLIST, "<?php\n\$REXPATH = " . var_export($REXPATH, true) . ";\n");
}
コード例 #12
0
ファイル: class.nav42.inc.php プロジェクト: omphteliba/seo42
 protected function _getNavigation($categoryId)
 {
     global $REX;
     static $depth = 0;
     if ($categoryId < 1) {
         $cats = OOCategory::getRootCategories($this->ignoreOfflines);
     } else {
         $cats = OOCategory::getChildrenById($categoryId, $this->ignoreOfflines);
     }
     $return = '';
     $ulIdAttribute = '';
     $ulClassAttribute = '';
     if (count($cats) > 0) {
         if (isset($this->ulId[$depth])) {
             $ulIdAttribute = ' id="' . $this->ulId[$depth] . '"';
         }
         if (isset($this->ulClass[$depth])) {
             $ulClassAttribute = ' class="' . $this->ulClass[$depth] . '"';
         }
         $return .= '<ul' . $ulIdAttribute . $ulClassAttribute . '>';
     }
     foreach ($cats as $cat) {
         if ($this->_checkCallbacks($cat, $depth)) {
             $cssClasses = '';
             $idAttribute = '';
             // default li class
             if ($this->liClass != '') {
                 $cssClasses .= ' ' . $this->liClass;
             }
             // li class
             if (is_array($this->liClassFromCategoryId) && isset($this->liClassFromCategoryId[$cat->getId()])) {
                 $cssClasses .= ' ' . $this->liClassFromCategoryId[$cat->getId()];
             }
             if ($this->liClassFromMetaField != '' && $cat->getValue($this->liClassFromMetaField) != '') {
                 $cssClasses .= ' ' . $cat->getValue($this->liClassFromMetaField);
             }
             // li id
             if (is_array($this->liIdFromCategoryId) && isset($this->liIdFromCategoryId[$cat->getId()])) {
                 $idAttribute = ' id="' . $this->liIdFromCategoryId[$cat->getId()] . '"';
             } elseif ($this->liIdFromMetaField != '' && $cat->getValue($this->liIdFromMetaField) != '') {
                 $idAttribute = ' id="' . $cat->getValue($this->liIdFromMetaField) . '"';
             }
             // selected class
             if ($cat->getId() == $this->current_category_id) {
                 // active menuitem
                 $cssClasses .= ' ' . $this->activeClass;
             } elseif (in_array($cat->getId(), $this->path)) {
                 // current menuitem
                 $cssClasses .= ' ' . $this->selectedClass;
             } else {
                 // do nothing
             }
             $trimmedCssClasses = trim($cssClasses);
             // build class attribute
             if ($trimmedCssClasses != '') {
                 $classAttribute = ' class="' . $trimmedCssClasses . '"';
             } else {
                 $classAttribute = '';
             }
             if ($this->hideWebsiteStartArticle && $cat->getId() == $REX['START_ARTICLE_ID'] || in_array($cat->getId(), $this->hideIds)) {
                 // do nothing
             } else {
                 $depth++;
                 $urlType = 0;
                 // default
                 $return .= '<li' . $idAttribute . $classAttribute . '>';
                 if ($this->linkFromUserFunc != '') {
                     $defaultLink = call_user_func($this->linkFromUserFunc, $cat, $depth);
                 } else {
                     $defaultLink = '<a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a>';
                 }
                 if (!class_exists('seo42')) {
                     // normal behaviour
                     $return .= $defaultLink;
                 } else {
                     // only with seo42 2.0.0+
                     $urlData = seo42::getCustomUrlData($cat);
                     // check if default lang has url clone option (but only if current categoy has no url data set)
                     if (count($REX['CLANG']) > 1 && !isset($urlData['url_type'])) {
                         $defaultLangCat = OOCategory::getCategoryById($cat->getId(), $REX['START_CLANG_ID']);
                         $urlDataDefaultLang = seo42::getCustomUrlData($defaultLangCat);
                         if (isset($urlDataDefaultLang['url_clone']) && $urlDataDefaultLang['url_clone']) {
                             // clone url data from default language to current language
                             $urlData = $urlDataDefaultLang;
                         }
                     }
                     if (isset($urlData['url_type'])) {
                         switch ($urlData['url_type']) {
                             case 5:
                                 // SEO42_URL_TYPE_NONE
                                 $return .= htmlspecialchars($cat->getName());
                                 break;
                             case 4:
                                 // SEO42_URL_TYPE_LANGSWITCH
                                 $newClangId = $urlData['clang_id'];
                                 $newArticleId = $REX['ARTICLE_ID'];
                                 $catNewLang = OOCategory::getCategoryById($newArticleId, $newClangId);
                                 // if category that should be switched is not online, switch to start article of website
                                 if (OOCategory::isValid($catNewLang) && !$catNewLang->isOnline()) {
                                     $newArticleId = $REX['START_ARTICLE_ID'];
                                 }
                                 // select li that is current language
                                 if ($REX['CUR_CLANG'] == $newClangId) {
                                     $return = substr($return, 0, strlen($return) - strlen('<li>'));
                                     $return .= '<li class="' . $this->selectedClass . '">';
                                 }
                                 $return .= '<a href="' . rex_getUrl($newArticleId, $newClangId) . '">' . htmlspecialchars($cat->getName()) . '</a>';
                                 break;
                             case 8:
                                 // SEO42_URL_TYPE_CALL_FUNC
                                 $return .= call_user_func($urlData['func'], $cat);
                                 break;
                             default:
                                 $return .= $defaultLink;
                                 break;
                         }
                     } else {
                         $return .= $defaultLink;
                     }
                 }
                 if (($this->showAll || $cat->getId() == $this->current_category_id || in_array($cat->getId(), $this->path)) && ($this->levelDepth > $depth || $this->levelDepth < 0)) {
                     $return .= $this->_getNavigation($cat->getId());
                 }
                 $depth--;
                 $return .= '</li>';
             }
         }
     }
     if (count($cats) > 0) {
         $return .= '</ul>';
     }
     return $return;
 }
コード例 #13
0
 function getParentTree()
 {
     $return = array();
     if ($this->_path) {
         $explode = explode('|', $this->_path);
         if (is_array($explode)) {
             foreach ($explode as $var) {
                 if ($var != '') {
                     $return[] = OOCategory::getCategoryById($var, $this->_clang);
                 }
             }
         }
         if ($this->_startpage) {
             $return[] = OOCategory::getCategoryById($this->_id, $this->_clang);
         }
     }
     return $return;
 }
コード例 #14
0
/**
 * Castet die Variable $var zum Typ $vartype
 *
 * Mögliche PHP-Typen sind:
 *  - bool (auch boolean)
 *  - int (auch integer)
 *  - double
 *  - string
 *  - float
 *  - real
 *  - object
 *  - array
 *  - '' (nicht casten)
 *
 * Mögliche REDAXO-Typen sind:
 *  - rex-article-id
 *  - rex-category-id
 *  - rex-clang-id
 *  - rex-template-id
 *  - rex-ctype-id
 *  - rex-slice-id
 *  - rex-module-id
 *  - rex-action-id
 *  - rex-media-id
 *  - rex-mediacategory-id
 *  - rex-user-id
 *
 * @access private
 */
function _rex_cast_var($var, $vartype, $default = null, $mode = 'default')
{
    global $REX;
    if (is_string($vartype)) {
        $casted = true;
        switch ($vartype) {
            // ---------------- REDAXO types
            case 'rex-article-id':
                $var = (int) $var;
                if ($mode == 'found') {
                    if (!OOArticle::isValid(OOArticle::getArticleById($var))) {
                        $var = (int) $default;
                    }
                }
                break;
            case 'rex-category-id':
                $var = (int) $var;
                if ($mode == 'found') {
                    if (!OOCategory::isValid(OOCategory::getCategoryById($var))) {
                        $var = (int) $default;
                    }
                }
                break;
            case 'rex-clang-id':
                $var = (int) $var;
                if ($mode == 'found') {
                    if (empty($REX['CLANG'][$var])) {
                        $var = (int) $default;
                    }
                }
                break;
            case 'rex-template-id':
            case 'rex-ctype-id':
            case 'rex-slice-id':
            case 'rex-module-id':
            case 'rex-action-id':
            case 'rex-media-id':
            case 'rex-mediacategory-id':
            case 'rex-user-id':
                // erstmal keine weitere validierung
                $var = (int) $var;
                break;
                // ---------------- PHP types
            // ---------------- PHP types
            case 'bool':
            case 'boolean':
                $var = (bool) $var;
                break;
            case 'int':
            case 'integer':
                $var = (int) $var;
                break;
            case 'double':
                $var = (double) $var;
                break;
            case 'float':
            case 'real':
                $var = (double) $var;
                break;
            case 'string':
                $var = (string) $var;
                break;
            case 'object':
                $var = (object) $var;
                break;
            case 'array':
                if ($var === '') {
                    $var = array();
                } else {
                    $var = (array) $var;
                }
                break;
                // kein Cast, nichts tun
            // kein Cast, nichts tun
            case '':
                break;
            default:
                // check for array with generic type
                if (strpos($vartype, 'array[') === 0) {
                    if (empty($var)) {
                        $var = array();
                    } else {
                        $var = (array) $var;
                    }
                    // check if every element in the array is from the generic type
                    $matches = array();
                    if (preg_match('@array\\[([^\\]]*)\\]@', $vartype, $matches)) {
                        foreach ($var as $key => $value) {
                            try {
                                $var[$key] = _rex_cast_var($value, $matches[1]);
                            } catch (InvalidArgumentException $e) {
                                // Evtl Typo im vartype, mit urspr. typ als fehler melden
                                throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!');
                            }
                        }
                    } else {
                        throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!');
                    }
                } else {
                    $casted = false;
                }
        }
        if ($casted) {
            return $var;
        }
    }
    if (is_callable($vartype)) {
        $var = call_user_func($vartype, $var);
    } elseif (is_array($vartype)) {
        $var = _rex_cast_var($var, 'array');
        $newVar = array();
        foreach ($vartype as $cast) {
            if (!is_array($cast) || !isset($cast[0])) {
                throw new InvalidArgumentException('Unexpected vartype in _rex_cast_var()!');
            }
            $key = $cast[0];
            $innerVartype = isset($cast[1]) ? $cast[1] : '';
            if (array_key_exists($key, $var)) {
                $newVar[$key] = _rex_cast_var($var[$key], $innerVartype);
            } elseif (!isset($cast[2])) {
                $newVar[$key] = _rex_cast_var('', $innerVartype);
            } else {
                $newVar[$key] = $cast[2];
            }
        }
        $var = $newVar;
    } elseif (is_string($vartype)) {
        throw new InvalidArgumentException('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!');
    } else {
        throw new InvalidArgumentException('Unexpected vartype in _rex_cast_var()!');
    }
    return $var;
}
コード例 #15
0
 function getParentTree()
 {
     $return = array();
     if ($this->_path) {
         if ($this->isStartArticle()) {
             $explode = explode('|', $this->_path . $this->_id . '|');
         } else {
             $explode = explode('|', $this->_path);
         }
         if (is_array($explode)) {
             foreach ($explode as $var) {
                 if ($var != '') {
                     $return[] = OOCategory::getCategoryById($var, $this->_clang);
                 }
             }
         }
     }
     return $return;
 }
コード例 #16
0
 function addCatOptions()
 {
     global $REX;
     if ($this->add_homepage) {
         $this->addOption('Homepage', 0);
     }
     if ($this->rootId !== null) {
         if (is_array($this->rootId)) {
             foreach ($this->rootId as $rootId) {
                 if ($rootCat = OOCategory::getCategoryById($rootId, $this->clang)) {
                     $this->addCatOption($rootCat, 0);
                 }
             }
         } else {
             if ($rootCat = OOCategory::getCategoryById($this->rootId, $this->clang)) {
                 $this->addCatOption($rootCat, 0);
             }
         }
     } else {
         if (!$this->check_perms || $REX['USER']->isAdmin() || $REX['USER']->hasPerm('csw[0]')) {
             if ($rootCats = OOCategory::getRootCategories($this->ignore_offlines, $this->clang)) {
                 foreach ($rootCats as $rootCat) {
                     $this->addCatOption($rootCat);
                 }
             }
         } elseif ($REX['USER']->hasMountpoints()) {
             $mountpoints = $REX['USER']->getMountpoints();
             foreach ($mountpoints as $id) {
                 $cat = OOCategory::getCategoryById($id, $this->clang);
                 if ($cat && !$REX['USER']->hasCategoryPerm($cat->getParentId())) {
                     $this->addCatOption($cat, 0);
                 }
             }
         }
     }
 }
コード例 #17
0
function d2u_stellenmarkt_extended_sitemap($_params)
{
    global $REX;
    // Hier werden Pfade zwischengespeichert um Performance zu gewinnen
    $artikel_pathnames = array();
    $query_kategorie = "SELECT lang.stellen_id, clang_id, artikel_id, interne_nummer, interne_bezeichnung, datum " . "FROM " . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen_lang AS lang " . "LEFT JOIN " . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen AS kategorie " . "ON lang.stellen_id = kategorie.stellen_id " . "WHERE status = 'online' " . "ORDER BY lang.stellen_id, clang_id";
    $sql_kategorie = new rex_sql();
    $sql_kategorie->setQuery($query_kategorie);
    $rows_kategorie = $sql_kategorie->getRows();
    // Hier werden Pfade der Kategorien gespeichert
    for ($i = 0; $i < $rows_kategorie; $i++, $sql_kategorie->next()) {
        $artikel_id = $sql_kategorie->getValue("artikel_id");
        $clang_id = $sql_kategorie->getValue("clang_id");
        $stellen_id = $sql_kategorie->getValue("stellen_id");
        $stellen_interne_bezeichnung = $sql_kategorie->getValue("interne_bezeichnung");
        $stellen_interne_nummer = $sql_kategorie->getValue("interne_nummer");
        $date_array = explode("-", $sql_kategorie->getValue("datum"));
        $change_date = mktime(0, 0, 0, $date_array[1], $date_array[2], $date_array[0]);
        $pathname = '';
        // Pfadnamen fuer Artikel
        if ($artikel_id > 0) {
            // Pfad wurde schon generiert
            if (array_key_exists($artikel_id, $artikel_pathnames) && array_key_exists($clang_id, $artikel_pathnames[$artikel_id])) {
                $pathname = $artikel_pathnames[$artikel_id][$clang_id];
            } else {
                // Sprachkuerzel
                if (count($REX['CLANG']) > 1 && $clang_id != $REX['ADDON']['seo42']['settings']['hide_langslug']) {
                    $pathname = seo42_appendToPath($pathname, $REX['ADDON']['seo42']['settings']['lang'][$clang_id]['code'], $REX['START_ARTICLE_ID'], $clang_id);
                }
                // Redaxo Artikel
                $artikel_kategorie = OOCategory::getCategoryById($artikel_id, $clang_id);
                if ($artikel_kategorie->isOnline() == false) {
                    // Nur in Index aufnehmen, wenn online
                    continue;
                }
                $artikel_hauptkategorien = $artikel_kategorie->getPathAsArray();
                for ($j = 0; $j < count($artikel_hauptkategorien); $j++) {
                    $artikel_hauptkategorie = OOCategory::getCategoryById($artikel_hauptkategorien[$j], $clang_id);
                    if ($artikel_hauptkategorie instanceof OOCategory) {
                        $pathname = seo42_appendToPath($pathname, $artikel_hauptkategorie->getName(), $artikel_hauptkategorie->getId(), $clang_id);
                    }
                }
                $pathname = seo42_appendToPath($pathname, $artikel_kategorie->getName(), $artikel_kategorie->getId(), $clang_id);
                if (!is_array($artikel_pathnames[$artikel_id])) {
                    $artikel_pathnames[$artikel_id] = array();
                }
                $artikel_pathnames[$artikel_id][$clang_id] = $pathname;
            }
        }
        // Pfad fuer Kategorie
        $pathname = seo42_appendToPath($pathname, $stellen_interne_bezeichnung . "-" . $stellen_interne_nummer, $artikel_id, $clang_id);
        // Nur wenn fuer Kategorien ebenfalls URLs vorgesehen sind
        $add_array = array();
        $add_array[$clang_id] = array('loc' => substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending'], 'lastmod' => date('c', $change_date), 'changefreq' => 'monthly', 'priority' => 0.6);
        $_params['subject'][] = $add_array;
    }
    return $_params['subject'];
    /*
    Allgemeiner Hinweis:
    In der config.inc.php muessen folgende Zeilen hinzugefuegt werden:
    -----%<-----
    require_once dirname(__FILE__) ."/extensions/seo42.inc.php";
    rex_register_extension('SEO42_SITEMAP_ARRAY_CREATED', 'd2u_stellenmarkt_extended_sitemap');
    -----%<-----
    */
}
コード例 #18
0
/**
 * Erweitert das Meta-Formular um die neuen Meta-Felder
 *
 * @param string   $prefix       Feldprefix
 * @param string   $params       EP Params
 * @param callback $saveCallback Callback, dass die Daten speichert
 */
function _rex_a62_metainfo_form($prefix, $params, $saveCallback)
{
    // Beim ADD gibts noch kein activeItem
    $activeItem = null;
    if (isset($params['activeItem'])) {
        $activeItem = $params['activeItem'];
    }
    $restrictionsCondition = '';
    if ($prefix == 'art_') {
        if ($params['id'] != '') {
            $s = '';
            $OOArt = OOArticle::getArticleById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOArt->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    } elseif ($prefix == 'cat_') {
        $s = '';
        if ($params['id'] != '') {
            $OOCat = OOCategory::getCategoryById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"';
        }
        $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
    } elseif ($prefix == 'med_') {
        $catId = rex_session('media[rex_file_category]', 'int');
        if ($activeItem) {
            $catId = $activeItem->getValue('category_id');
        }
        if ($catId !== '') {
            $s = '';
            if ($catId != 0) {
                $OOCat = OOMediaCategory::getCategoryById($catId);
                // Alle Metafelder des Pfades sind erlaubt
                foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                    if ($pathElement != '') {
                        $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                    }
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"';
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    }
    $sqlFields = _rex_a62_metainfo_sqlfields($prefix, $restrictionsCondition);
    $params = rex_call_func($saveCallback, array($params, $sqlFields), false);
    return rex_a62_metaFields($sqlFields, $activeItem, 'rex_a62_metainfo_form_item', $params);
}
コード例 #19
0
 function getCategory()
 {
     return OOCategory::getCategoryById($this->_category_id);
 }
コード例 #20
0
 function getTemplates($category_id, $ignore_inactive = true)
 {
     global $REX;
     $ignore_inactive = $ignore_inactive ? 1 : 0;
     $templates = array();
     $t_sql = rex_sql::factory();
     $t_sql->setQuery('select id,name,attributes from ' . $REX['TABLE_PREFIX'] . 'template where active=' . $ignore_inactive . ' order by name');
     if ($category_id < 1) {
         // Alle globalen Templates
         foreach ($t_sql->getArray() as $t) {
             $categories = rex_getAttributes("categories", $t["attributes"]);
             if (!is_array($categories) || $categories["all"] == 1) {
                 $templates[$t["id"]] = $t['name'];
             }
         }
     } else {
         if ($c = OOCategory::getCategoryById($category_id)) {
             $path = $c->getPathAsArray();
             $path[] = $category_id;
             foreach ($t_sql->getArray() as $t) {
                 $categories = rex_getAttributes("categories", $t["attributes"]);
                 // template ist nicht kategoriespezifisch -> includen
                 if (!is_array($categories) || $categories["all"] == 1) {
                     $templates[$t["id"]] = $t['name'];
                 } else {
                     // template ist auf kategorien beschraenkt..
                     // nachschauen ob eine davon im pfad der aktuellen kategorie liegt
                     foreach ($path as $p) {
                         if (in_array($p, $categories)) {
                             $templates[$t["id"]] = $t['name'];
                             break;
                         }
                     }
                 }
             }
         }
     }
     return $templates;
 }
コード例 #21
0
/**
* seo42_generate_pathlist()
*
* generiert die Pathlist, abhängig von Aktion
* @author markus.staab[at]redaxo[dot]de Markus Staab
* @package redaxo4.2
*/
function seo42_generate_pathlist($params)
{
    global $REX, $SEO42_IDS, $SEO42_URLS;
    // temporary community install workaround
    if (!isset($REX['ADDON']['seo42'])) {
        return;
    }
    // include pathlist file
    if (file_exists(SEO42_PATHLIST)) {
        require_once SEO42_PATHLIST;
    }
    // EXTENSION POINT "SEO42_PATHLIST_BEFORE_REBUILD"
    $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS);
    rex_register_extension_point('SEO42_PATHLIST_BEFORE_REBUILD', $subject);
    $SEO42_IDS = array();
    $SEO42_URLS = array();
    $REX['SEO42_URL_CLONE'] = array();
    $db = new rex_sql();
    // REVISION FIX
    $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article SET revision = 0 WHERE revision IS NULL;');
    $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article_slice SET revision = 0 WHERE revision IS NULL;');
    if ($REX['ADDON']['seo42']['settings']['ignore_root_cats']) {
        $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE re_id != 0 OR (re_id = 0 AND catname LIKE "") AND revision=0 OR revision IS NULL ORDER BY id';
    } else {
        $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE revision=0 OR revision IS NULL ORDER BY id';
    }
    $db->setQuery($sqlQuery);
    // redirects start articles withou slash: /xx to /xx/
    if (count($REX['CLANG']) > 1) {
        foreach ($REX['CLANG'] as $clangId => $clangName) {
            if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') {
                $langSlug = seo42::getLangUrlSlug($clangId) . '/';
            } else {
                $langSlug = seo42::getLangUrlSlug($clangId);
            }
            if ($REX['ADDON']['seo42']['settings']['homelang'] != $clangId) {
                $SEO42_URLS[$langSlug] = array('id' => $REX['START_ARTICLE_ID'], 'clang' => $clangId, 'status' => 301);
            }
        }
    }
    while ($db->hasNext()) {
        $pathname = '';
        $id = $db->getValue('id');
        $clang = $db->getValue('clang');
        $path = $db->getValue('path');
        // LANG SLUG
        if (count($REX['CLANG']) > 1 && $clang != $REX['ADDON']['seo42']['settings']['hide_langslug']) {
            $pathname = '';
            $pathname = seo42_appendToPath($pathname, seo42::getLangUrlSlug($clang), $id, $clang);
        }
        // pfad über kategorien bauen
        $path = trim($path, '|');
        if ($path != '') {
            $path = explode('|', $path);
            foreach ($path as $p) {
                $ooc = OOCategory::getCategoryById($p, seo42_utils::getInheritedClang($clang));
                // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC
                if (!is_a($ooc, 'OOCategory')) {
                    continue;
                }
                // 42
                if ($REX['ADDON']['seo42']['settings']['ignore_root_cats'] && $ooc->getParentId() == 0) {
                    continue;
                }
                $name = $ooc->getName();
                unset($ooc);
                $pathname = seo42_appendToPath($pathname, $name, $id, $clang);
            }
        }
        $ooa = OOArticle::getArticleById($id, seo42_utils::getInheritedClang($clang));
        // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC
        if (!is_a($ooa, 'OOArticle')) {
            $db->next();
            continue;
        }
        if ($ooa->isStartArticle()) {
            $ooc = $ooa->getCategory();
            $catname = $ooc->getName();
            unset($ooc);
            $pathname = seo42_appendToPath($pathname, $catname, $id, $clang);
        }
        // url_schema: seo42
        if (!$ooa->isStartArticle()) {
            // eigentlicher artikel anhängen
            $name = $ooa->getName();
            unset($ooa);
            $pathname = seo42_appendToPath($pathname, $name, $id, $clang);
        }
        // ALLGEMEINE URL ENDUNG
        $pathname = substr($pathname, 0, strlen($pathname) - 1) . $REX['ADDON']['seo42']['settings']['url_ending'];
        // STARTSEITEN URL FORMAT
        if ($db->getValue('id') == $REX['START_ARTICLE_ID'] && $db->getValue('clang') == $REX['ADDON']['seo42']['settings']['homelang'] && ($REX['ADDON']['seo42']['settings']['homeurl'] == 1 || $REX['ADDON']['seo42']['settings']['homeurl'] == 2)) {
            $pathname = '';
        } elseif ($REX['ADDON']['seo42']['settings']['homeurl'] == 2 && $db->getValue('id') == $REX['START_ARTICLE_ID'] && count($REX['CLANG']) > 1) {
            if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') {
                $langSlug = seo42::getLangUrlSlug($clang);
            } else {
                $langSlug = seo42::getLangUrlSlug($clang) . '/';
            }
            $pathname = $langSlug;
        }
        // UNSET OLD URL FROM $SEO42_URLS
        if (isset($SEO42_IDS[$id][$clang]['url']) && isset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']])) {
            unset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']]);
        }
        $SEO42_IDS[$id][$clang] = array('url' => $pathname);
        $SEO42_URLS[$pathname] = array('id' => (int) $id, 'clang' => (int) $clang);
        // get data from default lang if clone option is enabled for all other langs
        $jsonData = json_decode($db->getValue('seo_custom_url'), true);
        $articleId = $db->getValue('id');
        $clangId = $db->getValue('clang');
        if (isset($jsonData['url_clone']) && $jsonData['url_clone'] == true && $clangId == $REX['START_CLANG_ID']) {
            $REX['SEO42_URL_CLONE'][$articleId] = $jsonData;
        }
        $db->next();
    }
    // URL MANIPULATION BY SEO42
    // -----------------------------------------------------------------------------------------------------------
    $interReplaceIds = array();
    $db->reset();
    for ($i = 0; $i < $db->getRows(); $i++) {
        $urlField = $db->getValue('seo_custom_url');
        $articleId = $db->getValue('id');
        $clangId = $db->getValue('clang');
        if ($urlField != '' || isset($REX['SEO42_URL_CLONE'][$articleId])) {
            $urlData = seo42_utils::getUrlTypeData($urlField);
            $jsonData = json_decode($urlData, true);
            if (isset($REX['SEO42_URL_CLONE'][$articleId]) && !isset($jsonData['url_type'])) {
                $jsonData = $REX['SEO42_URL_CLONE'][$articleId];
            }
            switch ($jsonData['url_type']) {
                case SEO42_URL_TYPE_DEFAULT:
                    // do nothing
                    break;
                case SEO42_URL_TYPE_USERDEF_INTERN:
                    $customUrl = $jsonData['custom_url'];
                    if ($SEO42_IDS[$articleId][$clangId]['url'] != $customUrl) {
                        // only if custom url ist different then auto url
                        $SEO42_URLS[$customUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']];
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    }
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_USERDEF_EXTERN:
                    $customUrl = $jsonData['custom_url'];
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_MEDIAPOOL:
                    $customUrl = $REX['MEDIA_DIR'] . '/' . $jsonData['file'];
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl);
                    break;
                case SEO42_URL_TYPE_INTERN_REPLACE:
                    $customArticleId = $jsonData['article_id'];
                    $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $clangId);
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    if (isset($SEO42_IDS[$customArticleId][$clangId]['url'])) {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$clangId]['url']);
                    } else {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    }
                    break;
                case SEO42_URL_TYPE_INTERN_REPLACE_CLANG:
                    $customArticleId = $jsonData['article_id'];
                    $customClangId = $jsonData['clang_id'];
                    $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $customClangId);
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    if (isset($SEO42_IDS[$customArticleId][$customClangId]['url'])) {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$customClangId]['url']);
                    } else {
                        $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    }
                    break;
                case SEO42_URL_TYPE_REMOVE_ROOT_CAT:
                    $curUrl = $SEO42_IDS[$articleId][$clangId]['url'];
                    $newUrl = seo42_utils::removeRootCatFromUrl($curUrl, $clangId);
                    if ($newUrl != '') {
                        // same as SEO42_URL_TYPE_USERDEF_INTERN
                        $SEO42_URLS[$newUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']];
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                        $SEO42_IDS[$articleId][$clangId] = array('url' => $newUrl);
                    }
                    break;
                case SEO42_URL_TYPE_CALL_FUNC:
                    if ($jsonData['no_url']) {
                        unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    }
                    break;
                case SEO42_URL_TYPE_LANGSWITCH:
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    break;
                case SEO42_URL_TYPE_NONE:
                    unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]);
                    $SEO42_IDS[$articleId][$clangId] = array('url' => '');
                    break;
            }
            unset($jsonData);
        }
        $db->next();
    }
    // workaround for #177
    foreach ($interReplaceIds as $clangId => $value) {
        foreach ($value as $interReplaceId => $targetArticle) {
            if (isset($SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url'])) {
                $SEO42_IDS[$interReplaceId][$clangId] = array('url' => $SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url']);
            }
        }
    }
    // -----------------------------------------------------------------------------------------------------------
    // EXTENSION POINT "SEO42_PATHLIST_CREATED"
    $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS);
    $subject = rex_register_extension_point('SEO42_PATHLIST_CREATED', $subject);
    // EXTENSION POINT "SEO42_PATHLIST_FINAL" - READ ONLY
    rex_register_extension_point('SEO42_PATHLIST_FINAL', $subject);
    // ASSEMBLE, COMPRESS & WRITE PATHLIST TO FILE
    $pathlist_content = '$SEO42_IDS = ' . var_export($subject['SEO42_IDS'], true) . ';' . PHP_EOL . '$SEO42_URLS = ' . var_export($subject['SEO42_URLS'], true) . ';';
    $pathlist_content = seo42_compressPathlist($pathlist_content);
    rex_put_file_contents(SEO42_PATHLIST, '<?php' . PHP_EOL . $pathlist_content);
    // PURGE *.CONTENT CACHEFILES TO UPDATE INTERNAL LINKS CREATED BY replceLinks() in rex_article_base
    seo42_purgeCacheFiles();
}
コード例 #22
0
 /**
  * Gibt die URL der Terminkategorie zurück.
  * @global mixed[] $REX Redaxo Variable
  * @var boolean $path_only Gibt an, ob die URL mit Domain oder ohne erstellt
  * werden soll.
  * @return String URL für das Objekt
  */
 function getURL($path_only = FALSE)
 {
     if ($this->url == "") {
         global $REX;
         $pathname = '';
         if (OOAddon::isActivated('seo42')) {
             // Mit SEO42
             require_once dirname(__FILE__) . "/../../seo42/classes/class.seo42_rewrite.inc.php";
             // Dann Redaxo Artikelfolge
             if ($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'] > 0 && $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'] != $REX['START_ARTICLE_ID']) {
                 $kategorie = OOCategory::getCategoryById($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']);
                 $hauptkategorien = $kategorie->getPathAsArray();
                 for ($i = 0; $i < count($hauptkategorien); $i++) {
                     $hauptkategorie = OOCategory::getCategoryById($hauptkategorien[$i], $REX['CUR_CLANG']);
                     if ($hauptkategorie instanceof OOCategory) {
                         $pathname = seo42_appendToPath($pathname, $hauptkategorie->getName(), $hauptkategorie->getId(), $REX['CUR_CLANG']);
                     }
                 }
                 if ($kategorie->getName() != "") {
                     $pathname = seo42_appendToPath($pathname, $kategorie->getName(), $kategorie->getId(), $REX['CUR_CLANG']);
                 } else {
                     // Wenn angegebener Artikel keine Kategorie ist, sondern nur Artikelname hat
                     $pathname = seo42_appendToPath($pathname, $kategorie->getValue("name"), $kategorie->getId(), $REX['CUR_CLANG']);
                 }
             }
             // Art der Startkachel
             $pathname = seo42_appendToPath($pathname, $REX['ADDON']['d2u_kurse']['settings']['termin_titel'], $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']);
             // Die Elternkategorie
             if ($this->eltern_terminkategorie !== FALSE) {
                 $pathname = seo42_appendToPath($pathname, $this->eltern_terminkategorie->name, $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']);
             }
             // Die Terminkategorie
             $pathname = seo42_appendToPath($pathname, $this->name, $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']);
             $pathname = substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending'];
         } else {
             // Ohne SEO42
             $parameterArray = array();
             $parameterArray['terminkategorie_id'] = $this->terminkategorie_id;
             $pathname = rex_getUrl($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG'], $parameterArray, "&");
         }
         $this->url = $pathname;
     }
     if ($path_only) {
         return $this->url;
     } else {
         return $REX['SERVER'] . $this->url;
     }
 }
コード例 #23
0
/**
 * Castet die Variable $var zum Typ $vartype
 * 
 * Mögliche PHP-Typen sind:
 *  - bool (auch boolean)
 *  - int (auch integer)
 *  - double
 *  - string
 *  - float
 *  - real
 *  - object
 *  - array
 *  - '' (nicht casten)
 *  
 * Mögliche REDAXO-Typen sind:
 *  - rex-article-id
 *  - rex-category-id
 *  - rex-clang-id
 *  - rex-template-id
 *  - rex-ctype-id
 *  - rex-slice-id
 *  - rex-module-id
 *  - rex-action-id
 *  - rex-media-id
 *  - rex-mediacategory-id
 *  - rex-user-id
 * 
 * @access private
 */
function _rex_cast_var($var, $vartype, $default, $mode)
{
    global $REX;
    if (!is_string($vartype)) {
        trigger_error('String expected for $vartype in _rex_cast_var()!', E_USER_ERROR);
        exit;
    }
    switch ($vartype) {
        // ---------------- REDAXO types
        case 'rex-article-id':
            $var = (int) $var;
            if ($mode == 'found') {
                if (!OOArticle::isValid(OOArticle::getArticleById($var))) {
                    $var = (int) $default;
                }
            }
            break;
        case 'rex-category-id':
            $var = (int) $var;
            if ($mode == 'found') {
                if (!OOCategory::isValid(OOCategory::getCategoryById($var))) {
                    $var = (int) $default;
                }
            }
            break;
        case 'rex-clang-id':
            $var = (int) $var;
            if ($mode == 'found') {
                if (empty($REX['CLANG'][$var])) {
                    $var = (int) $default;
                }
            }
            break;
        case 'rex-template-id':
        case 'rex-ctype-id':
        case 'rex-slice-id':
        case 'rex-module-id':
        case 'rex-action-id':
        case 'rex-media-id':
        case 'rex-mediacategory-id':
        case 'rex-user-id':
            // erstmal keine weitere validierung
            $var = (int) $var;
            break;
            // ---------------- PHP types
        // ---------------- PHP types
        case 'bool':
        case 'boolean':
            $var = (bool) $var;
            break;
        case 'int':
        case 'integer':
            $var = (int) $var;
            break;
        case 'double':
            $var = (double) $var;
            break;
        case 'float':
        case 'real':
            $var = (double) $var;
            break;
        case 'string':
            $var = (string) $var;
            break;
        case 'object':
            $var = (object) $var;
            break;
        case 'array':
            if (empty($var)) {
                $var = array();
            } else {
                $var = (array) $var;
            }
            break;
            // kein Cast, nichts tun
        // kein Cast, nichts tun
        case '':
            break;
            // Evtl Typo im vartype, deshalb hier fehlermeldung!
        // Evtl Typo im vartype, deshalb hier fehlermeldung!
        default:
            trigger_error('Unexpected vartype "' . $vartype . '" in _rex_cast_var()!', E_USER_ERROR);
            exit;
    }
    return $var;
}
コード例 #24
0
 function getCategory()
 {
     return OOCategory::getCategoryById($this->getCategoryId(), $this->getClang());
 }
コード例 #25
0
 function getParent()
 {
     return $this->_re_category_id > 0 ? OOCategory::getCategoryById($this->_re_category_id) : null;
 }
コード例 #26
0
 function &_getCategoryObject($category, $clang = false)
 {
     if (is_object($category)) {
         return $category;
     } elseif (is_int($category)) {
         return OOCategory::getCategoryById($category, $clang);
     } elseif (is_array($category)) {
         $catlist = array();
         foreach ($category as $cat) {
             $catobj = OOCategory::_getCategoryObject($cat, $clang);
             if (is_object($catobj)) {
                 $catlist[] = $catobj;
             } else {
                 return null;
             }
         }
         return $catlist;
     }
     return null;
 }
コード例 #27
0
 /**
  * Gibt die URL dieses Stellenangebots zurück.
  * @param int clang_id SprachID aus Redaxo
  * @return string URL für dieses Stellenangebot.
  */
 public function getURL($clang_id = -1)
 {
     if ($clang_id == -1) {
         $clang_id = $this->clang_id;
     }
     if ($this->url != "") {
         return $this->url;
     } else {
         global $REX;
         $url = $REX['SERVER'];
         $pathname = '';
         if ($REX['MOD_REWRITE'] == true && OOAddon::isActivated('seo42')) {
             // Mit SEO42
             require_once dirname(__FILE__) . "/../../seo42/classes/class.seo42_rewrite.inc.php";
             if (count($REX['CLANG']) > 1 && $clang_id != $REX['ADDON']['seo42']['settings']['hide_langslug']) {
                 // Sprachkuerzel
                 $pathname = seo42_appendToPath($pathname, $REX['ADDON']['seo42']['settings']['lang'][$clang_id]['code'], $REX['START_ARTICLE_ID'], $clang_id);
             }
             // Dann Redaxo Artikelfolge
             if ($this->artikel_id > 0 && $clang_id > -1) {
                 $kategorie = OOCategory::getCategoryById($this->artikel_id, $clang_id);
                 $hauptkategorien = $kategorie->getPathAsArray();
                 for ($i = 0; $i < count($hauptkategorien); $i++) {
                     $hauptkategorie = OOCategory::getCategoryById($hauptkategorien[$i], $clang_id);
                     if ($hauptkategorie instanceof OOCategory) {
                         $pathname = seo42_appendToPath($pathname, $hauptkategorie->getName(), $hauptkategorie->getId(), $clang_id);
                     }
                 }
                 $pathname = seo42_appendToPath($pathname, $kategorie->getName(), $kategorie->getId(), $clang_id);
             }
             // Jetzt die Stelle
             $pathname = seo42_appendToPath($pathname, $this->interne_bezeichnung . "-" . $this->interne_nummer, $this->artikel_id, $clang_id);
             $pathname = substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending'];
         } else {
             // Ohne SEO42
             $parameterArray = array();
             $parameterArray['stellen_id'] = $this->stellen_id;
             $pathname = rex_getUrl($this->artikel_id, $clang_id, $parameterArray, "&");
         }
         $url .= $pathname;
         return $url;
     }
 }