public function getShippingOptions($shipping_configuration)
 {
     if ($this->cache_result) {
         if (($options = $this->_getCachedOptions($shipping_configuration)) !== false) {
             return $options;
         }
     }
     if (!($options = $this->_doGetShippingOptions($shipping_configuration))) {
         return array();
     }
     $options = ComplexArray::sortArray($options, array('price' => 'ASC'));
     if ($this->cache_result) {
         $this->_saveCachedOptions($shipping_configuration, $options);
     }
     return $options;
 }
Ejemplo n.º 2
0
  static function _doSort($tree_array, & $sorted_tree_array, $sort_params, $parent_id, $id_hash, $parent_hash)
  {
    $children = array();

    foreach($tree_array as $index => $item)
    {
      if($item[$parent_hash] == $parent_id)
      {
        $children[] = $item;
        unset($tree_array[$index]);
      }
    }

    if(!($count = sizeof($children)))
      return;

    $children = ComplexArray :: sortArray($children, $sort_params);

    if(!$sorted_tree_array)
    {
      $sorted_tree_array = $children;
    }
    else
    {
      $ids = ComplexArray :: getColumnValues($id_hash, $sorted_tree_array);

      $offset = array_search($parent_id, $ids) + 1;

      array_splice($sorted_tree_array, $offset, 0, $children);
    }

    for($i=0; $i < $count; $i++)
    {
      TreeSorter :: _doSort($tree_array, $sorted_tree_array, $sort_params, $children[$i][$id_hash], $id_hash, $parent_hash);
    }
  }
  function _checkProperNesting($nodes, $line='')
  {
    $this->assertEqual(ComplexArray :: sortArray($nodes, array('path' => 'ASC')),
                       $nodes);

    $path = ComplexArray :: getMinColumnValue('path', $nodes, $index);
    $parent_paths[] = $this->_getParentPath($path);

    $counter = 0;
    foreach($nodes as $id => $node)
    {
      $parent_path = $this->_getParentPath($node['path']);

      $this->assertTrue(in_array($parent_path, $parent_paths),
        'path is improperly nested: ' . $node['path'] . ' , expected parent not found: ' . $parent_path . ' at line: ' . $line);

      $parent_paths[] = $node['path'];
    }
  }