protected function parseStoreSelect($active_ids, $areaSelected)
 {
     if ($areaSelected) {
         $stores = $this->getPageChildren($active_ids[count($active_ids) - 5]);
     } else {
         $stores = $this->getPageChildren($active_ids[count($active_ids) - 4]);
     }
     $stores = php_multisort($stores, array(array('key' => 'title', 'sort' => 'asc')));
     foreach ($stores as $store) {
         if ($store['publish'] == 1 && is_numeric($store['content'])) {
             $store['selected'] = in_array($store['id'], $active_ids) ? 'selected="selected"' : '';
             $this->tpl->assign("STORE", $store);
             $this->tpl->parse("content.store_dropdown.store");
         }
     }
     $this->tpl->parse("content.store_dropdown");
 }
示例#2
0
文件: index.php 项目: rauchg/moogets
            // Clear stat() cache to free up memory (not really needed).
            clearstatcache();
            // Add this items file size to this folders total size
            $total_size += $item['bytes'];
        }
    }
    // Close the directory when finished.
    closedir($handle);
}
// Sort folder list.
if ($folder_list) {
    $folder_list = php_multisort($folder_list, $sort);
}
// Sort file list.
if ($file_list) {
    $file_list = php_multisort($file_list, $sort);
}
// Calculate the total folder size
if ($file_list && $folder_list) {
    $total_size = bytes_to_string($total_size, 2);
}
/**********************************************************************************************************************************/
/******************************************************************************************************************[ FUNCTIONS ]***/
/**
 *	http://us.php.net/manual/en/function.array-multisort.php#83117
 */
