Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
css_file_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/files/file/file_edit_fns.inc';
19 
29 {
30 
31 
36  function __construct()
37  {
38  parent::__construct();
39 
40  }//end constructor
41 
42 
53  function paintEditFile(CSS_File $asset, Backend_Outputter $o, $prefix)
54  {
55  if (SQ_ROLLBACK_VIEW) {
56  // get an older version of the parse file
57  $fv = $GLOBALS['SQ_SYSTEM']->getFileVersioning();
58  $rep_file = $asset->data_path_suffix.'/'.$asset->name;
59  $then = iso8601_ts($_SESSION['sq_rollback_view']['rollback_time']);
60  $info = @$fv->_checkOutCheck($rep_file, NULL, $then);
61  $parse_file = $info['source_file'];
62  ob_start();
63  $success = $fv->output($rep_file, NULL, $then);
64  $str = ob_get_clean();
65  if (!$success) return FALSE;
66  } else {
67  require_once SQ_FUDGE_PATH.'/general/file_system.inc';
68  $parse_file = $asset->data_path.'/'.$asset->name;
69  $str = file_to_string($parse_file);
70  }
71 
72  if ($asset->writeAccess('attributes')) {
73  text_area($prefix.'_new_file', $str, 0, 0, 0, 'style="font-family: \'Courier New\', Courier, monospace; white-space: pre-wrap; width: 99%; height: 480px"');
74  return TRUE;
75  } else {
76  echo '<pre>', htmlspecialchars($str), '</pre>';
77  }
78  return FALSE;
79 
80  }//end paintEditFile()
81 
82 
93  function processEditFile(CSS_File $asset, Backend_Outputter $o, $prefix)
94  {
95  if (!$asset->writeAccess('attributes')) return FALSE;
96  if (isset($_POST[$prefix.'_new_file'])) {
97 
98  // make them unix format ;)
99  $str = str_replace("\r\n", "\n", $_POST[$prefix.'_new_file']);
100 
101  require_once SQ_FUDGE_PATH.'/general/file_system.inc';
102 
103  // it's easier if we just use the processFileUpload() (future proof's this a little bit)
104  // so create a temporary file that will be moved to the proper file
105  $file_info = Array(
106  'name' => $asset->name,
107  'tmp_name' => $asset->data_path.'/'.$asset->name.'.new',
108  'non_uploaded_file' => TRUE,
109  );
110 
111  if (!string_to_file($str, $file_info['tmp_name'])) {
112  return FALSE;
113  }
114 
115  $ret_val = $this->processFileUpload($asset, $o, $prefix, $file_info);
116  unlink($file_info['tmp_name']);
117  return $ret_val;
118 
119  }//end if
120 
121  return FALSE;
122 
123  }//end processEditFile()
124 
125 
126 }//end class
127 ?>