/**
  * Walks through the pageIdStack, collects all pageIds
  * as array and passes them on to clearPageCache.
  *
  * @return void
  */
 public function clearCachesOfRegisteredPageIds()
 {
     if (!$this->pageIdStack->isEmpty()) {
         $pageIds = array();
         while (!$this->pageIdStack->isEmpty()) {
             $pageIds[] = (int) $this->pageIdStack->pop();
         }
         $pageIds = array_values(array_unique($pageIds));
         $this->clearPageCache($pageIds);
     }
 }
Exemple #2
0
 public function enterNode(Node $node)
 {
     if ($node instanceof Node\Stmt\Foreach_) {
         $this->checkNestedByReferenceForeach($node);
         $this->foreachStack->push($node);
     } elseif (!$this->foreachStack->isEmpty()) {
         $this->checkInternalArrayPointerAccessInByValueForeach($node);
         $this->checkArrayModificationByFunctionInByReferenceForeach($node);
         $this->checkAddingToArrayInByReferenceForeach($node);
     }
 }
 /**
  * @param \PHP\Manipulator\Token $token
  */
 protected function _checkLevel(Token $token)
 {
     if ($this->isOpeningCurlyBrace($token)) {
         $this->_level++;
         $this->_maxLevel = max(array($this->_level, $this->_maxLevel));
     }
     if ($this->isClosingCurlyBrace($token)) {
         $this->_level--;
         if (!$this->_classStack->isEmpty() && $this->_level === $this->_classStack[count($this->_classStack) - 1]) {
             $this->_classStack->pop();
         }
     }
 }
Exemple #4
0
 /**
  * Converts the current expression into a single matcher, applying
  * coordination operators to operands according to their binding rules
  *
  * @throws \RuntimeException
  * @return \Hamcrest_Matcher
  */
 public function build()
 {
     // Apply Shunting Yard algorithm to convert the infix expression
     // into Reverse Polish Notation. Since we have a very limited
     // set of operators and binding rules, the implementation becomes
     // really simple
     $ops = new \SplStack();
     $rpn = array();
     foreach ($this->parts as $token) {
         if ($token instanceof Operator) {
             while (!$ops->isEmpty() && $token->compare($ops->top()) <= 0) {
                 $rpn[] = $ops->pop();
             }
             $ops->push($token);
         } else {
             $rpn[] = $token;
         }
     }
     // Append the remaining operators
     while (!$ops->isEmpty()) {
         $rpn[] = $ops->pop();
     }
     // Walk the RPN expression to create AnyOf and AllOf matchers
     $stack = new \splStack();
     foreach ($rpn as $token) {
         if ($token instanceof Operator) {
             // Our operators always need two operands
             if ($stack->count() < 2) {
                 throw new \RuntimeException('Unable to build a valid expression. Not enough operands available.');
             }
             $operands = array($stack->pop(), $stack->pop());
             // Check what kind of matcher we need to create
             if ($token->getKeyword() === 'OR') {
                 $matcher = new \Hamcrest_Core_AnyOf($operands);
             } else {
                 // AND, BUT
                 $matcher = new \Hamcrest_Core_AllOf($operands);
             }
             $stack->push($matcher);
         } else {
             $stack[] = $token;
         }
     }
     if ($stack->count() !== 1) {
         throw new \RuntimeException('Unable to build a valid expression. The RPN stack should have just one item.');
     }
     return $stack->pop();
 }
 /**
  * Resolves yield calls tree
  * and gives a return value if outcome of yield is CoroutineReturnValue instance
  *
  * @param \Generator $coroutine nested coroutine tree
  * @return \Generator
  */
 private static function stackedCoroutine(\Generator $coroutine)
 {
     $stack = new \SplStack();
     while (true) {
         $value = $coroutine->current();
         // nested generator/coroutine
         if ($value instanceof \Generator) {
             $stack->push($coroutine);
             $coroutine = $value;
             continue;
         }
         // coroutine end or value is a value object instance
         if (!$coroutine->valid() || $value instanceof CoroutineReturnValue) {
             // if till this point, there are no coroutines in a stack thatn stop here
             if ($stack->isEmpty()) {
                 return;
             }
             $coroutine = $stack->pop();
             $value = $value instanceof CoroutineReturnValue ? $value->getValue() : null;
             $coroutine->send($value);
             continue;
         }
         $coroutine->send((yield $coroutine->key() => $value));
     }
 }
