-
-
Save tedkulp/15516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('getPageChooser')) { | |
function getPageChooser($pageLinks=array(), $activeIndexNumber=0, $previousText="Previous", $nextText="Next", $firstVisableNumber=1) { | |
// This function takes an array with links and makes a nice page chooser from it. | |
// The index of the array is 0 based, so is the activeIndexNumber. | |
// Make firstVisableNumber 0 if you want to see pagenumbers start with 0 (Why would you???). | |
$pagermenu = array(); | |
if (!is_array($pageLinks)) return ""; | |
$pageLinksCount = count($pageLinks); | |
if (!function_exists('getPageCooserLinkHtml')) { | |
function getPageCooserLinkHtml($l, $n) { return '<a href=\"' . $l . '">' . $n . '</a> '; } | |
} | |
if ($activeIndexNumber > 0) { | |
$pagermenu[] = preg_replace ( '/(\<a.*\>).*(\<\/a.*\>)/', "\$1$previousText\$2", $pageLinks[$activeIndexNumber - 1]); | |
} | |
for ($i=0; $i<3; $i++) { | |
if ($i<=$pageLinksCount) { | |
$pagermenu[] = ($i==$activeIndexNumber) ? '<em>'.($i+$firstVisableNumber).'</em>' : $pageLinks[$i]; | |
} | |
} | |
// display ... when there are enough pages and the active number is high or low | |
if (($activeIndexNumber>4 || $activeIndexNumber<2) && $pageLinksCount>7) { $pagermenu[] = "..."; } | |
for ($i=$activeIndexNumber-1; $i<=$activeIndexNumber+1; $i++) { | |
if ($i>2 && $i<$pageLinksCount-3) { | |
$pagermenu[] = ($i==$activeIndexNumber) ? '<em>'.($i+$firstVisableNumber).'</em>' : $pageLinks[$i]; | |
} | |
} | |
// display ... when there is room between the active page and the pagecount AND the active page is in the middle block | |
if ($activeIndexNumber<$pageLinksCount-5 && $activeIndexNumber>1) { $pagermenu[] = "..." ; } | |
for ($i=$pageLinksCount-3; $i<$pageLinksCount; $i++) { | |
if ($i>3) { | |
$pagermenu[] = ($i==$activeIndexNumber) ? '<em>'.($i+$firstVisableNumber).'</em>' : $pageLinks[$i]; | |
} | |
} | |
if ($activeIndexNumber+1 < $pageLinksCount) { | |
$pagermenu[] = preg_replace ( '/(\<a.*\>).*(\<\/a.*\>)/', "\$1$nextText\$2", $pageLinks[$activeIndexNumber + 1]); | |
} | |
return '<!-- pagechooser start -->' . implode(" ", $pagermenu) . '<!-- pagechooser end -->'; | |
} | |
} | |
if (!isset($gCms)) return; | |
if (isset($params["catid"]) && $params["catid"]!="") { | |
$this->RedirectForFrontend($id, $returnid, 'showcategory', $params); | |
} | |
$numentries=10; if (isset($params["numentries"])) $numentries=$params["numentries"]; | |
$startpageoffset=0; if (isset($params["startpageoffset"])) $startpageoffset=$params["startpageoffset"]; | |
$latestfirst=true; | |
if (isset($params["oldestfirst"])) { | |
$latestfirst=false; | |
} | |
$dbentries=$this->GetAllEntries(true,$numentries,$latestfirst,'createtime',$numentries*$startpageoffset); | |
if ($dbentries===false) return; | |
$entries=array(); | |
$dbcount=$this->GetAllEntriesCount(true,$numentries,$latestfirst,'createtime',$numentries*$startpageoffset); | |
$pagechooser=''; | |
if ($dbcount>$numentries) { | |
$pageLinks=array(); | |
$numberOfPages=ceil($dbcount/$numentries); | |
for ($p=0; $p<$numberOfPages; $p++) { | |
$pageLinks[$p] = $this->CreateLink($id, 'showblog', $returnid, $p+1, | |
array('startpageoffset'=>$p,'numentries'=>$numentries), '', false, false, '', false, 'Blogs/'.$dbentry["id"].'/'.$returnid); | |
} | |
$pagechooser.=getPageChooser($pageLinks, $startpageoffset, "Previous", "Next"); | |
} | |
$this->smarty->assign('pagechooser', $pagechooser); | |
$shortlength=$this->GetPreference("shortlength",130); | |
if (isset($params["shortlength"])) $shortlength=$params["shortlength"]; | |
$moretext=$this->GetPreference("moretext","..."); | |
if (isset($params["moretext"])) $moretext=$params["moretext"]; | |
if (count($dbentries)==0) { | |
$this->smarty->assign('noentriestext', $this->Lang("noentries")); | |
} else { | |
$mostrecent=true; | |
foreach ($dbentries as $dbentry) { | |
$entry=$this->GetEntry($dbentry["id"]); | |
$onerow = new stdClass(); | |
if ($mostrecent) { | |
$onerow->mostrecent=1; | |
$mostrecent=false; | |
} else { | |
$onerow->mostrecent=0; | |
} | |
$onerow->title =$entry["title"]; | |
$onerow->author =$entry["author"]; | |
///////////////////////////////////////////// ADDED///////////////////////////////////////// | |
//LINK "entryid" | |
//$onerow->entryurl=$this->CreateLink($id, 'showentry', $returnid, '', | |
//array('entryid'=>$dbentry["id"]), '', true); | |
$onerow->entryurl=$this->CreateLink($id, 'showentry', $returnid, '', | |
array('entryid'=>$dbentry["id"]), '', true, false, '', false, 'Blogs/'.$dbentry["id"].'/'.$returnid); | |
//LINK "moretext" | |
//$shorttextlink=$this->CreateLink($id, 'showentry', $returnid, $moretext, | |
//array('entryid'=>$dbentry["id"])); | |
$shorttextlink=$this->CreateLink($id, 'showentry', $returnid, $moretext, | |
array('entryid'=>$dbentry["id"]), '', false, false, '', false, 'Blogs/'.$dbentry["id"].'/'.$returnid); | |
///////////////////////////////////////////// END ADDED///////////////////////////////////////// | |
/* $onerow->entryurl=$this->CreateLink($id, 'showentry', $returnid, "", array('entryid'=>$dbentry["id"]),"",true); | |
$shorttextlink=$this->CreateLink($id, 'showentry', $returnid, $moretext, array('entryid'=>$dbentry["id"])); | |
*/ | |
$onerow->shorttext=strip_tags(substr($entry["text"],0,$shortlength))." ".$shorttextlink; | |
$onerow->text =$entry["text"]; | |
$time=$entry["createtime"]; | |
$onerow->time=$this->MakeDateTime($time); | |
$nocomments=$this->CountComments($dbentry["id"]); | |
if ($nocomments==1) $nocomments.=" ".$this->Lang("comment"); else $nocomments.=" ".$this->Lang("comments"); | |
/* $onerow->comments=$this->CreateLink($id, 'showentry', $returnid, $nocomments, array('entryid'=>$dbentry["id"]));*/ | |
///////////////////////////////////////////// ADDED///////////////////////////////////////// | |
//LINK "comments" | |
//$onerow->comments=$this->CreateLink($id, 'showentry', $returnid, $nocomments, | |
//array('entryid'=>$dbentry["id"])); | |
$onerow->comments=$this->CreateLink($id, 'showentry', $returnid, $nocomments, | |
array('entryid'=>$dbentry["id"]), '', false, false, '', false, 'Blogs/'.$dbentry["id"].'/'.$returnid); | |
/* $onerow->categorylink=$this->CreateLink($id, 'showcategory', $returnid, $this->GetCategoryTitle($entry["category"]), array('catid'=>$entry["category"]));*/ | |
//LINK "showcategory" | |
//$onerow->categorylink=$this->CreateLink($id, 'showcategory', $returnid, $this->GetCategoryTitle($entry["category"]), | |
//array('catid'=>$entry["category"])); | |
$onerow->categorylink=$this->CreateLink($id, 'showcategory', $returnid, $this->GetCategoryTitle($entry["category"]), | |
array('catid'=>$entry["category"]), '', false, false, '', false, 'Blogs/'.$entry["category"].'/'.$entry["category"].'/'.$returnid); | |
///////////////////////////////////////////// END ADDED///////////////////////////////////////// | |
array_push($entries, $onerow); | |
} | |
$this->smarty->assign_by_ref('items', $entries); | |
} | |
$this->smarty->assign_by_ref('itemcount', count($entries)); | |
echo $this->ProcessTemplateFromDatabase('showblogs'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment