Skip to content

Commit

Permalink
Merge pull request #47 from mageplaza/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
imsamthomas authored Apr 28, 2017
2 parents 10329e0 + f6d15f3 commit dc04830
Show file tree
Hide file tree
Showing 132 changed files with 5,981 additions and 996 deletions.
94 changes: 94 additions & 0 deletions Block/Adminhtml/Author/Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Adminhtml\Author;

class Edit extends \Magento\Backend\Block\Widget\Form\Container
{
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
public $coreRegistry;

/**
* constructor
*
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Backend\Block\Widget\Context $context
* @param array $data
*/
public function __construct(
\Magento\Framework\Registry $coreRegistry,
\Magento\Backend\Block\Widget\Context $context,
array $data = []
) {

$this->coreRegistry = $coreRegistry;
parent::__construct($context, $data);
}

/**
* Initialize Post edit block
*
* @return void
*/
protected function _construct()
{
$this->_objectId = 'user_id';
$this->_blockGroup = 'Mageplaza_Blog';
$this->_controller = 'adminhtml_author';
parent::_construct();
$this->buttonList->remove('save');
$this->buttonList->remove('reset');
$this->buttonList->add(
'save-and-continue',
[
'label' => __('Save Change'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
]
],
-100
);
$this->buttonList->remove('delete');
}
/**
* Retrieve text for header element depending on loaded Post
*
* @return string
*/
public function getHeaderText()
{
/** @var \Mageplaza\Blog\Model\Post $post */
$author = $this->coreRegistry->registry('mageplaza_blog_author');
if ($author->getId()) {
return __("Edit Author '%1'", $this->escapeHtml($author->getName()));
}
return __('New Author');
}
}
47 changes: 47 additions & 0 deletions Block/Adminhtml/Author/Edit/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Adminhtml\Author\Edit;

class Form extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getData('action'),
'method' => 'post',
'enctype' => 'multipart/form-data'
]
]
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
169 changes: 169 additions & 0 deletions Block/Adminhtml/Author/Edit/Tab/Author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Adminhtml\Author\Edit\Tab;

class Author extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
public $systemStore;

public function __construct(
\Magento\Store\Model\System\Store $systemStore,
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
array $data = []
) {
$this->systemStore = $systemStore;
parent::__construct($context, $registry, $formFactory, $data);
}

/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
$author = $this->_coreRegistry->registry('mageplaza_blog_author');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('author_');
$form->setFieldNameSuffix('author');
$fieldset = $form->addFieldset(
'base_fieldset',
[
'legend' => __('Author Info'),
'class' => 'fieldset-wide'
]
);
$fieldset->addType('image', 'Mageplaza\Blog\Block\Adminhtml\Author\Helper\Image');
if ($author->getId()){
$fieldset->addField(
'user_id',
'hidden',
['name' => 'user_id']
);
}

$fieldset->addField(
'name',
'text',
[
'name' => 'name',
'label' => __('Display Name'),
'title' => __('Display Name'),
'note' => __('This name will displayed into frontend'),
]
);

$fieldset->addField(
'short_description',
'textarea',
[
'name' => 'short_description',
'label' => __('Short Description'),
'title' => __('Short Description'),
'note' => __('Short Description'),
]
);

$fieldset->addField(
'image',
'image',
[
'name' => 'image',
'label' => __('Image'),
'title' => __('Image'),
'note' => __('Featured image'),
]
);
$fieldset->addField(
'facebook_link',
'text',
[
'name' => 'facebook_link',
'label' => __('Facebook'),
'title' => __('Facebook'),
'note' => __('Facebook Link'),
]
);
$fieldset->addField(
'twitter_link',
'text',
[
'name' => 'twitter_link',
'label' => __('Twitter'),
'title' => __('Twitter'),
'note' => __('Twitter Link'),
]
);
$authorData = $this->_session->getData('mageplaza_blog_author_data', true);
if ($authorData) {
$author->addData($authorData);
} else {
if (!$author->getId()) {
$author->addData($author->getDefaultValues());
}
}
$form->addValues($author->getData());
$this->setForm($form);
return parent::_prepareForm();
}

/**
* Prepare label for tab
*
* @return string
*/
public function getTabLabel()
{
return __('Author Info');
}

/**
* Prepare title for tab
*
* @return string
*/
public function getTabTitle()
{
return $this->getTabLabel();
}

/**
* Can show tab in tabs
*
* @return boolean
*/
public function canShowTab()
{
return true;
}

/**
* Tab is hidden
*
* @return boolean
*/
public function isHidden()
{
return false;
}
}
40 changes: 40 additions & 0 deletions Block/Adminhtml/Author/Edit/Tabs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Adminhtml\Author\Edit;

/**
* @method Tabs setTitle(\string $title)
*/
class Tabs extends \Magento\Backend\Block\Widget\Tabs
{
/**
* constructor
*
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->setId('author_tabs');
$this->setDestElementId('edit_form');
$this->setTitle(__('Author Information'));
}
}
4 changes: 2 additions & 2 deletions Block/Adminhtml/Category/Edit/Tab/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Category extends \Magento\Backend\Block\Widget\Form\Generic implements \Ma
public function __construct(
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
\Magento\Config\Model\Config\Source\Yesno $booleanOptions,
\Mageplaza\Blog\Model\Category\Source\MetaRobots $metaRobotsOptions,
\Mageplaza\Blog\Model\Config\Source\MetaRobots $metaRobotsOptions,
\Magento\Store\Model\System\Store $systemStore,
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
Expand Down Expand Up @@ -200,7 +200,7 @@ protected function _prepareForm()
'name' => 'meta_robots',
'label' => __('Meta Robots'),
'title' => __('Meta Robots'),
'values' => array_merge(['' => ''], $this->metaRobotsOptions->toOptionArray()),
'values' => $this->metaRobotsOptions->toOptionArray(),
]
);

Expand Down
Loading

0 comments on commit dc04830

Please sign in to comment.