本文整理汇总了PHP中OOCategory::getCategoryById方法的典型用法代码示例。如果您正苦于以下问题:PHP OOCategory::getCategoryById方法的具体用法?PHP OOCategory::getCategoryById怎么用?PHP OOCategory::getCategoryById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OOCategory
的用法示例。
在下文中一共展示了OOCategory::getCategoryById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBreadcrumb
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: rex_a62_metainfo_button
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: hasCategoryPerm
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: array
<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:
<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: getListValue
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: rex_addArticle
/**
* 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: insertLink
// ------------------------ 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: getParent
function getParent()
{
return OOCategory::getCategoryById($this->re_id);
}
示例10: rex_request
<?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: rex_rewriter_generate_pathnames
/**
* 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: _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'];
//.........这里部分代码省略.........
示例13: getParentTree
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: _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;
}
//.........这里部分代码省略.........
示例15: getParentTree
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;
}