/** * @param $areaId * @param $weight * * @return mixed * @throws \Thelia\Exception\OrderException */ public static function getPostageAmount($areaId, $weight) { $freeshipping = ColissimoFreeshippingQuery::create()->getLast(); $postage = 0; if (!$freeshipping) { $prices = self::getPrices(); /* check if Colissimo delivers the asked area */ if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) { throw new DeliveryException(Translator::getInstance()->trans("Colissimo delivery unavailable for the delivery country", [], self::MESSAGE_DOMAIN)); } $areaPrices = $prices[$areaId]["slices"]; ksort($areaPrices); /* Check cart weight is below the maximum weight */ end($areaPrices); $maxWeight = key($areaPrices); if ($weight > $maxWeight) { throw new DeliveryException(Translator::getInstance()->trans("Colissimo delivery unavailable for this cart weight (%weight kg)", array("%weight" => $weight), self::MESSAGE_DOMAIN)); } $postage = current($areaPrices); while (prev($areaPrices)) { if ($weight > key($areaPrices)) { break; } $postage = current($areaPrices); } } return $postage; }
/** * @param $areaId * @param $weight * * @return mixed * @throws DeliveryException */ public static function getPostageAmount($areaId, $weight) { $freeshipping = @(bool) ConfigQuery::read("predict_freeshipping"); $postage = 0; if (!$freeshipping) { $prices = static::getPrices(); /* check if Predict delivers the asked area */ if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) { throw new DeliveryException("Predict delivery unavailable for the chosen delivery country"); } $areaPrices = $prices[$areaId]["slices"]; ksort($areaPrices); /* check this weight is not too much */ end($areaPrices); $maxWeight = key($areaPrices); if ($weight > $maxWeight) { throw new DeliveryException(sprintf("Predict delivery unavailable for this cart weight (%s kg)", $weight)); } $postage = current($areaPrices); while (prev($areaPrices)) { if ($weight > key($areaPrices)) { break; } $postage = current($areaPrices); } } return $postage; }
public function getSourceText() { if ($this->getDiffSource() == false) { $c = new Criteria(); $c->add("source_id", $this->getSourceId()); $source = DB_PageSourcePeer::instance()->selectOne($c); return $source->getText(); } else { // select last revisions and sources. $q = "SELECT page_source.* FROM page_source, page_revision WHERE " . "page_revision.page_id =" . $this->getPageId() . " " . "AND page_revision.revision_id <= " . $this->getRevisionId() . " " . "AND (page_revision.flag_text = TRUE OR page_revision.flag_new = TRUE) " . "AND page_revision.source_id = page_source.source_id " . "ORDER BY page_revision.revision_id DESC " . "LIMIT " . ($this->getSinceFullSource() + 1); $c = new Criteria(); $c->setExplicitQuery($q); $sources = DB_PageSourcePeer::instance()->select($c); // original source... $s = end($sources); $s0 = $s->getText(); $differ = new ODiff(); while ($s = prev($sources)) { $s0 = $differ->patchString($s0, $s->getText()); if ($differ->getErrors() != null) { return "Error processing the source - please report the problem to the support"; } } return trim($s0); } }
/** * Check and correct URL * @param string $url * @return string */ public function check_base($url, $options) { if (!is_string($url) || empty($url)) { return $url; } global $wp_rewrite; $base_defined = $options->base_defined; $permastruct = $wp_rewrite->get_extra_permastruct($options->get_tax_query()); if ($permastruct) { $permastruct = explode('/', $permastruct); end($permastruct); $permastruct = prev($permastruct); if (false !== $permastruct) { $base_defined = $permastruct; } } $base_option = get_option($options->base_option); if (empty($base_option)) { $base_option = $options->base_defined; } if ($base_defined != $base_option) { $search = '/' . $base_defined . '/'; $replace = '/' . $base_option . '/'; $count = 1; $url = str_replace($search, $replace, $url, $count); } return $url; }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $groupId = $params->additionalParamList['entityId']; $userId = OW::getUser()->getId(); $service = GROUPS_BOL_Service::getInstance(); $feedService = GROUPRSS_BOL_FeedService::getInstance(); $whoCanAdd = OW::getConfig()->getValue('grouprss', 'actionMember'); if ($whoCanAdd == 'admin' && !OW::getUser()->isAdmin()) { $this->setVisible(false); return; } $mypaths = explode("/", UTIL_Url::selfUrl()); $groupId = strtolower(end($mypaths)); if ($groupId == 'customize') { $groupId = strtolower(prev($mypaths)); } if ($whoCanAdd == 'creator' && $feedService->getGroupCreater($groupId) !== $userId) { $this->setVisible(false); return; } if ($whoCanAdd == 'both') { if (!OW::getUser()->isAdmin() && $feedService->getGroupCreater($groupId) !== $userId) { $this->setVisible(false); return; } } $this->assign('groupId', (int) $groupId); }
public function format($source) { $this->tkns = token_get_all($source); $this->code = ''; while (list($index, $token) = each($this->tkns)) { list($id, $text) = $this->getToken($token); $this->ptr = $index; switch ($id) { case T_NAMESPACE: if ($this->rightUsefulTokenIs(T_NS_SEPARATOR)) { break; } $this->appendCode($text); list($foundId, $foundText) = $this->printAndStopAt([ST_CURLY_OPEN, ST_SEMI_COLON]); if (ST_CURLY_OPEN == $foundId) { $this->appendCode($foundText); $this->printCurlyBlock(); } elseif (ST_SEMI_COLON == $foundId) { $this->appendCode(ST_CURLY_OPEN); list($foundId, $foundText) = $this->printAndStopAt([T_NAMESPACE, T_CLOSE_TAG]); if (T_CLOSE_TAG == $foundId) { return $source; } $this->appendCode($this->getCrlf() . ST_CURLY_CLOSE . $this->getCrlf()); prev($this->tkns); continue; } break; default: $this->appendCode($text); } } return $this->code; }
/** * Load the data */ private function loadData() { // get the current page id $pageId = $this->getContainer()->get('page')->getId(); $navigation = FrontendNavigation::getNavigation(); $pageInfo = FrontendNavigation::getPageInfo($pageId); $this->navigation = array(); if (isset($navigation['page'][$pageInfo['parent_id']])) { $pages = $navigation['page'][$pageInfo['parent_id']]; // store $pagesPrev = $pages; $pagesNext = $pages; // check for current id foreach ($pagesNext as $key => $value) { if ((int) $key != (int) $pageId) { // go to next pointer in array next($pagesNext); next($pagesPrev); } else { break; } } // get previous page $this->navigation['previous'] = prev($pagesPrev); // get next page $this->navigation['next'] = next($pagesNext); // get parent page $this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']); } }
public function prev() { if (!prev($this->filters)) { end($this->filters); } return current($this->filters); }
/** * Add a question to a quiz * * Adds a question to a quiz by updating $quiz as well as the * quiz and quiz_question_instances tables. It also adds a page break * if required. * @return boolean false if the question was already in the quiz * @param int $id The id of the question to be added * @param object $quiz The extended quiz object as used by edit.php * This is updated by this function */ function quiz_add_quiz_question($id, &$quiz) { $questions = explode(",", $quiz->questions); if (in_array($id, $questions)) { return false; } // remove ending page break if it is not needed if ($breaks = array_keys($questions, 0)) { // determine location of the last two page breaks $end = end($breaks); $last = prev($breaks); $last = $last ? $last : -1; if (!$quiz->questionsperpage or $end - $last - 1 < $quiz->questionsperpage) { array_pop($questions); } } // add question $questions[] = $id; // add ending page break $questions[] = 0; // Save new questionslist in database $quiz->questions = implode(",", $questions); if (!set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id)) { error('Could not save question list'); } // update question grades $questionrecord = get_record("question", "id", $id); $quiz->grades[$id] = $questionrecord->defaultgrade; quiz_update_question_instance($quiz->grades[$id], $id, $quiz->instance); return true; }
/** * Processes command line options. * * @param array $options * @return \ApiGen\Config */ public function processCliOptions(array $options) { while ($option = current($options)) { if (preg_match('~^--([a-z][-a-z]*[a-z])(?:=(.+))?$~', $option, $matches) || preg_match('~^-([a-z])=?(.*)~', $option, $matches)) { $name = $matches[1]; if (!empty($matches[2])) { $value = $matches[2]; } else { $next = next($options); if (false === $next || '-' === $next[0]) { prev($options); $value = ''; } else { $value = $next; } } $this->options[$name][] = $value; } next($options); } $this->options = array_map(function ($value) { return 1 === count($value) ? $value[0] : $value; }, $this->options); // Compatibility with ApiGen 1.0 foreach (array('config', 'source', 'destination') as $option) { if (isset($this->options[$option[0]]) && !isset($this->options[$option])) { $this->options[$option] = $this->options[$option[0]]; } unset($this->options[$option[0]]); } return $this; }
public function examineStateChange(&$sToken, ParseState $aParseState) { if ($sToken !== 'TABLE' and $sToken !== 'TABLES') { return false; } $aParseState->arrTree[] = $sToken; $sOriToken = $sToken; // IF NOT EXISTS $arrTokenList = array('IF', 'NOT', 'EXISTS'); while (1) { $sToken = next($aParseState->arrTokenList); if (empty($arrTokenList) or array_shift($arrTokenList) !== $sToken) { break; } $aParseState->arrTree[] = $sToken; } // 到头了, table/tables 后面没有内容 if ($sToken === false) { prev($aParseState->arrTokenList); array_pop($aParseState->arrTree); $sToken = $sOriToken; return false; } else { if (strtolower($sToken) === 'status') { $aParseState->arrTree[] = $sToken; $sToken = next($aParseState->arrTokenList); } } // 遇到 TABLE ,检查下一个token 是否是有效的表名 // $sToken = next($aParseState->arrTokenList) ; return parent::examineStateChange($sToken, $aParseState); }
public function process() { $f = $this->modx->getOption(xPDO::OPT_CACHE_PATH) . 'logs/error.log'; $content = ''; $tooLarge = false; $size = 0; $empty = true; if (file_exists($f)) { $size = round(@filesize($f) / 1000 / 1000, 2); $content = @file_get_contents($f); if ($size > 1) { $tooLarge = true; $lines = preg_split('/\\r\\n?|\\n/', $content); $content = end($lines); for ($i = 1; $i < $this->getProperty('last', 10); $i++) { $content = prev($lines) . "\n" . $content; } } unset($lines); } if (mb_strlen(trim($content)) > 0 || $tooLarge) { $empty = false; } $connector_url = $this->modx->getOption('assets_url') . 'components/controlerrorlog/connector.php'; $la = array('name' => $f, 'log' => $content, 'tooLarge' => $tooLarge, 'size' => $size, 'empty' => $empty, 'last' => $this->getProperty('last'), 'connector_url' => $connector_url); return $this->success('', $la); }
function solution($A) { // we sort array $A in ascending order from minimum to maximum integer; if closest integers // don't fullfill triangular conditions, farther integers will not fulfill it also // index association is not maintained because rule 0 ≤ P < Q < R < N is not important; // namely the following rules cover every possible combination: // A[P] + A[Q] > A[R] // A[Q] + A[R] > A[P] // A[R] + A[P] > A[Q] sort($A); $N = count($A); $arrayEnd = false; // while we haven't reached array end while (!$arrayEnd) { $P = key($A); // advance the internal array pointer of an array next($A); $Q = key($A); next($A); $R = key($A); // if $Q and $R exist, we haven't reached array $A end if ($Q !== NULL && $R !== NULL) { // rewind the internal array pointer 1 place back prev($A); // if triangular conditions are matched if ($A[$P] + $A[$Q] > $A[$R] && $A[$Q] + $A[$R] > $A[$P] && $A[$R] + $A[$P] > $A[$Q]) { return 1; } } else { $arrayEnd = true; } } return 0; }
public function postProcessSignOff() { if ($this->checkObjectClassTypeCorrect("SignOff") == true) { $signOff = end($this->stack); // get the previous object of the stack $currentRecord = prev($this->stack); // reset stack pointer to end end($this->stack); // Signing off of the wrong type of record, this is an error! Log it and continue if ($currentRecord->getRegistryEntryType() !== Constants::REGISTRY_ENTRY_TYPE_INCOMING) { $this->logger->warn('The following RegistryEntry has been signedOff, but it is not specified as Incoming (' . Constants . REGISTRY_ENTRY_TYPE_INCOMING . '). The actual RegistryEntry is ' . $currentRecord . ' while the signOff is ' . $signOff . ' This message is coming from ' . __METHOD__); $this->errorsEncountered = true; $this->numberErrorsEncountered++; } if (isset($this->listOfRegistryEntryIncoming[$currentRecord->getSystemId()])) { unset($this->listOfRegistryEntryIncoming[$currentRecord->getSystemId()]); } else { $this->logger->warn('Encountered a sigoff for the following RegistryEntry, but am not expecting this RegistryEntry. The actual RegistryEntry is ' . $currentRecord . ' while the signOff is ' . $signOff . ' This message is coming from ' . __METHOD__); $this->errorsEncountered = true; $this->numberErrorsEncountered++; } $this->logger->trace('Post process SignOff. Method (' . __METHOD__ . ')' . $signOff); } else { throw new Exception(Constants::STACK_ERROR . __METHOD__ . ". Expected SignOff found " . get_class(end($this->stack))); } }
/** * @return bool, moves the internal array pointer backward one place. * Returns true, or false if there is no more element before the current pointer. */ public function prev() { if (false !== prev($this->array)) { return true; } return false; }
/** * Processes and returns command line arguments. * * @param array $argv Command line arguments * @return array * @todo Throw exception if an unexpected argument is found */ public function parseArguments(array $argv) { $options = array(); while ($argument = current($argv)) { if (preg_match('~^--([a-z][-a-z]*[a-z])(?:=(.+))?$~', $argument, $matches) || preg_match('~^-([a-z])=?(.*)~', $argument, $matches)) { $name = $matches[1]; if (!empty($matches[2])) { $value = $matches[2]; } else { $next = next($argv); if (false === $next || '-' === $next[0]) { prev($argv); $value = ''; } else { $value = $next; } } $options[$name][] = $value; } next($argv); } $options = array_map(function ($value) { return 1 === count($value) ? $value[0] : $value; }, $options); return $options; }
function foo(&$state) { $contentDict = end($state); for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) { echo key($state) . " => " . current($state) . "\n"; } }
function so_remove_all_menus() { global $menu, $submenu, $user_ID; $the_user = new WP_User($user_ID); $valid_page = "admin.php?page=contact-form-7/admin/admin.php"; // only contactform7 is allowed $restricted = array('index.php', 'edit.php', 'categories.php', 'upload.php', 'link-manager.php', 'edit-pages.php', 'edit-comments.php', 'themes.php', 'plugins.php', 'users.php', 'profile.php', 'tools.php', 'options-general.php'); $restricted_str = 'widgets.php'; end($menu); while (prev($menu)) { $menu_item = $menu[key($menu)]; $restricted_str .= '|' . $menu_item[2]; if (in_array($menu_item[2], $restricted)) { $submenu_item = $submenu[$menu_item[2]]; if ($submenu_item != NULL) { $tmp = $submenu_item; $max = array_pop(array_keys($tmp)); for ($i = $max; $i > 0; $i -= 5) { if ($submenu_item[$i] != NULL) { $restricted_str .= '|' . $submenu[$menu_item[2]][$i][2]; unset($submenu[$menu_item[2]][$i]); } } } unset($menu[key($menu)]); } } $result = preg_match('/(.*?)\\/wp-admin\\/?(' . $restricted_str . ')??((' . $restricted_str . '){1})(.*?)/', $_SERVER['REQUEST_URI']); if ($result != 0 && $result != FALSE) { wp_redirect(get_option('siteurl') . '/wp-admin/' . $valid_page); exit(0); } }
public function start() { $migrations = $this->migration->find_migrations(); $versions = array_map('intval', array_keys($migrations)); $db_version = intval($this->migration->get_db_version()); end($versions); while ($version = prev($versions)) { if ($version !== $db_version) { break; } } if ($version + $db_version <= 0) { return $this->note("Can't rollback anymore"); } else { $version === FALSE && ($version = 0); $this->text('Migrating database <info>DOWN</info> to version ' . '<comment>' . $version . '</comment> from <comment>' . $db_version . '</comment>'); $case = 'reverting'; $signal = '--'; } $this->newLine(); $this->text('<info>' . $signal . '</info> ' . $case); $time_start = microtime(true); $this->migration->version($version); $time_end = microtime(true); list($query_exec_time, $exec_queries) = $this->measureQueries($this->migration->db->queries); $this->summary($signal, $time_start, $time_end, $query_exec_time, $exec_queries); }
/** * Function to get the Display Value, for the current field type with given DB Insert Value * @param <Object> $value * @return <Object> */ public function getDisplayValue($tree, $record = false, $recordInstance = false, $rawText = false) { $template = $this->get('field')->getFieldParams(); $name = Vtiger_Cache::get('TreeData' . $template, $tree); if ($name) { return $name; } $adb = PearDatabase::getInstance(); $result = $adb->pquery('SELECT * FROM vtiger_trees_templates_data WHERE templateid = ? AND tree = ?', [$template, $tree]); $parentName = ''; $module = $this->get('field')->getModuleName(); $name = false; if ($adb->num_rows($result)) { if ($adb->query_result_raw($result, 0, 'depth') > 0) { $parenttrre = $adb->query_result_raw($result, 0, 'parenttrre'); $pieces = explode('::', $parenttrre); end($pieces); $parent = prev($pieces); $result2 = $adb->pquery('SELECT name FROM vtiger_trees_templates_data WHERE templateid = ? AND tree = ?', [$template, $parent]); $parentName = $adb->query_result_raw($result2, 0, 'name'); $parentName = '(' . vtranslate($parentName, $module) . ') '; } $name = $parentName . vtranslate($adb->query_result($result, 0, 'name'), $module); } Vtiger_Cache::set('TreeData' . $template, $tree, $name); return $name; }
function _get_prev_item(&$items, $current_id) { reset($items); $prev = array(); foreach(array_keys($items) as $id) if ($current_id == $items[$id]['id']) { break; } else { next($items); } if (($item = prev($items)) !== false) return $item; else return array(); if (!$prev) return array(); if($prev['id'] == $current_id) return array(); return $prev; }
/** * Trains all perceptron weights by given input data * and expected outputs. * * @param mixed $input * @param mixed $expectedOutput * @return $this */ public function train($input, $expectedOutput) { // Run the forward propagation first. $this->test($input); // Copy fields. $strategy = $this->getPropagationStrategy(); $layers = $this->getLayers(); // Init for first iteration. $layer = end($layers); $layerInFront = prev($layers); foreach ($layer->getNamedNodes() as $name => $node) { $node->delta = $strategy->calculateOutputDelta($this, $node, $expectedOutput[$name]); $this->updateNodesInFront($layerInFront, $node); } // Process the previous layer. $layerBehind = $layer; $layer = $layerInFront; $layerInFront = prev($layers); // Backpropagation. while ($layerInFront !== false) { foreach ($layer->getNodes() as $node) { $node->delta = $strategy->calculateHiddenDelta($this, $node, $layerBehind); $this->updateNodesInFront($layerInFront, $node); } // Process the previous layer. $layerBehind = $layer; $layer = $layerInFront; $layerInFront = prev($layers); } return $this; }
/** * @param cfhCompile_CodeWriter $codeWriter * @param cfhCompile_Class_Interface $class * @param unknown_type $sourceCode * @param cfhCompile_ClassRegistry $classRegistry * @return String */ public function preWrite(cfhCompile_CodeWriter $codeWriter, cfhCompile_Class_Interface $class, $sourceCode, cfhCompile_ClassRegistry $classRegistry) { if (is_null($sourceCode)) { return NULL; } $tokens = token_get_all('<?php ' . $sourceCode); $sourceCode = ''; $lastWasString = FALSE; while ($token = current($tokens)) { $nextIsString = is_string(next($tokens)); prev($tokens); if (is_string($token)) { $sourceCode .= $token; $lastWasString = TRUE; } else { list($token, $text) = $token; if ($token == T_WHITESPACE) { if ($lastWasString === FALSE && $nextIsString === FALSE) { $sourceCode .= ' '; } } else { $sourceCode .= $text; } $lastWasString = FALSE; } next($tokens); } return trim(substr($sourceCode, 5)); }
public function format($source) { $this->tkns = token_get_all($source); $this->code = ''; while (list($index, $token) = each($this->tkns)) { list($id, $text) = $this->getToken($token); $this->ptr = $index; switch ($id) { case T_FUNCTION: $this->appendCode($text); $this->printUntil(ST_PARENTHESES_OPEN); $this->printBlock(ST_PARENTHESES_OPEN, ST_PARENTHESES_CLOSE); $this->printAndStopAt(ST_CURLY_OPEN); if ($this->rightTokenIs(ST_CURLY_CLOSE)) { $this->rtrimAndAppendCode($this->getSpace() . ST_CURLY_OPEN); $this->printAndStopAt(ST_CURLY_CLOSE); $this->rtrimAndAppendCode(ST_CURLY_CLOSE); break; } prev($this->tkns); break; default: $this->appendCode($text); } } return $this->code; }
public function recommendEnrichment(Request $request) { try { $users = MecanexUser::all(); $videos = Video::all(); $euscreen_id = $request->video; $video_id = $videos->where('video_id', $euscreen_id)->first()->id; $username = $request->user; $user_id = $users->where('username', $username)->first()->id; $recommendedEnrichments = []; $listEnrichments = DB::select(DB::raw('SELECT * FROM enrichments_videos_time WHERE video_id=?'), [$video_id]); $listEnrichments = json_decode(json_encode($listEnrichments), true); usort($listEnrichments, $this->make_comparer('time')); while ($listEnrichments != []) { // get first element of the list reset($listEnrichments); $i = key($listEnrichments); // create a simultaneous list with all enrichments simultaneous with the first one $simultaneous_enrichments = [$listEnrichments[$i]]; // get next enrichment on list (they are ranked chronologically) next($listEnrichments); $next = key($listEnrichments); // if it exists and it is simultaneous, add it to the simultaneous list while (array_key_exists($next, $listEnrichments) and $listEnrichments[$next]["time"] == $listEnrichments[$i]["time"]) { $simultaneous_enrichments[] = $listEnrichments[$next]; prev($listEnrichments); // so that unset does not break the next unset($listEnrichments[$next]); next($listEnrichments); $next = key($listEnrichments); } while ($simultaneous_enrichments != []) { reset($simultaneous_enrichments); $j = key($simultaneous_enrichments); $tmp_enrichments = []; $first_enrichment = $simultaneous_enrichments[$j]; foreach ($simultaneous_enrichments as $id => $enrichment) { if ($first_enrichment["height"] == $enrichment["height"] and $first_enrichment["width"] == $enrichment["width"] and $first_enrichment["x_min"] == $enrichment["x_min"] and $first_enrichment["y_min"] == $enrichment["y_min"]) { $tmp_enrichments[] = $enrichment; unset($simultaneous_enrichments[$id]); } } $enrichmentScores = $this->recommend_enr($tmp_enrichments, $user_id); // first key of enrichmentScores list - the most recommended enrichment $recommended_enrichment = key($enrichmentScores); $recommendedEnrichments[] = array('enrichment_id' => Enrichment::find($recommended_enrichment)->enrichment_id, 'score' => current($enrichmentScores), 'frame' => $listEnrichments[$i]["time"], 'height' => $first_enrichment["height"], 'width' => $first_enrichment["width"], 'x_min' => $first_enrichment["x_min"], 'y_min' => $first_enrichment["y_min"]); } unset($listEnrichments[$i]); } // $recommendedEnrichments[] = $this->recommend_enr($listEnrichments, $user_id); $statusCode = 200; $response = $recommendedEnrichments; return $response; } catch (Exception $e) { $statusCode = 400; } finally { return Response::json($response, $statusCode); } }
public function set_filterInfo() { $locale = fusion_get_locale("", FORUM_LOCALE); $time = isset($_GET['time']) ? $_GET['time'] : ''; $type = isset($_GET['type']) ? $_GET['type'] : ''; $sort = isset($_GET['sort']) ? $_GET['sort'] : ''; $order = isset($_GET['order']) ? $_GET['order'] : ''; $timeCol = ''; $typeCol = ''; if ($time) { $time_array = array('today' => strtotime('today'), '2days' => strtotime('-2 days'), '1week' => strtotime('-1 week'), '2week' => strtotime('-2 weeks'), '1month' => strtotime('-2 months'), '2month' => strtotime('-2 months'), '3month' => strtotime('-2 months'), '6month' => strtotime('-6 months'), '1year' => strtotime('-1 year')); $time_stop = $time_array['today']; foreach ($time_array as $key => $value) { if ($time == $key) { $time_stop = prev($time_array); break; } } if ($time !== 'today') { $start_time = intval($time_array[$time]); $end_time = time(); $timeCol = "AND ((p1.post_datestamp BETWEEN '{$start_time}' AND '{$end_time}') OR (t.thread_lastpost BETWEEN '{$start_time}' AND '{$end_time}'))"; } else { $timeCol = "AND (p1.post_datestamp >= " . intval($time_array[$time]) . " OR t.thread_lastpost >= " . intval($time_stop) . " )"; } } if ($type) { $type_array = array('all' => '', 'discussions' => "AND (a1.attach_name IS NULL or a1.attach_name='') AND (a2.attach_name IS NULL or a2.attach_name='') AND (forum_poll_title IS NULL or forum_poll_title='')", 'attachments' => "AND a1.attach_name !='' OR a2.attach_name !='' AND (forum_poll_title IS NULL or forum_poll_title='')", 'poll' => "AND (a1.attach_name IS NULL or a1.attach_name='') AND (a2.attach_name IS NULL or a2.attach_name='') AND forum_poll_title !=''", 'solved' => "AND t.thread_answered = '1'", 'unsolved' => "AND t.thread_answered = '0'"); $typeCol = $type_array[$type]; } $sortCol = "ORDER BY t.thread_lastpost "; $orderCol = 'DESC'; if ($sort) { $sort_array = array('author' => 't.thread_author', 'time' => 't.thread_lastpost', 'subject' => 't.thread_subject', 'reply' => 't.thread_postcount', 'view' => 't.thread_views'); $sortCol = "ORDER BY " . $sort_array[$sort] . " "; } if ($order) { $order_array = array('ascending' => 'ASC', 'descending' => 'DESC'); $orderCol = $order_array[$order]; } $this->filter_sql = array('condition' => $timeCol . $typeCol, 'order' => $sortCol . $orderCol); // Filter Links $timeExt = isset($_GET['time']) ? "&time=" . $time : ''; $typeExt = isset($_GET['type']) ? "&type=" . $type : ''; $sortExt = isset($_GET['sort']) ? "&sort=" . $sort : ''; $orderExt = isset($_GET['order']) ? "&order=" . $order : ''; $baseLink = clean_request("", array("time", "type", "sort", "order"), FALSE); if (isset($_GET['viewforum']) && isset($_GET['forum_id'])) { $baseLink = INFUSIONS . 'forum/index.php?viewforum&forum_id=' . $_GET['forum_id'] . '' . (isset($_GET['parent_id']) ? '&parent_id=' . $_GET['parent_id'] . '' : ''); } $timeLink = $baseLink . $typeExt . $sortExt . $orderExt; $this->filter_info['time'] = array($locale['forum_3006'] => $baseLink, $locale['forum_3007'] => $timeLink . '&time=today', $locale['forum_3008'] => $timeLink . '&time=2days', $locale['forum_3009'] => $timeLink . '&time=1week', $locale['forum_3010'] => $timeLink . '&time=2week', $locale['forum_3011'] => $timeLink . '&time=1month', $locale['forum_3012'] => $timeLink . '&time=2month', $locale['forum_3013'] => $timeLink . '&time=3month', $locale['forum_3014'] => $timeLink . '&time=6month', $locale['forum_3015'] => $timeLink . '&time=1year'); $typeLink = $baseLink . $timeExt . $sortExt . $orderExt; $this->filter_info['type'] = array($locale['forum_3000'] => $typeLink . '&type=all', $locale['forum_3001'] => $typeLink . '&type=discussions', $locale['forum_3002'] => $typeLink . '&type=attachments', $locale['forum_3003'] => $typeLink . '&type=poll', $locale['forum_3004'] => $typeLink . '&type=solved', $locale['forum_3005'] => $typeLink . '&type=unsolved'); $sortLink = $baseLink . $timeExt . $typeExt . $orderExt; $this->filter_info['sort'] = array($locale['forum_3016'] => $sortLink . '&sort=author', $locale['forum_3017'] => $sortLink . '&sort=time', $locale['forum_3018'] => $sortLink . '&sort=subject', $locale['forum_3019'] => $sortLink . '&sort=reply', $locale['forum_3020'] => $sortLink . '&sort=view'); $orderLink = $baseLink . $timeExt . $typeExt . $sortExt; $this->filter_info['order'] = array($locale['forum_3021'] => $orderLink . '&order=descending', $locale['forum_3022'] => $orderLink . '&order=ascending'); }
public function prev() { if ($this->position() === 0) { // do not change cursor return false; } return prev($this->tokens); }
/** * advances to the next element. */ public function next() { if ($this->reverse) { prev($this->tables); } else { next($this->tables); } }
/** * Calls parent block. * @return void */ public static function callBlockParent(\stdClass $context, $name, array $params) { if (empty($context->blocks[$name]) || ($block = next($context->blocks[$name])) === FALSE) { throw new RuntimeException("Cannot include undefined parent block '{$name}'."); } $block($context, $params); prev($context->blocks[$name]); }
/** * This method will back one position left the internal pointer of the iterator. * It will also return the previous place that's pointed to by the internal array pointer, or FALSE if there are no more elements. * * @return mixed Returns the array value in the previous place that's pointed to by the internal array pointer, or FALSE if there are no more elements. */ public function &previous() { if ($this->_internal_point > 0) { $this->_internal_point--; } $return_value = prev($this->_collection); return $return_value; }