Example #1
2
function base_getBreadcrumbs()
{
    if (is_404()) {
        return false;
    }
    // Hack to fix breadcrumbs when you're viewing the news home
    if (is_home()) {
        $post = new \Timber\Post(get_option('page_for_posts'));
    } else {
        global $post;
    }
    $breadcrumbs = [];
    if ($post->post_parent) {
        $parent_id = $post->post_parent;
        while ($parent_id) {
            $page = get_page($parent_id);
            $breadcrumbs[] = new \Timber\Post($page->ID);
            $parent_id = $page->post_parent;
        }
        $breadcrumbs = array_reverse($breadcrumbs);
    }
    // Add 'Blog Home' to breadcrumbs if you're on a news post or archive
    if ((is_single() || is_archive()) && !is_search()) {
        $breadcrumbs[] = new \Timber\Post(get_option('page_for_posts'));
    }
    return $breadcrumbs;
}
Example #2
1
 /**
  * Truncates a string to the given length.  It will optionally preserve
  * HTML tags if $is_html is set to true.
  *
  * @param   string  $string        the string to truncate
  * @param   int     $limit         the number of characters to truncate too
  * @param   string  $continuation  the string to use to denote it was truncated
  * @param   bool    $is_html       whether the string has HTML
  * @return  string  the truncated string
  */
 public static function truncate($string, $limit, $continuation = '...', $is_html = false)
 {
     $offset = 0;
     $tags = array();
     if ($is_html) {
         // Handle special characters.
         preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] >= $limit) {
                 break;
             }
             $limit += static::length($match[0][0]) - 1;
         }
         // Handle all the html tags.
         preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] - $offset >= $limit) {
                 break;
             }
             $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1);
             if ($tag[0] != '/') {
                 $tags[] = $tag;
             } elseif (end($tags) == static::sub($tag, 1)) {
                 array_pop($tags);
             }
             $offset += $match[1][1] - $match[0][1];
         }
     }
     $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset));
     $new_string .= static::length($string) > $limit ? $continuation : '';
     $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
     return $new_string;
 }
 public function getPath($categoryId, $accountId, $delimiter = ' > ')
 {
     $account = Mage::helper('M2ePro/Component_Ebay')->getCachedObject('Account', $accountId);
     $categories = $account->getChildObject()->getEbayStoreCategories();
     $pathData = array();
     while (true) {
         $currentCategory = NULL;
         foreach ($categories as $category) {
             if ($category['category_id'] == $categoryId) {
                 $currentCategory = $category;
                 break;
             }
         }
         if (is_null($currentCategory)) {
             break;
         }
         $pathData[] = $currentCategory['title'];
         if ($currentCategory['parent_id'] == 0) {
             break;
         }
         $categoryId = $currentCategory['parent_id'];
     }
     array_reverse($pathData);
     return implode($delimiter, $pathData);
 }
