Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #67 #68

Merged
merged 9 commits into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Webguys_Easytemplate_Block_Input_Renderer_Reference extends Webguys_Easytemplate_Block_Input_Renderer_Abstract
{
public function __construct(array $args = array())
public function __construct(array $args = [])
{
parent::__construct($args);
$this->setTemplate('easytemplate/input/renderer/reference.phtml');
Expand Down Expand Up @@ -47,6 +47,15 @@ public function getReferenceLabel()
public function getReferenceDefaultName()
{
$configModel = Mage::getSingleton('easytemplate/input_parser');
if (!$configModel->getTemplate($this->getReference())) {
Mage::getSingleton('core/session')->addError(
$this->__('Template with reference name "%s" not found.', $this->getReference())
);
$ex = new Webguys_Easytemplate_Exception_RedirectException();
$ex->prepareRedirect('adminhtml/cms_page');
throw $ex;

}
return $configModel->getTemplate($this->getReference())->getLabel();
}
}
}
4 changes: 2 additions & 2 deletions app/code/community/Webguys/Easytemplate/Block/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function getChildTemplates()
return $this->getRenderer()->getChild();
}

public function getChildHtml()
public function getChildHtml($name = '', $useCache = true, $sorted = false)
{
return $this->getRenderer()->toHtml();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

class Webguys_Easytemplate_Exception_RedirectException extends Mage_Core_Controller_Varien_Exception
{
public function prepareRedirect($path, $arguments = [])
{
$this->_resultCallback = self::RESULT_REDIRECT;
$this->_resultCallbackParams = [$path, $arguments];
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function prepareForSave($data)
}
}

if (empty($data['value']) && empty($data['existing'])) {
return '';
}

$fileName = !empty($data['value']) ? $data['value'] : $data['existing'];
return Mage_Core_Model_File_Uploader::getNewFileName(strtolower($fileName));
}
Expand Down Expand Up @@ -100,4 +104,4 @@ protected function uploadComplete()
{
return ($this->extractFilePostInformation('error') === UPLOAD_ERR_OK);
}
}
}
8 changes: 6 additions & 2 deletions app/code/community/Webguys/Easytemplate/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public function _afterSave()

foreach ($model->getFields() as $field) {

if (!isset($this->_field_data[$field->getCode()])) {
continue;
}

$inputValidator = $field->getInputRendererValidator();
$inputValidator->setTemplate($this);
$inputValidator->setField($field);
Expand Down Expand Up @@ -209,6 +213,6 @@ public function getFieldData($field = null)
if ($field === null) {
return $this->_field_data;
}
return $this->_field_data[$field];
return isset($this->_field_data[$field]) ? $this->_field_data[$field] : null;
}
}
}
Loading