当前位置: 首页>>代码示例>>PHP>>正文


PHP OOCategory::isValid方法代码示例

本文整理汇总了PHP中OOCategory::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP OOCategory::isValid方法的具体用法?PHP OOCategory::isValid怎么用?PHP OOCategory::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OOCategory的用法示例。


在下文中一共展示了OOCategory::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getNavigation

 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'];
//.........这里部分代码省略.........
开发者ID:omphteliba,项目名称:seo42,代码行数:101,代码来源:class.nav42.inc.php

示例2: _rex_cast_var

/**
 * 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 {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:101,代码来源:function_rex_globals.inc.php

示例3: _formatNode

 function _formatNode(&$node)
 {
     if ($this->ignore_startarticles && OOArticle::isValid($node) && $node->isStartPage()) {
         return '';
     }
     $name = $node->getName();
     if ($name == '') {
         if ($this->ignore_empty) {
             return '';
         } else {
             $name = $this->empty_value;
         }
     }
     if ($this->depth_limit > 0 && $this->_depth >= $this->depth_limit) {
         return '';
     }
     $s = '';
     $s_self = '';
     $s_child = '';
     // Kategorien ingorieren?
     if (OOCategory::isValid($node) && !$this->ignore_categories || OOArticle::isValid($node) && !($this->ignore_startarticles && $node->isStartPage())) {
         $s_self .= $this->_formatNodeValue($name, $node);
         if (OOCategory::isValid($node)) {
             $childs = $node->getChildren($this->ignore_offlines, $this->clang);
             $articles = $node->getArticles($this->ignore_offlines, $this->clang);
             if (is_array($childs) && count($childs) > 0 || is_array($articles) && count($articles) > 0 && !$this->ignore_articles) {
                 $this->_depth++;
                 if (is_array($childs)) {
                     foreach ($childs as $child) {
                         $s_child .= $this->_formatNode($child);
                     }
                 }
                 // Artikel ingorieren?
                 if (!$this->ignore_articles) {
                     if (is_array($articles)) {
                         foreach ($articles as $article) {
                             //                if ($article->isStartPage())
                             //                {
                             //                  continue;
                             //                }
                             $s_child .= '<' . $this->child_tag . $this->child_attr . '>';
                             $s_child .= $this->_formatNodeValue($article->getName(), $article);
                             $s_child .= '</' . $this->child_tag . '>';
                         }
                     }
                 }
                 // Parent Tag nur erstellen, wenn auch Childs vorhanden sind
                 if ($s_child != '') {
                     $s_self .= '<' . $this->parent_tag . $this->parent_attr . '>';
                     $s_self .= $s_child;
                     $s_self .= '</' . $this->parent_tag . '>';
                 }
                 $this->_depth--;
             }
         }
         // Parent Tag nur erstellen, wenn auch Childs vorhanden sind
         if ($s_self != '') {
             $s .= '<' . $this->child_tag . $this->child_attr . '>';
             $s .= $s_self;
             $s .= '</' . $this->child_tag . '>';
         }
     }
     return $s;
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-addons,代码行数:64,代码来源:class.oostructure.inc.php

示例4: _rex_cast_var

/**
 * 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;
                }
//.........这里部分代码省略.........
开发者ID:Barnhiac,项目名称:MTW_REDAXO,代码行数:101,代码来源:function_rex_globals.inc.php


注:本文中的OOCategory::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。