Exemple #6
0
 /**
  * Resets the suites tree with a new root
  *
  * @static
  * @param \DrSlump\Spec\TestSuite
  */
 public static function reset(Spec\TestSuite $root)
 {
     while (!self::$suites->isEmpty()) {
         self::$suites->pop();
     }
     self::$suites->push($root);
 }
Exemple #7
0
 /**
  * 加载指定目录下的配置并生成[绝对路径=>配置]
  * (备用)
  *
  * @param        $filePath
  * @param string $ext
  */
 private function LoadV2($filePath, $ext = '.php')
 {
     $resConfig = [];
     $split = '.';
     if (file_exists($filePath)) {
         $key = basename($filePath, $ext);
         $configs = (include $filePath);
         $keyStack = new \SplStack();
         $keyStack->push([$key, $configs]);
         $whileCount = 0;
         //防止意外进入死循环,限制最多循环1024层
         while (!$keyStack->isEmpty() && $whileCount < 1024) {
             $whileCount++;
             $pair = $keyStack->pop();
             foreach ($pair[1] as $pairKey => $pairVal) {
                 if (is_array($pairVal)) {
                     $keyStack->push([$pair[0] . $split . $pairKey, $pairVal]);
                 } else {
                     $resConfig[$pair[0] . $split . $pairKey] = $pairVal;
                 }
             }
         }
     }
     return $resConfig;
 }
 /**
  * {@inheritdoc}
  */
 public function leaveNode(Node $node)
 {
     if ($this->argumentModificationStack->isEmpty()) {
         return;
     }
     if ($node instanceof Node\FunctionLike) {
         $this->argumentModificationStack->pop();
         return;
     }
     foreach ($this->possiblyArgumentModifyingClasses as $class) {
         if ($node instanceof $class) {
             $this->argumentModificationStack->pop();
             $this->argumentModificationStack->push(true);
             return;
         }
     }
 }
Exemple #9
0
function stackedCoroutine(Generator $gen)
{
    $stack = new SplStack();
    $exception = null;
    for (;;) {
        try {
            if ($exception) {
                $gen->throw($exception);
                $exception = null;
                continue;
            }
            $value = $gen->current();
            if ($value instanceof Generator) {
                $stack->push($gen);
                $gen = $value;
                continue;
            }
            $isReturnValue = $value instanceof CoroutineReturnValue;
            if (!$gen->valid() || $isReturnValue) {
                if ($stack->isEmpty()) {
                    return;
                }
                $gen = $stack->pop();
                $gen->send($isReturnValue ? $value->getValue() : NULL);
                continue;
            }
            if ($value instanceof CoroutinePlainValue) {
                $value = $value->getValue();
            }
            try {
                $sendValue = (yield $gen->key() => $value);
            } catch (Exception $e) {
                $gen->throw($e);
                continue;
            }
            $gen->send($sendValue);
        } catch (Exception $e) {
            if ($stack->isEmpty()) {
                throw $e;
            }
            $gen = $stack->pop();
            $exception = $e;
        }
    }
}
Exemple #10
0
 /**
  * Determine if there is operator token in operator stack
  * 
  * @return boolean
  */
 private function hasOperatorInStack()
 {
     $hasOperatorInStack = false;
     if (!$this->operatorStack->isEmpty()) {
         $top = $this->operatorStack->top();
         if ($top instanceof Operator) {
             $hasOperatorInStack = true;
         }
     }
     return $hasOperatorInStack;
 }
 /**
  * Determine if there is operator token in operato stack
  * 
  * @return boolean
  */
 private function hasOperatorInStack()
 {
     $hasOperatorInStack = false;
     if (!$this->operatorStack->isEmpty()) {
         $top = $this->operatorStack->top();
         if (Token::T_OPERATOR == $top->getType()) {
             $hasOperatorInStack = true;
         }
     }
     return $hasOperatorInStack;
 }
