From f03d9d5c483bb69155a1c1889fa04363572ebc7d Mon Sep 17 00:00:00 2001 From: Jacob Flygenring Date: Thu, 31 Oct 2013 11:11:28 +0100 Subject: [PATCH 1/2] Update babellinks.snippet.php --- .../elements/snippets/babellinks.snippet.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/components/babel/elements/snippets/babellinks.snippet.php b/core/components/babel/elements/snippets/babellinks.snippet.php index 4fa699c..1e234b7 100644 --- a/core/components/babel/elements/snippets/babellinks.snippet.php +++ b/core/components/babel/elements/snippets/babellinks.snippet.php @@ -38,15 +38,16 @@ */ $babel = $modx->getService('babel','Babel',$modx->getOption('babel.core_path',null,$modx->getOption('core_path').'components/babel/').'model/babel/',$scriptProperties); -if (!($babel instanceof Babel)) return; - -/* be sure babel TV is loaded */ -if(!$babel->babelTv) return; +/* be sure babel and babel TV is loaded */ +if (!($babel instanceof Babel) || !$babel->babelTv) return; /* get snippet properties */ -$resourceId = $modx->resource->get('id'); -if(!empty($scriptProperties['resourceId'])) { - $resourceId = intval($modx->getOption('resourceId',$scriptProperties,$resourceId)); +if(!empty($scriptProperties['resourceId']) && is_numeric($scriptProperties['resourceId'])) { + $resourceId = intval($scriptProperties['resourceId']); +} else if(!empty($modx->resource) && is_object($modx->resource)) { + $resourceId = $modx->resource->get('id'); +} else { + return; } $tpl = $modx->getOption('tpl',$scriptProperties,'babelLink'); $activeCls = $modx->getOption('activeCls',$scriptProperties,'active'); @@ -98,4 +99,4 @@ $output .= $babel->getChunk($tpl,$placeholders); } -return $output; \ No newline at end of file +return $output; From c78b6d048c34b033197305054730fe8177ee8677 Mon Sep 17 00:00:00 2001 From: Jacob Flygenring Date: Thu, 31 Oct 2013 11:11:30 +0100 Subject: [PATCH 2/2] Update babeltranslation.snippet.php --- .../snippets/babeltranslation.snippet.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/components/babel/elements/snippets/babeltranslation.snippet.php b/core/components/babel/elements/snippets/babeltranslation.snippet.php index 152b218..a303746 100644 --- a/core/components/babel/elements/snippets/babeltranslation.snippet.php +++ b/core/components/babel/elements/snippets/babeltranslation.snippet.php @@ -34,15 +34,16 @@ */ $babel = $modx->getService('babel','Babel',$modx->getOption('babel.core_path',null,$modx->getOption('core_path').'components/babel/').'model/babel/',$scriptProperties); -if (!($babel instanceof Babel)) return; - -/* be sure babel TV is loaded */ -if(!$babel->babelTv) return; +/* be sure babel and babel TV is loaded */ +if (!($babel instanceof Babel) || !$babel->babelTv) return; /* get snippet properties */ -$resourceId = $modx->resource->get('id'); -if(!empty($scriptProperties['resourceId'])) { - $resourceId = intval($modx->getOption('resourceId',$scriptProperties,$resourceId)); +if(!empty($scriptProperties['resourceId']) && is_numeric($scriptProperties['resourceId'])) { + $resourceId = intval($scriptProperties['resourceId']); +} else if(!empty($modx->resource) && is_object($modx->resource)) { + $resourceId = $modx->resource->get('id'); +} else { + return; } $contextKey = $modx->getOption('contextKey',$scriptProperties,''); $showUnpublished = $modx->getOption('showUnpublished',$scriptProperties,0); @@ -56,4 +57,4 @@ $output = $resource->get('id'); } } -return $output; \ No newline at end of file +return $output;