/** * Creates a way to navigate between pages. * * @param array $params * @param object $smarty * @return string */ function smarty_paging($params, &$smarty) { global $PIVOTX, $modifier; $params = cleanParams($params); $action = getDefault($params['action'], "digg"); $showalways = getDefault($params['showalways'], false); $funcs = new Paging("paging"); // Check if we are called correctly and on the correct page $msg = $funcs->sanity_check($action); if ($msg != "" && $showalways == false) { return $msg; } // Currently only finds the offset $msg = $funcs->setup($action); if ($msg != "" && $showalways == false) { return $msg; } $subweblogs = $PIVOTX['weblogs']->getSubweblogs(); $num_entries = 0; $cats = array(); // Find the number of entries displayed on the page, as defined // in the weblog configuration, unless specified as a parameter if (!empty($params['amount'])) { $num_entries = intval($params['amount']); } else { if (!empty($params['showme'])) { // Note: 'showme' is deprecated. included for backwards compatibility. $num_entries = intval($params['showme']); } else { foreach ($subweblogs as $subweblog) { $subweblog = $PIVOTX['weblogs']->getSubweblog('', $subweblog); $num_entries = max($subweblog['num_entries'], $num_entries); } } } // Find the categories displayed on the page, as defined in // the weblog configuration, unless specified as a parameter // // If we have a 'c=' parameter, use the cats in that to display.. // To prevent weird things from happening, we only allow changing weblogs // with a name like 'default', 'standard', 'main' or 'weblog'. // Alternatively, we check if the template specifies the categories to // display, like [[ weblog name='weblog' category="default, movies, music" ]] if (!empty($modifier['category'])) { $cats = explode(",", safeString($modifier['category'])); $cats = array(array_map("trim", $cats)); } else { if (!empty($params['category']) && $params['category'] == "*") { $cats = array($PIVOTX['categories']->getCategorynames()); $params['catsinlink'] = true; } else { if (!empty($params['category'])) { $cats = explode(",", safeString($params['category'])); $cats = array(array_map("trim", $cats)); $params['catsinlink'] = true; } else { // We have to keep the subweblogs separate, because we need to be able to figure // out which subweblog has the most entries, and _not_ the entries combined. foreach ($subweblogs as $subweblog) { $subweblog = $PIVOTX['weblogs']->getSubweblog('', $subweblog); // Only add categories from subweblogs that have any categories assigned. if (count($subweblog['categories']) > 0) { $cats[] = $subweblog['categories']; } } } } } return $funcs->doit($action, $text, $cats, $num_entries, $params); }