Exemple #12
0
 /**
  * To remove a property from the instance.
  *
  * Data management : In PHP7, \Closure::bind(), \Closure::bindTo() and \Closure::call()
  * can not change the scope about non real closure (all closures obtained by \ReflectionMethod::getClosure()) to avoid
  * error due to compilation pass with self::
  *
  * Thise change does not impact rebinding of $this, but the scope stay unchanged, and private or protected attributes
  * or method are not available in this closure (the scope differ).
  *
  * So we use magic call to restore this behavior during a calling
  *
  * @param string $name
  *
  * @throws \ErrorException of the property is not accessible
  */
 public function __unset(string $name)
 {
     if (!$this->callerStatedClassesStack->isEmpty() && property_exists($this, $name)) {
         unset($this->{$name});
         return;
     }
     if ($this->isPublicProperty($name)) {
         unset($this->{$name});
         return;
     }
     throw new \ErrorException('Error: Cannot access private property ' . get_class($this) . '::' . $name);
 }
Exemple #13
0
 /**
  *  get the total executed time
  *  
  *  @return float
  */
 public function getTotal()
 {
     $ret_total = $this->total;
     // if there is still stuff on the stack, the first item is the oldest, so use that
     // to calculate the total time...
     if (!$this->stack_started->isEmpty()) {
         $profile_map = $this->stack_started->top();
         $ret_total += $this->getTime($profile_map['start'], microtime(true));
     }
     //if
     return $ret_total;
 }
Exemple #14
0
 /**
  * @param bool $pop
  * @return Item|null
  */
 public function top($pop = false)
 {
     if ($this->items->isEmpty()) {
         return null;
     }
     if ($pop) {
         return $this->items->pop();
     }
     while ($top = $this->items->top()) {
         /** @var Item $top */
         // WARNING Non-parallel code for the stack may be modified by other code
         if ($top->getState() instanceof StateStopped) {
             $this->handle($this->items->pop());
             if ($this->items->isEmpty()) {
                 return null;
             }
         } else {
             return $top;
         }
     }
     return null;
 }
Exemple #15
0
 /**
  * Conversão de Formato Infixo para Posfixo
  * @return array Fila de Tokens para Cálculo Posfixo
  */
 public function toPostfix()
 {
     /* Analisador Léxico */
     $lexer = $this->getLexer();
     /* Pilha para Conversão */
     $stack = new \SplStack();
     /* Notação Polonesa Reversa */
     $postfix = array();
     /* Execução */
     while (($token = $lexer->getToken()) != null) {
         /* Analisador Sintático */
         if ($token->isA('T_NUMBER') || $token->isA('T_FLOAT') || $token->isA('T_VAR') || $token->isA('T_DEF') || $token->isA('T_BLOCKDEF')) {
             $postfix[] = $token;
         } elseif ($token->isA('T_OPERATOR') || $token->isA('T_ASSIGN')) {
             /* @todo Melhorar Pesquisa */
             $found = false;
             while (!$found) {
                 if ($stack->isEmpty()) {
                     $stack->push($token);
                     $found = true;
                 } else {
                     if ($stack->top()->isA('T_OB')) {
                         $stack->push($token);
                         $found = true;
                     } elseif ($this->precedence($token, $stack->top()) > 0) {
                         $stack->push($token);
                         $found = true;
                     } else {
                         $postfix[] = $stack->pop();
                     }
                 }
             }
         } elseif ($token->isA('T_OB')) {
             $stack->push($token);
         } elseif ($token->isA('T_CB')) {
             while (!$stack->isEmpty() && !$stack->top()->isA('T_OB')) {
                 $postfix[] = $stack->pop();
             }
             $stack->pop();
         } else {
             $format = "Invalid Token '%s' @column %d";
             $message = sprintf($format, $token->getType(), $token->getPosition());
             throw new Exception($message);
         }
     }
     /* Tokens Restantes na Pilha */
     while (!$stack->isEmpty()) {
         $postfix[] = $stack->pop();
     }
     return $postfix;
 }
 /**
  *  return whether the current element is valid
  *
  *  this will pop the previous iterator off the stack (if one is available) if the
  *  current iterator is no longer valid
  *  
  *  @return boolean            
  */
 public function valid()
 {
     $is_valid = $this->iterator->valid();
     if ($is_valid === false) {
         if (!$this->stack->isEmpty()) {
             $this->iterator = $this->stack->pop();
             array_pop($this->keys);
             $is_valid = $this->valid();
         }
         //if
     }
     //if
     return $is_valid;
 }
