/**
 Will attempt to get the value of the fieldname, via the
 $tokens array and any $fieldname_default.
 */
 function get_field_value($fieldname, $s_attribute_type, $tokens)
 {
     if (isset($this->field_column_r[$fieldname]) && is_numeric($this->field_column_r[$fieldname]) && strlen($tokens[$this->field_column_r[$fieldname]]) > 0) {
         // Only support INITCAP of actual tokens imported from CSV/DIF file!!!
         if ($this->field_initcap_r[$fieldname] == 'true' && !is_array($tokens[$this->field_column_r[$fieldname]])) {
             return initcap($tokens[$this->field_column_r[$fieldname]]);
         } else {
             return $tokens[$this->field_column_r[$fieldname]];
         }
     } else {
         if (isset($this->field_default_r[$fieldname])) {
             return $this->field_default_r[$fieldname];
         } else {
             // no $value to return
             return FALSE;
         }
     }
 }
Example #2
0
function display_patch_list($title, $patchdir)
{
    global $ADMIN_TYPE;
    echo "<h3>" . $title . "</h3>";
    $filelist = get_file_list('./admin/patch_facility/sql/' . $patchdir, 'sql');
    $sqllist = NULL;
    if (is_not_empty_array($filelist)) {
        for ($i = 0; $i < count($filelist); $i++) {
            $parsedfile_r = parse_file($filelist[$i]);
            $sqllist[] = array('sqlfile' => $filelist[$i], 'name' => initcap(str_replace('_', ' ', $parsedfile_r['name'])));
        }
        if (is_not_empty_array($sqllist)) {
            echo "<table>";
            echo "<tr class=\"navbar\">" . "<th>Patch</th>" . "<th>SQL File</th>" . "<th></th>" . "<th></th>" . "</tr>";
            for ($i = 0; $i < count($sqllist); $i++) {
                echo "<tr class=\"oddRow\">" . "<td>" . $sqllist[$i]['name'] . "</td>" . "<td>" . $sqllist[$i]['sqlfile'] . "</td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=previewsql&mode=job&title=" . urlencode($sqllist[$i]['sqlfile']) . "&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "&preview=true\" target=\"_new\">Preview</a></td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=installsql&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "\">Install</a></td>" . "</tr>";
            }
            echo "</table>";
        }
    }
}
Example #3
0
 /**
  * create the dropdowns based on the previously set query or result array
  * @throws \Exception
  */
 protected function createDropdowns()
 {
     if (empty($this->data)) {
         throw new \Exception('Error creating dropdowns, because there are no results to create dropdowns from.');
     }
     // the separator we use to glue the values of the different columns together to ensure uniqueness
     $separator = '_';
     // collect all values with their parent value into $options
     $options = array();
     foreach ($this->data as $row) {
         $class = null;
         foreach ($row as $colname => $value) {
             // we store $class . $separator . $value instead of just $val, because it is possible that different level1's have same level2's
             // and by collecting this way, they will not get overwritten
             // Example: [ADSL2+][1. Geen mening]  and  [Fiber][1. Geen mening]
             $title = $class . $separator . $value;
             $options[$colname][$title] = array('value' => $value, 'label' => $value, 'class' => $class);
             $class = $title;
             // for the next column
         }
     }
     $selected = $this->getSelected();
     foreach ($options as $ddName => $ddOptionsAttributes) {
         // create the dropdown
         $dropdown = new Dropdown($ddName);
         $dropdown->setLabel(initcap($ddName));
         $dropdown->prependOption('', '-- all --');
         $dropdown->appendOptionClass('');
         // also add dummy values here
         $dropdown->appendOptionTitle('');
         // create the options with class and title
         foreach ($ddOptionsAttributes as $title => $attributes) {
             // add as option if label is not empty
             if (!empty($attributes['label'])) {
                 $dropdown->appendOption($attributes['value'], $attributes['label']);
                 // replace spaces and other invalid class characters with underscores
                 // based on the class we search for parent options with title equals that class, so title needs the same replacements
                 $dropdown->appendOptionClass($this->toValidHtmlId($attributes['class'], '_'));
                 $dropdown->appendOptionTitle($this->toValidHtmlId($title, '_'));
             }
         }
         // set the selected value
         if (is_array($selected) && sizeof($selected)) {
             $dropdown->setSelected(array_shift($selected));
         }
         // add to array of dropdowns
         $this->dropdowns[] = $dropdown;
     }
     // refresh the posted values
     if ($this->isPosted()) {
         $this->setPosted();
     }
 }
Example #4
0
 function parseTracks($entryBlock)
 {
     // Collect titles in two passes
     // In the first pass, just find the raw data: the lines that begin
     // with TITLEnn. A long title can wrap around, e.g.:
     //	TITLE5=This is a ve
     //	TITLE5=ry long title
     // so we append to what's already in $entry[tracks][n].
     $tracks = NULL;
     if (preg_match_all("/^TTITLE([0-9]+)=([^\$]+)\$/mU", $entryBlock, $matches)) {
         for ($i = 0; $i < count($matches[2]); $i++) {
             $tracks[$matches[1][$i]] .= $matches[2][$i];
         }
     }
     // Now that we have the raw titles, clean them up. This is done in
     // a separate loop rather than the preceding one because a title
     // might be split in the middle of a word, so ucwords() would
     // capitalize whatever happened to be at the beginning of a split
     // line ("This Is A VeRy Long Title", above).
     if (is_array($tracks)) {
         for ($i = 0; $i < count($tracks); $i++) {
             $tracks[$i] = initcap(preg_replace('/[\\s]+/', ' ', trim($tracks[$i])));
         }
     }
     return $tracks;
 }