本文整理匯總了PHP中tree::get_tree_array方法的典型用法代碼示例。如果您正苦於以下問題:PHP tree::get_tree_array方法的具體用法?PHP tree::get_tree_array怎麽用?PHP tree::get_tree_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tree
的用法示例。
在下文中一共展示了tree::get_tree_array方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
/**
* 顯示編輯商品表單
*/
public function edit()
{
// 初始化返回結構體
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
try {
// 初始化返回數據
$return_data = array();
// 收集請求數據
$request_data = $this->input->get();
if (empty($request_data['id'])) {
throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400);
}
$product = BLL_Product::get($request_data['id']);
if (empty($product['id'])) {
throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400);
}
// 分類列表默認關聯第一個
$categorys_tree = CategoryService::get_instance()->get_tree("<option value=\\\"\$id\\\" \$selected>\$spacer\$title</option>", $product['category_id']);
$categories = CategoryService::get_instance()->query_assoc(array());
$categories = tree::get_tree_array($categories);
$classifies = ClassifyService::get_instance()->index(array('orderby' => array('id' => 'ASC')));
$classify_content['features'] = $this->load_features($product['classify_id'], $product['fetuoptrs']);
$classify_content['brands'] = $this->load_brands($product['classify_id'], $product['brand_id']);
// 處理商品類型特定的模板區塊
$ptype_layout = NULL;
switch ($product['type']) {
case ProductService::PRODUCT_TYPE_ASSEMBLY:
throw new MyRuntimeException('Coming soon ...', 400);
//暫時不支持組合商品
$ptype_layout = new View($this->package_name . '/' . $this->class_name . '/assembly/layout');
break;
case ProductService::PRODUCT_TYPE_CONFIGURABLE:
$ptype_layout = new View($this->package_name . '/' . $this->class_name . '/configurable/layout');
break;
case ProductService::PRODUCT_TYPE_GOODS:
default:
$ptype_layout = new View($this->package_name . '/' . $this->class_name . '/simple/layout');
break;
}
$ptype_layout->product = $product;
$return_struct['content'] = array('product' => $product);
//* 請求類型 */
if ($this->is_ajax_request()) {
// ajax 請求
// json 輸出
$this->template->content = $return_struct;
} else {
// html 輸出
//* 模板輸出 */
$this->template->return_struct = $return_struct;
$content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__);
//* 變量綁定 */
$this->template->title = Kohana::config('site.name');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->request_data = $request_data;
//* 返回結構體綁定 */
$this->template->content->return_struct = $return_struct;
$this->template->content->categorys_tree = $categorys_tree;
$this->template->content->categories = $categories;
$this->template->content->classifies = $classifies;
$this->template->content->classify_content = $classify_content;
$this->template->content->ptype_layout = $ptype_layout;
$this->template->content->listurl = isset($request_data['listurl']) ? $request_data['listurl'] : '';
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$this->_ex($ex, $return_struct, $request_data);
}
}