Ejemplo n.º 1
0
 /**
  * Runs through all the routes and runs them
  * @author Tim Perry
  */
 public function route()
 {
     $this->routes->rewind();
     while ($this->routes->valid()) {
         $route = $this->routes->current();
         if ($route->run()) {
             return;
         }
         $this->routes->next();
     }
     throw new \RuntimeException("FlexPress router: No route found - please make sure you have setup routes.");
 }
Ejemplo n.º 2
0
 /**
  * Runs through all the callable functions provided, if all are met call the given callable
  * @author Tim Perry
  */
 public function run()
 {
     if (!isset($this->conditions) || !isset($this->callable)) {
         $message = "You have called the run function but have not provided both a array of conditions";
         $message .= " and a callable function, which will be called if all the given conditions are met.";
         throw new \RuntimeException($message);
     }
     $this->conditions->rewind();
     while ($this->conditions->valid()) {
         $condition = $this->conditions->current();
         if (!call_user_func($condition)) {
             return false;
         }
         $this->conditions->next();
     }
     call_user_func($this->callable, $this->request);
     return true;
 }
Ejemplo n.º 3
0
 /**
  * 调用 middleware
  *
  * @return mixed
  */
 public function call()
 {
     $this->queue->rewind();
     while ($this->queue->valid()) {
         if ($this->getPropagation()) {
             break;
         }
         $callbale = $this->queue->current();
         $response = call_user_func_array($callbale, func_get_args());
         if ($response === false) {
             break;
         } elseif (!empty($response)) {
             $this->response = $response;
         }
         $this->queue->next();
     }
     return $this->response;
 }
Ejemplo n.º 4
0
 /**
  * Return breadcrumb string
  **/
 function StringifyBreadcrumbs()
 {
     $output = "<ul class=\"breadcrumb\" id=\"breadcrumb\">";
     if (0 != $this->GetConfigValue('enable_breadcrumbs') && isset($_SESSION['user']) && isset($_SESSION['breadcrumbs'])) {
         $delimiter = $this->GetConfigValue('breadcrumb_node_delimiter');
         $q = new SplQueue();
         $q->unserialize($_SESSION['breadcrumbs']);
         $q->rewind();
         $output .= "<li>";
         $output .= "<a href=\"" . $this->Href('', $q->current()) . "\">" . $q->current() . "</a>";
         $q->next();
         while ($q->valid()) {
             $output .= " {$delimiter} ";
             $output .= "</li><li>";
             $output .= "<a href=\"" . $this->Href('', $q->current()) . "\">" . $q->current() . "</a>";
             $q->next();
         }
         $output .= "</li></ul>";
     }
     return $output;
 }
Ejemplo n.º 5
0
$qoperatingsystems = new SplQueue();
$qoperatingsystems->push(array('Windows 7', 'desktop', 'NT', 56.11));
$qoperatingsystems->push(array('Windows XP', 'desktop', 'NT', 10.59));
$qoperatingsystems->push(array('Windows 8', 'desktop', 'NT', 2.88));
$qoperatingsystems->push(array('Windows 8.1', 'desktop', 'NT', 11.15));
$qoperatingsystems->push(array('Windows 10', 'desktop', 'NT', 9));
$qoperatingsystems->push(array('Windows Vista', 'desktop', 'NT', 0));
$qoperatingsystems->push(array('Mac OS X 11', 'desktop', 'Unix', 2.66));
$qoperatingsystems->push(array('Mac OS X 10', 'desktop', 'Unix', 2.45));
$qoperatingsystems->push(array('Linux Mint', 'desktop', 'Linux', 0));
$qoperatingsystems->push(array('Linux Debian', 'desktop', 'Linux', 0));
$qoperatingsystems->push(array('Android', 'mobile', 'Linux', 48.12));
$qoperatingsystems->push(array('iOS', 'mobile', 'Unix', 34.71));
echo "\nSPL QUEUE ARRAY FOR LOOP: FIFO\n";
$qoperatingsystems->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
for ($qoperatingsystems->rewind(); $qoperatingsystems->valid(); $qoperatingsystems->next()) {
    echo $qoperatingsystems->current()[0] . "\n";
    echo $qoperatingsystems->current()[1] . "\n";
    echo $qoperatingsystems->current()[2] . "\n";
    echo $qoperatingsystems->current()[3] . "\n";
}
/* ------------------BASIC OPERATIONS------------------ */
// SORT
// BY LANGUAGE RANKING
usort($nlanguages, function ($a, $b) {
    return $b[2] - $a[2];
});
// FILTER
// BY DATABASE SIZE
function serveronly($var)
{
Ejemplo n.º 6
0
/**
 * Determines if we have a valid buffer for optimising.
 *
 * Has to be G1s all round with no Z movements, and either all extrusions or all movements.
 *
 * The extrusions also have to be the same mm^3/mm along the path.
 *
 * They also have to describe a circle
 * @param  SplQueue $buffer The buffer
 * @return Boolean          Whether the buffer is valid
 */
function bufferValid($buffer)
{
    global $debug;
    global $pos_error;
    for ($buffer->rewind(); $buffer->valid(); $buffer->next()) {
        if (substr($buffer->current(), 0, 2) !== "G1") {
            $buffer->rewind();
            return false;
        } else {
            if (strpos($buffer->current(), "Z") !== FALSE) {
                $buffer->rewind();
                return false;
            }
        }
    }
    $lines = getLines($buffer);
    $allE = false;
    $allF = false;
    if (!is_null($lines[0]['E'])) {
        $allE = true;
    }
    if (!is_null($lines[0]['F'])) {
        $allF = true;
    }
    foreach ($lines as $num => $line) {
        $allE = $allE && is_null($line['F']) && !is_null($line['E']);
        $allF = $allF && is_null($line['E']) && !is_null($line['F']);
    }
    if (!($allE || $allF)) {
        $buffer->rewind();
        return false;
    }
    if ($allE) {
        $extrusions = getExtrusionLengths($lines);
        $eerror = calculateExtrusionError($extrusions);
        if (calculateExtrusionError($extrusions) === false) {
            $buffer->rewind();
            return false;
        }
    }
    $lines->rewind();
    $circle = getCircle($lines);
    if ($circle === false) {
        $buffer->rewind();
        return false;
    }
    if (max($circle['errors']) > $pos_error) {
        return false;
    }
    $buffer->rewind();
    return $circle;
}
Ejemplo n.º 7
0
 /**
  * Move forward to next element
  * @link http://php.net/manual/en/iterator.next.php
  */
 public function next()
 {
     $this->queue->next();
 }