Exemple #17
0
 /**
  * 将第二个数组递归合并到第一个数组(与系统array_merge_recursive策略不同)
  * 策略为:
  * 如果子项都是数组,则继续根据子项内的Key进行合并;
  * 如果有任一子项不是数组,则使用第二个数组的对应子项覆盖第一个数组的对应子项。
  * (使用Stack实现)
  *
  * @param $ary1
  * @param $ary2
  * @param $recursiveMax 最大递归的层数(防止死循环)
  */
 public static function MergeRecursive(&$ary1, $ary2, $recursiveMax = 256)
 {
     $keyStack = new \SplStack();
     $keyStack->push([&$ary1, $ary2]);
     $count = 0;
     while (!$keyStack->isEmpty() && ++$count < $recursiveMax) {
         $pair = $keyStack->pop();
         foreach ($pair[1] as $pairKey => $pairVal) {
             if (isset($pair[0][$pairKey])) {
                 if (is_array($pair[0][$pairKey]) && is_array($pairVal)) {
                     $keyStack->push([&$pair[0][$pairKey], &$pairVal]);
                     continue;
                 }
             }
             $pair[0][$pairKey] = $pairVal;
         }
     }
 }
 public function wordsToNumber($data)
 {
     // Replace all number words with an equivalent numeric value
     $data = strtr($data, array('zero' => '0', 'a' => '1', 'one' => '1', 'two' => '2', 'three' => '3', 'four' => '4', 'five' => '5', 'six' => '6', 'seven' => '7', 'eight' => '8', 'nine' => '9', 'ten' => '10', 'eleven' => '11', 'twelve' => '12', 'thirteen' => '13', 'fourteen' => '14', 'fifteen' => '15', 'sixteen' => '16', 'seventeen' => '17', 'eighteen' => '18', 'nineteen' => '19', 'twenty' => '20', 'thirty' => '30', 'forty' => '40', 'fourty' => '40', 'fifty' => '50', 'sixty' => '60', 'seventy' => '70', 'eighty' => '80', 'ninety' => '90', 'hundred' => '100', 'thousand' => '1000', 'million' => '1000000', 'billion' => '1000000000', 'and' => ''));
     // Coerce all tokens to numbers
     $parts = array_map(function ($val) {
         return floatval($val);
     }, preg_split('/[\\s-]+/', $data));
     $stack = new SplStack();
     // Current work stack
     $sum = 0;
     // Running total
     $last = null;
     foreach ($parts as $part) {
         if (!$stack->isEmpty()) {
             // We're part way through a phrase
             if ($stack->top() > $part) {
                 // Decreasing step, e.g. from hundreds to ones
                 if ($last >= 1000) {
                     // If we drop from more than 1000 then we've finished the phrase
                     $sum += $stack->pop();
                     // This is the first element of a new phrase
                     $stack->push($part);
                 } else {
                     // Drop down from less than 1000, just addition
                     // e.g. "seventy one" -> "70 1" -> "70 + 1"
                     $stack->push($stack->pop() + $part);
                 }
             } else {
                 // Increasing step, e.g ones to hundreds
                 $stack->push($stack->pop() * $part);
             }
         } else {
             // This is the first element of a new phrase
             $stack->push($part);
         }
         // Store the last processed part
         $last = $part;
     }
     return $sum + $stack->pop();
 }
 /**
  * Looks up the PHP meta data for the element.
  *
  * Allow the parser to build the required PHP object for an element.
  *
  * @param string $name The name of the element.
  * @param arrary $attributes Associative array of the element's attributes.
  *
  * @returns array Associative array containing the PHP meta data.
  */
 private function getPhpMeta($elementName, $attributes)
 {
     $meta = new \StdClass();
     $meta->propertyName = '';
     $meta->phpType = '';
     $meta->repeatable = false;
     $meta->attribute = false;
     $meta->elementName = '';
     $meta->strData = '';
     if (!$this->metaStack->isEmpty()) {
         $parentObject = $this->getParentObject();
         if ($parentObject) {
             $elementMeta = $parentObject->elementMeta($elementName);
             if ($elementMeta) {
                 $meta = $elementMeta;
             }
         }
     } else {
         $meta->phpType = $this->rootObjectClass;
     }
     $meta->phpObject = $this->newPhpObject($meta);
     if ($meta->phpObject) {
         foreach ($attributes as $attribute => $value) {
             // These attribute will simply not exist in a PHP object.
             if ('xmlns' === $attribute) {
                 continue;
             }
             $attributeMeta = $meta->phpObject->elementMeta($attribute);
             // Attribute in the XML may not exist as a property name in the class.
             // This could happen if the SDK is out of date with what eBay return.
             // It could also happen if eBay return elements that are not mentioned in any WSDL.
             if ($attributeMeta) {
                 $attributeMeta->strData = $value;
                 $meta->phpObject->{$attributeMeta->propertyName} = $this->getValueToAssignToProperty($attributeMeta);
             }
         }
     }
     return $meta;
 }
 /**
  * Compiles the given template tags.
  *
  * Throws an exception in case there are unclosed tags remaining.
  *
  * @param array $templateTags The template tags to compile
  * @param array $textBlocks Text blocks outside of template-tags
  * @throws \Ableron\Core\Exception\SystemException
  * @return array
  */
 private function compileTemplateTags($templateTags, $textBlocks)
 {
     // prepare return value and get number of template tags to compile
     $compiledTags = array();
     $templateTagsCount = count($templateTags);
     // compile template tags, one by one
     for ($currentTagIndex = 0; $currentTagIndex < $templateTagsCount; $currentTagIndex++) {
         $this->currentLineNumber += StringUtil::getSubstringCount($textBlocks[$currentTagIndex], StringUtil::CHAR_LINE_FEED);
         $compiledTags[] = $this->compileTemplateTag($templateTags[$currentTagIndex]);
         $this->currentLineNumber += StringUtil::getSubstringCount($templateTags[$currentTagIndex], StringUtil::CHAR_LINE_FEED);
     }
     // check for unclosed tags
     if (!$this->compilerPluginTagStack->isEmpty()) {
         throw new SystemException(sprintf('Unclosed tag {%s} in template "%s" on line %s', $this->getLastCompilerPluginTagParameter('tagName'), $this->getCurrentTemplateName(), $this->getLastCompilerPluginTagParameter('lineNumber')), 0, E_USER_ERROR, __FILE__, __LINE__);
     }
     // return compiled tags
     return $compiledTags;
 }
 private function constructAST(Queue $tokens) : AST\Node
 {
     if ($tokens->isEmpty()) {
         throw new ParseException("Unexpected end of file");
     }
     $stack = new Stack();
     while (!$tokens->isEmpty()) {
         $token = $tokens->bottom();
         if ($this->isNumber($token)) {
             $tokens->dequeue();
             $stack->push(new AST\Constant($token->getLine(), (double) $token->getContent()));
         } else {
             if ($this->isVariable($token)) {
                 $tokens->dequeue();
                 $stack->push(new AST\Variable($token->getLine(), $token->getContent()));
             } else {
                 if ($this->isOperator($token)) {
                     $tokens->dequeue();
                     $right = $stack->pop();
                     $left = $stack->pop();
                     $stack->push(new AST\Operator($left->getLine(), $token->getId(), $left, $right));
                 } else {
                     if ($this->isFunctionName($token)) {
                         $tokens->dequeue();
                         $arguments = [];
                         for ($i = 0; $i < FUNCTIONS[$token->getContent()]['arity']; $i++) {
                             if ($stack->isEmpty()) {
                                 throw new ParseException("Not enough arguments on stack for '{$token->getContent()}', some function is missing an argument");
                             }
                             $arguments[] = $stack->pop();
                         }
                         // sin(1,2) would be [2 1 sin] on the stack
                         $arguments = \array_reverse($arguments);
                         $stack->push(new AST\FunctionCall($token->getLine(), $token->getContent(), $arguments));
                     } else {
                         throw new ParseException("Unexpected token {$token->getName()} on line {$token->getLine()}");
                     }
                 }
             }
         }
     }
     if ($stack->isEmpty()) {
         throw new ParseException("??????");
     }
     if ($stack->count() !== 1) {
         throw new ParseException("Missing operator");
     }
     return $stack->pop();
 }
