editionguard_drm - Version 1.0.1.0

Version Notes

Changed admin so that an existing eBook on EditionGuard account can be used.

Download this release

Release Info

Developer EditionGuard
Extension editionguard_drm
Version 1.0.1.0
Comparing to
See all releases


Code changes from version 1.0.0.3 to 1.0.1.0

app/code/community/Editionguard/Editionguard/Block/Downloadable/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php CHANGED
@@ -46,7 +46,9 @@ class Editionguard_Editionguard_Block_Downloadable_Adminhtml_Catalog_Product_Edi
46
  'sample_file' => $item->getSampleFile(),
47
  'sample_url' => $item->getSampleUrl(),
48
  'sample_type' => $item->getSampleType(),
 
49
  'sort_order' => $item->getSortOrder(),
 
50
  );
51
  $file = Mage::helper('downloadable/file')->getFilePath(
52
  Mage_Downloadable_Model_Link::getBasePath(), $item->getLinkFile()
@@ -92,7 +94,7 @@ class Editionguard_Editionguard_Block_Downloadable_Adminhtml_Catalog_Product_Edi
92
  $tmpLinkItem['website_price'] = $item->getWebsitePrice();
93
  }
94
  $linkArr[] = new Varien_Object($tmpLinkItem);
95
- }
96
  return $linkArr;
97
  }
98
  }
46
  'sample_file' => $item->getSampleFile(),
47
  'sample_url' => $item->getSampleUrl(),
48
  'sample_type' => $item->getSampleType(),
49
+ 'editionguard_resource'=> $item->getEditionguardResource(),
50
  'sort_order' => $item->getSortOrder(),
51
+
52
  );
53
  $file = Mage::helper('downloadable/file')->getFilePath(
54
  Mage_Downloadable_Model_Link::getBasePath(), $item->getLinkFile()
94
  $tmpLinkItem['website_price'] = $item->getWebsitePrice();
95
  }
96
  $linkArr[] = new Varien_Object($tmpLinkItem);
97
+ }
98
  return $linkArr;
99
  }
100
  }
app/code/community/Editionguard/Editionguard/Helper/Data.php CHANGED
@@ -15,6 +15,8 @@ class Editionguard_Editionguard_Helper_Data extends Mage_Core_Helper_Data
15
  const API_SET_STATUS_URL = 'http://www.editionguard.com/api/set_status';
16
  const API_DELETE_URL = 'http://www.editionguard.com/api/delete';
17
  const API_LINK_URL = 'http://acs4.editionguard.com/fulfillment/URLLink.acsm';
 
 
18
  const LINK_EDITIONGUARD_YES = 1;
19
  const LINK_EDITIONGUARD_NO = 0;
20
  const LINK_EDITIONGUARD_CONFIG = 2;
@@ -74,6 +76,7 @@ class Editionguard_Editionguard_Helper_Data extends Mage_Core_Helper_Data
74
  $body = $response->getRawBody();
75
  }