Example #4
1
 /** Creates directory or throws exception on fail
  * @param string $pathname
  * @param int    $mode     Mode in octal
  * @return bool
  */
 public static function create($pathname, $mode = self::MOD_DEFAULT)
 {
     if (strpos($pathname, '/') !== false) {
         $pathname = explode('/', $pathname);
     }
     if (is_array($pathname)) {
         $current_dir = '';
         $create = array();
         do {
             $current_dir = implode('/', $pathname);
             if (is_dir($current_dir)) {
                 break;
             }
             $create[] = array_pop($pathname);
         } while (any($pathname));
         if (any($create)) {
             $create = array_reverse($create);
             $current_dir = implode('/', $pathname);
             foreach ($create as $dir) {
                 $current_dir .= '/' . $dir;
                 if (!is_dir($current_dir)) {
                     if (!($action = @mkdir($current_dir, $mode))) {
                         throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $current_dir, base_convert($mode, 10, 8)));
                     }
                 }
             }
         }
     } else {
         if (!($action = @mkdir($pathname, $mode, true))) {
             throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $pathname, base_convert($mode, 10, 8)));
         }
     }
     return $action;
 }
 public function get_info($base)
 {
     $sitename = $this->sitename($base);
     $c = new Crawler($base);
     $c->go_to('id="listing"');
     $list = array();
     while ($line = $c->readline()) {
         if (Crawler::is_there($line, 'class="chico_')) {
             if (!Crawler::is_there($line, ' href="')) {
                 $line = $c->readline();
             }
             $chp = Crawler::extract($line, 'href="', '"');
             $ifx = Crawler::cutfromlast1($chp, '/');
             $ifx = str_replace('chapter-', '', $ifx);
             $ifx = str_replace('.html', '', $ifx);
             $list[] = array('url' => $sitename . $chp, 'infix' => $ifx, 'desc' => strip_tags(Crawler::extract($line, '">', '</td>')));
         } else {
             if (Crawler::is_there($line, '</table>')) {
                 break;
             }
         }
     }
     $c->close();
     return array_reverse($list);
 }
 public static function NewStr($FinallyStr)
 {
     if (preg_match('/[^a-z0-9]/i', $FinallyStr)) {
         return false;
     }
     $StrLength = strlen($FinallyStr);
     if ($StrLength < 0) {
         return false;
     }
     $NewArr = array();
     $i = 0;
     $AnStr = str_split($FinallyStr);
     $obj = new str_increment();
     //instantiation self
     do {
         $NewAnStr = $obj->Calculation(array_pop($AnStr));
         ++$i;
         $IsDo = false;
         if ($NewAnStr !== false) {
             if ($NewAnStr === $obj->Table[0]) {
                 if ($i < $StrLength) {
                     $IsDo = true;
                 }
             }
             $NewArr[] = $NewAnStr;
         }
     } while ($IsDo);
     $ObverseStr = implode('', $AnStr) . implode('', array_reverse($NewArr));
     if (self::$FirstRandomCode) {
         $ObverseStr = $obj->ReplaceFirstCode($ObverseStr);
     }
     return $StrLength == strlen($ObverseStr) ? $ObverseStr : false;
 }
 public function testRecreateEntity()
 {
     $type_name = Unicode::strtolower($this->randomMachineName(16));
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type one'));
     $content_type->save();
     node_add_body_field($content_type);
     /** @var \Drupal\Core\Config\StorageInterface $active */
     $active = $this->container->get('config.storage');
     /** @var \Drupal\Core\Config\StorageInterface $sync */
     $sync = $this->container->get('config.storage.sync');
     $config_name = $content_type->getEntityType()->getConfigPrefix() . '.' . $content_type->id();
     $this->copyConfig($active, $sync);
     // Delete the content type. This will also delete a field storage, a field,
     // an entity view display and an entity form display.
     $content_type->delete();
     $this->assertFalse($active->exists($config_name), 'Content type\'s old name does not exist active store.');
     // Recreate with the same type - this will have a different UUID.
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type two'));
     $content_type->save();
     node_add_body_field($content_type);
     $this->configImporter->reset();
     // A node type, a field, an entity view display and an entity form display
     // will be recreated.
     $creates = $this->configImporter->getUnprocessedConfiguration('create');
     $deletes = $this->configImporter->getUnprocessedConfiguration('delete');
     $this->assertEqual(5, count($creates), 'There are 5 configuration items to create.');
     $this->assertEqual(5, count($deletes), 'There are 5 configuration items to delete.');
     $this->assertEqual(0, count($this->configImporter->getUnprocessedConfiguration('update')), 'There are no configuration items to update.');
     $this->assertIdentical($creates, array_reverse($deletes), 'Deletes and creates contain the same configuration names in opposite orders due to dependencies.');
     $this->configImporter->import();
     // Verify that there is nothing more to import.
     $this->assertFalse($this->configImporter->reset()->hasUnprocessedConfigurationChanges());
     $content_type = NodeType::load($type_name);
     $this->assertEqual('Node type one', $content_type->label());
 }