Exemple #22
0
	/**
	 * Deletes backup
	 *
	 * @author : Rafał Trójniak rafal@trojniak.net
	 */
	public function delete()
	{
		$stack = new \SplStack();
		$stack -> push ( $this->getPath());

		$pushed=null;

		while(!$stack->isEmpty()){
			$pushed=false;
			$dirPath=$stack->pop();

			$dir = new \DirectoryIterator($dirPath);
			foreach ($dir as $file) {

				// Skipping '.' and '..'
				if(in_array($file->getFilename(), array('..','.'))){
					continue;
				}

				if($file->isDir()){
					// Push current
					$stack -> push ( $dirPath );
					// Push new one
					$stack -> push ( $file->getPathName() );

					$pushed=true;

					break;
				}

				$path=$file->getPathName();
				if(!unlink($path)){
					throw new \RuntimeException( 'Failed to remove "'.$path.'"');
				}

			}

			if(!$pushed and !rmdir($dirPath)){
				throw new \RuntimeException(
					'Failed to remove directory "'.$path.'"' );
			}

		}

	}
Exemple #23
0
 public function getCurrent()
 {
     return $this->stack->isEmpty() ? null : $this->stack->top();
 }
 protected function parseOperator(OperatorBase $expression, \SplStack $output, \SplStack $operators)
 {
     $end = !$operators->isEmpty() ? $operators->top() : null;
     if (!$end) {
         $operators->push($expression);
     } elseif ($end->isOperator()) {
         do {
             if ($expression->isLeftAssoc() && $expression->getPrecedence() <= $end->getPrecedence()) {
                 $el = $operators->isEmpty() ? null : $operators->pop();
                 $output->push($el);
             } elseif (!$expression->isLeftAssoc() && $expression->getPrecedence() < $end->getPrecedence()) {
                 $el = $operators->isEmpty() ? null : $operators->pop();
                 $output->push($el);
             } else {
                 break;
             }
         } while (!$operators->isEmpty() && ($end = $operators->top()) && $end->isOperator());
         $operators->push($expression);
     } else {
         $operators->push($expression);
     }
 }
