static function count_form_rows_or_cols($data, $row = true, $returnvals = false) { $key = $row ? 'row' : 'col'; $count = 0; $vals = array(); $newvalcount = 0; $short_count = count($data[$key . 'short']); $long_count = count($data[$key . 'long']); $min = min($short_count, $long_count); for ($k = 0; $k < $min; $k++) { $short = aget($data, $key . 'short'); //isset($data[$key . 'short'][$k]) ? $data[$key . 'short'][$k] : ''; $short = aget($short, $k); $long = aget($data, $key . 'long'); //isset($data[$key . 'long'][$k]) ? $data[$key . 'long'][$k] : ''; $long = aget($long, $k); $feedback = aget($data, $key . 'feedback'); $feedback = aget($feedback, $k); $shorttext = is_array($short) ? reset($short) : $short; $description = is_array($long) ? reset($long) : $long; $format = is_array($long) ? end($long) : ''; if (!empty($short) || !empty($long)) { $count++; if ($returnvals) { if (array_key_exists($key . 'id', $data) && array_key_exists($k, $data[$key . 'id']) && !empty($data[$key . 'id'][$k])) { $thiskey = $data[$key . 'id'][$k]; } else { $thiskey = $newvalcount; $newvalcount++; } $vals[$thiskey] = compact('shorttext', 'description', 'format', 'feedback'); } } } return $returnvals ? $vals : $count; }
function end_paren() { array_pop($this->context); if ($this->array_brace_count) { if (aget($this->array_assoc_count, $this->array_brace_count)) { $this->array_assoc_count[$this->array_brace_count]--; $this->jsbuf .= ']'; } $this->array_brace_count--; } $this->jsbuf .= ')'; }
function handle_char($char) { switch ($char) { case ';': $in_global_decl = $this->in_global_decl(); if (!in_array($this->context(0), array('(', '{', 'global_scope'))) { array_pop($this->context); } // avoid printing 'global $var;' lines. if ($in_global_decl) { break; } if ($this->need_closing_paren) { $this->jsbuf .= ')'; $this->need_closing_paren--; } $this->jsbuf .= $char; break; case '"': $this->in_quoted_string = !$this->in_quoted_string; $this->jsbuf .= $char; break; case '.': $this->jsbuf .= '+'; break; case ',': if ($this->in_global_decl()) { // variables are global by default in JS. no need to declare them. break; } if ($this->array_brace_count) { if (aget($this->array_assoc_count, $this->array_brace_count)) { $this->array_assoc_count[$this->array_brace_count]--; $this->jsbuf .= ']'; } } $this->jsbuf .= ','; break; case '{': $this->context[] = $char; // create new variable scope $this->local_scope[] = array(); if ($this->context(1) == 'function') { // specify that this is function scope, which is special. $this->local_scope[count($this->local_scope) - 1]['___scope_func'] = true; } // print_r( $this->local_scope ); $this->jsbuf .= $char; break; case '}': array_pop($this->context); if (!in_array($this->context(0), array('(', '{'))) { array_pop($this->context); } array_pop($this->local_scope); $this->jsbuf .= $char; break; case '(': $this->context[] = $char; if ($this->array_brace_count) { break; } $this->jsbuf .= $char; break; case ')': array_pop($this->context); if ($this->array_brace_count) { if (aget($this->array_assoc_count, $this->array_brace_count)) { $this->array_assoc_count[$this->array_brace_count]--; $this->jsbuf .= ']'; } $this->array_brace_count--; } $this->jsbuf .= ')'; break; default: $this->jsbuf .= $char; break; } }
function FAIhookEntry(&$config_space, &$faiobject) { $classname = $faiobject['..']['cn'][0]; $task = aget($faiobject, "faitask"); if ($task == "prepareapt") { $task = "repository"; } // "prepareapt" is deprecated, use "repository" instead $code = aget($faiobject, "faiscript"); $config_space["hooks/{$task}.{$classname}"] = $code; }