public function bar()
 {
     $x = Is_array($array);
     $y = some_thing($x);
 }
Пример #2
0
 /**
 * [#beging ...#]...[#end ...#] tag parsing
 *
 * @access private
 * @param string $res template strings
 * @param array $hash data params
 */
 function parseArrays(&$res, &$hash, $dir)
 {
     // [#begin ARRAY#][#DATA#][#end ARRAY#] - arrays/blocks
     while (preg_match_all('/\\[#begin (.*?)#\\](.*?)\\[#end \\1#\\]/is', $res, $matches, PREG_PATTERN_ORDER)) {
         $count_matches_0 = count($matches[0]);
         for ($i = 0; $i < $count_matches_0; $i++) {
             $var = $hash[$matches[1][$i]];
             $line1 = $matches[2][$i];
             $res1 = "";
             if (Is_array($var) && count($var) > 0 && !isset($var[0])) {
                 // hashtable
                 if (preg_match_all("/<#{$matches[1][$i]}\\.(\\w+?)#>/", $line1, $matches2, PREG_PATTERN_ORDER)) {
                     for ($m = 0; $m < count($matches2[1]); $m++) {
                         @($line1 = str_replace($matches2[0][$m], $this->templateSafe($var[$matches2[1][$m]]), $line1));
                     }
                 }
                 $res1 .= $this->parse($line1, $var, $dir);
             } elseif (Is_Array($var) && count($var) > 0 && Is_Array($var[0])) {
                 //    echo $matches[1][$i]."<br>";
                 // index array
                 $count_var = count($var);
                 for ($k = 0; $k < $count_var; $k++) {
                     $line2 = $line1;
                     $matches1 = array();
                     // <#ARRAY.VARIABLE#> - array variables
                     if (preg_match_all("/<#{$matches[1][$i]}\\.(\\w+?)#>/", $line1, $matches1, PREG_PATTERN_ORDER)) {
                         $count_matches1_1 = count($matches1[1]);
                         for ($m = 0; $m < $count_matches1_1; $m++) {
                             @($line2 = str_replace($matches1[0][$m], $this->templateSafe($var[$k][$matches1[1][$m]]), $line2));
                         }
                     }
                     // IF operations if no sub-arrays
                     if (!Is_Integer(strpos($line2, "[#begin"))) {
                         // CONDITIONS
                         if (Is_Integer(strpos($line2, "[#if"))) {
                             $this->parseIf($line2, $var[$k]);
                         }
                         $this->parseVariables($line2, $var[$k]);
                     }
                     // SELF-CALL FOR ARRAY ELEMENT
                     $line2 = str_replace("[#tree " . $matches[1][$i] . "#]", "[#begin " . $matches[1][$i] . "#]" . $line1 . "[#end " . $matches[1][$i] . "#]", $line2);
                     if (Is_Integer(strpos($line2, "[#"))) {
                         $res1 .= $this->parse($line2, $var[$k], $dir);
                     } else {
                         $res1 .= $line2;
                     }
                 }
             } elseif (Is_array($var) && count($var) > 0 && isset($var[0]) && !Is_Array($var[0])) {
                 // NOT HASH TABLE - PLAIN ARRAY
                 $this->parseHashes($line1, $hash);
                 if (isset($hash['VALUE'])) {
                     $tmp = $hash['VALUE'];
                 }
                 $hash['__Count__'] = count($var);
                 for ($k = 0; $k < count($var); $k++) {
                     $hash['VALUE'] =& $var[$k];
                     $hash['__Key__'] = $k;
                     $res1 .= $this->parse($line1, $hash, $dir);
                 }
                 if (isset($tmp)) {
                     $hash['VALUE'] = $tmp;
                 }
                 unset($tmp);
                 unset($hash['__Count__']);
                 unset($hash['__Key__']);
             }
             $res = str_replace($matches[0][$i], $res1, $res);
         }
     }
 }
Пример #3
0
/**
* @deprecated
*/
function aColsModeProj(&$table, $mode, $projection = '')
{
    if (!Is_array($table)) {
        $table = dd_tableref($table);
    }
    // begin with the info from the data dictionary
    $cols1 = aColInfoFromDD($table);
    // Combine the base parameters with the parameters
    // for a particular mode
    $keys = array_keys($cols1['base']);
    $cols2 = array();
    foreach ($keys as $key) {
        $cols2[$key] = array_merge($cols1['base'][$key], $cols1[$mode][$key]);
    }
    // Make a javascript routine to calculate extended values
    //
    aColsModeProjcalcRow($table, $cols2);
    // Call out to the projection resolver, which includes
    // nifty row-level security, and get the list of
    // columns we will handle
    //
    $colsp = DDProjectionResolve($table, $projection);
    foreach ($colsp as $column_id) {
        $cols3[$column_id] = $cols2[$column_id];
        // while we're going row by row, set some props.
        // This way downstream stuff doesn't need to be
        // told again what mode we are in.
        $cols3[$column_id]['mode'] = $mode;
        // KFD 3/1/08, correction for column security
        if (ArraySafe($table['flat'][$column_id], 'securero') == 'Y' && $mode != 'search') {
            $cols3[$column_id]['writable'] = false;
        }
        // KFD 3/21/08, add in a calculated tooltip, if option is set
        if (OPtionGet('TOOLTIP', 'N') != 'NONE') {
            if (ArraySafe($table['flat'][$column_id], 'tooltip') == '') {
                $tooltip = '';
                $aid = trim($table['flat'][$column_id]['auto_formula']);
                switch (trim($table['flat'][$column_id]['automation_id'])) {
                    case 'SEQUENCE':
                        $tooltip = "This value is automatically generated";
                        break;
                    case 'SUM':
                        $tooltip = "This value is the calculated sum of " . $aid;
                        break;
                    case 'MAX':
                        $tooltip = "This value is the calculated minimum from " . $aid;
                        break;
                    case 'MIN':
                        $tooltip = "This value is the calculated minimum from " . $aid;
                        break;
                }
                if ($tooltip != '') {
                    $cols3[$column_id]['tooltip'] = $tooltip;
                }
            }
        }
    }
    return $cols3;
}