function edit1($word)
{
    $list1 = delete($word);
    $list2 = insert($word);
    $list3 = transpose($word);
    $list4 = replace($word);
    $union = array_merge($list1, $list2, $list3, $list4);
    $union = array_unique($union);
    return $union;
}
Example #2
0
 /**
  * Load the dataset, received from the data base.
  *
  * @param array $data Dataset.
  *
  * @see QAL::select()
  */
 public function load($data)
 {
     if (is_array($data) && !empty($data)) {
         $data = transpose($data);
         foreach ($data as $fieldName => $fieldValues) {
             //Если такого поля не существует еще, то создаем
             if (!($fieldObject = $this->getFieldByName($fieldName))) {
                 $fieldObject = new Field($fieldName);
                 $this->addField($fieldObject);
             }
             //и заносим в него данные
             $fieldObject->setData($fieldValues);
         }
     }
 }
Example #3
0
function maakBingokaart()
{
    $matrix = array();
    for ($i = 1, $j = 0; $i <= 61; $i += 10, $j++) {
        $matrix[$j] = maakKolom($i, $i + 9, 5);
    }
    $tmatrix = transpose($matrix);
    $output = "";
    for ($i = 0; $i <= 4; $i++) {
        $output .= "<tr>";
        for ($j = 0; $j <= 6; $j++) {
            $output .= "<td>";
            $output .= $tmatrix[$i][$j];
            $output .= "</td>";
        }
        $output .= "</tr>";
    }
    echo "<table>\n\t\t\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>A</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>L</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>B</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>I</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>N</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>G</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<th>O</th>\n\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t\t\t\t\t<tbody>{$output}</tbody>\n\t\t\t\t\t\t\t\t\t\t  </table>";
}
 protected function loadData()
 {
     $data = parent::loadData();
     if ($this->getState() == 'getRawData' && $data) {
         $inverted = transpose($data);
         $upl_ids = $inverted['upl_id'];
         $res = $this->dbh->select('share_uploads', ['upl_id', 'upl_path', 'upl_title as upl_name', 'upl_duration'], ['upl_id' => $upl_ids]);
         foreach ($data as $i => $row) {
             if ($res) {
                 $new_row = false;
                 foreach ($res as $row2) {
                     if ($row2['upl_id'] == $row['upl_id']) {
                         $new_row = $row2;
                     }
                 }
                 if ($new_row) {
                     $data[$i]['upl_path'] = $new_row['upl_path'];
                     $data[$i]['upl_name'] = $new_row['upl_name'];
                 }
             }
         }
     }
     return $data;
 }
Example #5
0
        $font = $m[1];
    } else {
        abort("Unknown parameter \"{$arg}\". Use \"help\" for more details.");
    }
}
if (!isset($transposeValue) || $transposeValue < -11 || $transposeValue > 11) {
    abort("Must provide an integer between -11 and 11 as transposition");
}
if ($transposeValue != 0 && !isset($transposeKey)) {
    $transposeKey = "C";
}
$clip = new NWC2Clip('php://stdin');
// 1. Scan each line
echo $clip->GetClipHeader() . "\n";
$nothingToDo = TRUE;
foreach ($clip->Items as $item) {
    $nothingToDo = FALSE;
    $o = new NWC2ClipItem($item);
    if ($o->GetObjType() == "Text" && ($t =& $o->GetTaggedOpt("Text")) && rootChordValue($t) && (isset($font) ? $o->GetTaggedOpt("Font") == $font : true)) {
        transpose($t);
        echo $o->ReconstructClipText() . "\n";
    } else {
        echo $item;
    }
    unset($o);
}
echo NWC2_ENDCLIP . "\n";
if ($nothingToDo) {
    abort("This tool requires a selection.\nPlease select something on the staff before invoking transpose_chords.");
}
exit(NWC2RC_SUCCESS);
Example #6
0
\t\t<td>1</td>
\t\t<td>2</td>
\t</tr>
\t<tr>
\t\t<td>3</td>
\t\t<td>4</td>
\t</tr>
\t<tr>
\t\t<td>5</td>
\t\t<td>6</td>
\t</tr>
</table>