Example #8
0
 function MZn2_Noticias()
 {
     global $s, $m, $system_ok;
     if (!$system_ok) {
         return;
     }
     if (!$this->pagina) {
         $this->pagina = 1;
     }
     $this->dbC = $s->db_table_open($s->cfg['file']['comments']);
     $this->dbC = $this->dbC['data'];
     $this->dbN = $s->db_table_open($s->cfg['file']['news']);
     $this->dbN = $this->dbN['data'];
     $this->filter_load();
     $addrs = array();
     foreach (array_reverse(explode(",", $s->req['HTTP_X_FORWARDED_FOR'])) as $x_f) {
         $x_f = trim($x_f);
         if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/", $x_f)) {
             $addrs[] = $x_f;
         }
     }
     $addrs[] = $s->req['REMOTE_ADDR'];
     $addrs[] = $s->req['HTTP_PROXY_USER'];
     $ip = $this->select_var($addrs);
     $ip = preg_replace("/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})/", "\\1.\\2.\\3.\\4", $ip);
     $s->req['REMOTE_ADDR'] = $ip;
     $this->ip = $ip;
 }
 /**
  * Expands a flat array to a nested array.
  *
  * For example, `['0_Foo_Bar' => 'Far']` becomes
  * `[['Foo' => ['Bar' => 'Far']]]`.
  *
  * @param array $environment Array of environment data
  * @return array
  */
 public function __invoke(array $environment)
 {
     $result = array();
     foreach ($environment as $flat => $value) {
         $keys = explode('_', $flat);
         $keys = array_reverse($keys);
         $child = array($keys[0] => $value);
         array_shift($keys);
         foreach ($keys as $k) {
             $child = array($k => $child);
         }
         $stack = array(array($child, &$result));
         while (!empty($stack)) {
             foreach ($stack as $curKey => &$curMerge) {
                 foreach ($curMerge[0] as $key => &$val) {
                     $hasKey = !empty($curMerge[1][$key]);
                     if ($hasKey && (array) $curMerge[1][$key] === $curMerge[1][$key] && (array) $val === $val) {
                         $stack[] = array(&$val, &$curMerge[1][$key]);
                     } else {
                         $curMerge[1][$key] = $val;
                     }
                 }
                 unset($stack[$curKey]);
             }
             unset($curMerge);
         }
     }
     return $result;
 }
 function act($qarray)
 {
     if (isset($_GET['process'])) {
         unset($_GET['process']);
         unset($qarray['process']);
         $_POST['process'] = "true";
     }
     $args = array_reverse(array_keys($qarray));
     $c_name = preg_replace("/[^A-Za-z0-9_]/", "", array_pop($args));
     $parts = split("_", $c_name);
     $name = "";
     foreach ($parts as $p) {
         $name .= ucfirst($p);
     }
     $c_name = $name;
     $c_action = preg_replace("/[^A-Za-z0-9_]/", "", array_pop($args));
     $args = array_reverse($args);
     if (!@call_user_func(array(Controller, "i_once"), $GLOBALS['fileroot'] . "/controllers/C_" . $c_name . ".class.php")) {
         echo "Unable to load controller {$name}\n, please check the first argument supplied in the URL and try again";
         exit;
     }
     $obj_name = "C_" . $c_name;
     $c_obj = new $obj_name();
     if (empty($c_action)) {
         $c_action = "default";
     }
     $c_obj->_current_action = $c_action;
     $args_array = array();
     foreach ($args as $arg) {
         $arg = preg_replace("/[^A-Za-z0-9_]/", "", $arg);
         //this is a workaround because call user func does funny things with passing args if they have no assigned value
         if (empty($qarray[$arg])) {
             //if argument is empty pass null as value and arg as assoc array key
             $args_array[$arg] = null;
         } else {
             $args_array[$arg] = $qarray[$arg];
         }
     }
     $output = "";
     //print_r($args_array);
     if ($_POST['process'] == "true") {
         if (is_callable(array(&$c_obj, $c_action . "_action_process"))) {
             //echo "ca: " . $c_action . "_action_process";
             $output .= call_user_func_array(array(&$c_obj, $c_action . "_action_process"), $args_array);
             if ($c_obj->_state == false) {
                 return $output;
             }
         }
         //echo "ca: " . $c_action . "_action";
         $output .= call_user_func_array(array(&$c_obj, $c_action . "_action"), $args_array);
     } else {
         if (is_callable(array(&$c_obj, $c_action . "_action"))) {
             //echo "ca: " . $c_action . "_action";
             $output .= call_user_func_array(array(&$c_obj, $c_action . "_action"), $args_array);
         } else {
             echo "The action trying to be performed: " . $c_action . " does not exist controller: " . $name;
         }
     }
     return $output;
 }
