function apply_filters_ref_array($tag, $args) { global $wp_filter, $merged_filters, $wp_current_filter; // Do 'all' actions first if (isset($wp_filter['all'])) { $wp_current_filter[] = $tag; $all_args = func_get_args(); _wp_call_all_hook($all_args); } if (!isset($wp_filter[$tag])) { if (isset($wp_filter['all'])) { array_pop($wp_current_filter); } return $args[0]; } if (!isset($wp_filter['all'])) { $wp_current_filter[] = $tag; } // Sort if (!isset($merged_filters[$tag])) { ksort($wp_filter[$tag]); $merged_filters[$tag] = true; } reset($wp_filter[$tag]); do { foreach ((array) current($wp_filter[$tag]) as $the_) { if (!is_null($the_['function'])) { $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } } } while (next($wp_filter[$tag]) !== false); array_pop($wp_current_filter); return $args[0]; }
/** * {@inheritdoc} */ public function prepare_form($request, $template, $user, $row, &$error) { $avatar_list = $this->get_avatar_list($user); $category = $request->variable('avatar_local_cat', key($avatar_list)); foreach ($avatar_list as $cat => $null) { if (!empty($avatar_list[$cat])) { $template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category)); } if ($cat != $category) { unset($avatar_list[$cat]); } } if (!empty($avatar_list[$category])) { $template->assign_vars(array('AVATAR_LOCAL_SHOW' => true)); $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4; $row_count = $col_count = $avatar_pos = 0; $avatar_count = sizeof($avatar_list[$category]); reset($avatar_list[$category]); while ($avatar_pos < $avatar_count) { $img = current($avatar_list[$category]); next($avatar_list[$category]); if ($col_count == 0) { ++$row_count; $template->assign_block_vars('avatar_local_row', array()); } $template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar'])); $template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar'])); $col_count = ($col_count + 1) % $table_cols; ++$avatar_pos; } } return true; }
function openDocumentPropeties($path, $propertiesSchema = '*') { $client = new \Nuxeo\Automation\Client\NuxeoPhpAutomationClient('http://172.17.42.1:8080/nuxeo/site/automation'); $session = $client->getSession('Administrator', 'Administrator'); $answer = $session->newRequest("Document.Query")->set('params', 'query', "SELECT * FROM Document WHERE ecm:path = '" . $path . "'")->setSchema($propertiesSchema)->sendRequest(); $documentsArray = $answer->getDocumentList(); $value = sizeof($documentsArray); echo '<table>'; echo '<tr><TH>uid</TH><TH>Path</TH> <TH>Type</TH><TH>State</TH><TH>Title</TH><TH>Property 1</TH> <TH>Property 2</TH><TH>Download as PDF</TH>'; for ($test = 0; $test < $value; $test++) { echo '<tr>'; echo '<td> ' . current($documentsArray)->getUid() . '</td>'; echo '<td> ' . current($documentsArray)->getPath() . '</td>'; echo '<td> ' . current($documentsArray)->getType() . '</td>'; echo '<td> ' . current($documentsArray)->getState() . '</td>'; echo '<td> ' . current($documentsArray)->getTitle() . '</td>'; echo '<td> ' . current($documentsArray)->getProperty('dc:description') . '</td>'; echo '<td> ' . current($documentsArray)->getProperty('dc:creator') . '</td>'; echo '<td><form id="test" action="../samples/B5bis.php" method="post" >'; echo '<input type="hidden" name="data" value="' . current($documentsArray)->getPath() . '"/>'; echo '<input type="submit" value="download"/>'; echo '</form></td></tr>'; next($documentsArray); } echo '</table>'; }
function SaveArray($vArray) { global $buffer; // Every array starts with chr(1)+"{" $buffer .= "{"; // Go through the given array reset($vArray); while (true) { $Current = current($vArray); $MyKey = addslashes(strval(key($vArray))); if (is_array($Current)) { $buffer .= $MyKey . ""; SaveArray($Current); $buffer .= ""; } else { $Current = addslashes($Current); $buffer .= "{$MyKey}{$Current}"; } ++$i; while (next($vArray) === false) { if (++$i > count($vArray)) { break; } } if ($i > count($vArray)) { break; } } $buffer .= "}"; }
public function lists() { if (isset($this->request->params['actor']) == true && isset($this->request->params['genre']) == true) { $genre = $this->request->params['genre']; $this->set('genre', $genre); $array_voiceMenu = $this->setMenu(); $tmp = $array_voiceMenu; //後でforeach構文で最後の処理をするため foreach ($array_voiceMenu as $menu) { //breadcrumbの設定 if ($menu['genre'] == $genre) { $this->set('sub_page', $menu['title']); break; } elseif (!next($tmp)) { //ジャンルがない場合 $this->redirect('/'); } } $voice = $this->Voice->find('first', array('conditions' => array('Voice.system_name' => $this->request->params['actor'], 'Voice.publish' => 1))); if ($voice) { $this->set('voice', $voice); } else { //公開されたデータがない場合 $this->redirect('/'); } // 出演作品一覧の取得 $this->Paginator->settings = array('conditions' => array('Product.voice_id' => $voice['Voice']['id'], 'Product.genre' => $this->request->params['genre'], 'Product.publish' => 1), 'order' => array('Product.date_from' => 'desc')); $lists = $this->Paginator->paginate('Product'); $this->set('lists', $lists); $this->render('lists'); } else { $this->redirect('/'); } }
function _get_select() { $exclude = array(); $wlk = $this->_tree_walk_preorder($this->node); while (!$wlk['recset']->EOF) { $row = $wlk['recset']->fields; $exclude[$row['id']] = 'yes'; $wlk['recset']->MoveNext(); } $mySelect = new CHAW_select($this->key); $node = $this->_tree_get_group_root_node($this->usergroup); $attributes = array('name'); $wlk = $this->_tree_walk_preorder($node); while ($curr = $this->_tree_walk_next($wlk)) { $level = $this->_tree_walk_level($wlk); $spaces = str_repeat('--', $level - 1); $att = reset($attributes); while ($att) { if ($level == 0) { $mySelect->add_option('(seleziona cartella)', $wlk['row']['id']); } elseif ($wlk['row']['file'] == '' && !isset($exclude[$wlk['row']['id']])) { $mySelect->add_option($spaces . $wlk['row'][$att], $wlk['row']['id']); } $att = next($attributes); } } return $mySelect; }
public function isValid($sValue) { $this->_setValue($sValue); if (null === self::$_filter) { require_once 'Zend/Filter/Digits.php'; self::$_filter = new Zend_Filter_Digits(); } $sValueFiltered = self::$_filter->filter($sValue); $nLength = strlen($sValueFiltered); if ($nLength != 10) { $this->_error(self::LENGTH); return false; } $nMod = 11; $nSum = 0; $aWeights = array(6, 5, 7, 2, 3, 4, 5, 6, 7); preg_match_all("/\\d/", $sValueFiltered, $aDigits); $aValueFiltered = $aDigits[0]; foreach ($aValueFiltered as $nDigit) { $nWeight = current($aWeights); $nSum += $nDigit * $nWeight; next($aWeights); } if (($nSum % $nMod == 10 ? 0 : $nSum % $nMod) != $aValueFiltered[$nLength - 1]) { $this->_error(self::CHECKSUM, $sValueFiltered); return false; } return true; }
function generateJSON($auth_key, $guid, $year, $filename) { // Get json from API $url = "http://api.quito.junar.com/datastreams/invoke/" . $guid . "?auth_key=" . $auth_key . "&output=json_array"; $str = file_get_contents($url); $json = json_decode($str, true); // Array of Zonales id $zonales_id = array(1 => "Calderón", 2 => "Eloy Alfaro", 3 => "Eugenio Espejo", 4 => "La Delicia", 5 => "Los Chillos", 6 => "Manuela Saenz", 7 => "Quitumbe", 8 => "Tumbaco", 12 => "Sur", 13 => "Norte", 16 => "Centro"); $datos = array(); // Reading JSON and verify foreach ($json['result'] as $data) { $id_zonal = 0; $zonal = reset($zonales_id); // Checks if json contains a valid zonal and returns id while ($zonal = current($zonales_id)) { if (strpos($zonal, $data[1]) !== false) { $id_zonal = key($zonales_id); break; } next($zonales_id); } // Assings data according to id if ($id_zonal > 0) { if ($id_zonal > 10) { $id_zonal = $id_zonal - 10; } $datos[] = array("id" => $id_zonal, "zonal" => html_entity_decode($zonales_id[$id_zonal]), "periodo" => 2014, "dato" => intval($data[14])); } } // Write json file_put_contents($filename, json_encode($datos)); }
public static function event_save_meta($result, $EM_Event) { if ($result && EM_ML::is_original($EM_Event)) { //save post meta for all others as well foreach (EM_ML::get_langs() as $lang_code => $language) { $event = EM_ML::get_translation($EM_Event, $lang_code); /* @var $EM_Event EM_Event */ if ($event->event_id != $EM_Event->event_id) { self::event_merge_original_meta($event, $EM_Event); //if we execute a meta save here, we will screw up the current em_event_save_meta $wp_filter pointer executed in do_action() //therefore, we save the current pointer position (priority) and set it back after saving the location further down global $wp_filter, $wp_current_filter; $wp_filter_priority = key($wp_filter['em_event_save_meta']); $tag = end($wp_current_filter); //save the event meta $event->save_meta(); //reset save_post pointer in $wp_filter to its original position reset($wp_filter[$tag]); do { if (key($wp_filter[$tag]) == $wp_filter_priority) { break; } } while (next($wp_filter[$tag]) !== false); } } } return $result; }
/** * create * @param array $_user_info * @param array $_data * @return boolean */ public function insertWorkRecord($_user_info, $_data) { if (!$_user_info || !$_data) { return false; } $adapter = GlobalAdapterFeature::getStaticAdapter(); $connection = $adapter->getDriver()->getConnection(); $connection->beginTransaction(); $work_no = $this->db->getMaxId('work_no') + 1; $row = false; do { $data = array('branch_no' => gv('branch_no', $_user_info), 'login_pw' => make_rand_str(8, 3), 'join_key' => sha1(time() . microtime() . rand(0, 1000)), 'work_no' => $work_no); try { $this->db->exchanegArray(array_merge(current($_data), $data)); $row = $this->db->insertRecord(gv('user_no', $_user_info)); } catch (\Exception $e) { if (IS_TEST) { $connection->rollback(); echo $e->getMessage(); } break; } } while (next($_data)); if ($row) { $this->db->checkLoginId($work_no); $connection->commit(); } return $row; }
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; }
private static function mergeCodeCoverage($left, $right) { $coverageMerged = array(); reset($left); reset($right); while (current($left) && current($right)) { $linenr_left = key($left); $linenr_right = key($right); if ($linenr_left < $linenr_right) { $coverageMerged[$linenr_left] = current($left); next($left); } elseif ($linenr_right < $linenr_left) { $coverageMerged[$linenr_right] = current($right); next($right); } else { if (current($left) < 0 || current($right) < 0) { $coverageMerged[$linenr_right] = current($right); } else { $coverageMerged[$linenr_right] = current($left) + current($right); } next($left); next($right); } } while (current($left)) { $coverageMerged[key($left)] = current($left); next($left); } while (current($right)) { $coverageMerged[key($right)] = current($right); next($right); } return $coverageMerged; }
/** * 连表查询 公共方法 * @param string $files 查询字段 * @param array $manTable 主表 array('表名'=>'别名') * @param array $link 关联表 array('$_link'=>'别名') * @param string $where 查询条件 * @param string $order 排序 * @param string $limit limit * @param int $type 1:返回一条一维数据 0:默认返回二维数组 * @return array */ public function getNewsCommonLink($files = '*', $manTable, $link, $where = '', $order = '', $limit = '', $type = 0) { $manTableName = key($manTable); $manTableAlse = $manTable[$manTableName]; $sql = "SELECT " . $files; $sql .= " FROM " . $manTableName . " AS " . $manTableAlse; if ($link) { while ($key = key($link)) { $sql .= " LEFT JOIN " . $this->_link[$key]['table'] . " AS " . $link[$key] . " ON " . $link[$key] . "." . $this->_link[$key]['otherKey'] . " = " . $manTableAlse . "." . $this->_link[$key]['selfKey']; next($link); } } if ($where) { $sql .= " WHERE " . $where; } if ($order) { $sql .= " ORDER BY " . $order; } if ($limit) { $sql .= " LIMIT " . $limit; } $query = $this->db->query($sql); if ($query->num_rows > 0) { if (!$type) { return $query->result_array(); } else { return $query->row_array(); } } else { return array(); } }
public function next() { $isValid = next($this->_collectionItems); if (false == $isValid) { $this->_valid = false; } }
public function next() { $hasNext = next($this->_taxonomiesFromWp); if (false == $hasNext) { $this->_hasNext = false; } }
private function advanceElementIterator(\Iterator $element) { $element->next(); if (!$element->valid()) { next($this->fields); } }
public function fromStringWithMessage($string, $message, $messagePrefix = '# ', $extension = null) { if (null !== $message) { $message = explode("\n", $message); foreach ($message as $line) { $source[] = $messagePrefix . $line; } $source = implode("\n", $source) . PHP_EOL; } else { $source = ''; } $source .= $string; $res = $this->fromString($source, $extension); $res = explode("\n", $res); $line = current($res); while (0 === strpos($line, $messagePrefix)) { $line = next($res); } $out = []; while ($line) { $out[] = $line; $line = next($res); } return implode("\n", $out); }
private function parseRawToList($raw) { $raw = trim($raw); if (!empty($raw)) { $list = new \ArrayObject(); $token = explode(PHP_EOL, $raw); $a = 1; while ($a < count($token)) { next($token); $attr = new Attribute(); if (!(current($token) == "!re") && !(current($token) == "!trap")) { $split = explode("=", current($token)); $attr->setName($split[1]); if (count($split) == 3) { $attr->setValue($split[2]); } else { $attr->setValue(NULL); } $list->append($attr); } $a++; } if ($list->count() != 0) { $this->result->add($list); } } }
* * @package Smarty * @subpackage PluginsShared */ if (!function_exists('smarty_mb_str_replace')) { /** * Multibyte string replace * * @param string $search the string to be searched * @param string $replace the replacement string * @param string $subject the source string * @param int &$count number of matches found * @return string replaced string * @author Rodney Rehm */ function smarty_mb_str_replace($search, $replace, $subject, &$count = 0) { if (!is_array($search) && is_array($replace)) { return false; } if (is_array($subject)) { // call mb_replace for each single string in $subject foreach ($subject as &$string) { $string =& smarty_mb_str_replace($search, $replace, $string, $c); $count += $c; } } elseif (is_array($search)) { if (!is_array($replace)) { foreach ($search as &$string) { $subject = smarty_mb_str_replace($string, $replace, $subject, $c); $count += $c; } } else { $n = max(count($search), count($replace));
/** * @covers Zend\Db\Sql\AbstractSql::processExpression */ public function testProcessExpressionWithDriverAndParameterizationTypeNamed() { $mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface'); $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue(DriverInterface::PARAMETERIZATION_NAMED)); $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnCallback(function ($x) { return ':' . $x; })); $expression = new Expression('? > ? AND y < ?', array('x', 5, 10), array(Expression::TYPE_IDENTIFIER)); $sqlAndParams = $this->invokeProcessExpressionMethod($expression, $mockDriver); $this->assertRegExp('#"x" > :expr\\d\\d\\d\\dParam1 AND y < :expr\\d\\d\\d\\dParam2#', $sqlAndParams['sql']); $this->assertInternalType('array', $sqlAndParams['parameters']); // test keys and values preg_match('#expr(\\d\\d\\d\\d)Param1#', key($sqlAndParams['parameters']), $matches); $expressionNumber = $matches[1]; $this->assertRegExp('#expr\\d\\d\\d\\dParam1#', key($sqlAndParams['parameters'])); $this->assertEquals(5, current($sqlAndParams['parameters'])); next($sqlAndParams['parameters']); $this->assertRegExp('#expr\\d\\d\\d\\dParam2#', key($sqlAndParams['parameters'])); $this->assertEquals(10, current($sqlAndParams['parameters'])); // ensure next invocation increases number by 1 $sqlAndParamsNext = $this->invokeProcessExpressionMethod($expression, $mockDriver); preg_match('#expr(\\d\\d\\d\\d)Param1#', key($sqlAndParamsNext['parameters']), $matches); $expressionNumberNext = $matches[1]; $this->assertEquals(1, (int) $expressionNumberNext - (int) $expressionNumber); }
public static function applyFunctorToCartesianProduct($arrays, TupleFunctor $functor) { $result = []; $size = sizeof($arrays) > 0 ? 1 : 0; foreach ($arrays as $array) { $size *= sizeof($array); } $keys = array_keys($arrays); foreach ($keys as $key) { $tmpArrays[] = $arrays[$key]; } for ($i = 0; $i < $size; $i++) { $result[$i] = []; for ($j = 0; $j < sizeof($tmpArrays); $j++) { $result[$i][$keys[$j]] = current($tmpArrays[$j]); } $functor->apply($result[$i]); unset($result[$i]); for ($j = sizeof($tmpArrays) - 1; $j >= 0; $j--) { if (next($tmpArrays[$j])) { break; } else { reset($tmpArrays[$j]); } } } }
function put_format_selects() { global $knews_delimiters, $knews_enclosure, $knews_encode, $knews_line_endings, $Knews_plugin; ?> <p><?php _e('Separator', 'knews'); ?> : <select name="knews_delimiters" id="knews_delimiters"> <?php while ($d = current($knews_delimiters)) { echo '<option value="' . key($knews_delimiters) . '"' . ($Knews_plugin->post_safe('knews_delimiters') == key($knews_delimiters) ? ' selected="selected"' : '') . '>' . key($knews_delimiters) . '</option>'; next($knews_delimiters); } ?> </select> <?php _e('Enclosure', 'knews'); ?> : <select name="knews_enclosure" id="knews_enclosure"> <?php while ($d = current($knews_enclosure)) { echo '<option value="' . key($knews_enclosure) . '"' . ($Knews_plugin->post_safe('knews_enclosure') == key($knews_enclosure) ? ' selected="selected"' : '') . '>' . key($knews_enclosure) . '</option>'; next($knews_enclosure); } ?> </select> </p> <?php }
public function testMessageBag() { $messageBag = new MessageBag(); $messageBag->writeInfo(' <blah>this is a line</blah> '); $messageBag->writeLine(' <blah>this is a line</blah> '); $messageBag->writeError(' <blah>this is a line</blah> '); $messageBag->writeComment(' <blah>this is a line</blah> '); $messageBag->writeQuestion(' <blah>this is a line</blah> '); $messages = $messageBag->getMessages(); $this->assertTrue($messageBag->hasMessages()); $this->assertInternalType('array', $messages); $message = current($messages); $this->assertEquals(MessageBag::INFO, $messageBag->getMessageType($message)); $this->assertEquals('this is a line', $messageBag->getMessage($message)); $message = next($messages); $this->assertEquals(MessageBag::LINE, $messageBag->getMessageType($message)); $this->assertEquals('this is a line', $messageBag->getMessage($message)); $message = next($messages); $this->assertEquals(MessageBag::ERROR, $messageBag->getMessageType($message)); $this->assertEquals('this is a line', $messageBag->getMessage($message)); $message = next($messages); $this->assertEquals(MessageBag::COMMENT, $messageBag->getMessageType($message)); $this->assertEquals('this is a line', $messageBag->getMessage($message)); $message = next($messages); $this->assertEquals(MessageBag::QUESTION, $messageBag->getMessageType($message)); $this->assertEquals('this is a line', $messageBag->getMessage($message)); $messageBag->deleteMessages(); $this->assertFalse($messageBag->hasMessages()); }
/** * 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']); } }
private function _splitToTokens() { $content = $this->_doc_content; $tmp = array(); $tmp2 = array(); $slength = array(); $content = str_replace(".", " ", $content); $tmp = explode(" ", $content); foreach ($tmp as $word) { // let's count only words with more then 4 chars if (mb_strlen($word, $this->_charset) > 3) { $tmp2[$word] = $word; $slength[$word] = strlen($word); } } array_multisort($slength, SORT_DESC, $tmp2, SORT_ASC); $count = count($slength); // Save only top15 (by length) sentences/words for ($i = 0; $i < $count && $i < 15; $i++) { $this->_tokens[] = current($tmp2); next($tmp2); } $this->length = count($this->_tokens); 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)); }
protected static function _autoLoad() { spl_autoload_register(function ($className) { $startIndex = strpos($className, '\\'); if ($startIndex !== false) { $className = substr($className, strpos($className, '\\') + 1); } $segments = explode('_', $className); $total_segments = count($segments); $directory = null; if ($total_segments === 0) { return false; } if ($total_segments === 1) { $directory = self::$_default_load_directory; } else { $directory = strtolower(array_shift($segments)); if (substr($directory, -1) === 'y') { $directory = substr($directory, 0, -1) . 'ies'; } else { $directory .= 's'; } } $path = PROJECT_ROOT . 'application' . DIRECTORY_SEPARATOR . $directory; do { $path .= DIRECTORY_SEPARATOR . current($segments); } while (next($segments)); $path .= '.php'; if (file_exists($path)) { require_once $path; } }); }
static function insertLineComments($scss, $filepath = '') { $lines = $scss; $new_scss_content = array(); $filepath = str_replace('\\', '/', $filepath); foreach ($lines as $linenumber => $line) { $line = trim($line); $nextline = trim(next($lines)); //check if empty if (empty($line)) { continue; } //check if line is a commment if (self::isComment($line) || self::$inside_multiline) { $new_scss_content[] = $line; continue; } //write line numbers for selectors only to reduce overhead if (self::isSelector($line, $nextline) == FALSE || self::isFunction($line) == TRUE || self::isMixin($line) == TRUE || self::isInclude($line) == TRUE || self::isCondition($line) == TRUE || self::isLoop($line) == TRUE || self::isMap($line) == TRUE) { $new_scss_content[] = $line; continue; } //output line commment $new_scss_content[] = self::comment_indicator_start . ' line ' . ($linenumber + 1) . ', ' . $filepath . ' ' . self::comment_indicator_end; $new_scss_content[] = $line; } return implode("\n", $new_scss_content); }
function testReorderSections() { $sections = array(20 => 0, 21 => 1, 22 => 2, 23 => 3, 24 => 4, 25 => 5); $this->assertFalse(reorder_sections(1, 3, 4)); $newsections = reorder_sections($sections, 2, 4); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $newsections = reorder_sections($sections, 4, 0); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $newsections = reorder_sections($sections, 1, 5); $newsections_flipped = array_flip($newsections); $this->assertEqual(20, reset($newsections_flipped)); $this->assertEqual(22, next($newsections_flipped)); $this->assertEqual(23, next($newsections_flipped)); $this->assertEqual(24, next($newsections_flipped)); $this->assertEqual(25, next($newsections_flipped)); $this->assertEqual(21, next($newsections_flipped)); }
/** * @return bool * @throws ValidationFailedException */ public function validate() { try { // results come from the data base, hence is an array of mapped array if ($this->limits[$this->key] === 'table') { return true; } if ($this->limits[$this->key] === 'pie') { $formatter = new ResultsPrepareFormatter(); $values = $formatter->prepareResults($this->values); $values = end($values); if ($values === false) { throw new ValidationFailedException("Results are not Pie Compatible", 500); } array_map([$this, 'isValueNumeric'], $values); return true; } try { array_map([$this, 'isValueNumeric'], $this->values); return true; } catch (NotPlotableException $e) { $formatter = new ResultsPrepareFormatter(); $values = $formatter->prepareResults($this->values); $values = next($values); array_map([$this, 'isValueNumeric'], $values); return true; } // TODO: fix this! } catch (NotPlotableException $e) { throw new ValidationFailedException($e->getMessage(), $e->getCode(), $e); } }