Exemple #25
0
 /**
  * @param object $object
  * @return array
  */
 private function buildDataFromObject($object)
 {
     $result = array();
     $stack = new \SplStack();
     $stack->push($object);
     while (!$stack->isEmpty()) {
         $current = $stack->pop();
         if (is_object($current)) {
             array_push($result, $current);
         }
         foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
             if (is_object($propertyValue) || is_array($propertyValue)) {
                 $stack->push($propertyValue);
             }
         }
     }
     return $result;
 }
 private function addEntries(ZipArchiveResource $zipresource, array $files, $recursive)
 {
     $stack = new \SplStack();
     $error = null;
     $cwd = getcwd();
     $collection = $this->manager->handle($cwd, $files);
     $this->chdir($collection->getContext());
     $adapter = $this;
     try {
         $collection->forAll(function ($i, Resource $resource) use($zipresource, $stack, $recursive, $adapter) {
             $adapter->checkReadability($zipresource->getResource(), $resource->getTarget());
             if (is_dir($resource->getTarget())) {
                 if ($recursive) {
                     $stack->push($resource->getTarget() . (substr($resource->getTarget(), -1) === DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR));
                 } else {
                     $adapter->addEmptyDir($zipresource->getResource(), $resource->getTarget());
                 }
             } else {
                 $adapter->addFileToZip($zipresource->getResource(), $resource->getTarget());
             }
             return true;
         });
         // recursively add dirs
         while (!$stack->isEmpty()) {
             $dir = $stack->pop();
             // removes . and ..
             $files = array_diff(scandir($dir), array(".", ".."));
             if (count($files) > 0) {
                 foreach ($files as $file) {
                     $file = $dir . $file;
                     $this->checkReadability($zipresource->getResource(), $file);
                     if (is_dir($file)) {
                         $stack->push($file . DIRECTORY_SEPARATOR);
                     } else {
                         $this->addFileToZip($zipresource->getResource(), $file);
                     }
                 }
             } else {
                 $this->addEmptyDir($zipresource->getResource(), $dir);
             }
         }
         $this->flush($zipresource->getResource());
         $this->manager->cleanup($collection);
     } catch (\Exception $e) {
         $error = $e;
     }
     $this->chdir($cwd);
     if ($error) {
         throw $error;
     }
 }
