本文整理汇总了PHP中JUDownloadHelper::getCatsByLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::getCatsByLevel方法的具体用法?PHP JUDownloadHelper::getCatsByLevel怎么用?PHP JUDownloadHelper::getCatsByLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDownloadHelper
的用法示例。
在下文中一共展示了JUDownloadHelper::getCatsByLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 = JUDownloadHelper::getCatsByLevel(1, $id);
break;
case 'document':
$catId = JUDownloadFrontHelperCategory::getMainCategoryId($id);
$topLevelCats = JUDownloadHelper::getCatsByLevel(1, $catId);
break;
}
if (!empty($topLevelCats))
{
$topLevelCat = $topLevelCats[0];
if ($view == 'category' || $view == 'document')
{
JUDownloadFrontHelperLanguage::loadLanguageFile('com_judownload_' . $topLevelCat->id, JPATH_SITE);
}
}
}
return;
}
示例2: getInput
public function getInput()
{
$categories = JUDownloadHelper::getCatsByLevel(1);
$rootCategory = JUDownloadFrontHelperCategory::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('#__judownload_categories AS c');
$query->join('', '#__judownload_emails_xref AS exref ON (exref.cat_id = c.id)');
$query->join('', '#__judownload_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;
}
示例3: 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 = JUDownloadHelper::getCatsByLevel(1);
if ($categories) {
foreach ($categories as $category) {
$options[] = JHtml::_('select.option', $category->id, $category->title);
}
}
return $options;
}
示例4: display
public function display($tpl = null)
{
$this->item = $this->get('Item');
if (!JUDownloadFrontHelperPermission::canViewDocument($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_JUDOWNLOAD_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['judl_recently_viewed_documents']))
{
$recently_viewed_doc_array = explode(',', $_COOKIE['judl_recently_viewed_documents']);
$recently_viewed_doc_array = array_unique($recently_viewed_doc_array);
$key = array_search($this->item->id, $recently_viewed_doc_array);
if ($key !== false)
{
unset($recently_viewed_doc_array[$key]);
}
else
{
if ($limitStart == 0)
{
$this->model->updateHits($this->item->id);
}
}
$maxDocuments = $this->params->get('max_recently_viewed_documents', 12);
if (count($recently_viewed_doc_array) >= $maxDocuments)
{
$recently_viewed_doc_array = array_slice($recently_viewed_doc_array, 0, $maxDocuments - 1);
}
array_unshift($recently_viewed_doc_array, $this->item->id);
$recently_viewed_doc_array = implode(',', $recently_viewed_doc_array);
setcookie('judl_recently_viewed_documents', $recently_viewed_doc_array, time() + (3600 * 24 * 15), $cookie_path, $cookie_domain);
}
else
{
if ($limitStart == 0)
{
$this->model->updateHits($this->item->id);
}
setcookie('judl_recently_viewed_documents', $this->item->id, time() + (3600 * 24 * 15), $cookie_path, $cookie_domain);
}
$topLevelCats = JUDownloadHelper::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 (JUDLPROVERSION && $this->user->id > 0)
{
//.........这里部分代码省略.........
示例5: getMenuItemIdArrayOfViewCategoryTreeLevel0And1
public static function getMenuItemIdArrayOfViewCategoryTreeLevel0And1()
{
$menuItemIdsOfViewCategoryTree = self::getMenuItemIdArrayOfViewCategoryTree();
$menuItemIds = array();
$categoryObjectListLevel1 = JUDownloadHelper::getCatsByLevel();
if ($categoryObjectListLevel1)
{
foreach ($categoryObjectListLevel1 AS $categoryObjectLevel1)
{
if (isset($menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id]))
{
$menuItemIds[$categoryObjectLevel1->id] = $menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id];
}
}
$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();
if (isset($menuItemIdsOfViewCategoryTree[$categoryRoot->id]))
{
$menuItemIds[$categoryRoot->id] = $menuItemIdsOfViewCategoryTree[$categoryRoot->id];
}
}
return $menuItemIds;
}