Addedbytes_Adminbookmarks - Version 0.1.1

Version Notes

This release includes the base functionality. It allows you to quickly save any admin URL to a convenient bar at the top of the admin panel.

Download this release

Release Info

Developer AddedBytes
Extension Addedbytes_Adminbookmarks
Version 0.1.1
Comparing to
See all releases


Code changes from version 0.1.0 to 0.1.1

app/code/local/Addedbytes/Adminbookmarks/controllers/Adminhtml/AdminbookmarkController.php CHANGED
@@ -21,8 +21,16 @@ class Addedbytes_Adminbookmarks_Adminhtml_AdminbookmarkController extends Mage_A
21
  // Extract variables from POST
22
  $bookmarkTitle = $_POST['title'];
23
  $bookmarkUrl = $_POST['url'];
 
24
  $bookmarkController = $_POST['controller'];
25
  $bookmarkAction = $_POST['action'];
 
 
 
 
 
 
 
26
 
27
  // Validate
28
  if (trim($bookmarkTitle) == '') {
@@ -45,15 +53,26 @@ class Addedbytes_Adminbookmarks_Adminhtml_AdminbookmarkController extends Mage_A
45
 
46
  // If no errors, add the bookmark
47
  if ($result['success']) {
 
48
  $bookmark = Mage::getModel('addedbytesadminbookmarks/bookmark');
49
  $bookmark->setBookmarkName($bookmarkTitle)
50
  ->setBookmarkUrl($bookmarkUrl)
51
- ->setBookmarkRoute($bookmarkController . '/' . $bookmarkAction)
52
  ->setUserId(Mage::getSingleton('admin/session')->getUser()->getUserId())
53
  ->setCreatedAt(Varien_Date::now())
54
  ->setIsActive(1);
55
  $bookmark->save();
56
- $result['bookmark_html'] = '<span id="bookmark' . $bookmark->getId() . '"><a href="' . htmlspecialchars($bookmarkUrl) . '">' . htmlspecialchars($bookmarkTitle) . '</a> ( <a style="text-decoration: none;" href="#" onclick="deleteLink(' . $bookmark->getId() . '); return false;">&ndash;</a> ) &nbsp; | &nbsp; </span>';
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  $result['message'] = 'Your bookmark has been added.';
21
  // Extract variables from POST
22
  $bookmarkTitle = $_POST['title'];
23
  $bookmarkUrl = $_POST['url'];
24
+ $bookmarkItemId = $_POST['item_id'];
25
  $bookmarkController = $_POST['controller'];
26
  $bookmarkAction = $_POST['action'];
27
+ $bookmarkRoute = $bookmarkController . '/' . $bookmarkAction;
28
+
29
+ // Bookmark URLs for the categories are special. Build them dynamically.
30
+ if ($bookmarkRoute == 'catalog_category/edit') {
31
+ $bookmarkRoute = 'catalog_category/index';
32
+ $bookmarkUrl = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_category/index', array('id' => $bookmarkItemId, 'clear' => 1));
33
+ }
34
 
35
  // Validate
36
  if (trim($bookmarkTitle) == '') {
53
 
54
  // If no errors, add the bookmark
55
  if ($result['success']) {
56
+ // Save bookmark
57
  $bookmark = Mage::getModel('addedbytesadminbookmarks/bookmark');
58
  $bookmark->setBookmarkName($bookmarkTitle)
59
  ->setBookmarkUrl($bookmarkUrl)
60
+ ->setBookmarkRoute($bookmarkRoute)
61
  ->setUserId(Mage::getSingleton('admin/session')->getUser()->getUserId())
62
  ->setCreatedAt(Varien_Date::now())
63
  ->setIsActive(1);
64
  $bookmark->save();
65
+
66
+ // Get bookmark key
67
+ $adminSecretKey = $bookmark->getBookmarkSecretKey();
68
+
69
+ $bookmarkUrlParts = parse_url($bookmarkUrl);
70
+ $bookmarkUrlWithKey = rtrim($bookmarkUrlParts['path'], '/') . '/key/' . $adminSecretKey;
71
+ if ((isset($bookmarkUrlParts['query'])) && ($bookmarkUrlParts['query'] != '')) {
72
+ $bookmarkUrlWithKey .= '?' . $bookmarkUrlParts['query'];
73
+ }
74
+
75
+ $result['bookmark_html'] = '<span id="bookmark' . $bookmark->getId() . '"><a href="' . htmlspecialchars($bookmarkUrlWithKey) . '">' . htmlspecialchars($bookmarkTitle) . '</a> ( <a style="text-decoration: none;" href="#" onclick="deleteLink(' . $bookmark->getId() . '); return false;">&ndash;</a> ) &nbsp; | &nbsp; </span>';
76
  }
77
 
78
  $result['message'] = 'Your bookmark has been added.';
app/code/local/Addedbytes/Adminbookmarks/etc/config.xml CHANGED
@@ -76,6 +76,26 @@
76
  </adminbookmarks>
77
  </updates>
78
  </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  </adminhtml>
80
  <default>
81
  <adminbookmarks>
76
  </adminbookmarks>
77
  </updates>
78
  </layout>
79
+ <acl>
80
+ <resources>
81
+ <admin>
82
+ <children>
83
+ <system>
84
+ <children>
85
+ <config>
86
+ <children>
87
+ <adminbookmarks translate="title" module="addedbytesadminbookmarks">
88
+ <title>Added Bytes Admin Bookmarks</title>
89
+ <sort_order>0</sort_order>
90
+ </adminbookmarks>
91
+ </children>
92
+ </config>
93
+ </children>
94
+ </system>
95
+ </children>
96
+ </admin>
97
+ </resources>
98
+ </acl>
99
  </adminhtml>
100
  <default>
101
  <adminbookmarks>
app/code/local/Addedbytes/Adminbookmarks/sql/adminbookmarks_setup/mysql4-install-0.1.0.php CHANGED
@@ -13,6 +13,7 @@ CREATE TABLE `" . $bookmark_table . "` (
13
  `bookmark_name` varchar(50) NOT NULL,
14
  `bookmark_url` varchar(500) NOT NULL,
15
  `bookmark_route` varchar(200) NOT NULL,
 
16
  `user_id` int(10) unsigned NOT NULL,
17
  `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
18
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Creation Time',
13
  `bookmark_name` varchar(50) NOT NULL,
14
  `bookmark_url` varchar(500) NOT NULL,
15
  `bookmark_route` varchar(200) NOT NULL,
16
+ `bookmark_item_id` int(10) unsigned NOT NULL,
17
  `user_id` int(10) unsigned NOT NULL,
18
  `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
19
  `created_at` timestamp NULL DEFAULT NULL COMMENT 'Creation Time',
app/design/adminhtml/default/default/template/addedbytes/adminbookmarks/bookmarks.phtml ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Check extension is enabled
4
+ $isEnabled = Mage::getStoreConfig('adminbookmarks/adminbookmarks_options/adminbookmarks_active');
5
+ if ($isEnabled != 1) {
6
+ return;
7
+ }
8
+
9
+ // Get current bookmarks
10
+ $_collection = $this->getBookmarkCollection();
11
+ $_total = count($_collection);
12
+
13
+ // Current page params
14
+ $_currentUrl = Mage::helper('core/url')->getCurrentUrl();
15
+ $_helper = $this->helper('addedbytesadminbookmarks');
16
+ $_recommendedTitle = $_helper->getRecommendedTitle();
17
+
18
+ $showConfirmations = Mage::getStoreConfig('adminbookmarks/adminbookmarks_preferences/adminbookmarks_confirmations');
19
+ $showCredits = Mage::getStoreConfig('adminbookmarks/adminbookmarks_preferences/adminbookmarks_credits');
20
+
21
+ ?><div id="adminbookmarks">
22
+ <div id="adminbookmarks_wrapper">
23
+ Quick Links: &nbsp;
24
+ <?php
25
+ if ($_collection->getSize() > 0) {
26
+ foreach ($_collection as $bookmarkItem):
27
+ $bookmarkName = $bookmarkItem->getBookmarkName();
28
+
29
+ // Get bookmark key
30
+ $adminSecretKey = $bookmarkItem->getBookmarkSecretKey();
31
+
32
+ $bookmarkUrl = $bookmarkItem->getBookmarkUrl();
33
+ $bookmarkUrlParts = parse_url($bookmarkUrl);
34
+ $bookmarkUrlWithKey = rtrim($bookmarkUrlParts['path'], '/') . '/key/' . $adminSecretKey;
35
+ if ((isset($bookmarkUrlParts['query'])) && ($bookmarkUrlParts['query'] != '')) {
36
+ $bookmarkUrlWithKey .= '?' . $bookmarkUrlParts['query'];
37
+ }
38
+ ?>
39
+ <span id="bookmark<?php echo $bookmarkItem->getId(); ?>"><a href="<?php echo htmlspecialchars($bookmarkUrlWithKey); ?>"><?php echo htmlspecialchars($bookmarkName); ?></a> ( <a style="text-decoration: none;" href="#" onclick="deleteLink(<?php echo $bookmarkItem->getId(); ?>); return false;">&ndash;</a> ) &nbsp; | &nbsp; </span>
40
+ <?php endforeach ?>
41
+ <?php } else { ?>
42
+ <span id="introBookmarks">No bookmarks found for this user. Click <a href="#" onclick="addNewLink(); return false;">Add This Page</a> to save any admin page to this bar.</span>
43
+ <?php } ?>
44
+ <span id="newBookmarks"></span>
45
+ <a href="#" onclick="addNewLink(); return false;">Add This Page</a>
46
+ <?php if ($showCredits == 1) { ?>
47
+ <div id="adminbookmarks_credits">Extension by <a href="http://www.addedbytes.com">Added Bytes</a></div>
48
+ <?php } ?>
49
+ </div>
50
+ </div>
51
+
52
+ <script type="text/javascript">
53
+
54
+ var itemId = 0;
55
+
56
+ function addNewLink() {
57
+
58
+ if (typeof tree != 'undefined') {
59
+ itemId = tree.currentNodeId;
60
+ } else {
61
+ itemId = 0;
62
+ }
63
+
64
+ // Get best title to use as default link text
65
+ var recommendedTitle = '<?php echo addslashes($_recommendedTitle); ?>';
66
+ // We grabbed the recommended title from Magento directly. Now we search the
67
+ // page for better titles.
68
+ var pageSubTitles = $$('#content .content-header h3');
69
+ if (pageSubTitles.length > 0) {
70
+ recommendedTitle = pageSubTitles[0].innerHTML;
71
+ } else {
72
+ // Try a wider search (catches listing page titles)
73
+ pageSubTitles = $$('.content-header h3');
74
+ if (pageSubTitles.length > 0) {
75
+ recommendedTitle = pageSubTitles[0].innerHTML;
76
+ }
77
+ }
78
+ // Prompt user for their own link text
79
+ var itemTitle = prompt('What text would you like to use for this quick bookmark?', recommendedTitle);
80
+
81
+ // Send new bookmark to server
82
+ new Ajax.Request("<?php echo $this->getUrl('adminhtml/adminbookmark/addLink') ?>", {
83
+ method: 'Post',
84
+ parameters: {
85
+ 'title' : itemTitle,
86
+ 'item_id' : itemId,
87
+ 'controller' : '<?php echo $this->getRequest()->getControllerName(); ?>',
88
+ 'action' : '<?php echo $this->getRequest()->getActionName(); ?>',
89
+ 'url' : '<?php echo addslashes($_currentUrl); ?>'
90
+ },
91
+ onComplete: function(transport) {
92
+ handleResponse(transport.responseText);
93
+ }
94
+ });
95
+ }
96
+
97
+ function deleteLink(thisLinkId) {
98
+
99
+ <?php if ($showConfirmations == 1) { ?>
100
+ var confirmed = confirm('Are you sure you want to delete this bookmark?');
101
+ if (!confirmed) {
102
+ return false;
103
+ }
104
+ <?php } ?>
105
+
106
+ new Ajax.Request("<?php echo $this->getUrl('adminhtml/adminbookmark/delete') ?>", {
107
+ method: 'Post',
108
+ parameters: {
109
+ 'bookmark_id' : thisLinkId
110
+ },
111
+ onComplete: function(transport) {
112
+ $('bookmark' + thisLinkId).hide();
113
+ handleResponse(transport.responseText);
114
+ }
115
+ });
116
+ }
117
+
118
+ function handleResponse(reponseText) {
119
+ result = JSON.parse(reponseText);
120
+ <?php if ($showConfirmations == 1) { ?>
121
+ alert(result.message);
122
+ <?php } ?>
123
+ // Add new bookmark to bar
124
+ if (typeof result.bookmark_html != 'undefined') {
125
+ $('newBookmarks').insert(result.bookmark_html);
126
+ if ($('introBookmarks')) {
127
+ $('introBookmarks').hide();
128
+ }
129
+ }
130
+ }
131
+
132
+ </script>
133
+
134
+ <style type="text/css">
135
+ /* This is added here to ensure that if the extension is disabled through
136
+ * config, the header isn't left floating near the top of the page.
137
+ */
138
+ .content-header-floating, .header {
139
+ margin-top: 30px;
140
+ }
141
+ </style>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Addedbytes_Adminbookmarks</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>
@@ -29,8 +29,8 @@
29
  <notes>This release includes the base functionality. It allows you to quickly save any admin URL to a convenient bar at the top of the admin panel.</notes>
30
  <authors><author><name>AddedBytes</name><user>AddedBytes</user><email>dave@addedbytes.com</email></author></authors>
31
  <date>2015-09-03</date>
32
- <time>15:31:14</time>
33
- <contents><target name="magelocal"><dir name="Addedbytes"><dir name="Adminbookmarks"><dir name="Block"><file name="Block.php" hash="a53d92f631890faf67630cf3ac35ca5c"/></dir><dir name="Helper"><file name="Data.php" hash="5768b596cbc7f2a34538407eecd97c4a"/></dir><dir name="Model"><file name="Bookmark.php" hash="d1383b4120746888cdc99dd1fcdb818e"/><dir name="Resource"><dir name="Bookmark"><file name="Collection.php" hash="7ddcfad72ae5560167bec537074583cd"/></dir><file name="Bookmark.php" hash="476fd9f0a87d0e55652c8f767ba68774"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AdminbookmarkController.php" hash="88e72fd8d9bee850f6ca4cf63fcf5196"/></dir></dir><dir name="etc"><file name="config.xml" hash="b77ad39d373cba0e790a3ca056302c63"/><file name="system.xml" hash="591b421d5a201e6a2a9e691fc308c3d1"/></dir><dir name="sql"><dir name="adminbookmarks_setup"><file name="mysql4-install-0.1.0.php" hash="1cb6cd3bf50a1dd7d3c64b2b393ee86d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Addedbytes_Adminbookmarks.xml" hash="c2577ab6bd8983f8cd9dd7c3ce162fcf"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="addedbytes"><file name="adminbookmarks" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><dir name="layout"><file name="addedbytes_adminbookmarks.xml" hash="67afb68b9b7a9a6cfca31616effeadd2"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="adminbookmarks" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></target></contents>
34
  <compatible/>
35
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
36
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Addedbytes_Adminbookmarks</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>
29
  <notes>This release includes the base functionality. It allows you to quickly save any admin URL to a convenient bar at the top of the admin panel.</notes>
30
  <authors><author><name>AddedBytes</name><user>AddedBytes</user><email>dave@addedbytes.com</email></author></authors>
31
  <date>2015-09-03</date>
32
+ <time>16:10:51</time>
33
+ <contents><target name="magelocal"><dir name="Addedbytes"><dir name="Adminbookmarks"><dir name="Block"><file name="Block.php" hash="a53d92f631890faf67630cf3ac35ca5c"/></dir><dir name="Helper"><file name="Data.php" hash="5768b596cbc7f2a34538407eecd97c4a"/></dir><dir name="Model"><file name="Bookmark.php" hash="d1383b4120746888cdc99dd1fcdb818e"/><dir name="Resource"><dir name="Bookmark"><file name="Collection.php" hash="7ddcfad72ae5560167bec537074583cd"/></dir><file name="Bookmark.php" hash="476fd9f0a87d0e55652c8f767ba68774"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AdminbookmarkController.php" hash="c27b4e35f4be45f12f59a4fa59793e63"/></dir></dir><dir name="etc"><file name="config.xml" hash="2088a738e926fd5c3f0590e1e0648889"/><file name="system.xml" hash="591b421d5a201e6a2a9e691fc308c3d1"/></dir><dir name="sql"><dir name="adminbookmarks_setup"><file name="mysql4-install-0.1.0.php" hash="efb8f990b47e73c2728857abf15e44a0"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Addedbytes_Adminbookmarks.xml" hash="c2577ab6bd8983f8cd9dd7c3ce162fcf"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="addedbytes"><dir name="adminbookmarks"><file name="bookmarks.phtml" hash="c525c3fb3309a339ece78a8fb1c7ca66"/></dir></dir></dir><dir name="layout"><file name="addedbytes_adminbookmarks.xml" hash="67afb68b9b7a9a6cfca31616effeadd2"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="adminbookmarks"><dir name="css"><file name="adminbookmarks.css" hash="1e0c18eb7bbe0a4f6c9fc694ee8ea4ed"/></dir></dir></dir></dir></dir></target></contents>
34
  <compatible/>
35
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
36
  </package>
skin/adminhtml/default/default/adminbookmarks/css/adminbookmarks.css ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #adminbookmarks {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ background: #333;
7
+ line-height: 30px;
8
+ z-index: 200;
9
+ color: #fff;
10
+ }
11
+ #adminbookmarks_wrapper {
12
+ padding: 0 28px;
13
+ }
14
+ #adminbookmarks_credits {
15
+ float: right;
16
+ }