예제 #1
0
 public function revoke_read($pPersonOrGroup)
 {
     $this->steamobject->set_read_access($pPersonOrGroup, 0);
     if (__isset("authorized_read")) {
         $authorized_discuss = __get("authorized_read");
         array_unset($authorized_discuss[array_search($authorized_discuss, $pPersonOrGroup)]);
         __set("authorized_read", $authorized_discuss);
     }
 }
예제 #2
0
파일: Config.php 프로젝트: ntd1712/common
 /** {@inheritdoc} @override */
 public function all(array $excludes = [])
 {
     if (!empty($excludes)) {
         foreach ($excludes as $v) {
             array_unset($this->data, $v);
         }
     }
     return $this->data;
 }
예제 #3
0
 public function hash($data)
 {
     if (array_key_exists('password', $data)) {
         $password = array_unset($data, "password");
         if (!empty($password)) {
             $data['password'] = Security::hash($password, 'sha1');
         }
     }
     return $data;
 }
예제 #4
0
파일: Pdf.php 프로젝트: verticis/boleto-oop
 public function __construct($data = array())
 {
     if (array_key_exists('library', $data)) {
         $library = array_unset($data, 'library');
         $library .= '_Library';
         require_once 'lib/utils/Pdf/' . $library . '.php';
         //pr($library);
         $this->object = new $library($data);
     } else {
         throw new PdfException('Library name not specified');
     }
 }
예제 #5
0
 /**
  * test array_unset with objects
  */
 function testArrayUnset_object()
 {
     $t1 = (object) ['foo' => 1, 'bar' => 20, 'qux' => 99];
     $t2 = (object) ['foo' => 2, 'bar' => 30, 'qux' => 99];
     $t3 = (object) ['foo' => 3, 'bar' => 40];
     $t4 = (object) ['foo' => 4, 'qux' => 99];
     $array = [$t1, $t2, $t3, $t4];
     $expect = [(object) ['foo' => 1, 'qux' => 99], (object) ['foo' => 2, 'qux' => 99], (object) ['foo' => 3], (object) ['foo' => 4, 'qux' => 99]];
     array_unset($array, 'bar');
     $this->assertEquals($expect, $array);
     $this->assertEquals($t1, $array[0]);
 }
예제 #6
0
 public function input($name, $options = array())
 {
     $options += array('name' => $name, 'type' => 'text', 'id' => 'Form' . Inflector::camelize($name), 'label' => Inflector::humanize($name), 'div' => true, 'value' => '');
     $label = array_unset($options, 'label');
     $div = array_unset($options, 'div');
     $type = $options['type'];
     switch ($options['type']) {
         case 'select':
             unset($options['type']);
             $input = $this->select($name, $options);
             break;
         case 'radio':
             $options['legend'] = $label;
             $label = false;
             $input = $this->radio($name, $options);
             break;
         case 'textarea':
             unset($options['type']);
             $value = Sanitize::html(array_unset($options, 'value'));
             $input = $this->html->tag('textarea', $value, $options);
             break;
         case 'hidden':
             $div = $label = false;
         default:
             if ($name == 'password') {
                 $options['type'] = 'password';
             }
             $options['value'] = Sanitize::html($options['value']);
             $input = $this->html->tag('input', '', $options, true);
     }
     if ($label) {
         $for = array('for' => $options['id']);
         $input = $this->html->tag('label', $label, $for) . $input;
     }
     if ($div) {
         $input = $this->div($div, $input, $type);
     }
     return $input;
 }
예제 #7
0
 /**
  *	Retorna o texto já aplicadas as suas condições
  *	
  *	@param	string	$col a coluna que será comparada
  *	@param	array	$conditions array com as condições
  *	@param integer	$row	O número da linha no array de dados
  *	@return string	O texto formatado e aplicado as condições
  */
 private function applyConditions($col, $conditions, $row)
 {
     //valor dessa linha e desse campo
     $curValue = $this->data[$row][$col];
     foreach ($conditions as $key => $cond) {
         $params = $conditions[$key];
         //Se for acima da versão 0.2
         //if((SPAGHETTI_VERSION >= 0.2)):
         $comparison = Validation::comparison($curValue, $params['operator'], $params['comparator']);
         //Se for a versão 0.1, não suportará operadores de comparação
         //else:
         //	$comparison = $curValue == $params['comparator'];
         //endif;
         //Se a comparação foi promissora
         if ($comparison) {
             //Se existir um label
             //$alt   = isset($params['alt'])   ? $params['alt'] : '';
             $label = isset($params['label']) ? $this->isImage($params['label'], $params) : $curValue;
             //Se um link foi definido
             $return = isset($params['href']) ? $this->link($label, $params['href']) : $label;
             //Se uma class de linha tiver definida
             if (isset($params['rowClass'])) {
                 $this->rowClass[$row] = array_unset($params, 'rowClass');
                 //$this->rowClass[$row] = $params['rowClass'];
             }
             //Se uma classe de célula estiver definida
             if (isset($params['cellClass'])) {
                 $this->cellClass[$col][$row] = array_unset($params, 'cellClass');
                 //					$this->cellClass[$col][$row] = $params['cellClass'];
             }
             $matched = true;
             break;
         }
     }
     //Se após o foreach achou-se o valor
     if ($matched === true) {
         return $this->extract($return, $row);
     } else {
         return $curValue;
     }
 }
