本文整理匯總了PHP中ShopFunctions::counter方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShopFunctions::counter方法的具體用法?PHP ShopFunctions::counter怎麽用?PHP ShopFunctions::counter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ShopFunctions
的用法示例。
在下文中一共展示了ShopFunctions::counter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: categoryListTreeLoop
/**
* Creates structured option fields for all categories
*
* @todo: Connect to vendor data
* @author Max Milbers, jseros
* @param array $selectedCategories All category IDs that will be pre-selected
* @param int $cid Internally used for recursion
* @param int $level Internally used for recursion
* @return string $category_tree HTML: Category tree list
*/
public static function categoryListTreeLoop($selectedCategories = array(), $cid = 0, $level = 0, $disabledFields = array(), $isSite, $vendorId, $vmlang, $categoryParentName = '')
{
static $categoryTree = '';
if ($level == 0) {
$categoryTree = '';
self::$counter = 0;
}
self::$counter++;
$categoryModel = VmModel::getModel('category');
$level++;
$categoryModel->_noLimit = TRUE;
$records = $categoryModel->getCategories($isSite, $cid, false, '', $vendorId);
$selected = "";
if (!empty($records)) {
foreach ($records as $key => $category) {
$childId = $category->category_child_id;
if ($childId != $cid) {
if (in_array($childId, $selectedCategories)) {
$selected = 'selected=\\"selected\\"';
} else {
$selected = '';
}
$disabled = '';
if (in_array($childId, $disabledFields)) {
$disabled = 'disabled="disabled"';
}
if ($disabled != '' && stristr($_SERVER['HTTP_USER_AGENT'], 'msie')) {
//IE7 suffers from a bug, which makes disabled option fields selectable
} else {
$categoryTree .= '<option ' . $selected . ' ' . $disabled . ' value="' . $childId . '">';
$categoryName = $category->category_name;
if (VmConfig::get('full_catname_tree', 0)) {
if (!empty($categoryParentName)) {
$categoryName = $categoryParentName . ' | ' . $category->category_name;
}
} else {
$categoryTree .= str_repeat(' - ', $level - 1);
}
$categoryTree .= $categoryName . '</option>';
}
}
if ($categoryModel->hasChildren($childId)) {
self::categoryListTreeLoop($selectedCategories, $childId, $level, $disabledFields, $isSite, $vendorId, $vmlang, $categoryName);
}
}
}
return $categoryTree;
}