diff --git a/.gitignore b/.gitignore index 210bd35..d323f7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ _build/build.config.php +_packages config.core.php nbproject .idea diff --git a/_build/build.transport.php b/_build/build.transport.php index 90559fb..3d6aa46 100644 --- a/_build/build.transport.php +++ b/_build/build.transport.php @@ -65,11 +65,12 @@ $modx= new modX(); $modx->initialize('mgr'); $modx->setLogLevel(xPDO::LOG_LEVEL_INFO); -if (!XPDO_CLI_MODE) { echo '
'; }
-$modx->setLogTarget('ECHO');
+$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
+echo 'Packing '.PKG_NAME_LOWER.'-'.PKG_VERSION.'-'.PKG_RELEASE.''; flush();
$modx->loadClass('transport.modPackageBuilder','',false, true);
$builder = new modPackageBuilder($modx);
+$builder->directory = dirname(dirname(__FILE__)).'/_packages/';
$builder->createPackage(PKG_NAME_LOWER,PKG_VERSION,PKG_RELEASE);
$builder->registerNamespace(PKG_NAME_LOWER,false,true,'{core_path}components/'.PKG_NAME_LOWER.'/');
@@ -77,13 +78,14 @@
$category= $modx->newObject('modCategory');
$category->set('id',1);
$category->set('category',PKG_NAME);
+$modx->log(modX::LOG_LEVEL_INFO,'Packaged in category.'); flush();
/* add snippets */
$snippets = include_once $sources['data'].'transport.snippets.php';
if (is_array($snippets)) {
$category->addMany($snippets);
- $modx->log(xPDO::LOG_LEVEL_INFO,'Packaged in '.count($snippets).' Snippets.');
-} else { $modx->log(xPDO::LOG_LEVEL_ERROR,'Adding snippets failed.'); }
+ $modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($snippets).' snippets.'); flush();
+} else { $modx->log(modX::LOG_LEVEL_FATAL,'Adding snippets failed.'); }
/* create category vehicle */
$attr = array(
@@ -99,6 +101,7 @@
),
)
);
+$modx->log(modX::LOG_LEVEL_INFO, 'Packaging in vehicle...'); flush();
$vehicle = $builder->createVehicle($category,$attr);
$vehicle->resolve('file',array(
'source' => $sources['source_core'],
@@ -111,6 +114,7 @@
));*/
$builder->putVehicle($vehicle);
+/* now pack in the license file, readme and setup options */
$builder->setPackageAttributes(array(
'license' => file_get_contents($sources['docs'] . 'license.txt'),
'readme' => file_get_contents($sources['docs'] . 'readme.txt'),
@@ -118,8 +122,11 @@
));
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in package attributes.'); flush();
+/* zip up package */
+$modx->log(modX::LOG_LEVEL_INFO,'Packing...'); flush();
$builder->pack();
+/* calculate build time */
$mtime= microtime();
$mtime= explode(" ", $mtime);
$mtime= $mtime[1] + $mtime[0];
diff --git a/_build/data/transport.snippets.php b/_build/data/transport.snippets.php
index 4dc01ad..68deadc 100644
--- a/_build/data/transport.snippets.php
+++ b/_build/data/transport.snippets.php
@@ -8,10 +8,28 @@
$snippets[0]= $modx->newObject('modSnippet');
$snippets[0]->fromArray(array(
'id' => 0,
- 'name' => 'Breadcrumbs',
- 'description' => '',
- 'snippet' => getSnippetContent($sources['source_core'].'/elements/snippets/snippet.breadcrumbs.php'),
+ 'name' => PKG_NAME,
+ 'description' => 'Creates a highly configurable and styleable breadcrumb navigation trail.',
+ 'snippet' => getSnippetContent($sources['snippets'].'snippet.'.PKG_NAME_LOWER.'.php'),
'properties' => '',
),'',true,true);
+$snippetProperties = array();
+$props = include $sources['snippets'].'snippet.'.PKG_NAME_LOWER.'.properties.php';
+foreach ($props as $key => $value) {
+ if (is_string($value) || is_int($value)) { $type = 'textfield'; }
+ elseif (is_bool($value)) { $type = 'combo-boolean'; }
+ else { $type = 'textfield'; }
+ $snippetProperties[] = array(
+ 'name' => $key,
+ 'desc' => PKG_NAME_LOWER.'.prop_desc.'.$key,
+ 'type' => $type,
+ 'options' => '',
+ 'value' => ($value != null) ? $value : '',
+ 'lexicon' => PKG_NAME_LOWER.':properties'
+ );
+}
+if (count($snippetProperties) > 0)
+ $snippets[0]->setProperties($snippetProperties);
+
return $snippets;
\ No newline at end of file
diff --git a/_packages/breadcrumbs-1.1.0-pl.transport.zip b/_packages/breadcrumbs-1.1.0-pl.transport.zip
new file mode 100644
index 0000000..aa85f7c
Binary files /dev/null and b/_packages/breadcrumbs-1.1.0-pl.transport.zip differ
diff --git a/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.php b/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.php
index 5bce9c9..437d82a 100644
--- a/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.php
+++ b/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.php
@@ -31,6 +31,7 @@
* @editor Shaun McCormick
* @editor Shawn Wilkerson
* @editor Wieger Sloot, Sterc.nl
+ * @editor Jerome Perrin
* @tester Bob Ray
* @package breadcrumbs
*
@@ -41,15 +42,16 @@
* @see breadcrumbs.class.php for config settings
*
* Included classes
- * .B_crumbBox Span that surrounds all crumb output
- * .B_hideCrumb Span surrounding the "..." if there are more crumbs than will be shown
- * .B_currentCrumb Span or A tag surrounding the current crumb
- * .B_firstCrumb Span that always surrounds the first crumb, whether it is "home" or not
- * .B_lastCrumb Span surrounding last crumb, whether it is the current page or not .
- * .B_crumb Class given to each A tag surrounding the intermediate crumbs (not home, or
- * hide)
- * .B_homeCrumb Class given to the home crumb
+ * .breadcrumb ul tag that surrounds all crumb output
+ * .active a tag surrounding the current crumb
+ * .maxDelimiter li tag surrounding the "..." if there are more crumbs than will be shown
*/
-require_once $modx->getOption('breadcrumbs.core_path',null,$modx->getOption('core_path').'components/breadcrumbs/').'model/breadcrumbs/breadcrumbs.class.php';
-$bc = new BreadCrumbs($modx,$scriptProperties);
-return $bc->run();
\ No newline at end of file
+$path = $modx->getOption('breadcrumbs.core_path',null,$modx->getOption('core_path').'components/breadcrumbs/');
+
+$p = include $path.'elements/snippets/snippet.breadcrumbs.properties.php';
+$p = array_merge($p,$scriptProperties);
+
+$breadcrumbs = $modx->getService('breadcrumbs','BreadCrumbs',$path.'model/',$p);
+if (!($breadcrumbs instanceof BreadCrumbs)) return $modx->lexicon('breadcrumbs.error.loadingclass',array('path' => $path.'model/'));
+
+return $breadcrumbs->run();
\ No newline at end of file
diff --git a/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.properties.php b/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.properties.php
new file mode 100644
index 0000000..6e8aa64
--- /dev/null
+++ b/core/components/breadcrumbs/elements/snippets/snippet.breadcrumbs.properties.php
@@ -0,0 +1,160 @@
+
+ *
+ * BreadCrumbs is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * BreadCrumbs is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BreadCrumbs; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @package breadcrumbs
+ */
+/**
+ * @name BreadCrumbs
+ * @version 0.9f
+ * @created 2012-04-02
+ * @since 2009-05-11
+ * @author Jerome Perrin
+ * @package breadcrumbs
+ *
+ * This snippet was designed to show the path through the various levels of site
+ * structure back to the root. It is NOT necessarily the path the user took to
+ * arrive at a given page.
+ *
+ */
+
+return array(
+
+ /**
+ * Max number of elements to have in a path. 100 is an arbitrary
+ * high number. If you make it smaller, like say 2, but you are 5
+ * levels deep, it will appear as: Home > ... > Level 4 > Level 5 It
+ * should be noted that "Home" and the current page do not count.
+ * Each of these are configured separately.
+ *
+ * @var integer $maxCrumbs
+ */
+ 'maxCrumbs' => 100,
+ /**
+ * When your path includes an unpublished folder, setting this to 1
+ * will show all documents in path EXCEPT the unpublished. Example
+ * path (unpublished in caps): home > news > CURRENT > SPORTS >
+ * skiiing > article $pathThruUnPub = true would give you this: home
+ * > news > skiiing > article $pathThruUnPub = false would give you
+ * this: home > skiiing > article (assuming you have home crumb
+ * turned on)
+ *
+ * @var boolean $pathThruUnPub
+ */
+ 'pathThruUnPub' => true,
+ /**
+ * Setting this to 1 will hide items in the breadcrumb list that
+ * are set to be hidden in menus.
+ *
+ * @var boolean $respectHidemenu
+ */
+ 'respectHidemenu' => true,
+ /**
+ * Would you like your crumb string to start with a link to home?
+ * Some would not because a home link is usually found in the site
+ * logo or elsewhere in the navigation scheme.
+ *
+ * @var boolean $showHomeCrumb
+ */
+ 'showHomeCrumb' => true,
+ /**
+ * You can use this to turn off the breadcrumbs on the home page
+ * with 1. grad: actually '1' shows and '0' hides crumbs at
+ * homepage.
+ *
+ * @var boolean $showCrumbsAtHome
+ */
+ 'showCrumbsAtHome' => false,
+ /**
+ * Show the current page in path with 1 or not with 0.
+ *
+ * @var boolean $showCurrentCrumb
+ */
+ 'showCurrentCrumb' => true,
+ /**
+ * If you want the current page crumb to be a link (to itself) then
+ * set to 1.
+ *
+ * @var boolean $currentAsLink
+ */
+ 'currentAsLink' => true,
+ /**
+ * Define what you want between the crumbs.
+ *
+ * @var string $crumbSeparator
+ */
+ 'crumbSeparator' => '»',
+ /**
+ * Just in case you want to have a home link, but want to call it
+ * something else.
+ *
+ * @var string $homeCrumbTitle
+ */
+ 'homeCrumbTitle' => 'Home',
+ /**
+ * In case you want to have a custom description of the home link.
+ * Defaults to title of home link.
+ *
+ * @var string $homeCrumbDescription
+ */
+ 'homeCrumbDescription' => 'Home',
+ /**
+ * To change default page field to be used as a breadcrumb title,
+ * default is pagetitle.
+ *
+ * @var string $titleField
+ */
+ 'titleField' => 'pagetitle',
+ /**
+ * To change default page field to be used as a breadcrumb
+ * description, default is description (GA: falls back to pagetitle
+ * if description is empty).
+ *
+ * @var string $descField
+ */
+ 'descField' => 'description',
+ /**
+ * The class of the outer container
+ *
+ * @var string $outerClass
+ */
+ 'outerClass' => 'breadcrumb',
+ /**
+ * The class of the current crumb
+ *
+ * @var string $currentCrumbClass
+ */
+ 'currentCrumbClass' => 'active',
+ /**
+ * The string that will show if the maximum number of breadcrumbs
+ * has been shown.
+ *
+ * @var string $max_delimiter
+ */
+ 'maxDelimiter' => '...',
+ 'bcTplCrumbCurrent' => '[[+text]] ',
+ 'bcTplCrumbCurrentLink' => '[[+text]]',
+ 'bcTplCrumbHome' => '[[+text]]',
+ 'bcTplCrumbMax' => '[[+text]] ',
+ 'bcTplCrumbLink' => '[[+text]]',
+ 'bcTplCrumbOuter' => '[[+text]]
',
+ 'bcTplCrumb' => '[[+text]] ',
+ 'bcTplCrumbSeparator' => '[[+separator]]'
+);
+
+?>
\ No newline at end of file
diff --git a/core/components/breadcrumbs/lexicon/en/default.inc.php b/core/components/breadcrumbs/lexicon/en/default.inc.php
new file mode 100644
index 0000000..0ba2ae3
--- /dev/null
+++ b/core/components/breadcrumbs/lexicon/en/default.inc.php
@@ -0,0 +1,33 @@
+
+ *
+ * BreadCrumbs is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * BreadCrumbs is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BreadCrumbs; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @package breadcrumbs
+ */
+
+/**
+ * Default English Topic for BreadCrumbs.
+ *
+ * @author Jerome Perrin
+ * @package BreadCrumbs
+ * @subpackage lexicon
+ * @language en
+ */
+$_lang['breadcrumbs'] = 'BreadCrumbs';
+$_lang['breadcrumbs.error.loadingclass'] = 'Error loading class BreadCrumbs from [[+path]].';
+
diff --git a/core/components/breadcrumbs/lexicon/en/properties.inc.php b/core/components/breadcrumbs/lexicon/en/properties.inc.php
new file mode 100644
index 0000000..4304cba
--- /dev/null
+++ b/core/components/breadcrumbs/lexicon/en/properties.inc.php
@@ -0,0 +1,51 @@
+
+ *
+ * BreadCrumbs is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * BreadCrumbs is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BreadCrumbs; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @package breadcrumbs
+ */
+
+/**
+ * Properties English Topic for breadcrumbs.
+ *
+ * @author Jerome Perrin
+ * @package BreadCrumbs
+ * @subpackage lexicon
+ * @language en
+ */
+$_lang['breadcrumbs.prop_desc.maxCrumbs'] = 'Max number of elements to have in a path. If you make it smaller, like say 2, but you are 5 levels deep, it will appear as: Home > ... > Level 4 > Level 5. "Home" and the current page do not count. Each of these are configured separately.';
+$_lang['breadcrumbs.prop_desc.pathThruUnPub'] = 'When your path includes an unpublished folder, setting this to 1 will show all documents in path EXCEPT the unpublished. Refer to the documentation for more details: http://rtfm.modx.com/display/ADDON/Breadcrumbs';
+$_lang['breadcrumbs.prop_desc.respectHidemenu'] = 'Setting this to 1 will hide items in the breadcrumb list that are set to be hidden in menus.';
+$_lang['breadcrumbs.prop_desc.showHomeCrumb'] = 'Would you like your crumb string to start with a link to home? Some would not because a home link is usually found in the site logo or elsewhere in the navigation scheme.';
+$_lang['breadcrumbs.prop_desc.showCrumbsAtHome'] = 'You can use this to turn off the breadcrumbs on the home page with 1. grad: actually \'1\' shows and \'0\' hides crumbs at homepage';
+$_lang['breadcrumbs.prop_desc.showCurrentCrumb'] = 'Show the current page in path with 1 or not with 0';
+$_lang['breadcrumbs.prop_desc.currentAsLink'] = 'If you want the current page crumb to be a link (to itself) then set to 1.';
+$_lang['breadcrumbs.prop_desc.crumbSeparator'] = 'Define what you want between the crumbs.';
+$_lang['breadcrumbs.prop_desc.homeCrumbTitle'] = 'Just in case you want to have a home link, but want to call it something else.';
+$_lang['breadcrumbs.prop_desc.homeCrumbDescription'] = 'In case you want to have a custom description of the home link. Defaults to title of home link.';
+$_lang['breadcrumbs.prop_desc.titleField'] = 'To change default page field to be used as a breadcrumb title, default is pagetitle.';
+$_lang['breadcrumbs.prop_desc.descField'] = 'To change default page field to be used as a breadcrumb description, default is description (GA: falls back to pagetitle if description is empty).';
+$_lang['breadcrumbs.prop_desc.maxDelimiter'] = 'The string that will show if the maximum number of breadcrumbs has been shown.';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbCurrent'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbCurrentLink'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbHome'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbMax'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbLink'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbOuter'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumb'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbSeparator'] = '';
diff --git a/core/components/breadcrumbs/lexicon/fr/default.inc.php b/core/components/breadcrumbs/lexicon/fr/default.inc.php
new file mode 100644
index 0000000..d7bef98
--- /dev/null
+++ b/core/components/breadcrumbs/lexicon/fr/default.inc.php
@@ -0,0 +1,32 @@
+
+ *
+ * BreadCrumbs is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * BreadCrumbs is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BreadCrumbs; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @package breadcrumbs
+ */
+
+/**
+ * Default French Topic for BreadCrumbs.
+ *
+ * @author Jerome Perrin
+ * @package BreadCrumbs
+ * @subpackage lexicon
+ * @language fr
+ */
+$_lang['breadcrumbs'] = 'BreadCrumbs';
+$_lang['breadcrumbs.error.loadingclass'] = 'Erreur lors du chargement de la classe BreadCrumbs à [[+path]].';
diff --git a/core/components/breadcrumbs/lexicon/fr/properties.inc.php b/core/components/breadcrumbs/lexicon/fr/properties.inc.php
new file mode 100644
index 0000000..ff80f56
--- /dev/null
+++ b/core/components/breadcrumbs/lexicon/fr/properties.inc.php
@@ -0,0 +1,52 @@
+
+ *
+ * BreadCrumbs is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * BreadCrumbs is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BreadCrumbs; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @package breadcrumbs
+ */
+
+/**
+ * Properties French Topic for breadcrumbs.
+ *
+ * @author Jerome Perrin
+ * @package BreadCrumbs
+ * @subpackage lexicon
+ * @language fr
+ */
+$_lang['breadcrumbs.prop_desc.maxCrumbs'] = 'Nombre maximun de liens dans le fil d\'ariane. Si vous réduisez le nombre à, disons 5, et que la page vue est au 5ème niveaux de profondeur, le fil d\'ariane sera : Accueil > ... > Niveau 4 > Niveau 5. "Accueil" et la page courante ne sont pas comptés et sont configurés séparément.';
+$_lang['breadcrumbs.prop_desc.pathThruUnPub'] = 'Quand le chemin contient un dossier non-publié, mettre cette propriété à 1 montrera toutes les ressources du chemin SAUF celles qui ne sont pas publiés. Voir la documentation pour plus de détails : http://rtfm.modx.com/display/ADDON/Breadcrumbs';
+$_lang['breadcrumbs.prop_desc.respectHidemenu'] = 'Masquer les ressources qui sont masqués dans les menus ?';
+$_lang['breadcrumbs.prop_desc.showHomeCrumb'] = 'Afficher un lien vers la page d\'accueil dans le fil d\'ariane ? Ceci n\'est pas toujours nécessaire car ce lien est habituellement disponible dans la navigation ou en cliquant sur le logo du site.';
+$_lang['breadcrumbs.prop_desc.showCrumbsAtHome'] = 'Montrer le fil d\'ariane sur la page d\'accueil ?';
+$_lang['breadcrumbs.prop_desc.showCurrentCrumb'] = 'Inclure la page courante ?';
+$_lang['breadcrumbs.prop_desc.currentAsLink'] = 'Nom de la page courante cliquable ?';
+$_lang['breadcrumbs.prop_desc.crumbSeparator'] = 'Caractère de séparation';
+$_lang['breadcrumbs.prop_desc.homeCrumbTitle'] = 'Nom de la page d\'accueil dans le fil d\'ariane.';
+$_lang['breadcrumbs.prop_desc.homeCrumbDescription'] = 'Description du lien de la page d\'accueil.';
+$_lang['breadcrumbs.prop_desc.titleField'] = 'Champ de la ressource à utiliser pour le titre des liens. Valeur par défaut : pagetitle.';
+$_lang['breadcrumbs.prop_desc.descField'] = 'Champ de la ressource à utiliser pour la description des liens. Valeur par défaut : description (si vide, pagetitle sera utilisé).';
+$_lang['breadcrumbs.prop_desc.maxDelimiter'] = 'Le caractère à utiliser si le nombre maximum de liens est atteint.';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbCurrent'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbCurrentLink'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbHome'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbMax'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbLink'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbOuter'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumb'] = '';
+$_lang['breadcrumbs.prop_desc.bcTplCrumbSeparator'] = '';
+
diff --git a/core/components/breadcrumbs/model/breadcrumbs/breadcrumbs.class.php b/core/components/breadcrumbs/model/breadcrumbs.class.php
similarity index 52%
rename from core/components/breadcrumbs/model/breadcrumbs/breadcrumbs.class.php
rename to core/components/breadcrumbs/model/breadcrumbs.class.php
index 8ec1b92..62dadfb 100644
--- a/core/components/breadcrumbs/model/breadcrumbs/breadcrumbs.class.php
+++ b/core/components/breadcrumbs/model/breadcrumbs.class.php
@@ -41,116 +41,9 @@ class BreadCrumbs {
function __construct(modX &$modx,array $config = array()) {
$this->modx =& $modx;
+ $basePath = $this->modx->getOption('breadcrumbs.core_path',$config,$this->modx->getOption('core_path').'components/breadcrumbs/');
$this->config = array_merge(array(
- /**
- * Max number of elements to have in a path. 100 is an arbitrary
- * high number. If you make it smaller, like say 2, but you are 5
- * levels deep, it will appear as: Home > ... > Level 4 > Level 5 It
- * should be noted that "Home" and the current page do not count.
- * Each of these are configured separately.
- *
- * @var integer $maxCrumbs
- */
- 'maxCrumbs' => 100,
- /**
- * When your path includes an unpublished folder, setting this to 1
- * will show all documents in path EXCEPT the unpublished. Example
- * path (unpublished in caps): home > news > CURRENT > SPORTS >
- * skiiing > article $pathThruUnPub = true would give you this: home
- * > news > skiiing > article $pathThruUnPub = false would give you
- * this: home > skiiing > article (assuming you have home crumb
- * turned on)
- *
- * @var boolean $pathThruUnPub
- */
- 'pathThruUnPub' => true,
- /**
- * Setting this to 1 will hide items in the breadcrumb list that
- * are set to be hidden in menus.
- *
- * @var boolean $respectHidemenu
- */
- 'respectHidemenu' => true,
- /**
- * Would you like your crumb string to start with a link to home?
- * Some would not because a home link is usually found in the site
- * logo or elsewhere in the navigation scheme.
- *
- * @var boolean $showHomeCrumb
- */
- 'showHomeCrumb' => true,
- /**
- * You can use this to turn off the breadcrumbs on the home page
- * with 1. grad: actually '1' shows and '0' hides crumbs at
- * homepage.
- *
- * @var boolean $showCrumbsAtHome
- */
- 'showCrumbsAtHome' => false,
- /**
- * Show the current page in path with 1 or not with 0.
- *
- * @var boolean $showCurrentCrumb
- */
- 'showCurrentCrumb' => true,
- /**
- * If you want the current page crumb to be a link (to itself) then
- * set to 1.
- *
- * @var boolean $currentAsLink
- */
- 'currentAsLink' => true,
- /**
- * Define what you want between the crumbs.
- *
- * @var string $crumbSeparator
- */
- 'crumbSeparator' => '»',
- /**
- * Just in case you want to have a home link, but want to call it
- * something else.
- *
- * @var string $homeCrumbTitle
- */
- 'homeCrumbTitle' => 'Home',
- /**
- * In case you want to have a custom description of the home link.
- * Defaults to title of home link.
- *
- * @var string $homeCrumbDescription
- */
- 'homeCrumbDescription' => 'Home',
- /**
- * To change default page field to be used as a breadcrumb title,
- * default is pagetitle.
- *
- * @var string $titleField
- */
- 'titleField' => 'pagetitle',
- /**
- * To change default page field to be used as a breadcrumb
- * description, default is description (GA: falls back to pagetitle
- * if description is empty).
- *
- * @var string $descField
- */
- 'descField' => 'description',
- /**
- * The string that will show if the maximum number of breadcrumbs
- * has been shown.
- *
- * @var string $max_delimiter
- */
- 'maxDelimiter' => '...',
- 'bcTplCrumbCurrent' => '[[+text]] ',
- 'bcTplCrumbCurrentLink' => '[[+text]]',
- 'bcTplCrumbFirst' => '[[+text]] ',
- 'bcTplCrumbHome' => '[[+text]]',
- 'bcTplCrumbLast' => '[[+text]] ',
- 'bcTplCrumbMax' => '[[+text]] ',
- 'bcTplCrumbLink' => '[[+text]]',
- 'bcTplCrumbOuter' => '[[+text]]
',
- 'bcTplCrumb' => '[[+text]] ',
+ 'elements_path' => $basePath.'elements/',
),$config);
$this->_crumbs = array();
$this->_tpls = array();
@@ -179,16 +72,15 @@ public function showCurrentPage($resourceId) {
? $resource->get($this->config['descField'])
: $resource->get('pagetitle');
- $this->_crumbs[] = $this->getChunk('bcTplCrumbCurrentLink',array(
+ $crumb = $this->getChunk('bcTplCrumbCurrentLink',array(
'resource' => $this->modx->resource->get('id'),
'description' => $descriptionToUse,
'text' => $titleToShow,
));
} else {
- $this->_crumbs[] = $this->getChunk('bcTplCrumbCurrent',array(
- 'text' => $titleToShow,
- ));
+ $crumb = $titleToShow;
}
+ $this->_crumbs[] = $this->getChunk('bcTplCrumbCurrent',array('text' => $crumb, 'class' => $this->config['currentCrumbClass']));
}
}
@@ -219,11 +111,12 @@ public function getMiddleCrumbs($resourceId,&$count) {
$descriptionToUse = $parent->get($this->config['descField'])
? $parent->get($this->config['descField'])
: $parent->get('pagetitle');
- $this->_crumbs[] = $this->getChunk('bcTplCrumbLink',array(
+ $crumb = $this->getChunk('bcTplCrumbLink',array(
'resource' => $parent->get('id'),
'description' => $descriptionToUse,
'text' => $titleToShow,
));
+ $this->_crumbs[] = $this->getChunk('bcTplCrumb',array('text' => $crumb));
}
}
} /* end if */
@@ -271,36 +164,28 @@ public function run() {
/* add home link if desired */
if ($this->config['showHomeCrumb'] && ($resource->get('id') != $this->modx->config['site_start'])) {
- $this->_crumbs[] = $this->getChunk('bcTplCrumbHome',array(
+ $crumb = $this->getChunk('bcTplCrumbHome',array(
'description' => $this->config['homeCrumbDescription'],
'text' => $this->config['homeCrumbTitle'],
));
+ $this->_crumbs[] = $this->getChunk('bcTplCrumb',array('text' => $crumb));
}
$this->_crumbs = array_reverse($this->_crumbs);
- $o = '';
- $idx = 0;
- $crumbCount = count($this->_crumbs)-1;
- foreach ($this->_crumbs as $crumb) {
- if ($idx == 0) {
- $o .= $this->getChunk('bcTplCrumbFirst',array(
- 'text' => $crumb,
- ))."\n";
- } else if ($idx == $crumbCount) {
- $o .= ' '.$this->config['crumbSeparator'].' ';
- $o .= $this->getChunk('bcTplCrumbLast',array(
- 'text' => $crumb,
- ))."\n";
- } else {
- $o .= ' '.$this->config['crumbSeparator'].' ';
- $o .= $this->getChunk('bcTplCrumb',array(
- 'text' => $crumb,
- ))."\n";
+ /* add crumb separator to each crumb except the first one */
+ $crumbsCount = count($this->_crumbs);
+ if ($crumbsCount > 1 && !empty($this->config['crumbSeparator'])) {
+ $crumbSeparator = $this->getChunk('bcTplCrumbSeparator', array('separator' => $this->config['crumbSeparator']));
+ for ($i=1; $i < $crumbsCount; $i++) {
+ $this->_crumbs[$i] = preg_replace('/>/', '$0'.$crumbSeparator, $this->_crumbs[$i], $limit = 1);
}
- $idx++;
}
- return $this->getChunk('bcTplCrumbOuter',array('text' => $o));
+
+ /* assemble all crumbs */
+ $o = implode("", $this->_crumbs);
+
+ return $this->getChunk('bcTplCrumbOuter',array('text' => $o, 'class' => $this->config['outerClass']));
}
/**