function php_multisort($data, $keys)
{
    foreach ($data as $key => $row) {
        foreach ($keys as $k) {
            $cols[$k['key']][$key] = $row[$k['key']];
示例#3
0
 /**
  * sort by priority
  */
 public function sortByPriority($list)
 {
     /**
      * first pass parent_priority to the same level in multiarray (preparation for multisort function)
      */
     foreach ($list as $k => $item) {
         $list[$k]['parent_priority'] = $item['parent_data']['priority'];
     }
     /**
      * use multisort function
      */
     $list = php_multisort($list, array(array('key' => 'parent_priority', 'sort' => 'DESC'), array('key' => 'parent', 'type' => 'numeric')));
     foreach ($list as $item) {
         $l[] = $item;
     }
     $list = $l;
     return $list;
 }
示例#4
0
 function createEventString($eventArray)
 {
     $entries = array();
     if (is_array($eventArray)) {
         foreach ($eventArray as $anEntry) {
             if (is_array($anEntry) && !empty($anEntry['title'])) {
                 $startTime = strtotime($anEntry['gd:when attr']['startTime']);
                 // A bunch of crappy custom logic to make the date display prettier.
                 $sameDate = false;
                 if (strcasecmp(date("mdY", strtotime($anEntry['gd:when attr']['startTime'])), date("mdY", strtotime($anEntry['gd:when attr']['endTime']))) == 0) {
                     $sameDate = true;
                 }
                 if (date("h:iA", strtotime($anEntry['gd:when attr']['startTime'])) != "12:00AM") {
                     $startDate = date("m/d/Y@h:iA", strtotime($anEntry['gd:when attr']['startTime']));
                 } else {
                     $startDate = date("m/d/Y", strtotime($anEntry['gd:when attr']['startTime']));
                 }
                 if (date("h:iA", strtotime($anEntry['gd:when attr']['endTime'])) != "12:00AM") {
                     $endDate = date("m/d/Y@h:iA", strtotime($anEntry['gd:when attr']['endTime']));
                 } else {
                     $endDate = date("m/d/Y", strtotime($anEntry['gd:when attr']['endTime']) - 86400);
                 }
                 if ($sameDate) {
                     $endDate = date("h:iA", strtotime($anEntry['gd:when attr']['endTime']));
                 }
                 if ($endDate == $startDate) {
                     $totalDate = $startDate;
                 } else {
                     $totalDate = " {$startDate} to {$endDate}";
                 }
                 $entries[] = array('entry' => $anEntry['title'] . ": " . $totalDate, 'startTime' => $startTime);
             }
         }
     }
     if (!empty($entries)) {
         $entries = php_multisort($entries, array(array('key' => 'startTime', 'sort' => 'asc')));
     }
     $this->displayArray($entries);
 }
示例#5
0
function dctl_putLink($theContent, $doc, $where, $selector = '', $label = '', $docBase = '', $class = '')
{
    $justLink = $label == '' || preg_match('/\\(_remove_\\)/', $label);
    $doc_xml = $doc;
    if ($selector != '') {
        $selector = strtolower($selector);
    }
    $returnText = '';
    if ($docBase != '' && $docBase != $doc) {
        $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
        $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
        $xml_resource = XMLDB_PATH_BASE . $db_collection;
        global $exist;
        $packageList = array();
        // TEXT
        $allowedExt = array();
        $allowedExt[] = '_img';
        $allowedExt[] = '_ptx';
        getPackageList($exist, $xml_resource, &$packageList, $allowedExt);
        $num = 0;
        foreach ($packageList as $idx => $package) {
            // if ($label == 'X') {
            // dump($docBase);
            // };
            // || (($package['type'] !== $selector) && (preg_match('/'.$package['ref'].'/i', $docBase)))
            if ($package['type'] == $selector && $doc != $package['ref'] && preg_match('/' . $docBase . '/i', $package['ref'])) {
                $link = '';
                $link .= '$().mastro(\'display\',\'' . $package['ref'] . '\', \'' . $where . '\', \'\', \'' . fixLabel($theContent) . '\');';
                $returnText .= '<li>';
                $returnText .= '<a class="box_head_extend_field ' . $class . '" href="javascript:void(0);" onclick="' . $link . '" title="' . TOOLTIP_SELECT . '">';
                $returnText .= $package['short'];
                $returnText .= '</a>';
                $returnText .= '</li>';
                ++$num;
                $idx2 = $idx;
            }
        }
        if ($returnText != '') {
            if ($num == 1 && !stripos($label, ':')) {
                $returnText = '<ul class="box_head_extend_item">' . str_ireplace($packageList[$idx2]['short'], $label, $returnText) . '</ul>';
            } else {
                $returnText = '<ul class="collapsible box_head_extend_item"><li><a class="collapsible_handle2" title="' . TOOLTIP_TOGGLE . '">' . $label . '&#160;</a><ul class="collapsible_body">' . $returnText . '</ul></li></ul>';
            }
        }
    } else {
        global $cachedID;
        if ($cachedID) {
            $label = preg_replace('/\\(_remove_\\)/', '', $label);
            $theRegExp = '/^(._)?p\\d\\d\\d/i';
            if (preg_match($theRegExp, $theContent)) {
                $fullItem = preg_replace('/^(._)/i', '', $theContent);
                $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
                $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
                $doc = str_ireplace('.xml', '', $doc_exploded[1]);
                $fullItem = 'xml://' . $db_collection . DB_PATH_SEP . $doc . DB_PATH_SEP . $fullItem;
                $s1 = ' ' . $fullItem;
                $s2 = $fullItem . ' ';
                $resultXML = $cachedID->xpath('//*[contains(@target, \'' . $s1 . '\') or contains(@target, \'' . $s2 . '\') or (@target = \'' . $fullItem . '\')]');
                if (count($resultXML) > 0) {
                    global $exist;
                    foreach ($resultXML as $n => $link) {
                        $attrs = $link->attributes();
                        if ($label == '') {
                            $label = fixLabel($attrs['n']);
                        }
                        $targets = explode(' ', $link['target']);
                        if (in_array($fullItem, $targets)) {
                            $links = array();
                            foreach ($targets as $k => $v) {
                                if ($v != '') {
                                    if ($v != $fullItem) {
                                        $parsed = explode(SYS_PATH_SEP, $v);
                                        $lnk_coll = $parsed[2];
                                        $lnk_pack = isset($parsed[3]) ? $parsed[3] : '';
                                        $lnk_item = isset($parsed[4]) ? $parsed[4] : '';
                                        $ext = substr($lnk_pack, -4, 4);
                                        if ($selector == $ext || $selector == '') {
                                            $links[$k]['rev'] = strrev($lnk_pack);
                                            $links[$k]['ext'] = $ext;
                                            $links[$k]['item'] = $v;
                                        }
                                    }
                                }
                            }
                            global $EXTENSION_PACKAGE;
                            $links2 = $links;
                            $links = array();
                            $kk = 0;
                            foreach ($EXTENSION_PACKAGE as $k => $v) {
                                foreach ($links2 as $k1 => $v1) {
                                    $ext = $v1['ext'];
                                    if ($ext == $v) {
                                        ++$kk;
                                        $item = $links2[$k1]['item'];
                                        $parsed = explode(SYS_PATH_SEP, $item);
                                        $lnk_coll = $parsed[2];
                                        $lnk_pack = $parsed[3];
                                        $lnk_item = $parsed[4];
                                        $lnk_itemblock = $lnk_item;
                                        // $lnk_itemblock = ($ext == '_txt') ? $lnk_item : substr($lnk_item, 0, 4);
                                        $doc = $lnk_coll . DCTL_RESERVED_INFIX . $lnk_pack . '.xml';
                                        $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
                                        $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
                                        $xml_resource = XMLDB_PATH_BASE . $db_collection . DB_PATH_SEP . $doc;
                                        $packageRecord = array();
                                        getPackageRecord($exist, $xml_resource, &$packageRecord);
                                        $links[$kk]['date'] = $packageRecord['date'];
                                        $links[$kk]['short'] = $packageRecord['short'];
                                        $links[$kk]['ext'] = $links2[$k1]['ext'];
                                        $links[$kk]['item'] = $item;
                                    }
                                }
                            }
                            if (count($links) > 0) {
                                $links = php_multisort($links, array(array('key' => 'date'), array('key' => 'short')));
                            }
                            $baseDoc = basename($doc);
                            $prev = '';
                            $closeIt = false;
                            $iter = -1;
                            foreach ($links as $k => $v) {
                                $ext = $v['ext'];
                                if ($ext == $selector) {
                                    ++$iter;
                                    if ($ext != $prev) {
                                        $prev = $ext;
                                        if (!$justLink) {
                                            if ($closeIt) {
                                                $returnText .= '</span>';
                                            }
                                            $returnText .= '<span class="' . $class . '">';
                                            $returnText .= $label;
                                            $returnText .= '</span>';
                                            $returnText .= '<span class="widget_field">';
                                            $closeIt = true;
                                        }
                                    }
                                    $parsed = explode(SYS_PATH_SEP, $v['item']);
                                    $lnk_coll = $parsed[2];
                                    $lnk_pack = $parsed[3];
                                    $lnk_item = $parsed[4];
                                    $lnk_itemblock = $lnk_item;
                                    // $lnk_itemblock = ($ext == '_txt') ? $lnk_item : substr($lnk_item, 0, 4);
                                    $doc = $lnk_coll . DCTL_RESERVED_INFIX . $lnk_pack . '.xml';
                                    $doc_exploded = explode(DCTL_RESERVED_INFIX, $doc);
                                    $db_collection = isset($doc_exploded[0]) ? $doc_exploded[0] : '';
                                    $xml_resource = XMLDB_PATH_BASE . $db_collection . DB_PATH_SEP . $doc;
                                    $block = $lnk_item;
                                    $db_resource = '';
                                    $xquery = DCTL_XQUERY_BASE;
                                    $xquery .= ' let $base := doc("' . $xml_resource . '")/id("' . $block . '") ';
                                    $xquery .= ' return ';
                                    $xquery .= ' if ($base) then ';
                                    $xquery .= '  if ($base/@rend != "") then ';
                                    $xquery .= '   ($base/@rend) ';
                                    $xquery .= '  else ';
                                    $xquery .= '   <div class="error">? UNDEFINED @REND ?</div> ';
                                    $xquery .= ' else ';
                                    $xquery .= '  <div class="error">' . basename($xml_resource) . '/' . $block . ' : ID non trovato...</div> ';
                                    $result = $exist->xquery($xquery) or dump($exist->getError());
                                    $resultXML = (array) $result["XML"];
                                    foreach ($resultXML as $k1 => $node) {
                                        $db_resource .= $node;
                                    }
                                    $lnk_block = $lnk_item;
                                    $link = '$().mastro(\'display\',\'' . $lnk_coll . DCTL_RESERVED_INFIX . $lnk_pack . '.xml\', \'' . $where . '\', \'\', \'' . $lnk_itemblock . '\', \'' . $lnk_item . '\', \'\', \'' . fixLabel($label) . '\');';
                                    if (!$justLink) {
                                        if ($iter > 0) {
                                            $returnText .= '; ';
                                        }
                                        $returnText .= '<a href="javascript:void(0);" onclick="' . $link . '" title="' . TOOLTIP_GOTO . '">';
                                        $returnText .= dctl_putRefs($db_resource, DISTINCT_SEP, $xml_resource, $where);
                                        $returnText .= '</a>';
                                    } else {
                                        $returnText .= $link;
                                    }
                                }
                            }
                            if (!$justLink) {
                                if ($closeIt) {
                                    $returnText .= '</span>';
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $returnText;
}
 /**
  * Return list of all ingredients for a recipe
  * Each element contains:
  *  - ingredient data
  *  - related product variety data as 'variety' field
  *  - related product data as 'product' field
  *  - unit name as 'unis_name' field
  */
 public function getIngredientsForRecipe($recipe_id)
 {
     if (!is_numeric($recipe_id)) {
         return false;
     }
     $ingredients = $this->listing("recipe_id = {$recipe_id}");
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $units_raw = $this->getUnits();
     foreach ($units_raw as $unit) {
         $units[$unit['id']] = $unit['title'];
     }
     foreach ($ingredients as &$ingredient) {
         $ingredient['units_name'] = $units[$ingredient['units']];
         $ingredient['variety'] = $Product->getProductVarietyDetail($ingredient['product_variety_id']);
         if ($ingredient['variety']) {
             $ingredient['product'] = $Product->detail($ingredient['variety']['product_id']);
         }
         $ingredient['name'] = $ingredient['product']['name'];
     }
     $ingredients = php_multisort($ingredients, array(array('key' => 'group_title', 'sort' => 'asc'), array('key' => 'name', 'sort' => 'asc')));
     return $ingredients;
 }
示例#7
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * Get input variables
      */
     if ($_POST['product-list-filter']) {
         $filter = $_POST['product-list-filter'];
     } else {
         $filter = $_SESSION['bo']['product-list-filter'];
     }
     if (is_numeric($this->GET['taxonomy_tree_id'])) {
         $filter['taxonomy_json'] = json_encode(array($this->GET['taxonomy_tree_id']));
     } else {
         $filter['taxonomy_json'] = false;
     }
     /**
      * Get the list
      */
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $product_list = $Product->getFilteredProductList($filter);
     if (!is_array($product_list)) {
         return false;
     }
     if (count($product_list) == 0) {
         $this->tpl->parse('content.empty_list');
         return true;
     }
     /**
      * Sorting
      */
     //$_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_list_sorting");
     //$this->tpl->assign('SORTING', $_Onxshop_Request->getContent());
     if ($this->GET['product-list-sort-by']) {
         $_SESSION['bo']['product-list-sort-by'] = $this->GET['product-list-sort-by'];
     }
     if ($this->GET['product-list-sort-direction']) {
         $_SESSION['bo']['product-list-sort-direction'] = $this->GET['product-list-sort-direction'];
     }
     if ($_SESSION['bo']['product-list-sort-by']) {
         $sortby = $_SESSION['bo']['product-list-sort-by'];
     } else {
         $sortby = "modified";
     }
     if ($_SESSION['bo']['product-list-sort-direction']) {
         $direction = $_SESSION['bo']['product-list-sort-direction'];
     } else {
         $direction = "DESC";
     }
     //msg("Sorted by $sortby $direction");
     $product_list_sorted = array();
     switch ($sortby) {
         default:
         case 'id':
             $product_list = php_multisort($product_list, array(array('key' => 'product_id', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'modified':
             $product_list = php_multisort($product_list, array(array('key' => 'modified', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'product_name':
             $product_list = php_multisort($product_list, array(array('key' => 'product_name', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'variety_name':
             $product_list = php_multisort($product_list, array(array('key' => 'variety_name', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'price':
             $product_list = php_multisort($product_list, array(array('key' => 'price', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'sku':
             $product_list = php_multisort($product_list, array(array('key' => 'sku', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'stock':
             $product_list = php_multisort($product_list, array(array('key' => 'stock', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
     }
     foreach ($product_list as $item) {
         $product_list_sorted[] = $item;
     }
     $product_list = $product_list_sorted;
     //print_r($product_list);exit;
     /**
      * Reformat
      */
     $pl = array();
     foreach ($product_list as $item) {
         $pl[$item['product_id']][] = $item;
     }
     $product_list = array();
     foreach ($pl as $item) {
         $product_list[] = $item;
     }
     /**
      * Initialize pagination variables
      */
     if (is_numeric($this->GET['limit_from'])) {
         $from = $this->GET['limit_from'];
     } else {
         $from = 0;
     }
     if (is_numeric($this->GET['limit_per_page'])) {
         $per_page = $this->GET['limit_per_page'];
     } else {
         $per_page = 25;
     }
     $limit = "{$from},{$per_page}";
     /**
      * Display pagination
      */
     //$link = "/page/" . $_SESSION['active_pages'][0];
     $count = count($product_list);
     $_Onxshop_Request = new Onxshop_Request("component/pagination~link=/request/bo/component/ecommerce/product_list:limit_from={$from}:limit_per_page={$per_page}:count={$count}~");
     $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent());
     /**
      * Parse items
      * Implemented pagination
      */
     //print_r($product_list); exit;
     foreach ($product_list as $i => $p_item) {
         if ($i >= $from && $i < $from + $per_page) {
             $item = $p_item[0];
             $rowspan = count($p_item);
             $this->tpl->assign('ROWSPAN', "rowspan='{$rowspan}'");
             $item['disabled'] = $item['publish'] ? '' : 'disabled';
             $this->tpl->assign('ITEM', $item);
             if ($item['image_src']) {
                 $this->tpl->parse('content.list.item.imagetitle.image');
             }
             $this->tpl->parse('content.list.item.imagetitle');
             $even_odd = 'odd' != $even_odd ? 'odd' : 'even';
             $this->tpl->assign('CLASS', "class='{$even_odd} fullproduct'");
             foreach ($p_item as $item) {
                 if ($item['variety_publish'] == 0) {
                     $item['variety_publish'] = 'disabled';
                 }
                 $this->checkNotifications($item);
                 $this->tpl->assign('ITEM', $item);
                 $this->tpl->parse('content.list.item');
                 $this->tpl->assign('CLASS', "class='{$even_odd}'");
             }
         }
     }
     $this->tpl->parse('content.list');
     return true;
 }
示例#8
0
 /**
  * main action
  */
 public function mainAction()
 {
     require_once 'models/client/client_customer.php';
     require_once 'models/client/client_customer_taxonomy.php';
     $Customer = new client_customer();
     $Taxonomy = new client_customer_taxonomy();
     //force cache even for back office user
     $Customer->setCacheable(true);
     /**
      * Filtering
      */
     /**
      * Get the list
      */
     $customer_filter = $_SESSION['bo']['customer-filter'];
     // account_type is integer, but we also allow in UI to use it for backoffice users
     if ($customer_filter['account_type'] == 'backoffice') {
         $customer_filter['backoffice_role_only'] = 1;
     }
     // get the list
     $customer_list = $Customer->getClientList(0, $customer_filter);
     if (is_array($customer_list) && count($customer_list) > 0) {
         /**
          * Sorting
          */
         if ($this->GET['customer-list-sort-by']) {
             $_SESSION['bo']['customer-list-sort-by'] = $this->GET['customer-list-sort-by'];
         }
         if ($this->GET['customer-list-sort-direction']) {
             $_SESSION['bo']['customer-list-sort-direction'] = $this->GET['customer-list-sort-direction'];
         }
         if ($_SESSION['bo']['customer-list-sort-by']) {
             $sortby = $_SESSION['bo']['customer-list-sort-by'];
         } else {
             $sortby = "id";
         }
         if ($_SESSION['bo']['customer-list-sort-direction']) {
             $direction = $_SESSION['bo']['customer-list-sort-direction'];
         } else {
             $direction = "DESC";
         }
         //msg("Sorted by $sortby $direction");
         switch ($sortby) {
             default:
             case 'id':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'customer_id', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
             case 'last_order':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'last_order', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
             case 'goods_net':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'goods_net', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
             case 'count_baskets':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'count_baskets', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
             case 'count_orders':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'count_orders', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
             case 'count_items':
                 $customer_list = php_multisort($customer_list, array(array('key' => 'count_items', 'sort' => $direction), array('key' => 'customer_id', 'type' => 'numeric')));
                 foreach ($customer_list as $item) {
                     $p[] = $item;
                 }
                 $customer_list = $p;
                 break;
         }
         /**
          * Initialize pagination variables
          */
         if (is_numeric($this->GET['limit_from'])) {
             $from = $this->GET['limit_from'];
         } else {
             $from = 0;
         }
         if (is_numeric($this->GET['limit_per_page'])) {
             $per_page = $this->GET['limit_per_page'];
         } else {
             $per_page = 25;
         }
         $limit = "{$from},{$per_page}";
         /**
          * Display pagination
          */
         //$link = "/page/" . $_SESSION['active_pages'][0];
         $count = count($customer_list);
         $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}~");
         $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent());
         /**
          * Display items
          * Implemented pagination
          */
         foreach ($customer_list as $i => $customer) {
             if ($i >= $from && $i < $from + $per_page) {
                 $even_odd = 'odd' != $even_odd ? 'odd' : 'even';
                 $item['even_odd'] = $even_odd;
                 $taxonomy = $Taxonomy->getRelationsToCustomer($customer['customer_id']);
                 foreach ($taxonomy as $t) {
                     $customer['class'] .= "t{$t} ";
                 }
                 $role_ids = $Customer->getRoleIds($customer['customer_id']);
                 foreach ($role_ids as $r) {
                     $customer['class'] .= "role_{$r} ";
                 }
                 $this->tpl->assign('ITEM', $customer);
                 $this->tpl->parse('content.list.item');
             }
         }
         $this->tpl->parse('content.list');
     } else {
         msg("No user found", 'error');
     }
     return true;
 }
示例#9
0
 /**
  * process sorting
  */
 function _processSorting($product_list, $sortby, $direction)
 {
     /**
      * reorder
      */
     //msg("Sorted by $sortby $direction");
     switch ($sortby) {
         case 'price':
             if ($direction == 'DESC') {
                 $direction = SORT_DESC;
             } else {
                 $direction = SORT_ASC;
             }
             array_multisort($product_list, $direction);
             break;
         case 'name':
             $product_list = php_multisort($product_list, array(array('key' => 'product_name', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             foreach ($product_list as $item) {
                 $p[] = $item;
             }
             $product_list = $p;
             break;
         case 'popularity':
             /* faster */
             /*$most_popular = $Product->getMostPopularProducts('DESC', 1000);
             		foreach ($most_popular as $item) {
             			$popularity[$item['product_id']] = $item['count'];
             		}
             		
             		foreach ($product_list as $i=>$item) {
             			$product_list[$i]['popularity'] = $popularity[$item['product_id']];
             		}*/
             /* more accurate */
             foreach ($product_list as $i => $item) {
                 $product_list[$i]['popularity'] = $this->Product->getPopularity($item['product_id']);
             }
             $product_list = php_multisort($product_list, array(array('key' => 'popularity', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             break;
         case 'priority':
             $product_list = php_multisort($product_list, array(array('key' => 'priority', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             foreach ($product_list as $item) {
                 $p[] = $item;
             }
             $product_list = $p;
             break;
         case 'share_counter':
             $product_list = php_multisort($product_list, array(array('key' => 'share_counter', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             foreach ($product_list as $item) {
                 $p[] = $item;
             }
             $product_list = $p;
             break;
         case 'created':
         default:
             //product_id, or modified, or TODO created attribute for ecommerce_product
             $product_list = php_multisort($product_list, array(array('key' => 'product_id', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric')));
             foreach ($product_list as $item) {
                 $p[] = $item;
             }
             $product_list = $p;
             break;
     }
     return $product_list;
 }