예제 #8
0
 function ApplyRedirects($req, $rules)
 {
     $doRedirect = false;
     foreach ($rules as $rule) {
         //if (!empty($rule->match)) { // FIXME - Never ever upgrade to PHP 5.2.6.  It breaks empty() on SimpleXML objects.
         if ($rule->match) {
             $ismatch = true;
             $isexcept = false;
             $matchvars = array(NULL);
             // Force first element to NULL to start array indexing at 1 (regex-style)
             foreach ($rule->match->attributes() as $matchkey => $matchstr) {
                 $checkstr = array_get($req, $matchkey);
                 if ($checkstr !== NULL) {
                     $m = NULL;
                     if (substr($matchstr, 0, 1) == "!") {
                         $ismatch &= !preg_match("#" . substr($matchstr, 1) . "#", $checkstr, $m);
                     } else {
                         $ismatch &= preg_match("#" . $matchstr . "#", $checkstr, $m);
                     }
                     //Logger::Debug("Check rewrite (%s): '%s' =~ '%s' ? %s", $matchkey, $checkstr, $matchstr, ($ismatch ? "YES" : "NO"));
                     if (is_array($m) && count($m) > 0) {
                         if (count($m) > 1) {
                             for ($i = 1; $i < count($m); $i++) {
                                 $matchvars[] = $m[$i];
                             }
                         }
                     }
                 } else {
                     if (substr($matchstr, 0, 1) != "!") {
                         $ismatch = false;
                     }
                 }
             }
             if ($ismatch && $rule->except) {
                 $exceptflag = true;
                 foreach ($rule->except->attributes() as $exceptkey => $exceptstr) {
                     $checkstr = array_get($req, $exceptkey);
                     if ($checkstr !== NULL) {
                         $m = NULL;
                         if (substr($exceptstr, 0, 1) == "!") {
                             $exceptflag &= !preg_match("#" . substr($exceptstr, 1) . "#", $checkstr, $m);
                         } else {
                             $exceptflag &= preg_match("#" . $exceptstr . "#", $checkstr, $m);
                         }
                     }
                 }
                 if ($exceptflag) {
                     $isexcept = true;
                 }
             }
             if ($ismatch && !$isexcept) {
                 // Apply nested rules first...
                 if ($rule->rule) {
                     $req = $this->ApplyRedirects($req, $rule->rule);
                 }
                 // Then process "set" command
                 if ($rule->set) {
                     Logger::Info("Applying redirect:\n   " . $rule->asXML());
                     if (!empty($req["args"]["testredir"])) {
                         print "<pre>" . htmlspecialchars($rule->asXML()) . "</pre><hr />";
                     }
                     foreach ($rule->set->attributes() as $rewritekey => $rewritestr) {
                         if (count($matchvars) > 1 && strpos($rewritestr, "%") !== false) {
                             $find = array(NULL);
                             for ($i = 1; $i < count($matchvars); $i++) {
                                 $find[] = "%{$i}";
                             }
                             $rewritestr = str_replace($find, $matchvars, $rewritestr);
                         }
                         array_set($req, (string) $rewritekey, (string) $rewritestr);
                     }
                     if ($rule["type"] == "redirect") {
                         $doRedirect = 301;
                     } else {
                         if ($rule["type"] == "bounce") {
                             $doRedirect = 302;
                         }
                     }
                 }
                 // And finally process "unset"
                 if ($rule->unset) {
                     $unset = false;
                     foreach ($rule->unset->attributes() as $unsetkey => $unsetval) {
                         if ($unsetkey == "_ALL_" && $unsetval == "ALL") {
                             $req["args"] = array();
                         } else {
                             if (!empty($unsetval)) {
                                 $reqval = array_get($req, $unsetkey);
                                 if ($reqval !== NULL) {
                                     array_unset($req, $unsetkey);
                                     $unset = true;
                                 }
                             }
                         }
                     }
                     if ($unset) {
                         if ($rule["type"] == "redirect") {
                             $doRedirect = 301;
                         } else {
                             if ($rule["type"] == "bounce") {
                                 $doRedirect = 302;
                             }
                         }
                     }
                 }
                 if ($doRedirect !== false) {
                     break;
                 }
             }
         }
     }
     if ($doRedirect !== false) {
         $origscheme = "http" . ($req["ssl"] ? "s" : "");
         if ($req["host"] != $_SERVER["HTTP_HOST"] || $req["scheme"] != $origscheme) {
             $newurl = sprintf("%s://%s%s", $req["scheme"], $req["host"], $req["path"]);
         } else {
             $newurl = $req["path"];
         }
         if (empty($req["args"]["testredir"])) {
             if (empty($req["friendly"])) {
                 $querystr = makeQueryString($req["args"]);
                 $newurl = http_build_url($newurl, array("query" => $querystr));
             } else {
                 $newurl = makeFriendlyURL($newurl, $req["args"]);
             }
             if ($newurl != $req["url"]) {
                 http_redirect($newurl, NULL, true, $doRedirect);
             }
         } else {
             print_pre($req);
         }
     }
     return $req;
 }
예제 #9
0
 /**
  *  Cria caixa de entrada formatada e com label.
  * 
  *  @param string $name Nome do campo de entrada
  *  @param array $options Atributos da tag
  *  @return string Campo de entrada do formulário
  */
 public function input($name, $options = array())
 {
     $options = array_merge(array("name" => $name, "type" => "text", "id" => Inflector::camelize("form_" . Inflector::slug($name)), "label" => Inflector::humanize($name), "div" => true), $options);
     $label = array_unset($options, "label");
     $div = array_unset($options, "div");
     switch ($options["type"]) {
         case "select":
             $selectOptions = $options;
             unset($selectOptions["type"]);
             $input = $this->select($name, $selectOptions);
             break;
         case "radio":
             $options["legend"] = $label;
             $label = false;
             $input = $this->radio($name, $options);
             break;
         case "date":
             $input = $this->date($name, $options);
             break;
         case "textarea":
             $input = $this->tag("textarea", array_unset($options, "value"), $options);
             break;
         default:
             if ($options["type"] == "hidden") {
                 $div = $label = false;
             } elseif ($name == "password") {
                 $options["type"] = "password";
             }
             $input = $this->tag("input", null, $options, false);
     }
     if ($label) {
         $input = $this->tag("label", $label, array("for" => $options["id"])) . $input;
     }
     if ($div) {
         if ($div === true) {
             $div = "input {$options['type']}";
         }
         $input = $this->div($input, $div);
     }
     return $this->output($input);
 }
예제 #10
0
 /**
  *	Retorna o texto já aplicadas as suas condições
  *	
  *	@param	string	$col a coluna que será comparada
  *	@param	array	$conditions array com as condições
  *	@param integer	$row	O número da linha no array de dados
  *	@return string	O texto formatado e aplicado as condições
  */
 private function applyConditions($col, $conditions, $row)
 {
     //valor dessa linha e desse campo
     $curValue = $this->data[$row][$col];
     foreach ($conditions as $key => $cond) {
         $params = $conditions[$key];
         $comparison = Validation::comparison($curValue, $params['operator'], $params['comparator']);
         //Se a comparação foi promissora
         if ($comparison) {
             //Se existir um label
             $label = isset($params['label']) ? $this->isImage($params['label'], $params) : $curValue;
             //Se um link foi definido
             $return = isset($params['href']) ? $this->link($label, $params['href']) : $label;
             //Se uma class de linha tiver definida
             if (isset($params['rowClass'])) {
                 $this->rowClass[$row] = array_unset($params, 'rowClass');
             }
             //Se uma classe de célula estiver definida
             if (isset($params['cellClass'])) {
                 $this->cellClass[$col][$row] = array_unset($params, 'cellClass');
             }
             $matched = true;
             break;
         }
     }
     //Se após o foreach achou-se o valor
     if ($matched === true) {
         return $this->extract($return, $row);
     } else {
         return $curValue;
     }
 }
