This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
app/code/community/MKleine/LanguageRoutes/Block/Translate/Uri.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
class MKleine_LanguageRoutes_Block_Translate_Uri extends Mage_Core_Block_Template | ||
{ | ||
public function __construct(array $args = array()) | ||
{ | ||
parent::__construct($args); | ||
$this->setTemplate('mkleine/languageroutes/translate/uri.phtml'); | ||
} | ||
|
||
/** | ||
* Returns the action to the admin form controller | ||
* | ||
* @return string | ||
*/ | ||
public function getFormAction() | ||
{ | ||
return Mage::getModel('adminhtml/url')->getUrl('adminhtml/languageroute/saveinline'); | ||
} | ||
|
||
/** | ||
* Checks, if the current user is allowed to translate the current url | ||
* | ||
* @return bool | ||
*/ | ||
public function isAllowed() | ||
{ | ||
/** @var $translate Mage_Core_Model_Translate_Inline */ | ||
$translate = Mage::getSingleton('core/translate_inline'); | ||
return $translate->isAllowed(); | ||
} | ||
|
||
/** | ||
* @param bool $translate | ||
* @return MKleine_LanguageRoutes_Model_Core_Url | ||
*/ | ||
protected function getUrlModel($translate = true) | ||
{ | ||
return Mage::getModel('core/url') | ||
->setRoutePath('*/*/*') | ||
->setNoTranslate(!$translate); | ||
} | ||
|
||
/** | ||
* Returns the translation of the current route | ||
* @return string | ||
*/ | ||
public function getValueRoute() | ||
{ | ||
$value = $this->getUrlModel()->getRouteFrontName(); | ||
return ($value != $this->getUntranslatedRoute()) ? $value : ''; | ||
} | ||
|
||
public function getUntranslatedRoute() | ||
{ | ||
return $this->getUrlModel(false)->getRouteFrontName(); | ||
} | ||
|
||
/** | ||
* Returns the translation of the current controller | ||
* @return string | ||
*/ | ||
public function getValueController() | ||
{ | ||
$value = $this->getUrlModel()->getControllerName(); | ||
return ($value != $this->getUntranslatedController()) ? $value : ''; | ||
} | ||
|
||
public function getUntranslatedController() | ||
{ | ||
return $this->getUrlModel(false)->getControllerName(); | ||
} | ||
|
||
/** | ||
* Returns the translation of the current action | ||
* @return string | ||
*/ | ||
public function getValueAction() | ||
{ | ||
$value = $this->getUrlModel()->getActionName(); | ||
return ($value != $this->getUntranslatedAction()) ? $value : ''; | ||
} | ||
|
||
public function getUntranslatedAction() | ||
{ | ||
return $this->getUrlModel(false)->getActionName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/design/frontend/base/default/template/mkleine/languageroutes/translate/uri.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php /** @var $this MKleine_LanguageRoutes_Block_Translate_Uri */ ?> | ||
|
||
<?php if ($this->isAllowed()) : ?> | ||
<div class="block block-translate" id="languageroute-translation" style="position: absolute; top: 10px; left: 10px; z-index: 1000;"> | ||
<div class="block-title"> | ||
<strong><span><?php echo $this->__('Translate Uri'); ?></span></strong> | ||
</div> | ||
<form id="languageRouteForm" action="<?php echo $this->getFormAction(); ?>" method="post"> | ||
<div class="block-content"> | ||
<p class="block-subtitle"><?php echo $this->__('Route'); ?> (<?php echo $this->getUntranslatedRoute(); ?>)</p> | ||
<input type="text" name="route" value="<?php echo $this->getValueRoute(); ?>"> | ||
<input type="hidden" name="route_untranslated" value="<?php echo $this->getUntranslatedRoute(); ?>"> | ||
|
||
<p class="block-subtitle"><?php echo $this->__('Controller'); ?> (<?php echo $this->getUntranslatedController(); ?>)</p> | ||
<input type="text" name="controller" value="<?php echo $this->getValueController(); ?>"> | ||
<input type="hidden" name="controller_untranslated" value="<?php echo $this->getUntranslatedController(); ?>"> | ||
|
||
<p class="block-subtitle"><?php echo $this->__('Action'); ?> (<?php echo $this->getUntranslatedAction(); ?>)</p> | ||
<input type="text" name="action" value="<?php echo $this->getValueAction(); ?>"> | ||
<input type="hidden" name="action_untranslated" value="<?php echo $this->getUntranslatedAction(); ?>"> | ||
|
||
<input type="hidden" name="store_id" value="<?php echo Mage::app()->getStore()->getId() ?>"> | ||
<input type="hidden" name="current_url" value="<?php echo Mage::getUrl('*/*/*') ?>"> | ||
<div class="actions"> | ||
<button type="submit" title="Abstimmen" class="button"><span><span><?php echo $this->__('Save'); ?></span></span></button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
app/code/community/MKleine/* app/code/community/MKleine/ | ||
app/etc/modules/* app/etc/modules/ | ||
app/design/adminhtml/default/default/layout/* app/design/adminhtml/default/default/layout/ | ||
app/design/frontend/base/default/template/mkleine/* app/design/frontend/base/default/template/mkleine/ | ||
app/locale/de_DE/* app/locale/de_DE/ | ||
app/locale/en_US/* app/locale/en_US/ |