Example #11
0
 public function getHTML()
 {
     wfProfileIn(__METHOD__);
     $this->report->loadSources();
     $aData = array();
     $aLabel = array();
     if (count($this->report->reportSources) == 0) {
         return '';
     }
     foreach ($this->report->reportSources as $reportSource) {
         $reportSource->getData();
         $this->actualDate = $reportSource->actualDate;
         if (!empty($reportSource->dataAll) && !empty($reportSource->dataTitles)) {
             if (is_array($reportSource->dataAll)) {
                 foreach ($reportSource->dataAll as $key => $val) {
                     if (isset($aData[$key])) {
                         $aData[$key] = array_merge($aData[$key], $val);
                     } else {
                         $aData[$key] = $val;
                     }
                 }
             }
             $aLabel += $reportSource->dataTitles;
         }
     }
     sort($aData);
     $this->sourceData = array_reverse($aData);
     $this->sourceLabels = array_reverse($aLabel);
     $oTmpl = F::build('EasyTemplate', array(dirname(__FILE__) . "/templates/"));
     /** @var $oTmpl EasyTemplate */
     $oTmpl->set_vars(array('data' => $this->sourceData, 'labels' => $this->sourceLabels));
     wfProfileOut(__METHOD__);
     $this->beforePrint();
     return $oTmpl->render('../../templates/output/' . self::TEMPLATE_MAIN);
 }
 /**
  * Gets a valid commit order for all current nodes.
  * 
  * Uses a depth-first search (DFS) to traverse the graph.
  * The desired topological sorting is the reverse postorder of these searches.
  *
  * @return array The list of ordered classes.
  */
 public function getCommitOrder()
 {
     // Check whether we need to do anything. 0 or 1 node is easy.
     $nodeCount = count($this->_classes);
     if ($nodeCount == 0) {
         return array();
     } else {
         if ($nodeCount == 1) {
             return array_values($this->_classes);
         }
     }
     // Init
     foreach ($this->_classes as $node) {
         $this->_nodeStates[$node->name] = self::NOT_VISITED;
     }
     // Go
     foreach ($this->_classes as $node) {
         if ($this->_nodeStates[$node->name] == self::NOT_VISITED) {
             $this->_visitNode($node);
         }
     }
     $sorted = array_reverse($this->_sorted);
     $this->_sorted = $this->_nodeStates = array();
     return $sorted;
 }
 private function getLatestSymfonyVersion()
 {
     // Get GitHub JSON request
     $opts = array('http' => array('method' => "GET", 'header' => "User-Agent: LiipMonitorBundle\r\n"));
     $context = stream_context_create($opts);
     $githubUrl = 'https://api.github.com/repos/symfony/symfony/tags';
     $githubJSONResponse = file_get_contents($githubUrl, false, $context);
     // Convert it to a PHP object
     $githubResponseArray = json_decode($githubJSONResponse, true);
     if (empty($githubResponseArray)) {
         throw new \Exception("No valid response or no tags received from GitHub.");
     }
     $tags = array();
     foreach ($githubResponseArray as $tag) {
         $tags[] = $tag['name'];
     }
     // Sort tags
     usort($tags, "version_compare");
     // Filter out non final tags
     $filteredTagList = array_filter($tags, function ($tag) {
         return !stripos($tag, "PR") && !stripos($tag, "RC") && !stripos($tag, "BETA");
     });
     // The first one is the last stable release for Symfony 2
     $reverseFilteredTagList = array_reverse($filteredTagList);
     return str_replace("v", "", $reverseFilteredTagList[0]);
 }
