Beispiel #1
0
 static function create_tree(ArrayIterator &$it)
 {
     if (!in_array($it->current()["term"], self::operators_dictionary)) {
         $leaf = new leaf($it->current());
         $it->next();
         return $leaf;
     } else {
         if ($it->current()["term"] == "not") {
             $it->next();
             $op = self::create_tree($it);
             return new notEx($op);
         } else {
             if ($it->current()["term"] == "and") {
                 $it->next();
                 $left = self::create_tree($it);
                 $right = self::create_tree($it);
                 return new andEx($left, $right);
             } else {
                 if ($it->current()["term"] == "or") {
                     $it->next();
                     $left = self::create_tree($it);
                     $right = self::create_tree($it);
                     return new orEx($left, $right);
                 }
             }
         }
     }
     return null;
 }
Beispiel #2
0
 /**
  * Switches to alternate nicks as needed when nick collisions occur.
  *
  * @return void
  */
 public function onResponse()
 {
     // If no alternate nick list was found, return
     if (empty($this->iterator)) {
         return;
     }
     // If the response event indicates that the nick set is in use...
     $code = $this->getEvent()->getCode();
     if ($code == Phergie_Event_Response::ERR_NICKNAMEINUSE) {
         // Attempt to move to the next nick in the alternate nick list
         $this->iterator->next();
         // If another nick is available...
         if ($this->iterator->valid()) {
             // Switch to the new nick
             $altNick = $this->iterator->current();
             $this->doNick($altNick);
             // Update the connection to reflect the nick change
             $this->getConnection()->setNick($altNick);
         } else {
             // If no other nicks are available...
             // Terminate the connection
             $this->doQuit('All specified alternate nicks are in use');
         }
     }
 }
 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
Beispiel #4
0
 public function next()
 {
     $this->items->next();
     if (!$this->items->valid()) {
         $this->page++;
         $this->load();
     }
 }
 private function dayInfo()
 {
     $this->daysInfo = new ArrayIterator();
     while ($this->days->valid()) {
         $day = explode(") - ", $this->days->current());
         $infos = explode("/", $day[1]);
         $this->daysInfo->append($this->buildWeatherDayInfo($day[0], $infos));
         $this->days->next();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (!$this->isExecuted) {
         $this->isExecuted = true;
         $this->results = $this->getResults();
     }
     if (null !== ($result = $this->results->current())) {
         $this->results->next();
         $this->stepExecution->incrementSummaryInfo('read');
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->results) {
         $items = $this->readItems();
         $this->results = new \ArrayIterator($items);
     }
     if (null !== ($result = $this->results->current())) {
         $this->results->next();
         $this->stepExecution->incrementSummaryInfo('read');
     }
     return $result;
 }
 /**
  * {@inheritDoc}
  */
 public function proceed(CommandMessageInterface $commandProceedWith = null)
 {
     if (null !== $commandProceedWith) {
         $this->command = $commandProceedWith;
     }
     if ($this->chain->valid()) {
         $next = $this->chain->current();
         $this->chain->next();
         return $next->handle($this->command, $this->unitOfWork, $this);
     } else {
         return $this->handler->handle($this->command, $this->unitOfWork);
     }
 }
 public function next()
 {
     $this->eventsIterator->next();
     $this->currentKey++;
     if ($this->eventsIterator->valid()) {
         return;
     }
     $this->feedIterator->next();
     if ($this->feedIterator->valid()) {
         $this->eventsIterator = $this->newEventsIterator();
     } else {
         $this->feedIterator = null;
     }
 }
 public function getById($id)
 {
     $this->conex = DataBase::getInstance();
     $stid = oci_parse($this->conex, "SELECT *\n\t\t\tFROM FISC_CIUDADANO WHERE ID_CIUDADANO=:id");
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id', $id);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Obtener los resultados de la consulta
     $alm = new FiscCiudadano();
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $alm;
 }
Beispiel #11
0
 public function processStatesItr(ArrayIterator $statesItr)
 {
     // ArrayIterator
     for ($statesItr; $statesItr->valid(); $statesItr->next()) {
         echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL;
     }
 }
 /**
  *
  *@param $id_ciu
  *
  *
  **/
 public function queryByIC($id_ciu)
 {
     $this->conex = DataBase::getInstance();
     $stid = oci_parse($this->conex, "SELECT * FROM TBL_REPRESENTANTEEMPRESAS WHERE CLV_REPRESENTANTE=:id_ciu");
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id_ciu', $id_ciu);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     $result = new RepresentanteEmpresa();
     // Obtener los resultados de la consulta
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         while ($it->valid()) {
             $result->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $result;
 }
 /**
 * Replace portion of the string
 *
 * @deprecated
 *
 * @param integer $index
 * @param string $value
 * @param integer $start
 * @param integer $length
 *
 * @access public
 * @return void
 */
 public function ReplaceChunk($index, $value, $start = 0, $length = null)
 {
     if (null !== $length) {
         $this->length = $length;
     }
     switch (true) {
         case is_string($value):
             $this->temp_string = new \ArrayIterator(str_split($value));
             if (null === $length) {
                 $this->length = strlen($value);
             }
             break;
         case $value instanceof \ArrayIterator:
             $this->temp_string = $value;
             if (null === $length) {
                 $this->length = $value->count();
             }
             break;
         case is_array($value):
             $this->temp_string = new \ArrayIterator($value);
             if (null === $length) {
                 $this->length = count($value);
             }
             break;
         default:
             throw new \Exception('Invalid data type', 101);
     }
     $this->temp_string->seek($start);
     for ($i = $start; $i < $this->length; $i++) {
         $this->offsetSet($index, $this->temp_string->current());
         $index++;
         $this->temp_string->next();
     }
     $this->temp_string = null;
 }
Beispiel #14
0
 /**
  * Sets the internal pointer on the next element.
  *
  * @return boolean	True, if the map has a next element, false otherwise
  */
 public function next()
 {
     if ($this->initializeIterator()) {
         $this->iterator->next();
     }
     return $this->iterator->valid();
 }
Beispiel #15
0
/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
 protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1)
 {
     $output = "";
     $rownumber = 0;
     foreach ($rows as $row) {
         if ($row->cols) {
             $columns = array();
             foreach ($row->cols as $col) {
                 $nextcontent = $splitcontent->current();
                 $isholder = !isset($col->rows);
                 if ($isholder) {
                     $splitcontent->next();
                     //advance iterator if there are no sub-rows
                     $pos++;
                     //wrap split content in a HTMLText object
                     $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content");
                     $dbObject->setOptions(array("shortcodes" => true));
                     $nextcontent = $dbObject;
                 }
                 $width = $col->width ? (int) $col->width : 1;
                 //width is at least 1
                 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null));
             }
             $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template);
         } else {
             //every row should have columns!!
         }
     }
     return $output;
 }
