private function _clean_cell() { clean_cell('site_article_asides_cell', 'tags'); }
function get_aim_data($excel) { $exceldata = array(); $k = 0; for ($i = 1; $i <= $excel->sheets[0]['numRows']; $i++) { for ($j = 4; $j <= $excel->sheets[0]['numCols']; $j++) { $exceldata[$k] = array(); $exceldata[$k]['exam_cell'] = $excel->val($i, 1); $lower_upper_cell = clean_cell($excel->val($i, 2)); $lower_upper_cell = str_replace("-", " - ", $lower_upper_cell); $lower_upper_cell = str_replace("<", "< ", $lower_upper_cell); $lower_upper_cell = str_replace(">", "> ", $lower_upper_cell); if (substr($lower_upper_cell, 0, 1) == "<") { $limits = array(); $limits[0] = trim(substr($lower_upper_cell, 2)); $limits[1] = ""; } elseif (substr($lower_upper_cell, 0, 1) == ">") { $limits = array(); $limits[0] = ""; $limits[1] = trim(substr($lower_upper_cell, 2)); } else { $limits = explode(" - ", $lower_upper_cell); } $exceldata[$k]['limits'] = $lower_upper_cell; $exceldata[$k]['lower'] = $limits[0]; $exceldata[$k]['upper'] = $limits[1]; $units_cell = $excel->val($i, 3); if (mb_detect_encoding($units_cell, 'UTF-8', true) != 'UTF-8') { $units_cell = iconv("ISO-8859-7", "UTF-8", $units_cell); // Epeidi kapoies eggrafes einai ISO-8859-7 !!! } $exceldata[$k]['units_cell'] = $units_cell; $exceldata[$k]['units_encoding'] = ""; $exceldata[$k]['index'] = "{$i}-{$j}"; $exceldata[$k]['date_cell'] = $excel->val(1, $j); $dateparts = explode("/", $exceldata[$k]['date_cell']); if ($dateparts[2] < 50) { $dateparts[2] = 2000 + $dateparts[2]; } else { $dateparts[2] = 1900 + $dateparts[2]; } $exceldata[$k]['mysql_date'] = $dateparts[2] . "-" . $dateparts[1] . "-" . $dateparts[0]; $exceldata[$k]['value_cell'] = clean_cell($excel->val($i, $j)); if ($exceldata[$k]['value_cell'] != "") { // Value exists so add the element to the array $k++; } } } return $exceldata; }
if (mb_detect_encoding($units_cell, 'UTF-8', true) != 'UTF-8') { $units_cell = iconv("ISO-8859-7", "UTF-8", $units_cell); // Epeidi kapoies eggrafes einai ISO-8859-7 !!! } $exceldata[$k]['units_cell'] = $units_cell; $exceldata[$k]['units_encoding'] = ""; $exceldata[$k]['index'] = "({$i} , {$j})"; $exceldata[$k]['date_cell'] = clean_cell($excel->val(1, $j)); $dateparts = explode("/", $exceldata[$k]['date_cell']); if ($dateparts[2] < 50) { $dateparts[2] = 2000 + $dateparts[2]; } else { $dateparts[2] = 1900 + $dateparts[2]; } $exceldata[$k]['mysql_date'] = $dateparts[0] . "-" . $dateparts[1] . "-" . $dateparts[2]; $exceldata[$k]['value_cell'] = clean_cell($excel->val($i, $j)); if ($exceldata[$k]['value_cell'] != "") { // Value exists so add the element to the array $k++; } } } echo "<pre>"; print_r($exceldata); die; $filename = "cleaned_up.xls"; // $filename = str_replace(" ", "_", substr($xlsfile, 0, strpos($xlsfile, "."))) . "_cleaned.xls"; // echo $filename; // die; writexls($exceldata, $filename, $xlsfile); //unlink("for_import.xls");
private function _clean_cell($article) { if (isset($article->id)) { clean_cell('site_cache_cell', 'article', $article->id); } clean_cell('site_article_asides_cell', 'news'); clean_cell('site_article_asides_cell', 'hots'); }
private function _clean_cell($work) { if (isset($work->id)) { clean_cell('site_cache_cell', 'work', $work->id); } }