Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
data_source_csv_edit_fns.inc
1 <?php
16 require_once SQ_INCLUDE_PATH.'/asset_edit/asset_edit_fns.inc';
17 require_once SQ_CORE_PACKAGE_PATH.'/data_source/data_source/data_source_edit_fns.inc';
18 
31 {
32 
33 
38  function __construct()
39  {
40  parent::__construct();
41 
42  }//end constructor
43 
44 
55  function paintUploadFile(&$asset, &$o, $prefix)
56  {
57  if (!$asset->writeAccess('attributes')) return FALSE;
58 
59  $o->openField(translate('csv_upload'));
60  file_upload($prefix.'_add_source_csv');
61  $o->note(translate('data_source_csv_upload_instructions'));
62  $o->closeField();
63 
64  }//end paintUploadFile()
65 
66 
77  function processUploadFile(&$asset, &$o, $prefix)
78  {
79  if (!$asset->writeAccess('attributes')) return FALSE;
80 
81  $file_info = get_file_upload_info($prefix.'_add_source_csv');
82  if (!empty($file_info)) {
83  require_once SQ_FUDGE_PATH.'/csv/csv.inc';
84  $csv = new CSV($file_info['tmp_name']);
85  $csv->import();
86 
87  $asset->setAttrValue('cached_content', $csv->values);
88 
89  // overwrite the cache with the new content
90  $asset->setResultSet(Array(), $asset->name);
91  $asset->getResultSet($asset->name);
92  }
93 
94  return TRUE;
95 
96  }//end processUploadFile()
97 
98 
109  function paintViewRecords(&$asset, &$o, $prefix)
110  {
111  echo '<pre>';
112  echo(print_r($asset->getItems(), TRUE));
113  echo '</pre>';
114 
115  }//end paintViewRecords()
116 
117 
128  function processViewRecords(&$asset, &$o, $prefix)
129  {
130  return TRUE;
131 
132  }//end processViewRecords()
133 
134 
135 }//end class
136 
137 
138 ?>