Version Notes
0.1.1 - Added support for Static Block duplication.
Download this release
Release Info
Developer | AddedBytes |
Extension | Addedbytes_Duplicatecmspage |
Version | 0.1.1 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.1.1
- app/code/local/Addedbytes/Duplicatecmspage/Block/Adminhtml/Cms/Block/Edit.php +31 -0
- app/code/local/Addedbytes/Duplicatecmspage/controllers/Adminhtml/Cms/BlockController.php +51 -0
- app/code/local/Addedbytes/Duplicatecmspage/controllers/Adminhtml/Cms/PageController.php +3 -0
- app/code/local/Addedbytes/Duplicatecmspage/etc/config.xml +4 -1
- package.xml +8 -8
app/code/local/Addedbytes/Duplicatecmspage/Block/Adminhtml/Cms/Block/Edit.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Block_Edit extends Mage_Adminhtml_Block_Cms_Block_Edit
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
|
8 |
+
// Create a button labelled Duplicate of which when clicked will call our action.
|
9 |
+
$this->_addButton(
|
10 |
+
'duplicate',
|
11 |
+
array(
|
12 |
+
'label' => Mage::helper('adminhtml')->__('Duplicate Block'),
|
13 |
+
'onclick' => 'window.location = \''.$this->_getDuplicateBlockUrl().'\'',
|
14 |
+
'class' => 'add',
|
15 |
+
),
|
16 |
+
-100
|
17 |
+
);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _getDuplicateBlockUrl()
|
21 |
+
{
|
22 |
+
return $this->getUrl(
|
23 |
+
'*/*/duplicate',
|
24 |
+
array(
|
25 |
+
'_current' => true,
|
26 |
+
'back' => 'edit',
|
27 |
+
'active_tab' => '{{tab_id}}'
|
28 |
+
)
|
29 |
+
);
|
30 |
+
}
|
31 |
+
}
|
app/code/local/Addedbytes/Duplicatecmspage/controllers/Adminhtml/Cms/BlockController.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Controllers are not autoloaded so we will have to do it manually:
|
4 |
+
require_once('Mage/Adminhtml/controllers/Cms/BlockController.php');
|
5 |
+
|
6 |
+
class Addedbytes_Duplicatecmspage_Adminhtml_Cms_BlockController extends Mage_Adminhtml_Cms_BlockController
|
7 |
+
{
|
8 |
+
public function duplicateAction()
|
9 |
+
{
|
10 |
+
// Load block being duplicated by block_id param
|
11 |
+
$params = $this->getRequest()->getParams();
|
12 |
+
$cmsBlock = Mage::getModel('cms/block')->load($params['block_id']);
|
13 |
+
if ($cmsBlock) {
|
14 |
+
|
15 |
+
// Create new block
|
16 |
+
$duplicateBlock = Mage::getModel('cms/block');
|
17 |
+
|
18 |
+
// Now we need to get the existing block data to populate new object
|
19 |
+
$cmsBlockData = $cmsBlock->getData();
|
20 |
+
|
21 |
+
// We don't want to set the block ID, otherwise we're just updating
|
22 |
+
// the original block.
|
23 |
+
unset($cmsBlockData['block_id']);
|
24 |
+
|
25 |
+
// Update title and identifier to make them unique. Trim any
|
26 |
+
// existing duplication info first.
|
27 |
+
$cmsBlockData['title'] = preg_replace('~( - Duplicate \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\))+$~i', '', $cmsBlockData['title']);
|
28 |
+
$cmsBlockData['identifier'] = preg_replace('~(-duplicate-[0-9]{14})+$~i', '', $cmsBlockData['identifier']);
|
29 |
+
$cmsBlockData['title'] = $cmsBlockData['title'] . ' - Duplicate (' . date('Y-m-d H:i:s') . ')';
|
30 |
+
$cmsBlockData['identifier'] = $cmsBlockData['identifier'] . '-duplicate-' . date('YmdHis');
|
31 |
+
|
32 |
+
// Set data and save
|
33 |
+
$duplicateBlock->setData($cmsBlockData)->save();
|
34 |
+
|
35 |
+
// Feedback
|
36 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('The block has been duplicated.'));
|
37 |
+
|
38 |
+
// Redirect to new block
|
39 |
+
$this->_redirect(
|
40 |
+
'*/*/edit',
|
41 |
+
array(
|
42 |
+
'block_id' => $duplicateBlock->getId(),
|
43 |
+
'_current' => true
|
44 |
+
)
|
45 |
+
);
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
}
|
app/code/local/Addedbytes/Duplicatecmspage/controllers/Adminhtml/Cms/PageController.php
CHANGED
@@ -32,6 +32,9 @@ class Addedbytes_Duplicatecmspage_Adminhtml_Cms_PageController extends Mage_Admi
|
|
32 |
// Set data and save
|
33 |
$duplicatePage->setData($cmsPageData)->save();
|
34 |
|
|
|
|
|
|
|
35 |
// Redirect to new page
|
36 |
$this->_redirect(
|
37 |
'*/*/edit',
|
32 |
// Set data and save
|
33 |
$duplicatePage->setData($cmsPageData)->save();
|
34 |
|
35 |
+
// Feedback
|
36 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('The page has been duplicated.'));
|
37 |
+
|
38 |
// Redirect to new page
|
39 |
$this->_redirect(
|
40 |
'*/*/edit',
|
app/code/local/Addedbytes/Duplicatecmspage/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Addedbytes_Duplicatecmspage>
|
5 |
-
<version>0.1.
|
6 |
</Addedbytes_Duplicatecmspage>
|
7 |
</modules>
|
8 |
<global>
|
@@ -11,6 +11,9 @@
|
|
11 |
<rewrite>
|
12 |
<cms_page_edit>Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Page_Edit</cms_page_edit>
|
13 |
</rewrite>
|
|
|
|
|
|
|
14 |
</adminhtml>
|
15 |
</blocks>
|
16 |
</global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Addedbytes_Duplicatecmspage>
|
5 |
+
<version>0.1.1</version>
|
6 |
</Addedbytes_Duplicatecmspage>
|
7 |
</modules>
|
8 |
<global>
|
11 |
<rewrite>
|
12 |
<cms_page_edit>Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Page_Edit</cms_page_edit>
|
13 |
</rewrite>
|
14 |
+
<rewrite>
|
15 |
+
<cms_block_edit>Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Block_Edit</cms_block_edit>
|
16 |
+
</rewrite>
|
17 |
</adminhtml>
|
18 |
</blocks>
|
19 |
</global>
|
package.xml
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Addedbytes_Duplicatecmspage</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Adds
|
10 |
-
<description> <p>Content editing can be a laborious affair at the best of times, but none more so than when you are duplicating a page between websites. This simple extension adds a button the the CMS
|
11 |

|
12 |
<h3>How Do I Use It?</h3>
|
13 |

|
@@ -18,17 +18,17 @@
|
|
18 |
<li>Upload the contents of the httpdocs folder to your website root folder</li>
|
19 |
<li>Clear Magento caches</li>
|
20 |
<li>Log out and log back in again</li>
|
21 |
-
<li>Edit any CMS page, and you will see a button with the text "Duplicate Page" at the top right.</li>
|
22 |
</ul>
|
23 |

|
24 |
<h3>How Do I Get Support?</h3>
|
25 |

|
26 |
<p>For technical or sales enquiries, please <a href="mailto:support+duplicatecmspage@addedbytes.com">email our support team</a>.</p></description>
|
27 |
-
<notes>
|
28 |
<authors><author><name>AddedBytes</name><user>AddedBytes</user><email>dave@addedbytes.com</email></author></authors>
|
29 |
-
<date>
|
30 |
-
<time>
|
31 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Addedbytes_Duplicatecmspage.xml" hash="839e740501685abc3959eccdef994349"/></dir></target><target name="magelocal"><dir name="Addedbytes"><dir name="Duplicatecmspage"><dir name="Block"><dir name="Adminhtml"><dir name="Cms"><dir name="Page"><file name="Edit.php" hash="ce4455daaac2c1e90a2167058f14340b"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="b9760d482ffe63cfc4cf7d478b4a2640"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Cms"><file name="PageController.php" hash="
|
32 |
<compatible/>
|
33 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
34 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Addedbytes_Duplicatecmspage</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Adds buttons to your CMS to enable quick duplication of CMS pages and static blocks. Ideal for copying pages or blocks between websites!</summary>
|
10 |
+
<description> <p>Content editing can be a laborious affair at the best of times, but none more so than when you are duplicating a page or static block between websites. This simple extension adds a button the the CMS editing system to allow instant duplication of any page or block.</p>
|
11 |

|
12 |
<h3>How Do I Use It?</h3>
|
13 |

|
18 |
<li>Upload the contents of the httpdocs folder to your website root folder</li>
|
19 |
<li>Clear Magento caches</li>
|
20 |
<li>Log out and log back in again</li>
|
21 |
+
<li>Edit any CMS page, and you will see a button with the text "Duplicate Page" at the top right, or edit any Static Block and you will see "Duplicate Block" at the top right.</li>
|
22 |
</ul>
|
23 |

|
24 |
<h3>How Do I Get Support?</h3>
|
25 |

|
26 |
<p>For technical or sales enquiries, please <a href="mailto:support+duplicatecmspage@addedbytes.com">email our support team</a>.</p></description>
|
27 |
+
<notes>0.1.1 - Added support for Static Block duplication.</notes>
|
28 |
<authors><author><name>AddedBytes</name><user>AddedBytes</user><email>dave@addedbytes.com</email></author></authors>
|
29 |
+
<date>2015-08-27</date>
|
30 |
+
<time>13:09:35</time>
|
31 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Addedbytes_Duplicatecmspage.xml" hash="839e740501685abc3959eccdef994349"/></dir></target><target name="magelocal"><dir name="Addedbytes"><dir name="Duplicatecmspage"><dir name="Block"><dir name="Adminhtml"><dir name="Cms"><dir name="Block"><file name="Edit.php" hash="c30efd9d3b2d977c53e2e71d48ec728b"/></dir><dir name="Page"><file name="Edit.php" hash="ce4455daaac2c1e90a2167058f14340b"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="b9760d482ffe63cfc4cf7d478b4a2640"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Cms"><file name="BlockController.php" hash="4e13727906d61f7480acffe69f7788cb"/><file name="PageController.php" hash="232e5beb4d2d5b7609d4fb9d8320ee9b"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="ea592514ddbaedb49e6b6d3c00f1424b"/></dir></dir></dir></target><target name="mage"><dir name="."><file name="Installation.pdf" hash="12e6124ebe2410aff79e56dad6ed0739"/></dir></target></contents>
|
32 |
<compatible/>
|
33 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
34 |
</package>
|