Skip to content

Commit

Permalink
Changed methodnames: ul in list and li in list item
Browse files Browse the repository at this point in the history
  • Loading branch information
RexDude committed Nov 15, 2015
1 parent f56c859 commit efbadf8
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 271 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ Navigation Factory - Changelog
### Version 1.0.0 DEV

* Geändert: Klasse `nav42` umbenannt und aufgeteilt in die Klassen `rex_nav`, `rex_lang_nav` und `rex_breadcrumb_nav`
* Geändert: Alle Methodennamen mit einem `Li` darin wurden umbenannt. `Li` = `ListItem`
* Geändert: Alle Methodennamen mit einem `Ul` darin wurden umbenannt. `Ul` = `List`
* Geändert: Alle Klassen geben einheitlich die Navigation über Ausgabemethode `getNavigation()` aus
* Geändert: `getNavigationByCategory()` entfernt, stattdessen `setStartCategoryId()` hinzugefügt
* Geändert: `getNavigationByLevel()` entfernt, stattdessen `setLevelStart()` hinzugefügt
* Geändert: `setLevelDepth()` hinzugefügt
* Geändert: `setLevelStart()` erstes Level beginnt jetzt bei 1, nicht mehr bei 0.
* Geändert: `setUlClass()` erstes Level beginnt jetzt bei 1, nicht mehr bei 0.
* Geändert: `setUlId()` erstes Level beginnt jetzt bei 1, nicht mehr bei 0.
* Geändert: `setListClass()` (ehemals `setUlClass()`) erstes Level beginnt jetzt bei 1, nicht mehr bei 0.
* Geändert: `setListId()` (ehemals `setUlId()`) erstes Level beginnt jetzt bei 1, nicht mehr bei 0.
* Geändert: Methode `setLinkFromUserFunc()` in `setCustomLink()` umbenannt
* Neu: Methode `setUlClass()` zur Klasse `rex_lang_nav` hinzugefügt, thx@darwin
* Geändert: Es gab umfangreiche Änderungen an der Breadcrumb Navigation. Bitte die Codebeispiele studieren
* Neu: Methode `setListClass()` zur Klasse `rex_lang_nav` hinzugefügt, thx@darwin
88 changes: 60 additions & 28 deletions classes/class.rex_breadcrumb_nav.inc.php
Original file line number Diff line number Diff line change
@@ -1,78 +1,110 @@
<?php

class rex_breadcrumb_nav {
protected $cssClass;
protected $olList;
protected $listId;
protected $listClass;
protected $orderedList;
protected $startArticleName;
protected $startArticleIconClass;
protected $hideStartArticleName;

public function __construct() {
$this->cssClass = '';
$this->olList = false;
$this->listId = '';
$this->listClass = '';
$this->orderedList = false;
$this->startArticleName = '';
$this->startArticleIconClass = '';
$this->hideStartArticleName = false;
}

public function setCssClass($cssClass) {
$this->cssClass = $cssClass;
public function setListId($listId) {
$this->listId = $listId;
}

public function setOlList($olList) {
$this->olList = $olList;
public function setListClass($listClass) {
$this->listClass = $listClass;
}

public function setOrderedList($orderedList) {
$this->orderedList = $orderedList;
}

public function setStartArticleName($startArticleName) {
$this->startArticleName = $startArticleName;
}

public function setStartArticleIconClass($startArticleIconClass) {
$this->startArticleIconClass = $startArticleIconClass;
}

public function setHideStartArticleName($hideStartArticleName) {
$this->hideStartArticleName = $hideStartArticleName;
}

public function getNavigation() {
global $REX;

$listType = 'ul';

if ($this->olList) {
if ($this->orderedList) {
$listType = 'ol';
} else {
$listType = 'ul';
}

if ($this->listId !== '') {
$listIdAttribute = ' id="' . $this->listId . '"';
} else {
$listIdAttribute = '';
}

if ($this->cssClass !== '') {
$cssClass = ' class="' . $this->cssClass . '"';
if ($this->listClass !== '') {
$listClassAttribute = ' class="' . $this->listClass . '"';
} else {
$cssClass = '';
$listClassAttribute = '';
}

$html = '<' . $listType . $cssClass . '>';
$html = '<' . $listType . $listIdAttribute . $listClassAttribute . '>';
$path = explode('|', $REX['ART'][$REX['ARTICLE_ID']]['path'][$REX['CUR_CLANG']] . $REX['ARTICLE_ID']);

if ($REX['ARTICLE_ID'] !== $REX['START_ARTICLE_ID']) {
$path = array_merge(array($REX['START_ARTICLE_ID']), $path);
}

foreach ($path as $id) {
if ($id) {
if ($this->startArticleName === false && intval($id) === $REX['START_ARTICLE_ID']) {
continue;
}

if ($id > 0) {
$article = OOArticle::getArticleById($id);
$articleName = $article->getName();

if ($article->isOnline()) {
if ($this->startArticleName !== '' && intval($id) === $REX['START_ARTICLE_ID']) {
$articleName = $this->startArticleName;
}

$linkText = $article->getName();
$html .= '<li>';

if (intval($id) === $REX['START_ARTICLE_ID']) {
if ($this->hideStartArticleName) {
$linkText = '';
} else {
if ($this->startArticleName != '') {
$linkText = $this->startArticleName;
}
}

if ($this->startArticleIconClass != '') {
$linkText = '<i class="' . $this->startArticleIconClass . '"></i>' . $linkText;
}
}

if (intval($id) === $REX['ARTICLE_ID']) {
$html .= $articleName;
$html .= $linkText;
} else {
$html .= '<a href="' . $article->getUrl() . '">' . $articleName . '</a>';
$html .= '<a href="' . $article->getUrl() . '">' . $linkText . '</a>';
}

$html .= '</li>';
}
}
}

$html .= '</' . $listType . '>';

return $html .= '</' . $listType . '>';
return $html;
}
}

64 changes: 32 additions & 32 deletions classes/class.rex_lang_nav.inc.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<?php

class rex_lang_nav {
protected $ulId;
protected $ulClass;
protected $listId;
protected $listClass;
protected $selectedClass;
protected $showLiIds;
protected $hideLiIfOfflineArticle;
protected $showListItemIds;
protected $hideListItemIfOfflineArticle;
protected $useLangCodeAsLinkText;
protected $upperCaseLinkText;

public function __construct() {
$this->ulId = '';
$this->ulClass = '';
$this->listId = '';
$this->listClass = '';
$this->selectedClass = 'selected';
$this->showLiIds = false;
$this->hideLiIfOfflineArticle = false;
$this->showListItemIds = false;
$this->hideListItemIfOfflineArticle = false;
$this->useLangCodeAsLinkText = false;
$this->upperCaseLinkText = false;
}

public function setUlId($ulId) {
$this->ulId = $ulId;
public function setListId($listId) {
$this->listId = $listId;
}

public function setUlClass($ulClass) {
$this->ulClass = $ulClass;
public function setListClass($listClass) {
$this->listClass = $listClass;
}

public function setSelectedClass($selectedClass) {
$this->selectedClass = $selectedClass;
}

public function setShowLiIds($showLiIds) {
$this->showLiIds = $showLiIds;
public function setShowListItemIds($showListItemIds) {
$this->showListItemIds = $showListItemIds;
}

public function setHideLiIfOfflineArticle($hideLiIfOfflineArticle) {
$this->hideLiIfOfflineArticle = $hideLiIfOfflineArticle;
public function setHideListItemIfOfflineArticle($hideListItemIfOfflineArticle) {
$this->hideListItemIfOfflineArticle = $hideListItemIfOfflineArticle;
}

public function setUseLangCodeAsLinkText($useLangCodeAsLinkText) {
Expand All @@ -50,21 +50,21 @@ public function setUpperCaseLinkText($upperCaseLinkText) {
public function getNavigation() {
global $REX;

// ul id
if ($this->ulId == '') {
$ulIdAttribute = '';
// list id
if ($this->listId == '') {
$listIdAttribute = '';
} else {
$ulIdAttribute = ' id="' . $this->ulId . '"';
$listIdAttribute = ' id="' . $this->listId . '"';
}

// ul class
if ($this->ulClass == '') {
$ulClassAttribute = '';
// list class
if ($this->listClass == '') {
$listClassAttribute = '';
} else {
$ulClassAttribute = ' class="' . $this->ulClass . '"';
$listClassAttribute = ' class="' . $this->listClass . '"';
}

$out = '<ul' . $ulIdAttribute . $ulClassAttribute . '>';
$out = '<ul' . $listIdAttribute . $listClassAttribute . '>';

foreach ($REX['CLANG'] as $clangId => $clangName) {
$article = OOArticle::getArticleById($REX['ARTICLE_ID'], $clangId);
Expand All @@ -78,7 +78,7 @@ public function getNavigation() {
$articleStatus = false;
}

if (!$articleStatus && $this->hideLiIfOfflineArticle) {
if (!$articleStatus && $this->hideListItemIfOfflineArticle) {
// do nothing
} else {
$langCode = '';
Expand Down Expand Up @@ -115,21 +115,21 @@ public function getNavigation() {
}

// li attribute
if ($this->showLiIds) {
$liIdAttribute = ' id="' . $langSlug . '"';
if ($this->showListItemIds) {
$listItemIdAttribute = ' id="' . $langSlug . '"';
} else {
$liIdAttribute = '';
$listItemIdAttribute = '';
}

// class attribute
if ($REX['CUR_CLANG'] == $clangId) {
$liClassAttribute = ' class="' . $this->selectedClass . '"';
$listItemClassAttribute = ' class="' . $this->selectedClass . '"';
} else {
$liClassAttribute = '';
$listItemClassAttribute = '';
}

// li out
$out .= '<li' . $liIdAttribute . $liClassAttribute . '><a href="' . rex_getUrl($newArticleId, $clangId) . '">' . $linkText . '</a></li>';
$out .= '<li' . $listItemIdAttribute . $listItemClassAttribute . '><a href="' . rex_getUrl($newArticleId, $clangId) . '">' . $linkText . '</a></li>';
}
}

Expand Down
Loading

0 comments on commit efbadf8

Please sign in to comment.