本文整理汇总了PHP中JUDirectoryHelper::getCatsByLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::getCatsByLevel方法的具体用法?PHP JUDirectoryHelper::getCatsByLevel怎么用?PHP JUDirectoryHelper::getCatsByLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::getCatsByLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
public function getInput()
{
$categories = JUDirectoryHelper::getCatsByLevel(1);
$rootCategory = JUDirectoryFrontHelperCategory::getRootCategory();
$document = JFactory::getDocument();
$script = 'jQuery(document).ready(function($){
$("#cat-' . $rootCategory->id . '").change(function(){
if($(this).is(":checked")){
$(this).parent().parent().find(".category-checkbox").attr("disabled", true).prop("checked", true);
}else{
$(this).parent().parent().find(".category-checkbox").attr("disabled", false).prop("checked", false);
}
});
});';
$document->addScriptDeclaration($script);
$relCatIds = array();
if ($this->form->getValue('id')) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('c.id');
$query->from('#__judirectory_categories AS c');
$query->join('', '#__judirectory_emails_xref AS exref ON (exref.cat_id = c.id)');
$query->join('', '#__judirectory_emails AS e ON (exref.email_id = e.id)');
$query->where('exref.email_id = ' . $this->form->getValue('id'));
$db->setQuery($query);
$relCatIds = $db->loadColumn();
}
$html = '<div id="categoriestoassignemail" class="categoriestoassignemail">';
$html .= '<ul id="' . $this->id . '" class="nav">';
$html .= '<li>';
$html .= '<input id="cat-' . $rootCategory->id . '" name="' . $this->name . '[]" value = "' . $rootCategory->id . '" ' . (in_array($rootCategory->id, $relCatIds) ? 'checked="checked"' : '') . ' class="input" type="checkbox" />';
$html .= '<label for="cat-' . $rootCategory->id . '">' . str_repeat('<span class="gi">|—</span>', $rootCategory->level) . $rootCategory->title . '</label>';
$html .= '</li>';
if ($categories) {
foreach ($categories as $category) {
$html .= '<li>';
$attr = '';
if (in_array($rootCategory->id, $relCatIds)) {
$attr = 'checked="checked" disabled="disabled"';
} elseif (in_array($category->id, $relCatIds)) {
$attr = 'checked="checked"';
}
$html .= '<input id="cat-' . $category->id . '" class="input category-checkbox" type="checkbox" name="' . $this->name . '[]" value = "' . $category->id . '" ' . $attr . '/>';
$html .= '<label for="cat-' . $category->id . '">' . str_repeat('<span class="gi">|—</span>', $category->level) . $category->title . '</label>';
$html .= '</li>';
}
}
$html .= '</ul></div>';
return $html;
}
示例2: getOptions
protected function getOptions()
{
$options = array();
foreach ($this->element->children() as $option) {
if ($option->getName() != 'option') {
continue;
}
$tmp = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true');
$tmp->class = (string) $option['class'];
$tmp->onclick = (string) $option['onclick'];
$options[] = $tmp;
}
reset($options);
$categories = JUDirectoryHelper::getCatsByLevel(1);
if ($categories) {
foreach ($categories as $category) {
$options[] = JHtml::_('select.option', $category->id, $category->title);
}
}
return $options;
}
示例3: loadLanguageForTopLevelCat
public static function loadLanguageForTopLevelCat()
{
$app = JFactory::getApplication();
$view = $app->input->getString('view', '');
$id = $app->input->getInt('id', 0);
if (isset($view)) {
switch ($view) {
case 'category':
$topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $id);
break;
case 'listing':
$catId = JUDirectoryFrontHelperCategory::getMainCategoryId($id);
$topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $catId);
break;
}
if (!empty($topLevelCats)) {
$topLevelCat = $topLevelCats[0];
if ($view == 'category' || $view == 'listing') {
JUDirectoryFrontHelperLanguage::loadLanguageFile('com_judirectory_' . $topLevelCat->id, JPATH_SITE);
}
}
}
return;
}
示例4: display
public function display($tpl = null)
{
$this->item = $this->get('Item');
if (!JUDirectoryFrontHelperPermission::canViewListing($this->item->id)) {
$user = JFactory::getUser();
if ($user->id) {
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
} else {
$uri = JUri::getInstance();
$loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false);
$app = JFactory::getApplication();
$app->redirect($loginUrl, JText::_('COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning');
return false;
}
}
$app = JFactory::getApplication();
$this->user = JFactory::getUser();
$this->print = $app->input->getBool('print', false);
$this->model = $this->getModel();
$this->state = $this->get('State');
$this->params = $this->state->get('params');
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$limitStart = $app->input->getUint('limitstart', 0);
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
if (isset($_COOKIE['judir_recently_viewed_listings'])) {
$recently_viewed_listing_array = explode(',', $_COOKIE['judir_recently_viewed_listings']);
$recently_viewed_listing_array = array_unique($recently_viewed_listing_array);
$key = array_search($this->item->id, $recently_viewed_listing_array);
if ($key !== false) {
unset($recently_viewed_listing_array[$key]);
} else {
if ($limitStart == 0) {
$this->model->updateHits($this->item->id);
}
}
$maxListings = $this->params->get('max_recently_viewed_listings', 12);
if (count($recently_viewed_listing_array) >= $maxListings) {
$recently_viewed_listing_array = array_slice($recently_viewed_listing_array, 0, $maxListings - 1);
}
array_unshift($recently_viewed_listing_array, $this->item->id);
$recently_viewed_listing_array = implode(',', $recently_viewed_listing_array);
setcookie('judir_recently_viewed_listings', $recently_viewed_listing_array, time() + 3600 * 24 * 15, $cookie_path, $cookie_domain);
} else {
if ($limitStart == 0) {
$this->model->updateHits($this->item->id);
}
setcookie('judir_recently_viewed_listings', $this->item->id, time() + 3600 * 24 * 15, $cookie_path, $cookie_domain);
}
$topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $this->item->cat_id);
if ($topLevelCats) {
$this->tl_catid = $topLevelCats[0]->id;
}
$this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx'));
$this->item->class_sfx = htmlspecialchars($this->item->class_sfx);
$this->collection_popup = false;
if (JUDIRPROVERSION && $this->user->id > 0) {
$this->collection_popup = true;
$this->collections = $this->model->getCollectionPopup($this->item->id);
}
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$this->item->event = new stdClass();
$context = 'com_judirectory.listing';
$results = $dispatcher->trigger('onContentAfterTitle', array($context, &$this->item, &$this->item->params, $limitStart));
$this->item->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->item->params, $limitStart));
$this->item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->item->params, $limitStart));
$this->item->event->afterDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onBeforeDisplayJUDIRComment', array($context, &$this->item, &$this->item->params, $limitStart));
$this->item->event->beforeDisplayJUDIRComment = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplayJUDIRComment', array($context, &$this->item, &$this->item->params, $limitStart));
$this->item->event->afterDisplayJUDIRComment = trim(implode("\n", $results));
$this->_prepareData();
$this->_prepareDocument();
$this->_setBreadcrumb();
parent::display($tpl);
}
示例5: getMenuItemIdArrayOfViewCategoryTreeLevel0And1
public static function getMenuItemIdArrayOfViewCategoryTreeLevel0And1()
{
$menuItemIdsOfViewCategoryTree = self::getMenuItemIdArrayOfViewCategoryTree();
$menuItemIds = array();
$categoryObjectListLevel1 = JUDirectoryHelper::getCatsByLevel();
if ($categoryObjectListLevel1) {
foreach ($categoryObjectListLevel1 as $categoryObjectLevel1) {
if (isset($menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id])) {
$menuItemIds[$categoryObjectLevel1->id] = $menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id];
}
}
$categoryRoot = JUDirectoryFrontHelperCategory::getRootCategory();
if (isset($menuItemIdsOfViewCategoryTree[$categoryRoot->id])) {
$menuItemIds[$categoryRoot->id] = $menuItemIdsOfViewCategoryTree[$categoryRoot->id];
}
}
return $menuItemIds;
}