Exemple #27
0
    </form>

    <div class="row">
        <ul id="myList" class="col-lg-8">
            <?php 
$stack = new SplStack();
if (isset($list[0])) {
}
$stack->push($list[0]->depth);
foreach ($list as $k => $item) {
    if ($item->depth > $stack->top()) {
        $stack->push($item->depth);
        echo "<ol>\n";
    }
    while (!$stack->isEmpty() && $stack->top() > $item->depth) {
        $stack->pop();
        echo "</ol></li>\n";
    }
    echo "<li class=\"sortableListsOpen\" id=\"row-" . $item->id . "\"><div>{$item->id}." . $item->name . "</div>\n";
}
while ($stack->count() > 1) {
    $stack->pop();
    echo "</ol>\n</li>\n";
}
?>
        </ul>
    </div>
</div>
<?php 
$root_id = (int) $root->id;
 public function leaveNode(Node $node)
 {
     if (!$this->expressionStack->isEmpty() && $node === $this->expressionStack->top()) {
         $this->expressionStack->pop();
     }
 }
Exemple #29
0
 /**
  * Commits a transaction previously started using begin().
  * If no transaction is in progress, a warning is issued.
  *
  * Nesting of transactions is not supported.
  *
  * @param string $fname
  * @param string $flush Flush flag, set to 'flush' to disable warnings about
  *   explicitly committing implicit transactions, or calling commit when no
  *   transaction is in progress. This will silently break any ongoing
  *   explicit transaction. Only set the flush flag if you are sure that it
  *   is safe to ignore these warnings in your context.
  * @throws DBUnexpectedError
  */
 public final function commit($fname = __METHOD__, $flush = '')
 {
     if (!$this->mTrxAtomicLevels->isEmpty()) {
         // There are still atomic sections open. This cannot be ignored
         throw new DBUnexpectedError($this, "Attempted to commit transaction while atomic sections are still open");
     }
     if ($flush === 'flush') {
         if (!$this->mTrxLevel) {
             return;
             // nothing to do
         } elseif (!$this->mTrxAutomatic) {
             wfWarn("{$fname}: Flushing an explicit transaction, getting out of sync!");
         }
     } else {
         if (!$this->mTrxLevel) {
             wfWarn("{$fname}: No transaction to commit, something got out of sync!");
             return;
             // nothing to do
         } elseif ($this->mTrxAutomatic) {
             wfWarn("{$fname}: Explicit commit of implicit transaction. Something may be out of sync!");
         }
     }
     # Avoid fatals if close() was called
     $this->assertOpen();
     $this->runOnTransactionPreCommitCallbacks();
     $writeTime = $this->pendingWriteQueryDuration();
     $this->doCommit($fname);
     if ($this->mTrxDoneWrites) {
         $this->mDoneWrites = microtime(true);
         $this->getTransactionProfiler()->transactionWritingOut($this->mServer, $this->mDBname, $this->mTrxShortId, $writeTime);
     }
     $this->runOnTransactionIdleCallbacks();
 }
Exemple #30
0
 /**
  * 匹配最小子科室未匹配到科室信息的情况
  * @author gaoqing
  * 2015年11月2日
  * @param SplStack $notMatchDepartmentStack 未匹配的子科室栈
  * @param array $matchArr 已匹配的父科室数组
  * @return int 更新后的最小子科室id 
  */
 private function dealWithChildDepartmentNotMatch($notMatchDepartmentStack, $matchArr)
 {
     $currentDepartmentID = 0;
     //都未匹配时:
     $pid = 0;
     //部分匹配时:
     if (!empty($matchArr)) {
         $pid = isset($matchArr[0]) ? isset($matchArr[0][0]) ? $matchArr[0][0]['id'] : 0 : 0;
     }
     $notMatchDepartmentStack->rewind();
     while ($notMatchDepartmentStack->valid()) {
         if ($notMatchDepartmentStack->isEmpty()) {
             break;
         }
         $departmentAndLevel = $notMatchDepartmentStack->pop();
         //向 wd_keshi_test 表中,插入科室信息
         $currentDepartmentID = $pid = $this->insertKeshiInfo($departmentAndLevel, $pid);
     }
     return $currentDepartmentID;
 }