table;
error_reporting(E_ALL & ~E_NOTICE);
echo transpose($html_in);
/****************************

HTML Table Transpose Function
Converts rows to columns and columns to rows in an HTML Table
By Darren Gates & Gary Beith, www.TUFaT.com

Example of usage:

$html_in = file_get_contents('some_table.html');
echo transpose($html_in);

****************************/
function transpose($html_in)
{
    $html_out = '';
            $tableau_valeurs = array();
            // la variable tableau_valeurs contient toutes les valeurs
            // tableau_valeurs[0] = première ligne du fichier texte explosé suivant tab
            // tableau_valeurs[1] = deuxième ligne du fichier texte explosé suivant tab
            while (!feof($monfichier)) {
                $arrM = explode("\t", fgets($monfichier));
                $tableau_valeurs[] = $arrM;
            }
            //fonction Transposer tableau
            function transpose($array)
            {
                array_unshift($array, null);
                return call_user_func_array('array_map', $array);
            }
            //le tableau est transposé ligne en dessous
            $tableau_reorganise = transpose($tableau_valeurs);
            //récuperation valeurs utiles
            $nombre_colonne = sizeof($tableau_reorganise);
            $nombre_ligne = sizeof($tableau_reorganise[0]);
            //boucle transtypage
            for ($i = 0; $i < $nombre_colonne; $i++) {
                for ($j = 1; $j < $nombre_ligne; $j++) {
                    $tableau_reorganise[$i][$j] = floatval($tableau_reorganise[$i][$j]);
                }
            }
            ?>

        <!-- sortie php -->
        <div id="container" style="height: 400px"></div>
        <div id="drag"></div>
        <div id="drop"></div>
Example #8
0
function scip_input($year, $season, $dept, $sname)
{
    /*
      error_reporting(E_ALL);
      ini_set('display_errors', TRUE);
      ini_set('display_startup_errors', TRUE);
    */
    //so we have three csv files to make: ta, section, pref.
    $tacsv = array();
    $prefcsv = array();
    $sectioncsv = array();
    //Each row gets its own array; let's start with headers.
    $header = array('Name', 'Ranking', 'Units', 'Status', 'Block', 'Sameday', 'Btb', 'Conflicts', 'NULL');
    array_push($tacsv, $header);
    $header = array('Course', 'Section', 'Instructor', 'Day', 'Time', 'Units', 'TAs', 'NULL');
    array_push($sectioncsv, $header);
    //given a TA, we already have a function to find all section prefs. So let the list of
    //  section names be the pref header.
    $db = new PDO(DB_PATH, DB_LOGIN, DB_PW);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    try {
        //first we want to loop through all current sections of this dept.
        $sql = count_sections($dept, $year, $season);
        $result = $db->query($sql)->fetch();
        if ($result[0] == 0) {
            return array("error-message", "Department {$dept} has no section data for {$sname} {$year}.");
        }
        $sql = sql_section($dept, $year, $season);
        //puts($sql);
        $result = $db->query($sql);
        $header = array("");
        foreach ($result as $r) {
            $course = $r['course'];
            $row = array($course, $r['name'], "");
            //Now to get the times.
            $sql2 = "SELECT *\n               FROM event\n               WHERE quarter_year = {$year} and quarter_season = {$season}\n                 AND department = '{$dept}' AND course = '" . $r['course'] . "' \n                 AND section = '" . $r['name'] . "' AND type = 'lecture'\n                 AND day != 'U' AND day != 'S'\n               GROUP BY day;";
            $result2 = $db->query($sql2);
            $days = "";
            $start = "";
            $end = "";
            foreach ($result2 as $r2) {
                $days .= $r2['day'];
                $start = $r2['start'];
                $end = $r2['end'];
            }
            //Gather all the lecture days and get times.
            $time_full = $start . '-' . $end;
            array_push($row, $days);
            array_push($row, $time_full);
            array_push($row, $r['units']);
            array_push($row, $r['weight']);
            array_push($row, "0");
            $row2 = array("", "", "");
            $sql2 = "SELECT *\n               FROM event\n               WHERE quarter_year = {$year} and quarter_season = {$season}\n                 AND department = '{$dept}' AND course = '" . $r['course'] . "'\n                 AND day != 'U' AND day != 'S'\n                 AND section = '" . $r['name'] . "' AND type = 'discussion';";
            //puts($sql2);
            $result2 = $db->query($sql2);
            $discussion = 0;
            $days = "";
            $start = "";
            $end = "";
            foreach ($result2 as $r2) {
                $days = $r2['day'];
                $start = $r2['start'];
                $end = $r2['end'];
                $discussion = 1;
                array_push($row2, $days);
                $time_full = $start . '-' . $end;
                array_push($row2, $time_full);
            }
            //enter the discussion.
            array_push($row2, $r['units']);
            array_push($row2, $r['weight']);
            array_push($row2, "0");
            //only put in sections with discussions
            array_push($header, $course . ' ' . $r['name']);
            array_push($sectioncsv, $row);
            array_push($sectioncsv, $row2);
        }
        //for all sections.
        array_push($prefcsv, $header);
        //Now we get all TAs. We can fill pref.csv as we go here.
        $sql = "SELECT t.name_first, t.name_last, t.rank, t.status, t.sid, u.value\n            FROM ta t, units u\n            WHERE u.sid = t.sid\n              AND t.department = '{$dept}' AND u.year = {$year} AND u.season = {$season};";
        //puts($sql);
        $result = $db->query($sql);
        foreach ($result as $r) {
            $fullname = scip_clean($r['name_first']) . ' ' . scip_clean($r['name_last']);
            $sid = $r['sid'];
            $row = array($fullname, $r['rank'], $r['value'], strtolower($r['status']));
            $sql2 = "SELECT * FROM pref WHERE sid = " . $r['sid'] . ";";
            $r2 = $db->query($sql2);
            $p = array();
            $countr2 = 0;
            foreach ($r2 as $rr2) {
                $countr2++;
                $p = array($rr2['block'], $rr2['same_day'], $rr2['back_to_back']);
            }
            if ($countr2 == 0) {
                $p = array(0, 0, 0);
            }
            foreach ($p as $p2) {
                array_push($row, $p2);
            }
            //finally we need to get all time conflicts in form D|SSSS|EEEE D|SSSS|EEEE....
            $sql2 = "SELECT day, start, end \n               FROM calendar\n               WHERE sid = {$sid} AND quarter_year = {$year} AND quarter_season = {$season};";
            $result2 = $db->query($sql2);
            $conflicts = "";
            foreach ($result2 as $r2) {
                $conflicts .= $r2['day'] . '|' . $r2['start'] . '|' . $r2['end'] . ' ';
            }
            //for each event of this TA
            array_push($row, $conflicts);
            array_push($row, "0");
            array_push($tacsv, $row);
            $prefs = get_prefs($sid, $year, $season, $dept, "scip");
            $prow = array($fullname);
            for ($i = 0; $i < count($prefs); $i++) {
                array_push($prow, $prefs[$i]->value);
                //   array_push($prow, ($prefs[$i]->value." ".$prefs[$i]->section));
            }
            array_push($prefcsv, $prow);
        }
        //foreach ta
    } catch (PDOException $e) {
        echo $e->getMessage();
    }
    //Now we can save the csv files in the scip folder.
    $fp = fopen('scip/ta.csv', 'w');
    foreach ($tacsv as $fields) {
        fputcsv2($fp, str_replace(array("(", ")"), "-", $fields));
    }
    fclose($fp);
    $fp = fopen('scip/section.csv', 'w');
    foreach ($sectioncsv as $fields) {
        fputcsv2($fp, $fields);
    }
    fclose($fp);
    $fp = fopen('scip/pref.csv', 'w');
    foreach (transpose($prefcsv) as $fields) {
        fputcsv2($fp, str_replace(array("(", ")"), "-", $fields));
    }
    $fp = fopen("csv/pref_{$dept}{$year}{$season}.csv", 'w');
    foreach (transpose($prefcsv) as $fields) {
        fputcsv2($fp, str_replace(array("(", ")"), "-", $fields));
    }
    fclose($fp);
}
// keep relevant columns only, namely 0,1,3,5,7,9,11,13
// transpose array
$transposeddata = transpose($tabledata);
// delete even columns
for ($i = 2; $i < 17; $i += 2) {
    unset($transposeddata[$i]);
}
// delete last column
array_pop($transposeddata);
// reindex array
$transposeddata = array_values($transposeddata);
$header = array_shift($transposeddata);
$header[0] = "Date";
$tabledata = transpose($transposeddata);
$tabledata = array_combine($header, $tabledata);
$transposeddata = transpose($tabledata);
foreach ($transposeddata as $key => $data) {
    scraperwiki::save_sqlite(array("Date"), $data);
}
function make_date($date = array())
{
    if ($date["year"]) {
        return DateTime::createFromFormat('Y-m-d', $date["year"] . "-" . $date["month"] . "-" . $date["day"])->format('Y-m-d');
    }
    return "";
}
function transpose($array)
{
    $transposed_array = array();
    if ($array) {
        foreach ($array as $row_key => $row) {
Example #10
0
function tran($p, $s, $f)
{
    $a = explod("\n", $s);
    for ($i = 0; $i < count($a); ++$i) {
        if (ereg("^[[:space:][:punct:]CDEFGAB#bdxXMimsuagdj+/0-9\\-]*\$", $a[$i])) {
            $r[$i] = transpose($p, $a[$i], $f);
        } else {
            $r[$i] = $a[$i];
        }
    }
    return implode("\n", $r);
}