Skip to content

Commit

Permalink
Bugfixes that I missed...
Browse files Browse the repository at this point in the history
  • Loading branch information
SvanteRichter committed Feb 6, 2016
1 parent 8d6f3c7 commit 1cd9076
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 200 deletions.
27 changes: 16 additions & 11 deletions Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function initialize()

$locales = $this->app['config']->get('general/locales');

$this->app['htmlsnippets'] = true;

if($locales){
$this->app['config']->getFields()->addField(new Field\LocaleField());
$this->app['twig.loader.filesystem']->addPath(__DIR__.'/assets/views');
Expand Down Expand Up @@ -229,17 +231,20 @@ public function translateForm($form = null)
*/
public function getSlugFromLocale($content, $locale)
{
if(is_a($content, "Bolt\Content")){
$query = "select value from bolt_translation where field = 'slug' and locale = ? and content_type = ? and content_type_id = ? ";
$stmt = $this->app['db']->prepare($query);
$stmt->bindValue(1, $locale);
$stmt->bindValue(2, $content->contenttype['slug']);
$stmt->bindValue(3, $content->id);
$stmt->execute();
$slug = $stmt->fetch();
if(!empty($slug)){
return $slug['value'];
}
if(!isset($content->contenttype['slug'])){
return false;
}
$query = "select value from bolt_translation where field = 'slug' and locale = ? and content_type = ? and content_type_id = ? ";
$stmt = $this->app['db']->prepare($query);
$stmt->bindValue(1, $locale);
$stmt->bindValue(2, $content->contenttype['slug']);
$stmt->bindValue(3, $content->id);
$stmt->execute();
$slug = $stmt->fetch();
if(isset($slug['value'])){
return $slug['value'];
}
if(isset($content->delocalizedValues['slug'])){
return $content->delocalizedValues['slug'];
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pages:
slug: pages
singular_name: Page
singular_slug: page
class: Bolt\Extension\Animal\Translate\Content\LocalizedContent
class: \Bolt\Extension\Animal\Translate\Content\LocalizedContent
fields:
locale:
type: locale
Expand Down
5 changes: 2 additions & 3 deletions assets/views/twig/_localeswitcher.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<li {% if locale.slug == app.request.get('_locale') %}class="active"{% endif %}>
<a href="{{ url(
app.request.get('_route'),
app.request.get('_route_params')|merge(
(newslug ? {_locale: locale.slug, slug: newslug} : {_locale: locale.slug})
))}}">
app.request.get('_route_params')|merge({_locale: locale.slug, slug: newslug ?: record.slug})
)}}">
{{ locale.label }}
</a>
{% endfor %}
Expand Down
184 changes: 0 additions & 184 deletions routing.yml.dist

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Bolt\Extension\Animal\Translate\Content;

use Bolt\Extension\Animal\Translate\Extension as Extension;
use Bolt\Library as Lib;

class LocalizedContent extends \Bolt\Content
Expand Down
File renamed without changes.

0 comments on commit 1cd9076

Please sign in to comment.