Example #14
0
 /**
  * Creates the exception output.
  *
  * @return string the exception output.
  *
  * @author Tobias Lückel[Megger]
  * @version
  * Version 0.1, 25.11.2013<br />
  */
 protected function buildExceptionOutput()
 {
     $output = PHP_EOL;
     $output .= '[' . $this->generateExceptionID() . ']';
     $output .= '[' . $this->exceptionNumber . ']';
     $output .= ' ' . $this->exceptionMessage . PHP_EOL;
     $output .= self::TAB . $this->exceptionFile . ':' . $this->exceptionLine . PHP_EOL;
     $output .= 'Stacktrace:' . PHP_EOL;
     $stacktrace = array_reverse($this->exceptionTrace);
     foreach ($stacktrace as $item) {
         $output .= self::TAB;
         if (isset($item['class'])) {
             $output .= $item['class'];
         }
         if (isset($item['type'])) {
             $output .= $item['type'];
         }
         if (isset($item['function'])) {
             $output .= $item['function'] . '()';
         }
         $output .= PHP_EOL;
         $output .= self::TAB . self::TAB;
         if (isset($item['file'])) {
             $output .= $item['file'];
         }
         if (isset($item['file'])) {
             $output .= ':' . $item['line'];
         }
         $output .= PHP_EOL;
     }
     $output .= PHP_EOL;
     return $output;
 }
Example #15
0
 private function setItemstoSend()
 {
     foreach ($this->_order->getAllItems() as $item) {
         $mcitem = array();
         $product = Mage::getSingleton('catalog/product')->load($item->getProductId());
         if (in_array($product->getTypeId(), $this->_productsToSkip) && $product->getPriceType() == 0) {
             if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
                 $this->_auxPrice = $item->getPrice();
             }
             continue;
         }
         $mcitem['product_id'] = $product->getEntityId();
         $mcitem['product_name'] = $product->getName();
         $names = array();
         $cat_ids = $product->getCategoryIds();
         if (is_array($cat_ids) && count($cat_ids) > 0) {
             $category = Mage::getModel('catalog/category')->load($cat_ids[0]);
             $mcitem['category_id'] = $cat_ids[0];
             $names[] = $category->getName();
             while ($category->getParentId() && $category->getParentId() != 1) {
                 $category = Mage::getModel('catalog/category')->load($category->getParentId());
                 $names[] = $category->getName();
             }
         }
         $mcitem['category_name'] = count($names) ? implode(" - ", array_reverse($names)) : 'None';
         $mcitem['qty'] = $item->getQtyOrdered();
         $mcitem['cost'] = $this->_auxPrice > 0 ? $this->_auxPrice : $item->getPrice();
         $this->_info['items'][] = $mcitem;
         $this->_auxPrice = 0;
     }
     return $this;
 }
Example #16
0
 public function constant($mm_config = array())
 {
     // Set theme primary information.
     foreach ($mm_config as $key => $value) {
         $this->constant[$key] = $value;
     }
     // Set theme identificators and prefixes.
     $this->constant['MM_OPTIONS_NAME'] = $this->constant['MM_WARE_SLUG'] . '_options';
     $this->constant['MM_OPTIONS_DB_NAME'] = $this->constant['MM_OPTIONS_NAME'];
     $this->constant['MM_TEXTDOMAIN'] = $this->constant['MM_WARE_SLUG'];
     $this->constant['MM_TEXTDOMAIN_ADMIN'] = $this->constant['MM_WARE_SLUG'] . '_admin';
     $this->constant['MM_THEME_PAGE_SLUG'] = $this->constant['MM_OPTIONS_NAME'];
     // Set theme static locations.
     // DIRECTORIES
     $this->constant['MM_WARE_DIR'] = dirname($this->constant['MM_WARE_INIT_FILE']);
     $this->constant['MM_WARE_FRAMEWORK_DIR'] = $this->constant['MM_WARE_DIR'] . '/framework';
     $this->constant['MM_WARE_EXTENSIONS_DIR'] = $this->constant['MM_WARE_DIR'] . '/extensions';
     $this->constant['MM_WARE_SRC_DIR'] = $this->constant['MM_WARE_DIR'] . '/src';
     $this->constant['MM_WARE_CSS_DIR'] = $this->constant['MM_WARE_SRC_DIR'] . '/css';
     // URL's
     if (is_multisite()) {
         $home_url = get_home_url();
     } else {
         $wpurl = get_bloginfo('wpurl');
         $home_url = $wpurl;
     }
     $ware_dir_explode = array_reverse(explode('/', str_replace('\\', '/', $this->constant['MM_WARE_DIR'])));
     $this->constant['MM_WARE_URL'] = $home_url . '/' . $ware_dir_explode[2] . '/' . $ware_dir_explode[1] . '/' . $ware_dir_explode[0];
     $this->constant['MM_WARE_SRC_URL'] = $this->constant['MM_WARE_URL'] . '/src';
     $this->constant['MM_WARE_CSS_URL'] = $this->constant['MM_WARE_SRC_URL'] . '/css';
     $this->constant['MM_WARE_JS_URL'] = $this->constant['MM_WARE_SRC_URL'] . '/js';
     $this->constant['MM_WARE_FONTS_URL'] = $this->constant['MM_WARE_SRC_URL'] . '/fonts';
     $this->constant['MM_WARE_IMG_URL'] = $this->constant['MM_WARE_SRC_URL'] . '/img';
 }
 /**
  * Stop a benchmarking timer.
  *
  * $name should be the same as the $name used in startTimer().
  *
  * @param string $name The name of the timer to end.
  * @access public
  * @return boolean true if timer was ended, false if timer was not started.
  * @static
  */
 function stopTimer($name = null)
 {
     $end = getMicrotime();
     $_this = DebugKitDebugger::getInstance();
     if (!$name) {
         $names = array_reverse(array_keys($_this->__benchmarks));
         foreach ($names as $name) {
             if (!empty($_this->__benchmarks[$name]['end'])) {
                 continue;
             }
             if (empty($_this->__benchmarks[$name]['named'])) {
                 break;
             }
         }
     } else {
         $i = 1;
         $_name = $name;
         while (isset($_this->__benchmarks[$name])) {
             if (empty($_this->__benchmarks[$name]['end'])) {
                 break;
             }
             $i++;
             $name = $_name . ' #' . $i;
         }
     }
     if (!isset($_this->__benchmarks[$name])) {
         return false;
     }
     $_this->__benchmarks[$name]['end'] = $end;
     return true;
 }
