Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RexDude committed Nov 14, 2015
1 parent ed0f830 commit d4f5b5f
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 214 deletions.
92 changes: 92 additions & 0 deletions CODEEXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Codebeispiele
=============

Ausgabe des 1. Navigationslevels
--------------------------------

```php
$nav = new rex_nav();
$nav->setLevelDepth(1);
echo $nav->getNavigationByLevel(0);

```

Ausgabe des 2. und 3. Navigationslevels
---------------------------------------

```php
$nav = new rex_nav();
$nav->setLevelDepth(3);
echo $nav->getNavigationByLevel(1);
```

Ausgabe der Navigation mit Startkategorie-Id = 42
-------------------------------------------------

```php
$nav = new rex_nav();
$nav->setLevelDepth(2);
echo $nav->getNavigationByCategory(42);
```


Alle Methoden und Paramater der rex_nav Klasse
----------------------------------------------

```php
$nav = new rex_nav();

$nav->setLevelDepth(2); // 2 level tief
$nav->setShowAll(true); // alle unterebenen werden angezeigt
$nav->setIgnoreOfflines(true); // offline artikel werden nicht angezeigt
$nav->setHideWebsiteStartArticle(false); // startartikel der website wird nicht ausgeblendet
$nav->setHideIds(array(42, 108)); // kategorien mit ids 42 und 108 werden ausgeblendet
$nav->setSelectedClass("current"); // li klasse für selektierte menüpunkte: "current"
$nav->setActiveClass("current active"); // li klasse für gerade aktiven menüpunkt: "current active"
$nav->setUlId("nav", 0); // erste ul id: "nav"
$nav->setUlClass("sf-menu", 0); // erste ul klasse "sf-menu"
$nav->setLiClass("list-item"); // li klasse "list-item"
$nav->setLiIdFromMetaField("cat_css_id"); // li id aus metainfo feld: "cat_css_id"
$nav->setLiClassFromMetaField("cat_css_class"); // li klasse aus metainfo feld: "cat_css_class"
$nav->setLiIdFromCategoryId(array(42 => "foo", 43 => "bar")); // li id anhand artikel id
$nav->setLiClassFromCategoryId(array(42 => "my-class")); // li klasse anhand artikel id
$nav->setCustomLink(function($cat, $depth) { // php funktion die den link zurückgibt (hier als beispiel: erste ebene ohne verlinkung)
if ($depth == 1) {
return htmlspecialchars($cat->getName());
} else {
return '<a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a>';
}
});

echo $nav->getNavigationByCategory(42);
```

Ausgabe einer einfachen Sprachnavigation
----------------------------------------

```php
$nav = new rex_lang_nav();

$nav->setUlId("lang-nav"); // ul id: "lang-nav"
$nav->setUlClass("my-lang-class"); // ul class: "my-lang-class"
$nav->setselectedClass("current"); // li klasse für selektierten menüpunkt: "current"
$nav->setshowLiIds(true); // zusätzliche, eindeutige li id's werden ausgegeben
$nav->sethideLiIfOfflineArticle(false); // bei einem offline artikel li nicht verstecken sondern auf startartikel der website verlinken
$nav->setuseLangCodeAsLinkText(true); // langcode anstelle sprachname als linktext ausgeben
$nav->setupperCaseLinkText(true); // linktext in großbuchstaben anzeigen

echo $nav->getNavigation();
```

Ausgabe einer Breadcrumb Navigation
-----------------------------------

```php
$nav = new rex_breadcrumb_nav();

$nav->setCssClass("breadcrumb"); // ul klasse: "breadcrumb"
$nav->setOlList(false); // es wird eine ul liste ausgegeben
$nav->setStartArticleName("<i class='fa fa-home'></i>"); // ausgabe mit font-awesome icon

echo $nav->getNavigation();
```
90 changes: 5 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,97 +22,17 @@ Features
* Ausgabe einer Breadcrumb Navigation möglich
* Codebeispiele in der Hilfe von SEO42

Codebeispiele
-------------

```php
<div style="background:#fff">
<?php
// ausgabe des 1. navigationslevels
$nav = new rex_nav();
$nav->setLevelDepth(1);
echo $nav->getNavigationByLevel(0);

echo '<hr>';

// ausgabe des 2. und 3. navigationslevels
$nav = new rex_nav();
$nav->setLevelDepth(3);
echo $nav->getNavigationByLevel(1);

echo '<hr>';

// ausgabe der navigation mit startkategorie id = 42
$nav = new rex_nav();
$nav->setLevelDepth(2); // 2 level tief
echo $nav->getNavigationByCategory(42);

echo '<hr>';

// ausgabe der navigation mit startkategorie id = 42
$nav = new rex_nav();

$nav->setLevelDepth(2); // 2 level tief
$nav->setShowAll(true); // alle unterebenen werden angezeigt
$nav->setIgnoreOfflines(true); // offline artikel werden nicht angezeigt
$nav->setHideWebsiteStartArticle(false); // startartikel der website wird nicht ausgeblendet
$nav->setHideIds(array(42, 108)); // kategorien mit ids 42 und 108 werden ausgeblendet
$nav->setSelectedClass("current"); // li klasse für selektierte menüpunkte: "current"
$nav->setActiveClass("current active"); // li klasse für gerade aktiven menüpunkt: "current active"
$nav->setUlId("nav", 0); // erste ul id: "nav"
$nav->setUlClass("sf-menu", 0); // erste ul klasse "sf-menu"
$nav->setLiClass("list-item"); // li klasse "list-item"
$nav->setLiIdFromMetaField("cat_css_id"); // li id aus metainfo feld: "cat_css_id"
$nav->setLiClassFromMetaField("cat_css_class"); // li klasse aus metainfo feld: "cat_css_class"
$nav->setLiIdFromCategoryId(array(42 => "foo", 43 => "bar")); // li id anhand artikel id
$nav->setLiClassFromCategoryId(array(42 => "my-class")); // li klasse anhand artikel id
$nav->setCustomLink(function($cat, $depth) { // php funktion die den link zurückgibt (hier als beispiel: erste ebene ohne verlinkung)
if ($depth == 1) {
return htmlspecialchars($cat->getName());
} else {
return '<a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a>';
}
});

echo $nav->getNavigationByCategory(42);

echo '<hr>';

// ausgabe einer einfachen sprachnavigation
$nav = new rex_lang_nav();

$nav->setUlId("lang-nav"); // ul id: "lang-nav"
$nav->setUlClass("my-lang-class"); // ul class: "my-lang-class"
$nav->setselectedClass("current"); // li klasse für selektierten menüpunkt: "current"
$nav->setshowLiIds(true); // zusätzliche, eindeutige li id's werden ausgegeben
$nav->sethideLiIfOfflineArticle(false); // bei einem offline artikel li nicht verstecken sondern auf startartikel der website verlinken
$nav->setuseLangCodeAsLinkText(true); // langcode anstelle sprachname als linktext ausgeben
$nav->setupperCaseLinkText(true); // linktext in großbuchstaben anzeigen

echo $nav->getNavigation();

echo '<hr>';

// ausgabe einer breadcrumb navigation
$nav = new rex_breadcrumb_nav();

$nav->setCssClass("breadcrumb"); // ul klasse: "breadcrumb"
$nav->setOlList(false); // es wird eine ul liste ausgegeben
$nav->setStartArticleName("<i class='fa fa-home'></i>"); // ausgabe mit font-awesome icon

echo $nav->getNavigation();

echo '<hr>';
?>
</div>
```

Hinweise
--------

* Getestet mit REDAXO 4.6
* AddOn-Ordner lautet: `navigation_factory`

Codebeispiele
-------------

siehe [CODEEXAMPLES.md](CODEEXAMPLES.md)

Changelog
---------

Expand Down
4 changes: 4 additions & 0 deletions classes/class.rex_navigation_factory_utils.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public static function getHtmlFromMDFile($mdFile, $search = array(), $replace =
$md = str_replace($search, $replace, $md);
$md = self::makeHeadlinePretty($md);

$md = str_replace('```php', "```php\r\n<?php", $md);

if (method_exists('Parsedown', 'set_breaks_enabled')) {
$out = Parsedown::instance()->set_breaks_enabled($setBreaksEnabled)->parse($md);
} elseif (method_exists('Parsedown', 'setBreaksEnabled')) {
Expand All @@ -175,6 +177,8 @@ public static function getHtmlFromMDFile($mdFile, $search = array(), $replace =
$out = Parsedown::instance()->parse($md);
}

$out = str_replace('&lt;?php<br />', "", $out);

return $out;
} else {
return '[translate:' . $file . ']';
Expand Down
5 changes: 1 addition & 4 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
if ($REX['REDAXO']) {
// add subpages
$REX['ADDON']['navigation_factory']['SUBPAGES'] = array(
array('', $I18N->msg('navigation_factory_start')),
array('settings', $I18N->msg('navigation_factory_settings')),
array('setup', $I18N->msg('navigation_factory_setup')),
array('help', $I18N->msg('navigation_factory_help'))
array('', $I18N->msg('navigation_factory_help'))
);

// add css/js files to page header
Expand Down
13 changes: 9 additions & 4 deletions files/backend.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
a.extern,
#rex-page-navigation-factory #subpage-help a[href^="http://"],
#rex-page-navigation-factory #subpage-help a[href^="https://"] {
#rex-page-navigation-factory #subpage-help a[href^="https://"],
#rex-page-navigation-factory #subpage- a[href^="http://"],
#rex-page-navigation-factory #subpage- a[href^="https://"] {
background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAA8CAYAAACq76C9AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFFSURBVHjaYtTpO/CfAQcACCAmBjwAIIAY//9HaNTtP4hiCkAAMeGSAAGAAGJCl7hcaM8IYwMEEBMuCRAACCAmXBIgABBAKA5CBwABhNcrAAGEVxIggPBKAgQQXkmAAMIrCRBAeCUBAgivJEAA4ZUECCC8kgABhFcSIIDwSgIEEF5JgADCKwkQQHglAQIIryRAAOGVBAggvJIAAYRXEiCA8EoCBBBeSYAAwisJEEB4JQECiAVbNoABgADCqxMggPDmMoAAwpvLAAIIby4DCCC8uQwggPDmMoAAwpvLAAIIr1cAAgivJEAA4ZUECCC8kgABhFcSIIDwSgIEEF5JgADCKwkQQHglAQIIryRAAOGVBAggvJIAAYRXEiCA8EoCBBBeSYAAwisJEEB4JQECCK8kQADhlQQIILySAAGEVxIggPBKAgQYAARTLlfrU5G2AAAAAElFTkSuQmCC) no-repeat right 3px;
padding-right: 10px;
}
Expand All @@ -15,15 +17,18 @@ a.extern,
margin-bottom: 7px;
}

#rex-page-navigation-factory #subpage-help a.rex-active {
#rex-page-navigation-factory #subpage-help a.rex-active,
#rex-page-navigation-factory #subpage- a.rex-active {
color: #14568A;
}