예제 #11
0
function filter_datajson(&$json_array)
{
    $array =& $json_array['data'];
    foreach ($array as &$value) {
        $value['partial'] = filter_datajsonstats($value['stats'], '/[ay]/');
        $value['supported'] = filter_datajsonstats($value['stats'], '/y/');
        array_unset($value, explode(' ', 'keywords categories description links spec notes stats status usage_perc_y usage_perc_a'));
    }
    return $array;
}
예제 #12
0
 /**
  *	Muda a posição de um campo do formulário
  *	Para a correta mudança de posição do campo, algumas regras
  *	devem ser observadas.
  *	São elas:
  *		- A contagem de posições inicia em 0
  *		- Leve em consideração a lista de campos existentes, inclusive os que não
  *		aparecem, como a abertura e o fechamento do formulário. Nesse caso, na
  *		maioria das vezes a contagem iniciará em 1, pois o "0" será o <form>
  *			
  *	@param int $pos	 A nova posição que a coluna deve assumir, começando do zero
  *	@return object
  */
 public function position($pos)
 {
     $cur_pos = array_search($this->nowfield, array_keys($this->attrs));
     //Só continua se a chave atual for diferente da desejada
     if ($cur_pos !== $pos) {
         $field = $this->attrs;
         $cur[$this->nowfield] = array_unset($field, $this->nowfield);
         $this->attrs = array_merge(array_slice($field, 0, $pos, true), $cur, array_slice($field, $pos));
     }
     return $this;
 }
예제 #13
0
 /**
  *    Cria o html dos campos baseado em algumas configurações
  *    
  *    @param $attrs      os atributos do campo em formato de array, onde a chave é o
  *    atributo e o valor do array é o valor do atributo. 
  *                             'type'=>'text', 'select'=>'multiple'
  *    @param $configs    As configurações do campo:
  *        'field'=>'input', 'opening'=>true, 'uses_label'=>true, 'has_more'=>'none'
  *    @return string Retorna o compo do formulário já formatado
  */
 public function tag($attrs = array(), $configs = array())
 {
     $field = $configs['field'];
     $configs = array_merge(array('opening' => true, 'uses_label' => true, 'label_position' => 'before', 'has_more' => 'none', 'container' => 'div'), $configs);
     $class = isset($attrs['class']) ? $attrs['class'] : "";
     //$class = isset($attrs['class']) ? " class=\"{$attrs['class']}\"" : "";
     if (isset($attrs['src'])) {
         $attrs['src'] = Mapper::url($attrs['src']);
     }
     if (isset($attrs['href'])) {
         $attrs['href'] = Mapper::url($attrs['href']);
     }
     $html = '';
     $closeDiv = '';
     //É input, select ou textarea?
     if (in_array($field, array('input', 'select', 'textarea'))) {
         //O container está definido e não é false
         if ($configs['container'] !== false) {
             //Recebe um container em volta
             $html .= '<' . $configs['container'] . $this->serialize(array('class' => $class)) . '>';
             $closeDiv = '</' . $configs['container'] . '>';
         }
     }
     //Tem prepend?
     if ($prepend = array_unset($attrs, 'prepend')) {
         $html .= $prepend;
     }
     //Tem append?
     if ($append = array_unset($attrs, 'append')) {
     } else {
         $append = '';
     }
     //Estou abrindo o campo?
     if ($configs['opening'] == true) {
         //O campo usa label, e o mesmo foi definido?
         if ($configs['uses_label'] == true && !is_null($attrs['label'])) {
             //O label não está vazio, ou é diference de FALSE?
             if (!empty($attrs['label']) || $attrs['label'] != false) {
                 //Gerando o label
                 $label = "\t<label" . $this->serialize(array('for' => $attrs['id'], 'class' => $class)) . ">" . $attrs['label'] . '</label>';
             }
         }
         $label_text = array_unset($attrs, 'label');
         //Tem value por padrão?
         if ($configs['has_more'] == 'value') {
             $value = array_unset($attrs, 'value');
         }
         //Existe label definido?
         $label = isset($label) ? $label : false;
         //O label deve ser exibido antes ou depois do elemento?
         $html .= $configs['label_position'] == 'before' ? $label : '';
         //Gerando a primeira parte do campo
         $html .= "<{$field}" . $this->serialize($attrs);
         //Verificando o tipo do campo. Se não exige fechamento, se tem um "value"
         // ou se o fechamento virá só depois
         switch ($configs['has_more']) {
             case 'none':
                 $html .= "/>\n";
                 break;
             case 'after':
                 $html .= ">\n";
                 break;
             case 'value':
                 $html .= ">{$value}</{$field}>\n";
                 break;
         }
         //Se for um select
         if ($field == 'select') {
             $html .= $this->makeSelectOptions($attrs['name']);
             $html .= "</select>\n";
         }
         //Se for um fieldset. Chamado pelo radioGroup().
         if ($field == 'fieldset') {
             $html .= '<legend>' . $label_text . '</legend>';
             $html .= $this->makeRadioOptions($attrs['name'], $configs['label_position']);
             $html .= "</fieldset>\n";
         }
     } else {
         $html .= "</{$field}>\n";
     }
     //O label é exibido após o campo
     $html .= $configs['label_position'] == 'after' ? $label : '';
     //Tem append?
     $html .= $append;
     //Fecha a div do campo atual
     $html .= $closeDiv;
     return $html;
 }