Example #18
0
 protected function dumpObject($obj, $hash)
 {
     if (isset($this->objectsDepth[$hash])) {
         if ($this->objectsDepth[$hash] < $this->depth) {
             $this->refPool[$this->counter]['ref_counter'] = $this->counter;
             $this->dumpRef(true, $this->counter, $obj, 'object');
             return;
         } else {
             unset($this->objectsDepth[$hash]);
         }
     }
     $a = (array) $obj;
     $c = get_class($obj);
     $p = array($c => $c) + class_parents($obj) + class_implements($obj) + array('*' => '*');
     foreach (array_reverse($p) as $p) {
         if (!empty($this->casters[$p = 'o:' . strtolower($p)])) {
             foreach ($this->casters[$p] as $p) {
                 try {
                     $a = call_user_func($p, $obj, $a);
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     $this->walkHash($c, $a, count($a));
 }
Example #19
0
 /**
  * Get array of last added items
  *
  * @return array
  */
 public function getRecentItems($count = null)
 {
     if ($count === null) {
         $count = $this->getItemCount();
     }
     $items = array();
     if (!$this->getSummaryCount()) {
         return $items;
     }
     $i = 0;
     $allItems = array_reverse($this->getItems());
     foreach ($allItems as $item) {
         /* @var $item Mage_Sales_Model_Quote_Item */
         if (!$item->getProduct()->isVisibleInSiteVisibility()) {
             $productId = $item->getProduct()->getId();
             $products = Mage::getResourceSingleton('catalog/url')->getRewriteByProductStore(array($productId => $item->getStoreId()));
             if (!isset($products[$productId])) {
                 continue;
             }
             $urlDataObject = new Varien_Object($products[$productId]);
             $item->getProduct()->setUrlDataObject($urlDataObject);
         }
         $items[] = $item;
         if (++$i == $count) {
             break;
         }
     }
     return $items;
 }
Example #20
0
 /**
  * Stop a benchmarking timer.
  *
  * $name should be the same as the $name used in startTimer().
  *
  * @param string $name The name of the timer to end.
  * @return bool true if timer was ended, false if timer was not started.
  */
 public static function stop($name = null)
 {
     $end = microtime(true);
     if (!$name) {
         $names = array_reverse(array_keys(self::$_timers));
         foreach ($names as $name) {
             if (!empty(self::$_timers[$name]['end'])) {
                 continue;
             }
             if (empty(self::$_timers[$name]['named'])) {
                 break;
             }
         }
     } else {
         $i = 1;
         $_name = $name;
         while (isset(self::$_timers[$name])) {
             if (empty(self::$_timers[$name]['end'])) {
                 break;
             }
             $i++;
             $name = $_name . ' #' . $i;
         }
     }
     if (!isset(self::$_timers[$name])) {
         return false;
     }
     self::$_timers[$name]['end'] = $end;
     return true;
 }
Example #21
0
 public function delete()
 {
     // Get items to remove from the request and reverse the order to delete child albums first
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     JFactory::getApplication()->input->set('cid', array_reverse($cid));
     parent::delete();
 }
Example #22
0
 public static function DoIt()
 {
     self::prepareHttpString();
     ob_start();
     try {
         $url = new BuUrl2(self::$httpString);
         bu::setBuUrlInstance($url);
         self::runController($url);
     } catch (Exception $e) {
         ob_end_clean();
         $msg = 'Ошибка на сайте';
         if (bu::config('rc/debug')) {
             $msg = get_class($e) . ': ' . $e->getMessage();
         }
         $content = $msg;
         if (bu::config('rc/debug')) {
             $content .= sprintf('<br><b>%s</b><br>', get_class($e));
             $content .= "<pre>";
             foreach (array_reverse($e->getTrace()) as $v) {
                 if (isset($v['line'])) {
                     $content .= $v['line'] . ' ' . $v['file'] . "\n";
                 }
             }
             $content .= "</pre>";
         }
         echo bu::view('layout/panic', array('content' => $content));
     }
 }
 public function get_datas()
 {
     global $dbh;
     $return = array();
     $selector = $this->get_selected_selector();
     if ($selector) {
         $value = $selector->get_value();
         $records = array();
         if (is_array($value) && count($value)) {
             for ($i = 0; $i < count($value); $i++) {
                 $query = "select notice_id from notices where notice_id='" . $value[$i] . "'";
                 $result = pmb_mysql_query($query, $dbh);
                 if (pmb_mysql_num_rows($result) > 0) {
                     $row = pmb_mysql_fetch_object($result);
                     $records[] = $row->notice_id;
                 }
             }
             $records = array_reverse($records);
             $return['records'] = $this->filter_datas("notices", $records);
             if ($this->parameters['nb_max_elements'] > 0) {
                 $return['records'] = array_slice($return['records'], 0, $this->parameters['nb_max_elements']);
             }
         }
         return $return;
     }
     return false;
 }
Example #24
0
 /**
  * Gets a pipe-separated string of available languages
  *
  * @return string
  */
 public function getAvailable()
 {
     $languagesArray = $this->languages;
     //Make local copy
     sort($languagesArray);
     return implode('|', array_reverse($languagesArray));
 }
 function icl_register_admin_options($array, $key = "", $option = array())
 {
     if (is_object($option)) {
         $option = object_to_array($option);
     }
     foreach ($array as $k => $v) {
         $option = $key === '' ? array($k => maybe_unserialize($this->get_option_without_filtering($k))) : $option;
         if (is_array($v)) {
             $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option[$k]);
         } else {
             $context = $this->get_context($key, $k);
             if ($v === '') {
                 icl_unregister_string($context, $key . $k);
             } elseif (isset($option[$k]) && ($key === '' || preg_match_all('#\\[([^\\]]+)\\]#', (string) $key, $opt_key_matches) > 0)) {
                 icl_register_string($context, $key . $k, $option[$k]);
                 $vals = array($k => 1);
                 $opt_keys = isset($opt_key_matches) ? array_reverse($opt_key_matches[1]) : array();
                 foreach ($opt_keys as $opt) {
                     $vals = array($opt => $vals);
                 }
                 update_option('_icl_admin_option_names', array_merge_recursive((array) get_option('_icl_admin_option_names'), $vals));
             }
         }
     }
 }
 /**
  * Reads extension metadata
  *
  * @param object $meta
  * @return array - the metatada configuration
  */
 public function getExtensionMetadata($meta)
 {
     if ($meta->isMappedSuperclass) {
         return;
         // ignore mappedSuperclasses for now
     }
     $config = array();
     $cmf = $this->objectManager->getMetadataFactory();
     $useObjectName = $meta->name;
     // collect metadata from inherited classes
     if (null !== $meta->reflClass) {
         foreach (array_reverse(class_parents($meta->name)) as $parentClass) {
             // read only inherited mapped classes
             if ($cmf->hasMetadataFor($parentClass)) {
                 $class = $this->objectManager->getClassMetadata($parentClass);
                 $this->driver->readExtendedMetadata($class, $config);
                 $isBaseInheritanceLevel = !$class->isInheritanceTypeNone() && !$class->parentClasses && $config;
                 if ($isBaseInheritanceLevel) {
                     $useObjectName = $class->name;
                 }
             }
         }
     }
     $this->driver->readExtendedMetadata($meta, $config);
     if ($config) {
         $config['useObjectClass'] = $useObjectName;
     }
     // cache the metadata (even if it's empty)
     // caching empty metadata will prevent re-parsing non-existent annotations
     $cacheId = self::getCacheId($meta->name, $this->extensionNamespace);
     if ($cacheDriver = $cmf->getCacheDriver()) {
         $cacheDriver->save($cacheId, $config, null);
     }
     return $config;
 }
 public function control()
 {
     $this->setViewTemplate('dashboard.tpl');
     if ($this->shouldRefreshCache()) {
         $this->setInstance();
         $this->view_name = isset($_GET['v']) ? $_GET['v'] : 'default';
         $webapp = Webapp::getInstance();
         if (isset($this->instance)) {
             $webapp->setActivePlugin($this->instance->network);
             $sidebar_menu = $webapp->getDashboardMenu($this->instance);
             $this->addToView('sidebar_menu', $sidebar_menu);
             $this->loadView();
         } else {
             if (!Session::isLoggedIn()) {
                 $this->addInfoMessage('There are no public accounts set up in this ThinkUp installation.');
             } else {
                 $this->addInfoMessage('Welcome to ThinkUp. Let\'s get started.');
                 $plugin_dao = DAOFactory::getDAO('PluginDAO');
                 $plugins = $plugin_dao->getInstalledPlugins();
                 $add_user_buttons = array();
                 foreach ($plugins as $plugin) {
                     if ($plugin->folder_name == 'twitter' || $plugin->folder_name == 'facebook' || $plugin->folder_name == 'googleplus') {
                         if ($plugin->is_active) {
                             $add_user_buttons[] = $plugin->folder_name;
                         }
                     }
                 }
                 $add_user_buttons = array_reverse($add_user_buttons);
                 $this->addToView('add_user_buttons', $add_user_buttons);
             }
         }
     }
     return $this->generateView();
 }
 /**
  * Iterates through elements of $each and renders child nodes
  *
  * @param array $each The array or SplObjectStorage to iterated over
  * @param string $as The name of the iteration variable
  * @param string $key The name of the variable to store the current array key
  * @param boolean $reverse If enabled, the iterator will start with the last element and proceed reversely
  * @return string Rendered string
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  * @api
  */
 public function render($each, $as, $key = '', $reverse = FALSE)
 {
     $output = '';
     if ($each === NULL) {
         return '';
     }
     if (is_object($each)) {
         if (!$each instanceof Traversable) {
             throw new Tx_Fluid_Core_ViewHelper_Exception('ForViewHelper only supports arrays and objects implementing Traversable interface', 1248728393);
         }
         $each = $this->convertToArray($each);
     }
     if ($reverse === TRUE) {
         $each = array_reverse($each);
     }
     $output = '';
     foreach ($each as $keyValue => $singleElement) {
         $this->templateVariableContainer->add($as, $singleElement);
         if ($key !== '') {
             $this->templateVariableContainer->add($key, $keyValue);
         }
         $output .= $this->renderChildren();
         $this->templateVariableContainer->remove($as);
         if ($key !== '') {
             $this->templateVariableContainer->remove($key);
         }
     }
     return $output;
 }
Example #29
0
function reverseTitle($text)
{
    $separator = Loggix_Core::LOGGIX_TITLE_SEPARATOR;
    $titles = explode($separator, $text);
    $text = implode($separator, array_reverse($titles));
    return $text;
}
Example #30
-15
 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }