linccce

Latest php code

Mar 20th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.31 KB | None | 0 0
  1.                 if($tableVisible==1) {
  2.                     $chart['chartWidth'] = "style='width: $chartWidth; display: inline-block; float: left'";
  3.                     $table = "<div style='width: $tableWidth;' class='SEO-table-container' ><table class='SEO-table'>\n\n";
  4.                     $f = fopen(".$csv", "r");
  5.                     $i = 0;
  6.                     while (($line = fgetcsv($f, null, ';')) !== false) {
  7.                         if($i==0){
  8.                             $table .= "<thead>";
  9.                         }
  10.  
  11.                         if($i==1){
  12.                             $table .= "<tbody>";
  13.                         }
  14.  
  15.                         $table .= "<tr>";
  16.                         foreach ($line as $k => $cell) {
  17.  
  18.                             $cell = mb_convert_encoding($cell, "UTF-8", "auto");
  19.                             $cell = $i == 0 && $k == 0 && $cell == '[keywords]' ? "Raktiniai žodžiai" : $cell;
  20.  
  21.                             /*if($i==0&&$k>0){
  22.                                 $cell = date_format('Y.m.d', date_create($cell));
  23.                             }*/
  24.  
  25.                             $cell = htmlentities(preg_replace('/\,.0{0,2}$/', '', $cell), null, 'UTF-8');
  26.  
  27.                             if(preg_match('/^[\d]*$/', $cell, $match)) {
  28.                                 if(preg_match('/\d+/g', $match[0],$number)) {
  29.                                     $cell = $match[0];
  30.                                 }
  31.                             }
  32.  
  33.                             $is_second_row_yellow = $i == 1 ? "<td class='SEO-table-top20 first-row'>" : "<td class='SEO-table-top20'>"; //pirma body eile geltoni bruksnys virsuje
  34.  
  35.                             $is_second_row_green = $i == 1 ? "<td class='SEO-table-top10 first-row'>" : "<td class='SEO-table-top10'>"; //pirma body eile geltoni bruksnys virsuje
  36.  
  37.                             $is_second_row_right_not_yellow = $i == 1 ? "<td class='SEO-table-values first-row'>" : "<td class='SEO-table-values'>"; //pirma body eile ne geltoni bruksnys virsuje
  38.  
  39.                             $is_top_twenty = (is_numeric($cell) && $cell <= 20 && $cell > 10) ? $is_second_row_yellow : $is_second_row_right_not_yellow; //ar priklauso top 20
  40.  
  41.                             $is_top_ten = (is_numeric($cell) && $cell <= 10) ? $is_second_row_green : $is_top_twenty; //ar priklauso top 10
  42.  
  43.                             $is_rightest_header = ($k == 0 ? "<th class='SEO-first-column-header'>" : "<th class='SEO-table-header-dates'><span>"); //datos vertikaliai
  44.  
  45.                             $is_second_row = $i == 1 ? "<td class='SEO-table-series first-row first-col'>" : "<td class='SEO-table-series-names first-col'>";
  46.  
  47.                             $is_rightest_body = ($k == 0 ? $is_second_row : $is_top_ten);
  48.  
  49.                             $cell_start = $i == 0 ? $is_rightest_header : $is_rightest_body;
  50.  
  51.                             $cell_end = $i == 0 ? ($k == 0?"</th>":"</span></th>") : "</td>";
  52.  
  53.                             $table .= $cell_start . $cell . $cell_end;
  54.  
  55.                         }
  56.                         $table .= "</tr>\n";
  57.                         $table .= $i == 0 ? "</thead>" : "";
  58.                         $i++;
  59.                     }
  60.                     fclose($f);
  61.                     $table .= "\n</tbody></table></div><br/>";
  62.                 }
Advertisement
Add Comment
Please, Sign In to add comment