#rex-page-navigation-factory #subpage-help div.rex-addon-content {
#rex-page-navigation-factory #subpage-help div.rex-addon-content,
#rex-page-navigation-factory #subpage- div.rex-addon-content {
padding: 10px 12px;
}

#rex-page-navigation-factory #subpage-help div.rex-addon-content ul {
#rex-page-navigation-factory #subpage-help div.rex-addon-content ul,
#rex-page-navigation-factory #subpage- div.rex-addon-content ul {
margin-top: 0;
}

Expand Down
Binary file removed files/logo.png
Binary file not shown.
1 change: 1 addition & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ navigation_factory_start_example_link_external = Externer Beispiellink

navigation_factory_help_chapter_readme = Readme
navigation_factory_help_chapter_changelog = Changelog
navigation_factory_help_chapter_codeexamples = Codebeispiele
navigation_factory_help_chapter_license = Lizenz

navigation_factory_setup_step1 = Schritt 1: Mach dies
Expand Down
30 changes: 0 additions & 30 deletions lang/de_de_utf8.lang

This file was deleted.

5 changes: 5 additions & 0 deletions pages/help.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
$chapter = rex_request('chapter', 'string');
$func = rex_request('func', 'string');

if ($chapter == '') {
$chapter = '';
}

// include markdwon parser
if (!class_exists('Parsedown')) {
require($REX['INCLUDE_PATH'] . '/addons/navigation_factory/classes/class.parsedown.inc.php');
Expand All @@ -14,6 +18,7 @@
$chapterpages = array (
'' => array($I18N->msg('navigation_factory_help_chapter_readme'), 'pages/help/readme.inc.php'),
'changelog' => array($I18N->msg('navigation_factory_help_chapter_changelog'), 'pages/help/changelog.inc.php'),
'codeexamples' => array($I18N->msg('navigation_factory_help_chapter_codeexamples'), 'pages/help/codeexamples.inc.php'),
'license' => array($I18N->msg('navigation_factory_help_chapter_license'), 'pages/help/license.inc.php'),
);

Expand Down
4 changes: 4 additions & 0 deletions pages/help/codeexamples.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

echo rex_navigation_factory_utils::getHtmlFromMDFile('CODEEXAMPLES.md');

4 changes: 2 additions & 2 deletions pages/help/readme.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$search = array('(CHANGELOG.md)', '(LICENSE.md)');
$replace = array('(index.php?page=navigation_factory&subpage=help&chapter=changelog)', '(index.php?page=navigation_factory&subpage=help&chapter=license)');
$search = array('(CHANGELOG.md)', '(LICENSE.md)', '(CODEEXAMPLES.md)');
$replace = array('(index.php?page=navigation_factory&subpage=help&chapter=changelog)', '(index.php?page=navigation_factory&subpage=help&chapter=license)', '(index.php?page=navigation_factory&subpage=help&chapter=codeexamples)');

echo rex_navigation_factory_utils::getHtmlFromMDFile('README.md', $search, $replace);

2 changes: 1 addition & 1 deletion pages/index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// if no subpage specified, use this one
if ($subpage == '') {
$subpage = 'start';
$subpage = 'help';
}

// layout top
Expand Down
56 changes: 0 additions & 56 deletions pages/settings.inc.php

This file was deleted.

Loading

0 comments on commit d4f5b5f

Please sign in to comment.