Addedbytes_Duplicatecmspage - Version 0.1.0

Version Notes

This release includes the base functionality.

Download this release

Release Info

Developer AddedBytes
Extension Addedbytes_Duplicatecmspage
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Installation.pdf ADDED
Binary file
app/code/local/Addedbytes/Duplicatecmspage/Block/Adminhtml/Cms/Page/Edit.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Page_Edit extends Mage_Adminhtml_Block_Cms_Page_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 Page'),
13
+ 'onclick' => 'window.location = \''.$this->_getDuplicatePageUrl().'\'',
14
+ 'class' => 'add',
15
+ ),
16
+ -100
17
+ );
18
+ }
19
+
20
+ protected function _getDuplicatePageUrl()
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/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Addedbytes_Duplicatecmspage_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Addedbytes/Duplicatecmspage/controllers/Adminhtml/Cms/PageController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Controllers are not autoloaded so we will have to do it manually:
4
+ require_once('Mage/Adminhtml/controllers/Cms/PageController.php');
5
+
6
+ class Addedbytes_Duplicatecmspage_Adminhtml_Cms_PageController extends Mage_Adminhtml_Cms_PageController
7
+ {
8
+ public function duplicateAction()
9
+ {
10
+ // Load page being duplicated by page_id param
11
+ $params = $this->getRequest()->getParams();
12
+ $cmsPage = Mage::getModel('cms/page')->load($params['page_id']);
13
+ if ($cmsPage) {
14
+
15
+ // Create new page
16
+ $duplicatePage = Mage::getModel('cms/page');
17
+
18
+ // Now we need to get the existing page data to populate new object
19
+ $cmsPageData = $cmsPage->getData();
20
+
21
+ // We don't want to set the page ID, otherwise we're just updating
22
+ // the original page.
23
+ unset($cmsPageData['page_id']);
24
+
25
+ // Update title and identifier to make them unique. Trim any
26
+ // existing duplication info first.
27
+ $cmsPageData['title'] = preg_replace('~( - Duplicate \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\))+$~i', '', $cmsPageData['title']);
28
+ $cmsPageData['identifier'] = preg_replace('~(-duplicate-[0-9]{14})+$~i', '', $cmsPageData['identifier']);
29
+ $cmsPageData['title'] = $cmsPageData['title'] . ' - Duplicate (' . date('Y-m-d H:i:s') . ')';
30
+ $cmsPageData['identifier'] = $cmsPageData['identifier'] . '-duplicate-' . date('YmdHis');
31
+
32
+ // Set data and save
33
+ $duplicatePage->setData($cmsPageData)->save();
34
+
35
+ // Redirect to new page
36
+ $this->_redirect(
37
+ '*/*/edit',
38
+ array(
39
+ 'page_id' => $duplicatePage->getId(),
40
+ '_current' => true
41
+ )
42
+ );
43
+
44
+ }
45
+
46
+ return true;
47
+ }
48
+ }
app/code/local/Addedbytes/Duplicatecmspage/etc/config.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Addedbytes_Duplicatecmspage>
5
+ <version>0.1.0</version>
6
+ </Addedbytes_Duplicatecmspage>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <adminhtml>
11
+ <rewrite>
12
+ <cms_page_edit>Addedbytes_Duplicatecmspage_Block_Adminhtml_Cms_Page_Edit</cms_page_edit>
13
+ </rewrite>
14
+ </adminhtml>
15
+ </blocks>
16
+ </global>
17
+ <admin>
18
+ <routers>
19
+ <adminhtml>
20
+ <args>
21
+ <modules>
22
+ <Addedbytes_Duplicatecmspage before="Mage_Adminhtml">Addedbytes_Duplicatecmspage_Adminhtml</Addedbytes_Duplicatecmspage>
23
+ </modules>
24
+ </args>
25
+ </adminhtml>
26
+ </routers>
27
+ </admin>
28
+ </config>
app/etc/modules/Addedbytes_Duplicatecmspage.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * This module provides a quick way to duplicate a CMS page
5
+ *
6
+ * By Added Bytes
7
+ * http://www.addedbytes.com
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Addedbytes_Duplicatecmspage>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Addedbytes_Duplicatecmspage>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Addedbytes_Duplicatecmspage</name>
4
+ <version>0.1.0</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 a button to your CMS to enable quick duplication of CMS pages. Ideal for copying pages between websites!</summary>
10
+ <description> &lt;p&gt;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 page editing system to allow instant duplication of any page.&lt;/p&gt;&#xD;
11
+ &#xD;
12
+ &lt;h3&gt;How Do I Use It?&lt;/h3&gt;&#xD;
13
+ &#xD;
14
+ &lt;p&gt;To install the extension:&lt;/p&gt;&#xD;
15
+ &#xD;
16
+ &lt;ul&gt;&#xD;
17
+ &lt;li&gt;Download the zip, and extract the contents&lt;/li&gt;&#xD;
18
+ &lt;li&gt;Upload the contents of the httpdocs folder to your website root folder&lt;/li&gt;&#xD;
19
+ &lt;li&gt;Clear Magento caches&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Log out and log back in again&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Edit any CMS page, and you will see a button with the text "Duplicate Page" at the top right.&lt;/li&gt;&#xD;
22
+ &lt;/ul&gt;&#xD;
23
+ &#xD;
24
+ &lt;h3&gt;How Do I Get Support?&lt;/h3&gt;&#xD;
25
+ &#xD;
26
+ &lt;p&gt;For technical or sales enquiries, please &lt;a href="mailto:support+duplicatecmspage@addedbytes.com"&gt;email our support team&lt;/a&gt;.&lt;/p&gt;</description>
27
+ <notes>This release includes the base functionality.</notes>
28
+ <authors><author><name>AddedBytes</name><user>AddedBytes</user><email>dave@addedbytes.com</email></author></authors>
29
+ <date>2014-08-09</date>
30
+ <time>14:27:43</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="f44f7f04bcf0b090fb8c1a7bddc954eb"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="2db471dd319e35e909fe8df6a295d4bd"/></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>