76
 
 
77
  try {
78
  $xml = new Varien_Simplexml_Element("<root>".$body."</root>");
79
  } catch (Exception $e) {
@@ -101,6 +104,76 @@ class Editionguard_Editionguard_Helper_Data extends Mage_Core_Helper_Data
101
 
102
  return $xml;
103
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  /**
106
  * Sends a file to Editionguard for DRM handling
@@ -133,7 +206,7 @@ class Editionguard_Editionguard_Helper_Data extends Mage_Core_Helper_Data
133
  if (!isset($xml->resourceItemInfo))
134
  {
135
  // Unknown response type. Assume it's a raw error.
136
- throw new Exception("Error: \"$body\" while uploading file to EditionGuard");
137
  }
138
 
139
  return array(
15
  const API_SET_STATUS_URL = 'http://www.editionguard.com/api/set_status';
16
  const API_DELETE_URL = 'http://www.editionguard.com/api/delete';
17
  const API_LINK_URL = 'http://acs4.editionguard.com/fulfillment/URLLink.acsm';
18
+ const API_EBOOK_LISTING = 'http://www.editionguard.com/api/ebook_list'; //API for getting uploaded files
19
+
20
  const LINK_EDITIONGUARD_YES = 1;
21
  const LINK_EDITIONGUARD_NO = 0;
22
  const LINK_EDITIONGUARD_CONFIG = 2;
76
  $body = $response->getRawBody();
77
  }
78
 
79
+ //echo 'xml->';echo '<pre>'; print_r($body); die();
80
  try {
81
  $xml = new Varien_Simplexml_Element("<root>".$body."</root>");
82
  } catch (Exception $e) {
104
 
105
  return $xml;
106
  }
107
+
108
+ /**
109
+ * Given a URL and parameters, makes a request to the editionguard API using the
110
+ * currently configured credentials.
111
+ *
112
+ * @param string $request_url
113
+ * @param array $params
114
+ *
115
+ * @return Varien_Simplexml_Element jSon object containing the result
116
+ * @throws Exception on failure
117
+ */
118
+ protected function _sendEditionguardApiRequestJson($request_url, array $params, $file = null)
119
+ {
120
+ $secret = Mage::getStoreConfig(Editionguard_Editionguard_Helper_Data::XML_PATH_CONFIG_EDITIONGUARD_SECRET);
121
+ $email = Mage::getStoreConfig(Editionguard_Editionguard_Helper_Data::XML_PATH_CONFIG_EDITIONGUARD_EMAIL);
122
+ $nonce = rand(1000000, 999999999);
123
+ $hash = hash_hmac("sha1", $nonce.$email, base64_decode($secret));
124
+
125
+ $httpClient = new Varien_Http_Client();
126
+ $params['email'] = $email;
127
+ $params['nonce'] = $nonce;
128
+ $params['hash'] = $hash;
129
+
130
+ $httpClient->setUri($request_url)
131
+ ->setParameterPost($params)
132
+ ->setConfig(array('timeout' => 3600));
133
+
134
+ if ($file && is_array($file))
135
+ {
136
+ $httpClient->setFileUpload(
137
+ $file['filename'],
138
+ $file['formname'],
139
+ $file['data'],
140
+ $file['type']
141
+ );
142
+ }
143
+
144
+ $response = $httpClient->request('POST');
145
+
146
+ // TODO: Handle non 200 responses
147
+ // - Follow 3**
148
+ // - Give errors on 4** and 5**
149
+
150
+ try {
151
+ $body = $response->getBody();
152
+ } catch (Zend_Http_Exception $e) {
153
+ // HACK: EditionGuard currently sends the response raw, even though
154
+ // the header indicates that it is chunked. Just grab the raw body
155
+ // and use it.
156
+ $body = $response->getRawBody();
157
+ }
158
+
159
+
160
+ $bodyDecoded = json_decode($body);
161
+ return $bodyDecoded;
162
+ }
163
+
164
+
165
+ /**
166
+ * Collects an Editionguard resources already uploaded files
167
+ */
168
+ public function listResource($resourceid)
169
+ {
170
+ $decoded_reponse = $this->_sendEditionguardApiRequestJson(Editionguard_Editionguard_Helper_Data::API_EBOOK_LISTING, array(
171
+ 'resource_id'=>$resourceid,
172
+ ));
173
+
174
+ return $decoded_reponse;
175
+ }
176
+
177
 
178
  /**
179
  * Sends a file to Editionguard for DRM handling
206
  if (!isset($xml->resourceItemInfo))
207
  {
208
  // Unknown response type. Assume it's a raw error.
209
+ throw new Exception("Error: \"$body\" while uploading file to EditionGuard test");
210
  }
211
 
212
  return array(
app/code/community/Editionguard/Editionguard/Model/Downloadable/Link.php CHANGED
@@ -22,16 +22,17 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
22
  * @return Mage_Downloadable_Model_Link
23
  */
24
  protected function _beforeSave()
25
- {
26
  $new = !$this->getLinkId();
27
  $add_editionguard = $this->_addingEditionguard;
28
  $remove_editionguard = $this->_removingEditionguard;
29
  $new_file = $this->_changingLinkFile;
30
-
31
  $this->_ensureOrigData();
32
 
33
- if ($new || $add_editionguard || $new_file)
34
  {
 
35
  // The file is new to editionguard.
36
  if (Mage::helper('editionguard')->getUseEditionguard($this))
37
  {
@@ -86,7 +87,7 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
86
  }
87
 
88
  if ($this->getEditionguardResource() && $remove_editionguard)
89
- {
90
  // had a resource, now removing editionguard handling. Disable editionguard on the file.
91
  try {
92
  $editionguard = Mage::helper('editionguard')->setResourceActive(
@@ -131,7 +132,7 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
131
 
132
  protected function _beforeLoad($id, $field = null)
133
  {
134
- $this->_loading = true;
135
  return parent::_beforeLoad($id, $field);
136
  }
137
 
@@ -142,10 +143,10 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
142
  }
143
 
144
  public function setData($key, $value=null)
145
- {
146
- if (!$this->_loading && is_array($key))
147
- {
148
- if (isset($key['use_editionguard']))
149
  {
150
  $use_editionguard = $key['use_editionguard'];
151
  unset($key['use_editionguard']);
@@ -159,19 +160,23 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
159
  if (isset($use_editionguard))
160
  {
161
  $this->setUseEditionguard($use_editionguard);
 
 
 
162
  }
163
  if (isset($link_file))
164
  {
165
  $this->setLinkFile($link_file);
166
- }
167
  return $this;
168
  }
169
 
170
  return parent::setData($key, $value);
 
171
  }
172
-
173
- public function setUseEditionguard($v)
174
- {
175
  $this->_ensureOrigData();
176
 
177
  if ($v && $v != $this->getOrigData('use_editionguard'))
@@ -186,9 +191,28 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
186
  }
187
  return $this->setData('use_editionguard', $v);
188
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  public function setLinkFile($v)
191
- {
192
  $this->_ensureOrigData();
193
 
194
  if ($v && $v != $this->getOrigData('link_file'))
@@ -202,7 +226,7 @@ class Editionguard_Editionguard_Model_Downloadable_Link extends Mage_Downloadabl
202
  }
203
 
204
  protected function _ensureOrigData()
205
- {
206
  // Magento doesn't always load the object. We need to delay load it to get the old values.
207
  if ($this->getLinkId() && !$this->getOrigData())
208
  {
22
  * @return Mage_Downloadable_Model_Link
23
  */
24
  protected function _beforeSave()
25
+ {
26
  $new = !$this->getLinkId();
27
  $add_editionguard = $this->_addingEditionguard;
28
  $remove_editionguard = $this->_removingEditionguard;
29
  $new_file = $this->_changingLinkFile;
30
+ $type = $this->getLinkType();
31
  $this->_ensureOrigData();
32
 
33
+ if (($new || $add_editionguard || $new_file) && $type != 'ebook')
34
  {
35
+
36
  // The file is new to editionguard.
37
  if (Mage::helper('editionguard')->getUseEditionguard($this))
38
  {
87
  }
88
 
89
  if ($this->getEditionguardResource() && $remove_editionguard)
90
+ {
91
  // had a resource, now removing editionguard handling. Disable editionguard on the file.
92
  try {
93
  $editionguard = Mage::helper('editionguard')->setResourceActive(
132
 
133
  protected function _beforeLoad($id, $field = null)
134
  {
135
+ $this->_loading = true;
136
  return parent::_beforeLoad($id, $field);
137
  }
138
 
143
  }
144
 
145
  public function setData($key, $value=null)
146
+ {
147
+ if (!$this->_loading && is_array($key))
148
+ {
149
+ if (isset($key['use_editionguard']) && $key['type']!='ebook')
150
  {
151
  $use_editionguard = $key['use_editionguard'];
152
  unset($key['use_editionguard']);
160
  if (isset($use_editionguard))
161
  {
162
  $this->setUseEditionguard($use_editionguard);
163
+ //
164
+ // $this->listResource();
165
+
166
  }
167
  if (isset($link_file))
168
  {
169
  $this->setLinkFile($link_file);
170
+ }
171
  return $this;
172
  }
173
 
174
  return parent::setData($key, $value);
175
+
176
  }
177
+ //
178
+ public function setListingEditionguard($v)
179
+ {
180
  $this->_ensureOrigData();
181
 
182
  if ($v && $v != $this->getOrigData('use_editionguard'))
191
  }
192
  return $this->setData('use_editionguard', $v);
193
  }
194
+
195
+ public function setUseEditionguard($v)
196
+ {
197
+ $this->_ensureOrigData();
198
+
199
+ if ($v && $v != $this->getOrigData('use_editionguard'))
200
+ {
201
+ $this->_addingEditionguard = true;
202
+ $this->_removingEditionguard = false;
203
+ }
204
+ else if (!$v && $v != $this->getOrigData('use_editionguard'))
205
+ {
206
+ $this->_addingEditionguard = false;
207
+ $this->_removingEditionguard = true;
208
+ }
209
+
210
+ return $this->setData('use_editionguard', $v);
211
+
212
+ }
213
 
214
  public function setLinkFile($v)
215
+ {
216
  $this->_ensureOrigData();
217
 
218
  if ($v && $v != $this->getOrigData('link_file'))
226
  }
227
 
228
  protected function _ensureOrigData()
229
+ {
230
  // Magento doesn't always load the object. We need to delay load it to get the old values.
231
  if ($this->getLinkId() && !$this->getOrigData())
232
  {
app/code/community/Editionguard/Editionguard/controllers/DownloadController.php CHANGED
@@ -17,6 +17,7 @@ class Editionguard_Editionguard_DownloadController extends Mage_Downloadable_Dow
17
  */
18
  public function linkAction()
19
  {
 
20
  $id = $this->getRequest()->getParam('id', 0);
21
  $linkPurchasedItem = Mage::getModel('downloadable/link_purchased_item')->load($id, 'link_hash');
22
  if (! $linkPurchasedItem->getId() ) {
@@ -74,7 +75,7 @@ class Editionguard_Editionguard_DownloadController extends Mage_Downloadable_Dow
74
  $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
75
  }
76
  try {
77
-
78
  $editionguard_url = Mage::helper('editionguard')->getDownloadUrl($linkPurchasedItem->getOrderItemId(), $linkPurchasedItem->getEditionguardResource());
79
 
80
  $linkPurchasedItem->setNumberOfDownloadsUsed($linkPurchasedItem->getNumberOfDownloadsUsed() + 1);
17
  */
18
  public function linkAction()
19
  {
20
+
21
  $id = $this->getRequest()->getParam('id', 0);
22
  $linkPurchasedItem = Mage::getModel('downloadable/link_purchased_item')->load($id, 'link_hash');
23
  if (! $linkPurchasedItem->getId() ) {
75
  $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
76
  }
77
  try {
78
+
79
  $editionguard_url = Mage::helper('editionguard')->getDownloadUrl($linkPurchasedItem->getOrderItemId(), $linkPurchasedItem->getEditionguardResource());
80
 
81
  $linkPurchasedItem->setNumberOfDownloadsUsed($linkPurchasedItem->getNumberOfDownloadsUsed() + 1);
app/code/community/Editionguard/Editionguard/etc/config.xml CHANGED
@@ -14,7 +14,7 @@
14
  <config>
15
  <modules>
16
  <Editionguard_Editionguard>
17
- <version>1.0.0.3</version>
18
  </Editionguard_Editionguard>
19
  </modules>
20
  <frontend>
14
  <config>
15
  <modules>
16
  <Editionguard_Editionguard>
17
+ <version>1.1.0.0</version>
18
  </Editionguard_Editionguard>
19
  </modules>
20
  <frontend>
app/design/adminhtml/default/default/template/editionguard/downloadable/product/edit/downloadable/links.phtml CHANGED
@@ -1,421 +1 @@
1
- <?php
2
- /**
3
- * EditionGuard
4
- *
5
- * This source file is proprietary property of EditionGuard. Any reuse or
6
- * distribution of any part of this file without prior consent is prohibited.
7
- *
8
- * @category EditionGuard
9
- * @package Editionguard_Editionguard
10
- * @copyright Copyright (c) 2012 EditionGuard. All rights Reserved.
11
- */
12
- ?>
13
- <?php
14
-
15
- /**
16
- * @see Editionguard_Editionguard_Block_Downloadable_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
17
- */
18
- ?>
19
- <?php $_product = $this->getProduct()?>
20
- <div class="fieldset">
21
- <table cellspacing="0" class="form-list">
22
- <tbody>
23
- <tr class="headings">
24
- <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Title')?></label>
25
- </td>
26
- <td class="value">
27
- <input type="text" class="input-text" id="downloadable_links_title" name="product[links_title]" value="<?php echo $_product->getId()?$_product->getLinksTitle():$this->getLinksTitle() ?>" <?php echo ($_product->getStoreId() && $this->getUsedDefault())?'disabled="disabled"':'' ?> />
28
- </td>
29
- <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[STORE VIEW]<?php endif; ?></td>
30
- <td class="value use-default">
31
- <?php if($_product->getStoreId()): ?>
32
- <input id="link_title_default" type="checkbox" name="use_default[]" value="links_title" onclick="toggleValueElements(this, this.parentNode.parentNode)" <?php echo $this->getUsedDefault()?'checked="checked"':'' ?> />
33
- <label class="normal" for="link_title_default"><?php echo Mage::helper('downloadable')->__('Use Default Value'); ?></label>
34
- <?php endif; ?>
35
- </td>
36
- </tr>
37
- </tbody>
38
- </table>
39
- <br />
40
- <table cellspacing="0" class="form-list">
41
- <tbody>
42
- <tr class="headings">
43
- <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Links can be purchased separately')?></label>
44
- </td>
45
- <td class="value">
46
- <?php echo $this->getPurchasedSeparatelySelect()?>
47
- </td>
48
- <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[GLOBAL]<?php endif; ?></td>
49
- <td><small>&nbsp;</small></td>
50
- </tr>
51
- </tbody>
52
- </table>
53
- <br />
54
- <div class="grid">
55
- <div class="hor-scroll">
56
- <table cellspacing="0" class="data border">
57
- <col width="33%" />
58
- <col />
59
- <col />
60
- <col />
61
- <col />
62
- <col width="1" />
63
- <col width="1" />
64
- <col width="1" />
65
- <col width="1" />
66
- <thead>
67
- <tr class="headings">
68
- <th><?php echo Mage::helper('downloadable')->__('Title')?> <span class="required">*</span></th>
69
- <?php if ($this->getCanReadPrice() !== false) : ?>
70
- <th><?php echo Mage::helper('downloadable')->__('Price')?></th>
71
- <?php endif; ?>
72
- <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Max. Downloads')?></span></th>
73
- <th><?php echo Mage::helper('downloadable')->__('Shareable')?></th>
74
- <th><?php echo Mage::helper('downloadable')->__('EditionGuard')?></th>
75
- <th><?php echo Mage::helper('downloadable')->__('Sample')?></th>
76
- <th><?php echo Mage::helper('downloadable')->__('File')?></th>
77
- <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Sort Order')?></span></th>
78
- <th>&nbsp;</th>
79
- </tr>
80
- </thead>
81
- <tfoot>
82
- <tr>
83
- <td colspan="9" class="a-right"><?php echo $this->getAddButtonHtml()?>&nbsp;<?php echo $this->getUploadButtonHtml() ?></td>
84
- </tr>
85
- </tfoot>
86
- <tbody id="link_items_body">
87
- </tbody>
88
- </table>
89
- <div><small><?php echo Mage::helper('downloadable')->__('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.')?></small></div>
90
- </div>
91
- </div>
92
- </div>
93
-
94
- <script type="text/javascript">
95
- //<![CDATA[
96
- var linkTemplate = '<tr>'+
97
- '<td>'+
98
- '<input type="hidden" class="__delete__" name="downloadable[link][{{id}}][is_delete]" value="" />'+
99
- '<input type="hidden" name="downloadable[link][{{id}}][link_id]" value="{{link_id}}" />'+
100
- '<input type="text" class="required-entry input-text" name="downloadable[link][{{id}}][title]" value="{{title}}" />'+
101
- '<?php echo $_product->getStoreId()?'<input type="checkbox" id="downloadable_link_{{id}}_title" name="downloadable[link][{{id}}][use_default_title]" value="1" /><label class="normal" for="downloadable_link_{{id}}_title">Use Default Value</label>':'' ?>'+
102
- '</td>'+
103
- <?php if ($this->getCanReadPrice() !== false) : ?>
104
- '<td class="input-price">'+
105
- '<input type="text" id="downloadable_link_{{id}}_price_value" class="input-text validate-number link-prices<?php if ($this->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][{{id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
106
- '<label>[<?php echo Mage::app()->getStore($_product->getStoreId())->getBaseCurrencyCode() ?>]</label>' +
107
- <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
108
- '<br /><input type="checkbox" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> <label for="downloadable_link_{{id}}_price">Use Default Value</label>' +
109
- <?php endif; ?>
110
- '</td>' +
111
- <?php else : ?>
112
- '<input type="hidden" id="downloadable_link_{{id}}_price_value" class="link-prices" name="downloadable[link][{{id}}][price]" value="0" />' +
113
- <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
114
- '<input type="hidden" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1" />' +
115
- <?php endif; ?>
116
- <?php endif; ?>
117
- '<td><input type="text" id="downloadable_link_{{id}}_downloads" name="downloadable[link][{{id}}][number_of_downloads]" class="input-text downloads" value="{{number_of_downloads}}" />'+
118
- '<p><input type="checkbox" class="checkbox" id="downloadable_link_{{id}}_is_unlimited" name="downloadable[link][{{id}}][is_unlimited]" value="1" {{is_unlimited}} /> <label for="downloadable_link_{{id}}_is_unlimited">Unlimited</label></p></td>'+
119
- '<td class="a-center">'+
120
- '<select id="downloadable_link _{{id}}_shareable" name="downloadable[link][{{id}}][is_shareable]">'+
121
- '<option value="1">Yes</option>'+
122
- '<option value="0">No</option>'+
123
- '<option value="2" selected="selected">Use config</option>'+
124
- '</select>'+
125
- '</td>'+
126
- '<td class="a-center">'+
127
- '<input type="hidden" id="downloadable_link _{{id}}_old_use_editionguard" class="old_use_editionguard" name="downloadable[link][{{id}}][old_use_editionguard]" value="{{use_editionguard}}" />'+
128
- '<select id="downloadable_link _{{id}}_editionguard" class="use_editionguard" name="downloadable[link][{{id}}][use_editionguard]">'+
129
- '<option value="1">Yes</option>'+
130
- '<option value="0">No</option>'+
131
- '<option value="2" selected="selected">Use config</option>'+
132
- '</select>'+
133
- '</td>'+
134
- '<td>'+
135
- '<div class="files">'+
136
- '<div class="row">'+
137
- '<label for="downloadable_link_{{id}}_sample_file_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_file_type" name="downloadable[link][{{id}}][sample][type]" value="file"{{sample_file_checked}} /> File:</label>'+
138
- '<input type="hidden" id="downloadable_link_{{id}}_sample_file_save" name="downloadable[link][{{id}}][sample][file]" value="{{sample_file_save}}" />'+
139
- '<div id="downloadable_link_{{id}}_sample_file" class="uploader">'+
140
- '<div id="downloadable_link_{{id}}_sample_file-old" class="file-row-info"></div>'+
141
- '<div id="downloadable_link_{{id}}_sample_file-new" class="file-row-info"></div>'+
142
- '<div class="buttons">'+
143
- '<div id="downloadable_link_{{id}}_sample_file-install-flash" style="display:none">'+
144
- '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>'+
145
- '</div>'+
146
- '</div>'+
147
- '<div class="clear"></div>'+
148
- '</div>'+
149
- '</div>'+
150
- '<div class="row">'+
151
- '<label for="downloadable_link_{{id}}_sample_url_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_url_type" name="downloadable[link][{{id}}][sample][type]" value="url"{{sample_url_checked}} /> URL:</label><input type="text" class="input-text" name="downloadable[link][{{id}}][sample][url]" value="{{sample_url}}" />'+
152
- '</div>'+
153
- '<div>'+
154
- '<span id="downloadable_link_{{id}}_sample_container"></span>'+
155
- '</div>'+
156
- '</div>'+
157
- '</td>'+
158
- '<td>'+
159
- '<div class="files">'+
160
- '<div class="row">'+
161
- '<label for="downloadable_link_{{id}}_file_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_{{id}}_file_type" name="downloadable[link][{{id}}][type]" value="file"{{file_checked}} /> File:</label>'+
162
- '<input type="hidden" class="validate-downloadable-file" id="downloadable_link_{{id}}_file_save" name="downloadable[link][{{id}}][file]" value="{{file_save}}" />'+
163
- '<div id="downloadable_link_{{id}}_file" class="uploader">'+
164
- '<div id="downloadable_link_{{id}}_file-old" class="file-row-info"></div>'+
165
- '<div id="downloadable_link_{{id}}_file-new" class="file-row-info new-file"></div>'+
166
- '<div class="buttons">'+
167
- '<div id="downloadable_link_{{id}}_file-install-flash" style="display:none">'+
168
- '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>'+
169
- '</div>'+
170
- '</div>'+
171
- '<div class="clear"></div>'+
172
- '</div>'+
173
- '</div>'+
174
- '<div class="row">'+
175
- '<label for="downloadable_link_{{id}}_url_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_{{id}}_url_type" name="downloadable[link][{{id}}][type]" value="url"{{url_checked}} /> URL:</label><input type="text" class="validate-downloadable-url input-text" name="downloadable[link][{{id}}][link_url]" value="{{link_url}}" />'+
176
- '</div>'+
177
- '<div>'+
178
- '<span id="downloadable_link_{{id}}_link_container"></span>'+
179
- '</div>'+
180
- '</div>'+
181
- '</td>'+
182
- '<td class="a-center"><input type="text" name="downloadable[link][{{id}}][sort_order]" value="{{sort_order}}" class="input-text sort" /></td>'+
183
- '<td>'+
184
- '<button id="downloadable_link_{{id}}_delete_button" type="button" class="scalable delete icon-btn delete-link-item"><span><?php echo Mage::helper('downloadable')->__('Delete'); ?></span></button>'+
185
- '</td>'+
186
- '</tr>';
187
-
188
- var linkItems = {
189
- tbody : $('link_items_body'),
190
- templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
191
- templateText : linkTemplate,
192
- itemCount : 0,
193
- add : function(data) {
194
- alertAlreadyDisplayed = false;
195
- this.template = new Template(this.templateText, this.templateSyntax);
196
-
197
- if(!data.link_id){
198
- data = {};
199
- data.link_id = 0;
200
- data.link_type = 'file';
201
- data.sample_type = 'none';
202
- data.number_of_downloads = '<?php echo $this->getConfigMaxDownloads() ?>';
203
- }
204
-
205
- data.id = this.itemCount;
206
-
207
- if (data.link_type == 'url') {
208
- data.url_checked = ' checked="checked"';
209
- } else if (data.link_type == 'file') {
210
- data.file_checked = ' checked="checked"';
211
- }
212
- if (data.sample_type == 'url') {
213
- data.sample_url_checked = ' checked="checked"';
214
- } else if (data.sample_type == 'file') {
215
- data.sample_file_checked = ' checked="checked"';
216
- }
217
-
218
- Element.insert(this.tbody, {'bottom':this.template.evaluate(data)});
219
-
220
- scopeTitle = $('downloadable_link_'+data.id+'_title');
221
- if (scopeTitle) {
222
- Event.observe(scopeTitle, 'click', function(event){
223
- scopeElm = $(Event.findElement(event, 'input'));
224
- titleField = scopeElm.up(0).down('input[type="text"]');
225
- if (scopeElm.checked == true) {
226
- titleField.disabled = true;
227
- } else {
228
- titleField.disabled = false;
229
- }
230
- });
231
- }
232
- if (!data.store_title && scopeTitle) {
233
- scopeTitle.up(0).down('input[type="text"]').disabled = true;
234
- scopeTitle.checked = true;
235
- }
236
-
237
- scopePrice = $('downloadable_link_'+data.id+'_price');
238
- if (scopePrice) {
239
- Event.observe(scopePrice, 'click', function(event){
240
- scopeElm = $(Event.findElement(event, 'input'));
241
- priceField = scopeElm.up(0).down('input[type="text"]');
242
- if (scopeElm.checked == true) {
243
- priceField.disabled = true;
244
- } else {
245
- priceField.disabled = false;
246
- }
247
- });
248
- }
249
- if (!data.website_price && scopePrice) {
250
- scopePrice.up(0).down('input[type="text"]').disabled = true;
251
- scopePrice.checked = true;
252
- }
253
- downloadsElm = $('downloadable_link_'+data.id+'_downloads');
254
- isUnlimitedElm = $('downloadable_link_'+data.id+'_is_unlimited');
255
- if (data.is_unlimited) {
256
- downloadsElm.disabled = true;
257
- }
258
- Event.observe(isUnlimitedElm, 'click', function(event){
259
- elm = Event.element(event);
260
- elm.up('td').down('input[type="text"].downloads').disabled = elm.checked;
261
- });
262
-
263
- if (data.is_shareable) {
264
- options = $('downloadable_link _'+data.id+'_shareable').options;
265
- for (var i=0; i < options.length; i++) {
266
- if (options[i].value == data.is_shareable) {
267
- options[i].selected = true;
268
- }
269
- }
270
- }
271
-
272
- if (data.use_editionguard) {
273
- options = $('downloadable_link _'+data.id+'_editionguard').options;
274
- for (var i=0; i < options.length; i++) {
275
- if (options[i].value == data.use_editionguard) {
276
- options[i].selected = true;
277
- }
278
- }
279
- }
280
-
281
- sampleUrl = $('downloadable_link_'+data.id+'_sample_url_type');
282
- linkUrl = $('downloadable_link_'+data.id+'_url_type');
283
-
284
- if (!data.file_save) {
285
- data.file_save = [];
286
- }
287
- if (!data.sample_file_save) {
288
- data.sample_file_save = [];
289
- }
290
-
291
- // link sample file
292
- new Downloadable.FileUploader(
293
- 'linkssample',
294
- 'linkssample_'+data.id,
295
- sampleUrl.up('td'),
296
- 'downloadable[link]['+data.id+'][sample]',
297
- data.sample_file_save,
298
- 'downloadable_link_'+data.id+'_sample_file',
299
- <?php echo $this->getConfigJson('link_samples') ?>
300
- );
301
- // link file
302
- new Downloadable.FileUploader(
303
- 'links',
304
- 'links_'+data.id,
305
- linkUrl.up('td'),
306
- 'downloadable[link]['+data.id+']',
307
- data.file_save,
308
- 'downloadable_link_'+data.id+'_file',
309
- <?php echo $this->getConfigJson() ?>
310
- );
311
-
312
- linkFile = $('downloadable_link_'+data.id+'_file_type');
313
- linkFile.advaiceContainer = 'downloadable_link_'+data.id+'_link_container';
314
- linkUrl.advaiceContainer = 'downloadable_link_'+data.id+'_link_container';
315
- $('downloadable_link_'+data.id+'_file_save').advaiceContainer = 'downloadable_link_'+data.id+'_link_container';
316
-
317
- sampleFile = $('downloadable_link_'+data.id+'_sample_file_type');
318
-
319
- this.itemCount++;
320
- this.togglePriceFields();
321
- this.bindRemoveButtons();
322
- this.bindEditionguardSelect();
323
- },
324
- remove : function(event){
325
- var element = $(Event.findElement(event, 'tr'));
326
- var use_editionguard = element.down('select.use_editionguard').value != 0;
327
- var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
328
- if (!old_use_editionguard || !use_editionguard || confirm("This file is managed by Editionguard. If you delete it, previous customers will no longer be able to download their file. This cannot be undone.\n\nAre you sure?"))
329
- {
330
- alertAlreadyDisplayed = false;
331
- if(element){
332
- element.down('input[type="hidden"].__delete__').value = '1';
333
- Element.select(element, 'div.flex').each(function(elm){
334
- elm.remove();
335
- });
336
- element.addClassName('no-display');
337
- element.addClassName('ignore-validate');
338
- element.hide();
339
- }
340
- }
341
- },
342
- editionguardSelect : function(event){
343
- var element = $(Event.findElement(event, 'tr'));
344
- var use_editionguard = element.down('select.use_editionguard').value == 1;
345
- var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
346
- if (old_use_editionguard && !use_editionguard && !confirm("This file is managed by Editionguard. If you disable it, previous customers will no longer be able to download their file.\n\nAre you sure?"))
347
- {
348
- element.down('select.use_editionguard').value = element.down('input[type="hidden"].old_use_editionguard').value;
349
- return false;
350
- }
351
-
352
- return true;
353
- },
354
- bindRemoveButtons : function(){
355
- var buttons = $$('tbody#link_items_body .delete-link-item');
356
- for(var i=0;i<buttons.length;i++){
357
- if(!$(buttons[i]).binded && !$(buttons[i]).hasClassName('disabled')){
358
- $(buttons[i]).binded = true;
359
- Event.observe(buttons[i], 'click', this.remove.bind(this));
360
- }
361
- }
362
- },
363
- bindEditionguardSelect : function(){
364
- var selects = $$('tbody#link_items_body select.use_editionguard');
365
- for(var i=0;i<selects.length;i++){
366
- if(!$(selects[i]).binded && !$(selects[i]).hasClassName('disabled')){
367
- $(selects[i]).binded = true;
368
- Event.observe(selects[i], 'change', this.editionguardSelect.bind(this));
369
- }
370
- }
371
- },
372
- togglePriceFields : function(){
373
- var toogleTo = $('downloadable_link_purchase_type').value;
374
- var disableFlag = true;
375
- if (toogleTo == '1') {
376
- disableFlag = false;
377
- }
378
- $$('.link-prices[type="text"]').each(function(elm){
379
- var flag = disableFlag;
380
- if (elm.hasClassName('disabled')) {
381
- flag = true;
382
- }
383
- elm.disabled = flag;
384
- });
385
- }
386
- }
387
-
388
- linkItems.bindRemoveButtons();
389
- linkItems.bindEditionguardSelect();
390
-
391
- if ($('downloadable_link_purchase_type')) {
392
- Event.observe('downloadable_link_purchase_type', 'change', linkItems.togglePriceFields.bind());
393
- }
394
-
395
- if($('add_link_item')) {
396
- Event.observe('add_link_item', 'click', linkItems.add.bind(linkItems));
397
- }
398
-
399
- <?php foreach ($this->getLinkData() as $item): ?>
400
- linkItems.add(<?php echo $item->toJson()?>);
401
- <?php endforeach; ?>
402
-
403
- Validation.addAllThese([
404
- ['validate-downloadable-link-sample-file', 'Please specify File.', function(v,element) {
405
- fileSaveElm = element.up('div').next('input[type="hidden"]');
406
- if (element.checked && (fileSaveElm.value == '' || fileSaveElm.value == '[]')) {
407
- return false;
408
- }
409
- return true;
410
- }]
411
- ]);
412
- Validation.addAllThese([
413
- ['validate-downloadable-link-sample-url', 'Please specify Sample URL.', function(v,element) {
414
- if (element.checked && element.up('p').down('input[type="text"]').value == '') {
415
- return false;
416
- }
417
- return true;
418
- }]
419
- ]);
420
- //]]>
421
- </script>
422
  * EditionGuard
423
  *
424
  * This source file is proprietary property of EditionGuard. Any reuse or
425
  * distribution of any part of this file without prior consent is prohibited.
426
  *
427
  * @category EditionGuard
428
  * @package Editionguard_Editionguard
429
  * @copyright Copyright (c) 2012 EditionGuard. All rights Reserved.
430
  */
431
  * @see Editionguard_Editionguard_Block_Downloadable_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
432
  */
433
  $this->getEditionguardResource()
434
  $eSelectbox .= '<option value="' . $value->resource . '">' . $value->title . '</option>';
435
  <table cellspacing="0" class="form-list">
436
  <tbody>
437
  <tr class="headings">
438
  <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Title') ?></label>
439
  </td>
440
  <td class="value">
441
  <input type="text" class="input-text" id="downloadable_links_title" name="product[links_title]" value="<?php echo $_product->getId() ? $_product->getLinksTitle() : $this->getLinksTitle() ?>" <?php echo ($_product->getStoreId() && $this->getUsedDefault()) ? 'disabled="disabled"' : '' ?> />
442
  </td>
443
  <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[STORE VIEW]<?php endif; ?></td>
444
  <td class="value use-default">
445
  <?php if ($_product->getStoreId()): ?>
446
  <input id="link_title_default" type="checkbox" name="use_default[]" value="links_title" onclick="toggleValueElements(this, this.parentNode.parentNode)" <?php echo $this->getUsedDefault() ? 'checked="checked"' : '' ?> />
447
  <label class="normal" for="link_title_default"><?php echo Mage::helper('downloadable')->__('Use Default Value'); ?></label>
448
  <?php endif; ?>
449
  </td>
450
  </tr>
451
  </tbody>
452
  </table>
453
  <br />
454
  <table cellspacing="0" class="form-list">
455
  <tbody>
456
  <tr class="headings">
457
  <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Links can be purchased separately') ?></label>
458
  </td>
459
  <td class="value">
460
  <?php echo $this->getPurchasedSeparatelySelect() ?>
461
  </td>
462
  <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[GLOBAL]<?php endif; ?></td>
463
  <td><small>&nbsp;</small></td>
464
  </tr>
465
  </tbody>
466
  </table>
467
  <br />
468
  <div class="grid">
469
  <div class="hor-scroll">
470
  <table cellspacing="0" class="data border">
471
  <col width="33%" />
472
  <col />
473
  <col />
474
  <col />
475
  <col />
476
  <col width="1" />
477
  <col width="1" />
478
  <col width="1" />
479
  <col width="1" />
480
  <thead>
481
  <tr class="headings">
482
  <th><?php echo Mage::helper('downloadable')->__('Title') ?> <span class="required">*</span></th>
483
  <?php if ($this->getCanReadPrice() !== false) : ?>
484
  <th><?php echo Mage::helper('downloadable')->__('Price') ?></th>
485
  <?php endif; ?>
486
  <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Max. Downloads') ?></span></th>
487
  <th><?php echo Mage::helper('downloadable')->__('Shareable') ?></th>
488
  <th><?php echo Mage::helper('downloadable')->__('EditionGuard') ?></th>
489
  <th><?php echo Mage::helper('downloadable')->__('Sample') ?></th>
490
  <th><?php echo Mage::helper('downloadable')->__('File') ?></th>
491
  <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Sort Order') ?></span></th>
492
  <th>&nbsp;</th>
493
  </tr>
494
  </thead>
495
  <tfoot>
496
  <tr>
497
  <td colspan="9" class="a-right"><?php echo $this->getAddButtonHtml() ?>&nbsp;<?php echo $this->getUploadButtonHtml() ?></td>
498
  </tr>
499
  </tfoot>
500
  <tbody id="link_items_body">
501
  </tbody>
502
  </table>
503
  <div><small><?php echo Mage::helper('downloadable')->__('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.') ?></small></div>
504
  </div>
505
  </div>
506
  //<![CDATA[
507
  var linkTemplate = '<tr>' +
508
  '<td>' +
509
  '<input type="hidden" class="__delete__" name="downloadable[link][{{id}}][is_delete]" value="" />' +
510
  '<input type="hidden" name="downloadable[link][{{id}}][link_id]" value="{{link_id}}" />' +
511
  '<input type="text" class="required-entry input-text" name="downloadable[link][{{id}}][title]" value="{{title}}" />' +
512
  '<?php echo $_product->getStoreId() ? '<input type="checkbox" id="downloadable_link_{{id}}_title" name="downloadable[link][{{id}}][use_default_title]" value="1" /><label class="normal" for="downloadable_link_{{id}}_title">Use Default Value</label>' : '' ?>' +
513
  '</td>' +
514
  '<td class="input-price">' +
515
  '<input type="text" id="downloadable_link_{{id}}_price_value" class="input-text validate-number link-prices<?php if ($this->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][{{id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
516
  '<label>[<?php echo Mage::app()->getStore($_product->getStoreId())->getBaseCurrencyCode() ?>]</label>' +
517
  <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
518
  '<br /><input type="checkbox" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> <label for="downloadable_link_{{id}}_price">Use Default Value</label>' +
519
  <?php endif; ?>
520
  '</td>' +
521
  '<input type="hidden" id="downloadable_link_{{id}}_price_value" class="link-prices" name="downloadable[link][{{id}}][price]" value="0" />' +
522
  <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
523
  '<input type="hidden" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1" />' +
524
  <?php endif; ?>
525
  '<td><input type="text" id="downloadable_link_{{id}}_downloads" name="downloadable[link][{{id}}][number_of_downloads]" class="input-text downloads" value="{{number_of_downloads}}" />' +
526
  '<p><input type="checkbox" class="checkbox" id="downloadable_link_{{id}}_is_unlimited" name="downloadable[link][{{id}}][is_unlimited]" value="1" {{is_unlimited}} /> <label for="downloadable_link_{{id}}_is_unlimited">Unlimited</label></p></td>' +
527
  '<td class="a-center">' +
528
  '<select id="downloadable_link _{{id}}_shareable" name="downloadable[link][{{id}}][is_shareable]">' +
529
  '<option value="1">Yes</option>' +
530
  '<option value="0">No</option>' +
531
  '<option value="2" selected="selected">Use config</option>' +
532
  '</select>' +
533
  '</td>' +
534
  '<td class="a-center">' +
535
  '<input type="hidden" id="downloadable_link _{{id}}_old_use_editionguard" class="old_use_editionguard" name="downloadable[link][{{id}}][old_use_editionguard]" value="{{use_editionguard}}" />' +
536
  '<select id="downloadable_link _{{id}}_editionguard" class="use_editionguard" name="downloadable[link][{{id}}][use_editionguard]">' +
537
  '<option value="1" selected="selected">Yes</option>' +
538
  '<option value="0">No</option>' +
539
  '<option value="2">Use config</option>' +
540
  '</select>' +
541
  '</td>' +
542
  '<td>' +
543
  '<div class="files">' +
544
  '<div class="row">' +
545
  '<label for="downloadable_link_{{id}}_sample_file_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_file_type" name="downloadable[link][{{id}}][sample][type]" value="file"{{sample_file_checked}} checked="checked"/> File:</label>' +
546
  '<input type="hidden" id="downloadable_link_{{id}}_sample_file_save" name="downloadable[link][{{id}}][sample][file]" value="{{sample_file_save}}" />' +
547
  '<div id="downloadable_link_{{id}}_sample_file" class="uploader">' +
548
  '<div id="downloadable_link_{{id}}_sample_file-old" class="file-row-info"></div>' +
549
  '<div id="downloadable_link_{{id}}_sample_file-new" class="file-row-info"></div>' +
550
  '<div class="buttons">' +
551
  '<div id="downloadable_link_{{id}}_sample_file-install-flash" style="display:none">' +
552
  '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>' +
553
  '</div>' +
554
  '</div>' +
555
  '<div class="clear"></div>' +
556
  '</div>' +
557
  '</div>' +
558
  '<div class="row">' +
559
  '<label for="downloadable_link_{{id}}_sample_url_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_url_type" name="downloadable[link][{{id}}][sample][type]" value="url"{{sample_url_checked}} /> URL:</label><input type="text" class="input-text" name="downloadable[link][{{id}}][sample][url]" value="{{sample_url}}" /> ' +
560
  '</div>' +
561
  '<div>' +
562
  '<span id="downloadable_link_{{id}}_sample_container"></span>' +
563
  '</div>' +
564
  '</div>' +
565
  '</td>' +
566
  '<td>' +
567
  '<div class="files">' +
568
  '<div class="row">' +
569
  '<label for="downloadable_link_{{id}}_file_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_{{id}}_file_type" name="downloadable[link][{{id}}][type]" value="file"{{file_checked}} checked="checked"/> File:</label>' +
570
  '<input type="hidden" class="validate-downloadable-file" id="downloadable_link_{{id}}_file_save" name="downloadable[link][{{id}}][file]" value="{{file_save}}" />' +
571
  '<div id="downloadable_link_{{id}}_file" class="uploader">' +
572
  '<div id="downloadable_link_{{id}}_file-old" class="file-row-info"></div>' +
573
  '<div id="downloadable_link_{{id}}_file-new" class="file-row-info new-file"></div>' +
574
  '<div class="buttons">' +
575
  '<div id="downloadable_link_{{id}}_file-install-flash" style="display:none">' +
576
  '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>' +
577
  '</div>' +
578
  '</div></div>' +
579
  '<div class="clear"></div>' +
580
  '<div class="urlwrap" style="{{url_display}}"><label for="downloadable_link_{{id}}_url_type"><input type="radio" class="radio validate-one-required-by-name file-radio" id="downloadable_link_{{id}}_url_type" name="downloadable[link][{{id}}][type]" value="url"{{url_checked}} /> URL:</label><input type="text" class="validate-downloadable-url input-text" name="downloadable[link][{{id}}][link_url]" value="{{link_url}}" /></div>' +
581
  '<div class="ebookwrap" style="{{ebook_display}}"><label for="downloadable_link_{{id}}_ebook_type"><input type="radio" class="radio validate-one-required-by-name ebook-radio" id="downloadable_link_{{id}}_url_type" name="downloadable[link][{{id}}][type]" value="ebook" {{ebook_checked}} /> eBook: </label><?php echo $eSelectbox ?></div></div>' +
582
  '' +
583
  '<div>' +
584
  '<span id="downloadable_link_{{id}}_link_container"></span>' +
585
  '</div>' +
586
  '</div>' +
587
  '</td>' +
588
  '<td class="a-center"><input type="text" name="downloadable[link][{{id}}][sort_order]" value="{{sort_order}}" class="input-text sort" /></td>' +
589
  '<td>' +
590
  '<button id="downloadable_link_{{id}}_delete_button" type="button" class="scalable delete icon-btn delete-link-item"><span><?php echo Mage::helper('downloadable')->__('Delete'); ?></span></button>' +
591
  '</td>' +
592
  '</tr>';
593
  var linkItems = {
594
  tbody: $('link_items_body'),
595
  templateSyntax: /(^|.|\r|\n)({{(\w+)}})/,
596
  templateText: linkTemplate,
597
  itemCount: 0,
598
  add: function(data) {
599
  alertAlreadyDisplayed = false;
600
  this.template = new Template(this.templateText, this.templateSyntax);
601
  if (!data.link_id) {
602
  data = {};
603
  data.link_id = 0;
604
  data.link_type = 'ebook';
605
  data.sample_type = 'none';
606
  data.use_editionguard = 1;
607
  data.number_of_downloads = '<?php echo $this->getConfigMaxDownloads() ?>';
608
  }
609
  data.id = this.itemCount;
610
  if (data.link_type == 'url') {
611
  data.url_checked = ' checked="checked"';
612
  data.ebook_display = 'display:none';
613
  } else if (data.link_type == 'file') {
614
  data.file_checked = ' checked="checked"';
615
  data.ebook_display = 'display:none';
616
  }
617
  else if (data.link_type == 'ebook') {
618
  data.ebook_checked = ' checked="checked"';
619
  data.url_display = 'display:none';
620
  }
621
  if (data.sample_type == 'url') {
622
  data.sample_url_checked = ' checked="checked"';
623
  } else if (data.sample_type == 'file') {
624
  data.sample_file_checked = ' checked="checked"';
625
  }
626
  Element.insert(this.tbody, {'bottom': this.template.evaluate(data)});
627
  scopeTitle = $('downloadable_link_' + data.id + '_title');
628
  if (scopeTitle) {
629
  Event.observe(scopeTitle, 'click', function(event) {
630
  scopeElm = $(Event.findElement(event, 'input'));
631
  titleField = scopeElm.up(0).down('input[type="text"]');
632
  if (scopeElm.checked == true) {
633
  titleField.disabled = true;
634
  } else {
635
  titleField.disabled = false;
636
  }
637
  });
638
  }
639
  if (!data.store_title && scopeTitle) {
640
  scopeTitle.up(0).down('input[type="text"]').disabled = true;
641
  scopeTitle.checked = true;
642
  }
643
  scopePrice = $('downloadable_link_' + data.id + '_price');
644
  if (scopePrice) {
645
  Event.observe(scopePrice, 'click', function(event) {
646
  scopeElm = $(Event.findElement(event, 'input'));
647
  priceField = scopeElm.up(0).down('input[type="text"]');
648
  if (scopeElm.checked == true) {
649
  priceField.disabled = true;
650
  } else {
651
  priceField.disabled = false;
652
  }
653
  });
654
  }
655
  if (!data.website_price && scopePrice) {
656
  scopePrice.up(0).down('input[type="text"]').disabled = true;
657
  scopePrice.checked = true;
658
  }
659
  downloadsElm = $('downloadable_link_' + data.id + '_downloads');
660
  isUnlimitedElm = $('downloadable_link_' + data.id + '_is_unlimited');
661
  if (data.is_unlimited) {
662
  downloadsElm.disabled = true;
663
  }
664
  Event.observe(isUnlimitedElm, 'click', function(event) {
665
  elm = Event.element(event);
666
  elm.up('td').down('input[type="text"].downloads').disabled = elm.checked;
667
  });
668
  if (data.is_shareable) {
669
  options = $('downloadable_link _' + data.id + '_shareable').options;
670
  for (var i = 0; i < options.length; i++) {
671
  //Made changes so that we can make Edition Guard to Yes bydefault
672
  if (options[i].value == '1') {
673
  options[i].selected = true;
674
  }
675
  }
676
  }
677
  if (data.editionguard_resource) {
678
  options = $('downloadable_link_' + data.id + '_editionguard_resource').options;
679
  for (var i = 0; i < options.length; i++) {
680
  if (options[i].value == data.editionguard_resource) {
681
  options[i].selected = true;
682
  }
683
  }
684
  }
685
  if (data.use_editionguard) {
686
  options = $('downloadable_link _' + data.id + '_editionguard').options;
687
  for (var i = 0; i < options.length; i++) {
688
  //Made changes so that we can make Edition Guard to Yes bydefault
689
  //if (options[i].value == data.use_editionguard) {
690
  if (options[i].value == data.use_editionguard) {
691
  options[i].selected = true;
692
  }
693
  }
694
  }
695
  sampleUrl = $('downloadable_link_' + data.id + '_sample_url_type');
696
  linkUrl = $('downloadable_link_' + data.id + '_url_type');
697
  if (!data.file_save) {
698
  data.file_save = [];
699
  }
700
  if (!data.sample_file_save) {
701
  data.sample_file_save = [];
702
  }
703
  // link sample file
704
  new Downloadable.FileUploader(
705
  'linkssample',
706
  'linkssample_' + data.id,
707
  sampleUrl.up('td'),
708
  'downloadable[link][' + data.id + '][sample]',
709
  data.sample_file_save,
710
  'downloadable_link_' + data.id + '_sample_file',
711
  );
712
  // link file
713
  new Downloadable.FileUploader(
714
  'links',
715
  'links_' + data.id,
716
  linkUrl.up('td'),
717
  'downloadable[link][' + data.id + ']',
718
  data.file_save,
719
  'downloadable_link_' + data.id + '_file',
720
  );
721
  linkFile = $('downloadable_link_' + data.id + '_file_type');
722
  linkFile.advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
723
  linkUrl.advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
724
  $('downloadable_link_' + data.id + '_file_save').advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
725
  sampleFile = $('downloadable_link_' + data.id + '_sample_file_type');
726
  this.itemCount++;
727
  this.togglePriceFields();
728
  this.bindRemoveButtons();
729
  this.bindEditionguardSelect();
730
  },
731
  remove: function(event) {
732
  var element = $(Event.findElement(event, 'tr'));
733
  var use_editionguard = element.down('select.use_editionguard').value != 0;
734
  var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
735
  if (!old_use_editionguard || !use_editionguard || confirm("This file is managed by Editionguard. If you delete it, previous customers will no longer be able to download their file. This cannot be undone.\n\nAre you sure?"))
736
  {
737
  alertAlreadyDisplayed = false;
738
  if (element) {
739
  element.down('input[type="hidden"].__delete__').value = '1';
740
  Element.select(element, 'div.flex').each(function(elm) {
741
  elm.remove();
742
  });
743
  element.addClassName('no-display');
744
  element.addClassName('ignore-validate');
745
  element.hide();
746
  }
747
  }
748
  },
749
  editionguardSelect: function(event) {
750
  var element = $(Event.findElement(event, 'tr'));
751
  var use_editionguard = element.down('select.use_editionguard').value == 1;
752
  var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
753
  if (old_use_editionguard && !use_editionguard && !confirm("This file is managed by Editionguard. If you disable it, previous customers will no longer be able to download their file.\n\nAre you sure?"))
754
  {
755
  element.down('select.use_editionguard').value = element.down('input[type="hidden"].old_use_editionguard').value;
756
  element.down('div.ebookwrap').show();
757
  element.down('div.urlwrap').hide();
758
  return false;
759
  }
760
  else {
761
  element.down('div.ebookwrap').hide();
762
  element.down('div.urlwrap').show();
763
  element.down('input[type="radio"][value="url"].file-radio').checked = true;
764
  }
765
  if (element.down('select.use_editionguard').value == 1) {
766
  element.down('div.ebookwrap').show();
767
  element.down('div.urlwrap').hide();
768
  element.down('input[type="radio"][value="ebook"].ebook-radio').checked = true;
769
  }
770
  if (element.down('select.use_editionguard').value != 1) {
771
  element.down('select.editionguardebook').selectedIndex = 0;
772
  }
773
  return true;
774
  },
775
  bindRemoveButtons: function() {
776
  var buttons = $$('tbody#link_items_body .delete-link-item');
777
  for (var i = 0; i < buttons.length; i++) {
778
  if (!$(buttons[i]).binded && !$(buttons[i]).hasClassName('disabled')) {
779
  $(buttons[i]).binded = true;
780
  Event.observe(buttons[i], 'click', this.remove.bind(this));
781
  }
782
  }
783
  },
784
  bindEditionguardSelect: function() {
785
  var selects = $$('tbody#link_items_body select.use_editionguard');
786
  for (var i = 0; i < selects.length; i++) {
787
  if (!$(selects[i]).binded && !$(selects[i]).hasClassName('disabled')) {
788
  $(selects[i]).binded = true;
789
  Event.observe(selects[i], 'change', this.editionguardSelect.bind(this));
790
  }
791
  }
792
  },
793
  togglePriceFields: function() {
794
  var toogleTo = $('downloadable_link_purchase_type').value;
795
  var disableFlag = true;
796
  if (toogleTo == '1') {
797
  disableFlag = false;
798
  }
799
  $$('.link-prices[type="text"]').each(function(elm) {
800
  var flag = disableFlag;
801
  if (elm.hasClassName('disabled')) {
802
  flag = true;
803
  }
804
  elm.disabled = flag;
805
  });
806
  }
807
  }
808
  linkItems.bindRemoveButtons();
809
  linkItems.bindEditionguardSelect();
810
  if ($('downloadable_link_purchase_type')) {
811
  Event.observe('downloadable_link_purchase_type', 'change', linkItems.togglePriceFields.bind());
812
  }
813
  if ($('add_link_item')) {
814
  Event.observe('add_link_item', 'click', linkItems.add.bind(linkItems));
815
  }
816
  linkItems.add(<?php echo $item->toJson() ?>);
817
  Validation.addAllThese([
818
  ['validate-downloadable-link-sample-file', 'Please specify File.', function(v, element) {
819
  fileSaveElm = element.up('div').next('input[type="hidden"]');
820
  if (element.checked && (fileSaveElm.value == '' || fileSaveElm.value == '[]')) {
821
  return false;
822
  }
823
  return true;
824
  }]
825
  ]);
826
  Validation.addAllThese([
827
  ['validate-downloadable-link-sample-url', 'Please specify Sample URL.', function(v, element) {
828
  if (element.checked && element.up('p').down('input[type="text"]').value == '') {
829
  return false;
830
  }
831
  return true;
832
  }]
833
  ]);
834
  Validation.addAllThese([
835
  ['validate-downloadable-ebook', 'Please Select an eBook', function(v, element) {
836
  linkType = element.up(0).down('input[value="ebook"]');
837
  if (linkType.checked && v == '') {
838
  return false;
839
  }
840
  return true;
841
  }]
842
  ]);
843
  //]]>
1
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  * EditionGuard
3
  *
4
  * This source file is proprietary property of EditionGuard. Any reuse or
5
  * distribution of any part of this file without prior consent is prohibited.
6
  *
7
  * @category EditionGuard
8
  * @package Editionguard_Editionguard
9
  * @copyright Copyright (c) 2012 EditionGuard. All rights Reserved.
10
  */
11
  * @see Editionguard_Editionguard_Block_Downloadable_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
12
  */
13
  $this->getEditionguardResource()
14
  $eSelectbox .= '<option value="' . $value->resource . '">' . $value->title . '</option>';
15
  <table cellspacing="0" class="form-list">
16
  <tbody>
17
  <tr class="headings">
18
  <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Title') ?></label>
19
  </td>
20
  <td class="value">
21
  <input type="text" class="input-text" id="downloadable_links_title" name="product[links_title]" value="<?php echo $_product->getId() ? $_product->getLinksTitle() : $this->getLinksTitle() ?>" <?php echo ($_product->getStoreId() && $this->getUsedDefault()) ? 'disabled="disabled"' : '' ?> />
22
  </td>
23
  <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[STORE VIEW]<?php endif; ?></td>
24
  <td class="value use-default">
25
  <?php if ($_product->getStoreId()): ?>
26
  <input id="link_title_default" type="checkbox" name="use_default[]" value="links_title" onclick="toggleValueElements(this, this.parentNode.parentNode)" <?php echo $this->getUsedDefault() ? 'checked="checked"' : '' ?> />
27
  <label class="normal" for="link_title_default"><?php echo Mage::helper('downloadable')->__('Use Default Value'); ?></label>
28
  <?php endif; ?>
29
  </td>
30
  </tr>
31
  </tbody>
32
  </table>
33
  <br />
34
  <table cellspacing="0" class="form-list">
35
  <tbody>
36
  <tr class="headings">
37
  <td class="label"><label for="name"><?php echo Mage::helper('downloadable')->__('Links can be purchased separately') ?></label>
38
  </td>
39
  <td class="value">
40
  <?php echo $this->getPurchasedSeparatelySelect() ?>
41
  </td>
42
  <td class="scope-label"><?php if (!Mage::app()->isSingleStoreMode()): ?>[GLOBAL]<?php endif; ?></td>
43
  <td><small>&nbsp;</small></td>
44
  </tr>
45
  </tbody>
46
  </table>
47
  <br />
48
  <div class="grid">
49
  <div class="hor-scroll">
50
  <table cellspacing="0" class="data border">
51
  <col width="33%" />
52
  <col />
53
  <col />
54
  <col />
55
  <col />
56
  <col width="1" />
57
  <col width="1" />
58
  <col width="1" />
59
  <col width="1" />
60
  <thead>
61
  <tr class="headings">
62
  <th><?php echo Mage::helper('downloadable')->__('Title') ?> <span class="required">*</span></th>
63
  <?php if ($this->getCanReadPrice() !== false) : ?>
64
  <th><?php echo Mage::helper('downloadable')->__('Price') ?></th>
65
  <?php endif; ?>
66
  <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Max. Downloads') ?></span></th>
67
  <th><?php echo Mage::helper('downloadable')->__('Shareable') ?></th>
68
  <th><?php echo Mage::helper('downloadable')->__('EditionGuard') ?></th>
69
  <th><?php echo Mage::helper('downloadable')->__('Sample') ?></th>
70
  <th><?php echo Mage::helper('downloadable')->__('File') ?></th>
71
  <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Sort Order') ?></span></th>
72
  <th>&nbsp;</th>
73
  </tr>
74
  </thead>
75
  <tfoot>
76
  <tr>
77
  <td colspan="9" class="a-right"><?php echo $this->getAddButtonHtml() ?>&nbsp;<?php echo $this->getUploadButtonHtml() ?></td>
78
  </tr>
79
  </tfoot>
80
  <tbody id="link_items_body">
81
  </tbody>
82
  </table>
83
  <div><small><?php echo Mage::helper('downloadable')->__('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.') ?></small></div>
84
  </div>
85
  </div>
86
  //<![CDATA[
87
  var linkTemplate = '<tr>' +
88
  '<td>' +
89
  '<input type="hidden" class="__delete__" name="downloadable[link][{{id}}][is_delete]" value="" />' +
90
  '<input type="hidden" name="downloadable[link][{{id}}][link_id]" value="{{link_id}}" />' +
91
  '<input type="text" class="required-entry input-text" name="downloadable[link][{{id}}][title]" value="{{title}}" />' +
92
  '<?php echo $_product->getStoreId() ? '<input type="checkbox" id="downloadable_link_{{id}}_title" name="downloadable[link][{{id}}][use_default_title]" value="1" /><label class="normal" for="downloadable_link_{{id}}_title">Use Default Value</label>' : '' ?>' +
93
  '</td>' +
94
  '<td class="input-price">' +
95
  '<input type="text" id="downloadable_link_{{id}}_price_value" class="input-text validate-number link-prices<?php if ($this->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][{{id}}][price]" value="{{price}}"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
96
  '<label>[<?php echo Mage::app()->getStore($_product->getStoreId())->getBaseCurrencyCode() ?>]</label>' +
97
  <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
98
  '<br /><input type="checkbox" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1"<?php if ($this->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> <label for="downloadable_link_{{id}}_price">Use Default Value</label>' +
99
  <?php endif; ?>
100
  '</td>' +
101
  '<input type="hidden" id="downloadable_link_{{id}}_price_value" class="link-prices" name="downloadable[link][{{id}}][price]" value="0" />' +
102
  <?php if ($_product->getStoreId() && $this->getIsPriceWebsiteScope()) : ?>
103
  '<input type="hidden" id="downloadable_link_{{id}}_price" name="downloadable[link][{{id}}][use_default_price]" value="1" />' +
104
  <?php endif; ?>
105
  '<td><input type="text" id="downloadable_link_{{id}}_downloads" name="downloadable[link][{{id}}][number_of_downloads]" class="input-text downloads" value="{{number_of_downloads}}" />' +
106
  '<p><input type="checkbox" class="checkbox" id="downloadable_link_{{id}}_is_unlimited" name="downloadable[link][{{id}}][is_unlimited]" value="1" {{is_unlimited}} /> <label for="downloadable_link_{{id}}_is_unlimited">Unlimited</label></p></td>' +
107
  '<td class="a-center">' +
108
  '<select id="downloadable_link _{{id}}_shareable" name="downloadable[link][{{id}}][is_shareable]">' +
109
  '<option value="1">Yes</option>' +
110
  '<option value="0">No</option>' +
111
  '<option value="2" selected="selected">Use config</option>' +
112
  '</select>' +
113
  '</td>' +
114
  '<td class="a-center">' +
115
  '<input type="hidden" id="downloadable_link _{{id}}_old_use_editionguard" class="old_use_editionguard" name="downloadable[link][{{id}}][old_use_editionguard]" value="{{use_editionguard}}" />' +
116
  '<select id="downloadable_link _{{id}}_editionguard" class="use_editionguard" name="downloadable[link][{{id}}][use_editionguard]">' +
117
  '<option value="1" selected="selected">Yes</option>' +
118
  '<option value="0">No</option>' +
119
  '<option value="2">Use config</option>' +
120
  '</select>' +
121
  '</td>' +
122
  '<td>' +
123
  '<div class="files">' +
124
  '<div class="row">' +
125
  '<label for="downloadable_link_{{id}}_sample_file_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_file_type" name="downloadable[link][{{id}}][sample][type]" value="file"{{sample_file_checked}} checked="checked"/> File:</label>' +
126
  '<input type="hidden" id="downloadable_link_{{id}}_sample_file_save" name="downloadable[link][{{id}}][sample][file]" value="{{sample_file_save}}" />' +
127
  '<div id="downloadable_link_{{id}}_sample_file" class="uploader">' +
128
  '<div id="downloadable_link_{{id}}_sample_file-old" class="file-row-info"></div>' +
129
  '<div id="downloadable_link_{{id}}_sample_file-new" class="file-row-info"></div>' +
130
  '<div class="buttons">' +
131
  '<div id="downloadable_link_{{id}}_sample_file-install-flash" style="display:none">' +
132
  '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>' +
133
  '</div>' +
134
  '</div>' +
135
  '<div class="clear"></div>' +
136
  '</div>' +
137
  '</div>' +
138
  '<div class="row">' +
139
  '<label for="downloadable_link_{{id}}_sample_url_type"><input type="radio" class="radio" id="downloadable_link_{{id}}_sample_url_type" name="downloadable[link][{{id}}][sample][type]" value="url"{{sample_url_checked}} /> URL:</label><input type="text" class="input-text" name="downloadable[link][{{id}}][sample][url]" value="{{sample_url}}" /> ' +
140
  '</div>' +
141
  '<div>' +
142
  '<span id="downloadable_link_{{id}}_sample_container"></span>' +
143
  '</div>' +
144
  '</div>' +
145
  '</td>' +
146
  '<td>' +
147
  '<div class="files">' +
148
  '<div class="row">' +
149
  '<label for="downloadable_link_{{id}}_file_type"><input type="radio" class="radio validate-one-required-by-name" id="downloadable_link_{{id}}_file_type" name="downloadable[link][{{id}}][type]" value="file"{{file_checked}} checked="checked"/> File:</label>' +
150
  '<input type="hidden" class="validate-downloadable-file" id="downloadable_link_{{id}}_file_save" name="downloadable[link][{{id}}][file]" value="{{file_save}}" />' +
151
  '<div id="downloadable_link_{{id}}_file" class="uploader">' +
152
  '<div id="downloadable_link_{{id}}_file-old" class="file-row-info"></div>' +
153
  '<div id="downloadable_link_{{id}}_file-new" class="file-row-info new-file"></div>' +
154
  '<div class="buttons">' +
155
  '<div id="downloadable_link_{{id}}_file-install-flash" style="display:none">' +
156
  '<?php echo $this->jsQuoteEscape(Mage::helper('media')->__('This content requires last version of Adobe Flash Player. <a href="%s">Get Flash</a>', 'http://www.adobe.com/go/getflash/')) ?>' +
157
  '</div>' +
158
  '</div></div>' +
159
  '<div class="clear"></div>' +
160
  '<div class="urlwrap" style="{{url_display}}"><label for="downloadable_link_{{id}}_url_type"><input type="radio" class="radio validate-one-required-by-name file-radio" id="downloadable_link_{{id}}_url_type" name="downloadable[link][{{id}}][type]" value="url"{{url_checked}} /> URL:</label><input type="text" class="validate-downloadable-url input-text" name="downloadable[link][{{id}}][link_url]" value="{{link_url}}" /></div>' +
161
  '<div class="ebookwrap" style="{{ebook_display}}"><label for="downloadable_link_{{id}}_ebook_type"><input type="radio" class="radio validate-one-required-by-name ebook-radio" id="downloadable_link_{{id}}_url_type" name="downloadable[link][{{id}}][type]" value="ebook" {{ebook_checked}} /> eBook: </label><?php echo $eSelectbox ?></div></div>' +
162
  '' +
163
  '<div>' +
164
  '<span id="downloadable_link_{{id}}_link_container"></span>' +
165
  '</div>' +
166
  '</div>' +
167
  '</td>' +
168
  '<td class="a-center"><input type="text" name="downloadable[link][{{id}}][sort_order]" value="{{sort_order}}" class="input-text sort" /></td>' +
169
  '<td>' +
170
  '<button id="downloadable_link_{{id}}_delete_button" type="button" class="scalable delete icon-btn delete-link-item"><span><?php echo Mage::helper('downloadable')->__('Delete'); ?></span></button>' +
171
  '</td>' +
172
  '</tr>';
173
  var linkItems = {
174
  tbody: $('link_items_body'),
175
  templateSyntax: /(^|.|\r|\n)({{(\w+)}})/,
176
  templateText: linkTemplate,
177
  itemCount: 0,
178
  add: function(data) {
179
  alertAlreadyDisplayed = false;
180
  this.template = new Template(this.templateText, this.templateSyntax);
181
  if (!data.link_id) {
182
  data = {};
183
  data.link_id = 0;
184
  data.link_type = 'ebook';
185
  data.sample_type = 'none';
186
  data.use_editionguard = 1;
187
  data.number_of_downloads = '<?php echo $this->getConfigMaxDownloads() ?>';
188
  }
189
  data.id = this.itemCount;
190
  if (data.link_type == 'url') {
191
  data.url_checked = ' checked="checked"';
192
  data.ebook_display = 'display:none';
193
  } else if (data.link_type == 'file') {
194
  data.file_checked = ' checked="checked"';
195
  data.ebook_display = 'display:none';
196
  }
197
  else if (data.link_type == 'ebook') {
198
  data.ebook_checked = ' checked="checked"';
199
  data.url_display = 'display:none';
200
  }
201
  if (data.sample_type == 'url') {
202
  data.sample_url_checked = ' checked="checked"';
203
  } else if (data.sample_type == 'file') {
204
  data.sample_file_checked = ' checked="checked"';
205
  }
206
  Element.insert(this.tbody, {'bottom': this.template.evaluate(data)});
207
  scopeTitle = $('downloadable_link_' + data.id + '_title');
208
  if (scopeTitle) {
209
  Event.observe(scopeTitle, 'click', function(event) {
210
  scopeElm = $(Event.findElement(event, 'input'));
211
  titleField = scopeElm.up(0).down('input[type="text"]');
212
  if (scopeElm.checked == true) {
213
  titleField.disabled = true;
214
  } else {
215
  titleField.disabled = false;
216
  }
217
  });
218
  }
219
  if (!data.store_title && scopeTitle) {
220
  scopeTitle.up(0).down('input[type="text"]').disabled = true;
221
  scopeTitle.checked = true;
222
  }
223
  scopePrice = $('downloadable_link_' + data.id + '_price');
224
  if (scopePrice) {
225
  Event.observe(scopePrice, 'click', function(event) {
226
  scopeElm = $(Event.findElement(event, 'input'));
227
  priceField = scopeElm.up(0).down('input[type="text"]');
228
  if (scopeElm.checked == true) {
229
  priceField.disabled = true;
230
  } else {
231
  priceField.disabled = false;
232
  }
233
  });
234
  }
235
  if (!data.website_price && scopePrice) {
236
  scopePrice.up(0).down('input[type="text"]').disabled = true;
237
  scopePrice.checked = true;
238
  }
239
  downloadsElm = $('downloadable_link_' + data.id + '_downloads');
240
  isUnlimitedElm = $('downloadable_link_' + data.id + '_is_unlimited');
241
  if (data.is_unlimited) {
242
  downloadsElm.disabled = true;
243
  }
244
  Event.observe(isUnlimitedElm, 'click', function(event) {
245
  elm = Event.element(event);
246
  elm.up('td').down('input[type="text"].downloads').disabled = elm.checked;
247
  });
248
  if (data.is_shareable) {
249
  options = $('downloadable_link _' + data.id + '_shareable').options;
250
  for (var i = 0; i < options.length; i++) {
251
  //Made changes so that we can make Edition Guard to Yes bydefault
252
  if (options[i].value == '1') {
253
  options[i].selected = true;
254
  }
255
  }
256
  }
257
  if (data.editionguard_resource) {
258
  options = $('downloadable_link_' + data.id + '_editionguard_resource').options;
259
  for (var i = 0; i < options.length; i++) {
260
  if (options[i].value == data.editionguard_resource) {
261
  options[i].selected = true;
262
  }
263
  }
264
  }
265
  if (data.use_editionguard) {
266
  options = $('downloadable_link _' + data.id + '_editionguard').options;
267
  for (var i = 0; i < options.length; i++) {
268
  //Made changes so that we can make Edition Guard to Yes bydefault
269
  //if (options[i].value == data.use_editionguard) {
270
  if (options[i].value == data.use_editionguard) {
271
  options[i].selected = true;
272
  }
273
  }
274
  }
275
  sampleUrl = $('downloadable_link_' + data.id + '_sample_url_type');
276
  linkUrl = $('downloadable_link_' + data.id + '_url_type');
277
  if (!data.file_save) {
278
  data.file_save = [];
279
  }
280
  if (!data.sample_file_save) {
281
  data.sample_file_save = [];
282
  }
283
  // link sample file
284
  new Downloadable.FileUploader(
285
  'linkssample',
286
  'linkssample_' + data.id,
287
  sampleUrl.up('td'),
288
  'downloadable[link][' + data.id + '][sample]',
289
  data.sample_file_save,
290
  'downloadable_link_' + data.id + '_sample_file',
291
  );
292
  // link file
293
  new Downloadable.FileUploader(
294
  'links',
295
  'links_' + data.id,
296
  linkUrl.up('td'),
297
  'downloadable[link][' + data.id + ']',
298
  data.file_save,
299
  'downloadable_link_' + data.id + '_file',
300
  );
301
  linkFile = $('downloadable_link_' + data.id + '_file_type');
302
  linkFile.advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
303
  linkUrl.advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
304
  $('downloadable_link_' + data.id + '_file_save').advaiceContainer = 'downloadable_link_' + data.id + '_link_container';
305
  sampleFile = $('downloadable_link_' + data.id + '_sample_file_type');
306
  this.itemCount++;
307
  this.togglePriceFields();
308
  this.bindRemoveButtons();
309
  this.bindEditionguardSelect();
310
  },
311
  remove: function(event) {
312
  var element = $(Event.findElement(event, 'tr'));
313
  var use_editionguard = element.down('select.use_editionguard').value != 0;
314
  var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
315
  if (!old_use_editionguard || !use_editionguard || confirm("This file is managed by Editionguard. If you delete it, previous customers will no longer be able to download their file. This cannot be undone.\n\nAre you sure?"))
316
  {
317
  alertAlreadyDisplayed = false;
318
  if (element) {
319
  element.down('input[type="hidden"].__delete__').value = '1';
320
  Element.select(element, 'div.flex').each(function(elm) {
321
  elm.remove();
322
  });
323
  element.addClassName('no-display');
324
  element.addClassName('ignore-validate');
325
  element.hide();
326
  }
327
  }
328
  },
329
  editionguardSelect: function(event) {
330
  var element = $(Event.findElement(event, 'tr'));
331
  var use_editionguard = element.down('select.use_editionguard').value == 1;
332
  var old_use_editionguard = element.down('input[type="hidden"].old_use_editionguard').value != 0;
333
  if (old_use_editionguard && !use_editionguard && !confirm("This file is managed by Editionguard. If you disable it, previous customers will no longer be able to download their file.\n\nAre you sure?"))
334
  {
335
  element.down('select.use_editionguard').value = element.down('input[type="hidden"].old_use_editionguard').value;
336
  element.down('div.ebookwrap').show();
337
  element.down('div.urlwrap').hide();
338
  return false;
339
  }
340
  else {
341
  element.down('div.ebookwrap').hide();
342
  element.down('div.urlwrap').show();
343
  element.down('input[type="radio"][value="url"].file-radio').checked = true;
344
  }
345
  if (element.down('select.use_editionguard').value == 1) {
346
  element.down('div.ebookwrap').show();
347
  element.down('div.urlwrap').hide();
348
  element.down('input[type="radio"][value="ebook"].ebook-radio').checked = true;
349
  }
350
  if (element.down('select.use_editionguard').value != 1) {
351
  element.down('select.editionguardebook').selectedIndex = 0;
352
  }
353
  return true;
354
  },
355
  bindRemoveButtons: function() {
356
  var buttons = $$('tbody#link_items_body .delete-link-item');
357
  for (var i = 0; i < buttons.length; i++) {
358
  if (!$(buttons[i]).binded && !$(buttons[i]).hasClassName('disabled')) {
359
  $(buttons[i]).binded = true;
360
  Event.observe(buttons[i], 'click', this.remove.bind(this));
361
  }
362
  }
363
  },
364
  bindEditionguardSelect: function() {
365
  var selects = $$('tbody#link_items_body select.use_editionguard');
366
  for (var i = 0; i < selects.length; i++) {
367
  if (!$(selects[i]).binded && !$(selects[i]).hasClassName('disabled')) {
368
  $(selects[i]).binded = true;
369
  Event.observe(selects[i], 'change', this.editionguardSelect.bind(this));
370
  }
371
  }
372
  },
373
  togglePriceFields: function() {
374
  var toogleTo = $('downloadable_link_purchase_type').value;
375
  var disableFlag = true;
376
  if (toogleTo == '1') {
377
  disableFlag = false;
378
  }
379
  $$('.link-prices[type="text"]').each(function(elm) {
380
  var flag = disableFlag;
381
  if (elm.hasClassName('disabled')) {
382
  flag = true;
383
  }
384
  elm.disabled = flag;
385
  });
386
  }
387
  }
388
  linkItems.bindRemoveButtons();
389
  linkItems.bindEditionguardSelect();
390
  if ($('downloadable_link_purchase_type')) {
391
  Event.observe('downloadable_link_purchase_type', 'change', linkItems.togglePriceFields.bind());
392
  }
393
  if ($('add_link_item')) {
394
  Event.observe('add_link_item', 'click', linkItems.add.bind(linkItems));
395
  }
396
  linkItems.add(<?php echo $item->toJson() ?>);
397
  Validation.addAllThese([
398
  ['validate-downloadable-link-sample-file', 'Please specify File.', function(v, element) {
399
  fileSaveElm = element.up('div').next('input[type="hidden"]');
400
  if (element.checked && (fileSaveElm.value == '' || fileSaveElm.value == '[]')) {
401
  return false;
402
  }
403
  return true;
404
  }]
405
  ]);
406
  Validation.addAllThese([
407
  ['validate-downloadable-link-sample-url', 'Please specify Sample URL.', function(v, element) {
408
  if (element.checked && element.up('p').down('input[type="text"]').value == '') {
409
  return false;
410
  }
411
  return true;
412
  }]
413
  ]);
414
  Validation.addAllThese([
415
  ['validate-downloadable-ebook', 'Please Select an eBook', function(v, element) {
416
  linkType = element.up(0).down('input[value="ebook"]');
417
  if (linkType.checked && v == '') {
418
  return false;
419
  }
420
  return true;
421
  }]
422
  ]);
423
  //]]>
app/design/adminhtml/default/default/template/editionguard/downloadable/product/edit/downloadable/links.phtml.zip ADDED
Binary file
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>editionguard_drm</name>
4
- <version>1.0.0.3</version>
5
  <stability>stable</stability>
6
  <license>New BSD</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension is used to integrate Magento with EditionGuard, a cost-effective Adobe DRM service for eBooks.</summary>
10
  <description>This extension will allow you to create eBooks protected with the industry standard Adobe Content Server 4 DRM through the EditionGuard APIs. Through the admin interface, you will be able to manage your DRM enabled eBooks and put them up for sale as Downloadable Products. Your clients will then be able to purchase your eBooks, download them securely on the frontend and open them in Adobe Digital Editions.</description>
11
- <notes>Increased API call timeouts to one hour so large file uploads can be accommodated.</notes>
12
  <authors><author><name>EditionGuard</name><user>EditionGuard</user><email>support@editionguard.com</email></author></authors>
13
- <date>2013-09-21</date>
14
- <time>11:12:34</time>
15
- <contents><target name="magecommunity"><dir><dir name="Editionguard"><dir name="Editionguard"><dir name="Block"><dir name="Downloadable"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><dir name="Downloadable"><file name="Links.php" hash="d5cc57710639854da0b3af6924195b8c"/></dir></dir></dir></dir></dir></dir><dir name="Customer"><dir name="Products"><file name="List.php" hash="d6ed16a7183e3e97e3725d39d87c4c37"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ab37a425f2aa78219a15075ce9109a34"/></dir><dir name="Model"><dir name="Downloadable"><file name="Link.php" hash="85bec88744d31a81853c8e76c3ff55c6"/></dir><file name="Exception.php" hash="18afd5abedb9a0413481ea5255a89a53"/><dir name="Mysql4"><dir name="Editionguard"><file name="Collection.php" hash="de7c2d9c3aa413612a6473dafdf2f779"/></dir><file name="Editionguard.php" hash="adaa5e0d1718f506e89c657420c4d31a"/></dir><dir name="Resource"><dir name="Downloadable"><file name="Link.php" hash="cfc4b1417f2fd0adf93daf15b24681e1"/></dir><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="ff76c3213b9b428220578ba48a667365"/></dir></dir></dir></dir><dir name="controllers"><file name="DownloadController.php" hash="22ef464060c9ffb33b9f031e9ece1752"/></dir><dir name="etc"><file name="config.xml" hash="bfd50698223bb0df94df2bda2e2a78a9"/><file name="system.xml" hash="e1a700fb181b7b11e318edd4612d93e3"/></dir><dir name="sql"><dir name="editionguard_setup"><file name="install-1.0.0.0.php" hash="9e9ccd8e5fb5f5f63b32fa6ccea92ce6"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="editionguard"><dir name="downloadable"><dir name="product"><dir name="edit"><dir name="downloadable"><file name="links.phtml" hash="f2d9b8635fd3ea05e23f62ee5e916782"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Editionguard_Editionguard.xml" hash="1d6aac7609bf2b57392b64213f3722ca"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.17</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>editionguard_drm</name>
4
+ <version>1.0.1.0</version>
5
  <stability>stable</stability>
6
  <license>New BSD</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension is used to integrate Magento with EditionGuard, a cost-effective Adobe DRM service for eBooks.</summary>
10
  <description>This extension will allow you to create eBooks protected with the industry standard Adobe Content Server 4 DRM through the EditionGuard APIs. Through the admin interface, you will be able to manage your DRM enabled eBooks and put them up for sale as Downloadable Products. Your clients will then be able to purchase your eBooks, download them securely on the frontend and open them in Adobe Digital Editions.</description>
11
+ <notes>Changed admin so that an existing eBook on EditionGuard account can be used.</notes>
12
  <authors><author><name>EditionGuard</name><user>EditionGuard</user><email>support@editionguard.com</email></author></authors>
13
+ <date>2013-10-16</date>
14
+ <time>17:20:44</time>
15
+ <contents><target name="magecommunity"><dir><dir name="Editionguard"><dir name="Editionguard"><dir name="Block"><dir name="Downloadable"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><dir name="Downloadable"><file name="Links.php" hash="cadc7871db136a3260392daf38a029aa"/></dir></dir></dir></dir></dir></dir><dir name="Customer"><dir name="Products"><file name="List.php" hash="d6ed16a7183e3e97e3725d39d87c4c37"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8fafe5c6f8437da4693eb5caae131a44"/></dir><dir name="Model"><dir name="Downloadable"><file name="Link.php" hash="0122cd737c42f502d20ffb25fa4b4bf0"/></dir><file name="Exception.php" hash="18afd5abedb9a0413481ea5255a89a53"/><dir name="Mysql4"><dir name="Editionguard"><file name="Collection.php" hash="de7c2d9c3aa413612a6473dafdf2f779"/></dir><file name="Editionguard.php" hash="adaa5e0d1718f506e89c657420c4d31a"/></dir><dir name="Resource"><dir name="Downloadable"><file name="Link.php" hash="cfc4b1417f2fd0adf93daf15b24681e1"/></dir><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="ff76c3213b9b428220578ba48a667365"/></dir></dir></dir></dir><dir name="controllers"><file name="DownloadController.php" hash="f7b27200e5ca4f612ab70e313631c2a9"/></dir><dir name="etc"><file name="config.xml" hash="3d73d5cd6a7e8a843db5da103fc9f671"/><file name="system.xml" hash="e1a700fb181b7b11e318edd4612d93e3"/></dir><dir name="sql"><dir name="editionguard_setup"><file name="install-1.0.0.0.php" hash="9e9ccd8e5fb5f5f63b32fa6ccea92ce6"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="editionguard"><dir name="downloadable"><dir name="product"><dir name="edit"><dir name="downloadable"><file name="links.phtml" hash="21e424782ae50c1d4b03c1e3cf94aee3"/><file name="links.phtml.zip" hash="cd0fe885b3fa3ad49b31666c933caef2"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Editionguard_Editionguard.xml" hash="1d6aac7609bf2b57392b64213f3722ca"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.17</min><max>6.0.0</max></php></required></dependencies>
18
  </package>