Beispiel #17
0
 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->yaml) {
         $fileData = $this->getFileData();
         if (null === $fileData) {
             return null;
         }
         $this->yaml = new \ArrayIterator($fileData);
     }
     if ($data = $this->yaml->current()) {
         $this->yaml->next();
         if (null !== $this->stepExecution) {
             $this->stepExecution->incrementSummaryInfo('read_lines');
         }
         try {
             $data = $this->converter->convert($data);
         } catch (DataArrayConversionException $e) {
             $this->skipItemFromConversionException($data, $e);
         }
         return $data;
     }
     // if not used in the context of an ItemStep, the previous read file will be returned
     $this->flush();
     return null;
 }
 public function matchesList(array $items)
 {
     $itemIterator = new \ArrayIterator($items);
     $matcherIterator = new \ArrayIterator($this->getMatchers());
     $currentMatcher = null;
     if ($matcherIterator->valid()) {
         $currentMatcher = $matcherIterator->current();
     }
     while ($itemIterator->valid() && null !== $currentMatcher) {
         $hasMatch = $currentMatcher->matches($itemIterator->current());
         if ($hasMatch) {
             $matcherIterator->next();
             if ($matcherIterator->valid()) {
                 $currentMatcher = $matcherIterator->current();
             } else {
                 $currentMatcher = null;
             }
         }
         $itemIterator->next();
     }
     //echo sprintf("%s->%s, %s->%s\n", $itemIterator->key(), $itemIterator->count(),
     //      $matcherIterator->key(), $matcherIterator->count());
     if (null !== $currentMatcher && !$currentMatcher->matches(null)) {
         $this->reportFailed($currentMatcher);
         return false;
     }
     $matcherIterator->next();
     return $this->matchRemainder($matcherIterator);
 }
Beispiel #19
0
/**
 * USU5 function to return the base filename
 */
function usu5_base_filename()
{
    // Probably won't get past SCRIPT_NAME unless this is reporting cgi location
    $base = new ArrayIterator(array('SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL'));
    while ($base->valid()) {
        if (array_key_exists($base->current(), $_SERVER) && !empty($_SERVER[$base->current()])) {
            if (false !== strpos($_SERVER[$base->current()], '.php')) {
                // ignore processing if this script is not running in the catalog directory
                if (dirname($_SERVER[$base->current()]) . '/' != DIR_WS_HTTP_CATALOG) {
                    return $_SERVER[$base->current()];
                }
                preg_match('@[a-z0-9_]+\\.php@i', $_SERVER[$base->current()], $matches);
                if (is_array($matches) && array_key_exists(0, $matches) && substr($matches[0], -4, 4) == '.php' && (is_readable($matches[0]) || false !== strpos($_SERVER[$base->current()], 'ext/modules/'))) {
                    return $matches[0];
                }
            }
        }
        $base->next();
    }
    // Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php
    if ($_SERVER['SCRIPT_NAME'] == '/' || $_SERVER['PHP_SELF'] == '/') {
        return HTTP_SERVER;
    }
    trigger_error('USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING);
}
Beispiel #20
0
 /**
  * Helper method for recursively building a parse tree.
  *
  * @param ArrayIterator $tokens Stream of  tokens
  *
  * @return array Token parse tree
  *
  * @throws LogicException when nesting errors or mismatched section tags are encountered.
  */
 private function _buildTree(ArrayIterator $tokens)
 {
     $stack = array();
     do {
         $token = $tokens->current();
         $tokens->next();
         if ($token === null) {
             continue;
         } else {
             switch ($token[Handlebars_Tokenizer::TYPE]) {
                 case Handlebars_Tokenizer::T_END_SECTION:
                     $newNodes = array();
                     $continue = true;
                     do {
                         $result = array_pop($stack);
                         if ($result === null) {
                             throw new LogicException('Unexpected closing tag: /' . $token[Handlebars_Tokenizer::NAME]);
                         }
                         if (!array_key_exists(Handlebars_Tokenizer::NODES, $result) && isset($result[Handlebars_Tokenizer::NAME]) && $result[Handlebars_Tokenizer::NAME] == $token[Handlebars_Tokenizer::NAME]) {
                             $result[Handlebars_Tokenizer::NODES] = $newNodes;
                             $result[Handlebars_Tokenizer::END] = $token[Handlebars_Tokenizer::INDEX];
                             array_push($stack, $result);
                             break 2;
                         } else {
                             array_unshift($newNodes, $result);
                         }
                     } while (true);
                     break;
                 default:
                     array_push($stack, $token);
             }
         }
     } while ($tokens->valid());
     return $stack;
 }
 /**
  *
  *@param $id_ciu
  *
  *
  **/
 public function getById($id_jefe)
 {
     $this->conex = DataBase::getInstance();
     //Consulta SQL
     $consulta = "SELECT * FROM FISC_JEFE_OFICINA WHERE \n\t\t\t\t\t\tID_JEFE=:id_jefe";
     $stid = oci_parse($this->conex, $consulta);
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id_jefe', $id_jefe);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     $result = array();
     // Obtener los resultados de la consulta
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         $alm = new Denuncia();
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
         $result[] = $alm;
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $result;
 }
 public function next()
 {
     parent::next();
     if (!parent::valid()) {
         $this->source->next();
     }
 }
Beispiel #23
0
 /**
  * Helper method for recursively building a parse tree.
  *
  * @param \ArrayIterator $tokens Stream of tokens
  *
  * @throws \LogicException when nesting errors or mismatched section tags
  * are encountered.
  * @return array Token parse tree
  *
  */
 private function _buildTree(\ArrayIterator $tokens)
 {
     $stack = array();
     do {
         $token = $tokens->current();
         $tokens->next();
         if ($token !== null) {
             switch ($token[Tokenizer::TYPE]) {
                 case Tokenizer::T_END_SECTION:
                     $newNodes = array();
                     do {
                         $result = array_pop($stack);
                         if ($result === null) {
                             throw new \LogicException('Unexpected closing tag: /' . $token[Tokenizer::NAME]);
                         }
                         if (!array_key_exists(Tokenizer::NODES, $result) && isset($result[Tokenizer::NAME]) && $result[Tokenizer::NAME] == $token[Tokenizer::NAME]) {
                             $result[Tokenizer::NODES] = $newNodes;
                             $result[Tokenizer::END] = $token[Tokenizer::INDEX];
                             array_push($stack, $result);
                             break;
                         } else {
                             array_unshift($newNodes, $result);
                         }
                     } while (true);
                     // There is no break here, since we need the end token to handle the whitespace trim
                 // There is no break here, since we need the end token to handle the whitespace trim
                 default:
                     array_push($stack, $token);
             }
         }
     } while ($tokens->valid());
     return $stack;
 }
Beispiel #24
0
 /**
  * Update = $sql = "UPDATE tabla SET campo1 = ?, campo2 = ?, campo3 = ?
  * WHERE idcampo = ?"
  * $stm->bindValue(4, idValor);  
  */
 public function update($table, $data, $where, $id)
 {
     $result = null;
     $iterator = new ArrayIterator($data);
     $sql = "UPDATE {$table} SET ";
     while ($iterator->valid()) {
         $sql .= $iterator->key() . " = ?, ";
         $iterator->next();
     }
     //Se elimina los dos ultimos caracteres (la coma y el espacio)
     $sql = substr($sql, 0, -2);
     $sql .= " WHERE {$where} = ?";
     $stm = $this->_getDbh()->prepare($sql);
     $i = 1;
     foreach ($iterator as $param) {
         $stm->bindValue($i, $param);
         $i++;
     }
     /**
      * Se asigna el bindValue para el parametro $id, como no esta contemplado en los ciclos del $data,
      * se asigna en la posicion ($iterator->count()+1) y se le asigna el tipo de dato: PDO::PARAM_INT 
      */
     $stm->bindValue($iterator->count() + 1, $id, PDO::PARAM_INT);
     $result = $stm->execute();
     return $result;
 }
 /**
  * Move forward to the next cache entry.
  *
  * @return void
  * @api
  */
 public function next()
 {
     if ($this->cacheEntriesIterator === null) {
         $this->rewind();
     }
     $this->cacheEntriesIterator->next();
 }
Beispiel #26
0
 /**
  * iterate the complete data collection and execute callback for each key => value pair passing the key
  * and the value to the callback function/method as first and second parameter. the callback must be
  * a valid callable that can be executed call_user_func_array
  *
  * @error 16307
  * @param callable $callback expects the callback function/method
  * @return void
  */
 public function each(callable $callback)
 {
     while ($this->iterator->valid()) {
         call_user_func_array($callback, array($this->iterator->key(), $this->iterator->current()));
         $this->iterator->next();
     }
 }
 public function next()
 {
     parent::next();
     if ($this->valid()) {
         $this->sum += parent::current();
     }
 }
 function printer(ArrayIterator $iterator){
     while($iterator->valid()){
         print_r($iterator->current());
         echo "<br /><br />";
         $iterator->next();
     }
 }
 /**
  * Assert that the given commands have been dispatched in the exact sequence provided.
  *
  * @param array $expected The commands expected to have been published on the bus
  * @throws GovernorAssertionError
  */
 public function assertDispatchedEqualTo(array $expected = array())
 {
     $actual = $this->commandBus->getDispatchedCommands();
     if (count($expected) !== count($actual)) {
         throw new GovernorAssertionError(sprintf("Got wrong number of commands dispatched. Expected <%s>, got <%s>", count($expected), count($actual)));
     }
     $actualIterator = new \ArrayIterator($actual);
     $expectedIterator = new \ArrayIterator($expected);
     $counter = 0;
     while ($actualIterator->valid()) {
         $actualItem = $actualIterator->current();
         $expectedItem = $expectedIterator->current();
         if ($expectedItem instanceof CommandMessageInterface) {
             if ($expectedItem->getPayloadType() !== $actualItem->getPayloadType()) {
                 throw new GovernorAssertionError(sprintf("Unexpected payload type of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getPayloadType(), $actualItem->getPayloadType()));
             }
             $this->assertCommandEquality($counter, $expectedItem->getPayloadType(), $actualItem->getPayload());
             if ($expectedItem->getMetaData() !== $actualItem->getMetaData()) {
                 throw new GovernorAssertionError(sprintf("Unexpected Meta Data of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getMetaData(), $actualItem->getMetaData()));
             }
         } else {
             $this->assertCommandEquality($counter, $expectedItem, $actualItem->getPayload());
         }
         $counter++;
         $actualIterator->next();
         $expectedIterator->next();
     }
 }
 public function testRewindRestartsIteratorToBeginning()
 {
     $iterator = new ArrayIterator(array('foo' => 'bar', 'oof' => 'rab'));
     $iterator->next();
     $iterator->rewind();
     $this->assertSame('foo', $iterator->key());
     $this->assertSame('bar', $iterator->current());
 }