Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
mp3_file_edit_fns.inc
1 <?php
16 require_once SQ_CORE_PACKAGE_PATH.'/files/file/file_edit_fns.inc';
17 require_once SQ_FUDGE_PATH.'/general/text.inc';
18 
33 {
34 
35  function MP3_File_Edit_Fns()
36  {
37  $this->File_Edit_Fns();
38  $this->static_screens['details']['force_unlock'] = 1;
39 
40  }// end constructor
41 
42 
65  function processFileUpload(&$asset, &$o, $prefix, $info=Array(), $redirect_in_limbo=TRUE, $asset_cloned=FALSE)
66  {
67  if (!parent::processFileUpload($asset, $o, $prefix, $info, $redirect_in_limbo, $asset_cloned)) {
68  return FALSE;
69  }
70 
71  // assetid will not be set if we are creating
72  if (!$asset->id) return TRUE;
73 
74  $info = $asset->getExistingFile();
75 
76  // Check to see if our getID3 System Tool is enabled
77  // If so, flag the asset for ID3 extraction on save
78  if (SQ_TOOL_GETID3_ENABLED) {
79  $asset->setAttrValue('extract_id3', TRUE);
80  }
81 
82  return TRUE;
83 
84  }// end processFileUpload()
85 
86 
96  function paintExtractID3(MP3_File $asset, Backend_Outputter $o, $prefix)
97  {
98  // Write attributes
99  $wa = $asset->writeAccess('attributes');
100 
101  if ($wa) {
102  check_box($prefix.'_extract_id3', 1, FALSE);
103  } else {
104  ?><em>Lock the asset to access this option</em><?php
105  }
106 
107  if (!SQ_TOOL_GETID3_ENABLED) {
108  // Check to see if getID3 is installed and turned on
109  ?><br/><span class="sq-backend-warning">ID3 Tag extraction is not currently enabled</span><?php
110  }
111 
112  return $wa;
113 
114  }// end paintExtractID3()
115 
116 
130  public function processExtractID3(MP3_File $asset, Backend_Outputter $o, $prefix)
131  {
132  if (!$asset->writeAccess('attributes')) return FALSE;
133  $extract = isset($_POST[$prefix.'_extract_id3']);
134 
135  if ($extract) {
136  $asset->setAttrValue('extract_id3', TRUE);
137  }
138 
139  return TRUE;
140 
141  }// end processExtractID3()
142 
143 
153  function paintWriteID3(MP3_File $asset, Backend_Outputter $o, $prefix)
154  {
155  // Write attributes
156  $wa = $asset->writeAccess('attributes');
157 
158  if ($wa) {
159  check_box($prefix.'_write_id3', 1, FALSE);
160  } else {
161  ?><em>Lock the asset to access this option</em><?php
162  }
163 
164  if (!SQ_TOOL_GETID3_ENABLED) {
165  // Check to see if getID3 is installed and turned on
166  ?><br/><span class="sq-backend-warning">ID3 Tag writing is not currently enabled</span><?php
167  }
168 
169  return $wa;
170 
171  }// end paintWriteID3()
172 
173 
187  public function processWriteID3(MP3_File $asset, Backend_Outputter $o, $prefix)
188  {
189  if (!$asset->writeAccess('attributes')) return FALSE;
190  $write = isset($_POST[$prefix.'_write_id3']);
191 
192  if ($write) {
193  $asset->setAttrValue('write_mp3', TRUE);
194  }//end if
195 
196  return TRUE;
197 
198  }// end processExtractID3()
199 
200 
201 }// end class
202 ?>