-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from mageplaza/dev
Dev
- Loading branch information
Showing
132 changed files
with
5,981 additions
and
996 deletions.
There are no files selected for viewing
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,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'); | ||
} | ||
} |
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,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(); | ||
} | ||
} |
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,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; | ||
} | ||
} |
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,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')); | ||
} | ||
} |
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
Oops, something went wrong.