Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_rest_resource_js_edit_fns.inc
1 <?php
17 require_once SQ_PACKAGES_PATH.'/web_services/rest/page_templates/page_rest_resource/page_rest_resource_edit_fns.inc';
18 
19 
32 {
33 
38  function __construct()
39  {
40  parent::__construct();
41  $this->static_screens['details']['force_unlock'] = FALSE;
42 
43  }//end constructor
44 
45 
56  function paintJavaScriptFiles(&$asset, &$o, $prefix)
57  {
58  $write_access = $asset->writeAccess('attributes');
59  $javascript_files = $asset->attr('javascript_files');
60 
61  if ($write_access) {
62  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
63  multiple_asset_finder($prefix.'_javascript_files', $javascript_files, Array('file' => 'D'));
64  } else {
65  echo '<ul>';
66  foreach ($javascript_files as $index => $assetid) {
67  echo '<li>'.get_asset_tag_line($assetid).'</li>';
68  }
69  echo '</ul>';
70  }
71 
72  return $write_access;
73 
74  }//end paintJavaScriptFiles()
75 
76 
87  function processJavaScriptFiles(&$asset, &$o, $prefix)
88  {
89  // need to have write access to make any changes
90  if (!$asset->writeAccess('attributes')) return FALSE;
91  if (empty($_POST[$prefix.'_javascript_files'])) return FALSE;
92 
93  $javascript_files = $_POST[$prefix.'_javascript_files'];
94  $save_javascript_files = Array();
95  foreach ($javascript_files as $index => $asset_info) {
96  if (!empty($asset_info['assetid'])) {
97  $save_javascript_files[] = $asset_info['assetid'];
98  }//end if
99  }//end foreach
100 
101  return $asset->setAttrValue('javascript_files', $save_javascript_files);
102 
103  }//end processJavaScriptFiles()
104 
105 
116  function paintJavaScript(&$asset, &$o, $prefix)
117  {
118  $write_access = $asset->writeAccess('attributes');
119  $javascript = $asset->attr('javascript');
120 
121  if ($write_access) {
122  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
123  text_area($prefix.'_javascript', $javascript, 100, 20, 0, 'style="font-family: monospace;');
124  } else {
125  echo "<pre>" . htmlspecialchars($javascript) . "</pre>\n";
126  }
127 
128  return $write_access;
129 
130  }//end paintJavaScript()
131 
132 
143  function processJavaScript(&$asset, &$o, $prefix)
144  {
145  // need to have write access to make any changes
146  if (!$asset->writeAccess('attributes')) return FALSE;
147 
148  $js = isset($_POST[$prefix.'_javascript']) ? $_POST[$prefix.'_javascript'] : '';
149  return $asset->setAttrValue('javascript', $js);
150 
151  }//end processJavaScript()
152 
153 }//end class
154 ?>