/** * Build a logic sequence, for a WHERE statement, of those category IDs children of the provided category ID, if any * * @param $nCatid * @param $logicOp * @param $oCat * @return string * @access private * @since 2005-11-02 * @author Matteo Scaramuccia <*****@*****.**> */ function _getCatidWhereSequence($nCatid, $logicOp = 'OR', $oCat = null) { $sqlWherefilter = ''; if (!isset($oCat)) { $oCat = new PMF_Category(); } $aChildren = array_values($oCat->getChildren($nCatid)); foreach ($aChildren as $catid) { $sqlWherefilter .= " " . $logicOp . " fcr.category_id = " . $catid; $sqlWherefilter .= $this->_getCatidWhereSequence($catid, 'OR', $oCat); } return $sqlWherefilter; }
} if ($level < $open) { if ($level - $open == -1) { print '</li>'; } print '</ul></li>'; } elseif ($level == $open) { print '</li>'; } if ($level > $open) { printf('<div id="div_%d" style="display: none; filter: inherit;">', $lastCatId); print '<ul><li>'; } else { print '<li>'; } if (count($category->getChildren($cat['id'])) != 0) { // Show name and icon for expand the sub-categories printf('<h4 class="category-header" data-category-id="%d">%s</h4> ', $cat['id'], $categoryName); } else { // Show just the name printf("<h4>%s</h4> ", $categoryName); } if ($cat["lang"] == $lang) { // add sub category (if current language) printf(' <a class="btn btn-info btn-mini" href="?action=addcategory&cat=%s&lang=%s"><span title="%s" class="icon-plus-sign icon-white"></span></a> ', $cat['id'], $cat['lang'], $PMF_LANG['ad_quick_category']); // rename (sub) category (if current language) printf(' <a class="btn btn-info btn-mini" href="?action=editcategory&cat=%s"><span title="%s" class="icon-edit icon-white"></a> ', $cat['id'], $PMF_LANG['ad_kateg_rename']); } // translate category (always)
for ($i = $leveldiff; $i > 1; $i--) { $templateVars['categoryTree'] .= '</ul></div></li>'; } } if ($level < $open) { if ($level - $open == -1) { $templateVars['categoryTree'] .= '</li>'; } $templateVars['categoryTree'] .= '</ul></li>'; } elseif ($level == $open) { $templateVars['categoryTree'] .= '</li>'; } if ($level > $open) { $templateVars['categoryTree'] .= sprintf('<div id="div_%d" style="display: none;">', $lastCatId); $templateVars['categoryTree'] .= '<ul><li>'; } else { $templateVars['categoryTree'] .= '<li>'; } $templateVars['categoryTree'] .= $twig->loadTemplate('category/treeItem.twig')->render(array('PMF_LANG' => $PMF_LANG, 'id' => $cat['id'], 'addButtonUrl' => sprintf('?action=addcategory&cat=%s&lang=%s', $cat['id'], $cat['lang']), 'cutButtonUrl' => sprintf('?action=cutcategory&cat=%s', $cat['id']), 'deleteButtonUrl' => sprintf('?action=deletecategory&cat=%s&catlang=%s', $cat['id'], $cat['lang']), 'moveButtonUrl' => sprintf('?action=movecategory&cat=%s&parent_id=%s', $cat['id'], $cat['parent_id']), 'name' => $categoryName, 'renameButtonUrl' => sprintf('?action=editcategory&cat=%s', $cat['id']), 'renderAddButton' => $cat["lang"] == $lang, 'renderCutButton' => $cat["lang"] == $lang, 'renderDeleteButton' => count($category->getChildren($cat['id'])) == 0 && $cat["lang"] == $lang, 'renderMoveButton' => $cat["lang"] == $lang && $category->numParent($cat['parent_id']) > 1, 'renderRenameButton' => $cat["lang"] == $lang, 'renderToggler' => count($category->getChildren($cat['id'])) != 0, 'translateButtonUrl' => sprintf('?action=translatecategory&cat=%s', $cat['id']))); $open = $level; $lastCatId = $cat['id']; } if ($open > 0) { $templateVars['categoryTree'] .= str_repeat("</li>\n\t</ul>\n\t", $open); } $templateVars['categoryTree'] .= "</li>\n</ul>"; $twig->loadTemplate('category/main.twig')->display($templateVars); unset($templateVars, $csrfToken, $open, $level, $category, $id, $cat, $lang, $lastCatId); } else { require 'noperm.php'; }