1 ) { if ( strpos( $mvars['tpl_inner'] ,'{edit}')!==false ) { $mvars['tpl_inner'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_inner']); $mvars['tpl_inner'] = str_replace('{noedit}', '', $mvars['tpl_inner']); $entries[]= $mvars['tpl_inner']; } elseif (strpos( $mvars['tpl_inner'] ,'{noedit}') ===false) { if ($mvars['edit_tpl_pos']!=='true') $entries[]= $mvars['tpl_inner'].$mvars['typegroup']; else $entries[]= $mvars['typegroup'].$mvars['tpl_inner']; } else { $entries[]= str_replace('{noedit}','',$mvars['tpl_inner']); } if ( strpos( $mvars['tpl_dupl'] ,'{edit}')!==false ) { $mvars['tpl_dupl'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_dupl']); $mvars['tpl_dupl'] = str_replace('{noedit}', '', $mvars['tpl_dupl']); $duplentries[]= $mvars['tpl_dupl']; } elseif (strpos( $mvars['tpl_dupl'] ,'{noedit}')===false ) { if ($mvars['edit_tpl_pos']!=='true') $duplentries[]= $mvars['tpl_dupl'].$mvars['typegroup']; else $duplentries[]= $mvars['typegroup'].$mvars['tpl_dupl']; } else { $duplentries[]= str_replace('{noedit}','',$mvars['tpl_dupl']); } } else { if (strpos( $mvars['tpl_inner'] ,'{noedit}')===false ) $entries[]= $mvars['typegroup']; if (strpos( $mvars['tpl_dupl'] ,'{noedit}') ===false) $duplentries[]= $mvars['typegroup']; $nocontentsflag=1; } // if the last entry is reached the output will be generated if ($mvars['is_last']) { // define current-page format-tags if ( strpos($mvars['tpl_nav'],'{page}')!==false ) { // format of the current page if ( $mvars['cpageformat'] == '1' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '2' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '3' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '4' ) { $mvars['tagin']=''; $mvars['tagout']=''; } else { $mvars['tagin']=''; $mvars['tagout']=''; } } if (!empty($mvars['currentpagestyle']) || !empty($mvars['currentpageattr']) ){ $mvars['currentpagestylein']=''; $mvars['currentpagestyleout']=''; } if (!empty($mvars['nextprevstyle']) || !empty($mvars['nextprevattr'])){ $mvars['nextprevstylein']=''; $mvars['nextprevstyleout']=''; } if (!empty($mvars['pagestyle']) || !empty($mvars['pageattr'])){ $mvars['pagestylein']=''; $mvars['pagestyleout']=''; } if ($mvars['maxpagenumbers']<'3') $mvars['maxpagenumbers']=3; if ( strpos($mvars['tpl_checkup'],'{colswap}')!==false ) $colswap=true; // get the number of entries $mvars["entries"] = count($entries); // default if no page switch $limit1=0; $limit2=$mvars["entries"]; if(! function_exists(str_chop)){ /** * Chop a string into a smaller string. * * @author Aidan Lister * @author2 Alexander M. Korn * @version ? * @link http://aidanlister.com/repos/v/function.str_chop.php * @param mixed $string The string you want to shorten * @param int $length The length you want to shorten the string to * @param bool $center If true, chop in the middle of the string * @param mixed $append String appended if it is shortened */ function str_chop($string, $length = 60, $center = true, $append = null) { $string=strip_tags($string); // Set the default append string if ($append === null) { $append = ($center === true) ? ' ... ' : ' ...'; } preg_match_all('#\&(.*)\;#sU',$string,$entities); $entities[0]=array_unique($entities[0]); if (is_array($entities[0]) && !empty($entities[0])) foreach($entities[0] as $v) $string=(str_replace( $v,utf8_encode(html_entity_decode( $v)),$string)); if ($center==="true") $center=true; // Get some measurements $len_string = strlen($string); $len_append = strlen($append); if ($len_string > $length) { // If the string is longer than the maximum length, we need to chop it // Check if we want to chop it in half if ($center === true) { // Get the lengths of each segment $len_start = $length / 2; $len_end = $len_start - $len_append; // Get each segment $seg_start = substr($string, 0, $len_start); $seg_end = substr($string, $len_string - $len_end, $len_end); $seg_start = substr( $seg_start, 0, strrpos ( $seg_start, " ")); $seg_end = substr( $seg_end, strpos ( $seg_end, " ")+1); // Stick them together $string = $seg_start . $append . $seg_end; } else { // Otherwise, just chop the end off $string = substr($string, 0, $length - $len_append); $string = substr($string, 0, strrpos ($string, " ")) . $append; } } return $string; } } if(! function_exists(getstringparts)) { function getstringparts($string, $tagin, $tagout) { /** * Splits a string into 3 parts dependent on tagin & tagout. * * @author Alexander M. Korn * @version 1.0.0 */ $tagin_pos = strpos($string,$tagin); $tagout_pos = strpos($string,$tagout); if ( $tagin_pos !== false || $tagout_pos !== false || $tagout_pos > $tagin_pos ) { $tagin_len = strlen($tagin); $tagout_len = strlen($tagout); $strparts['first'] = substr($string,0,$tagin_pos); $strparts['middle'] = substr($string,$tagin_pos+$tagin_len,$tagout_pos-($tagin_pos+$tagin_len)); $strparts['last'] = substr($string,$tagout_pos+$tagout_len); } else { $strparts['first'] = $string; $strparts['middle'] = ''; $strparts['last'] = ''; } return $strparts; } } // function for number conversion if(! function_exists(arab2rom)){ function arab2rom($input) { if ( $input<=0 ) return " "; //Römische Zeichen $rz = array( 1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD', 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ); //Berechnung $out = ''; foreach ($rz as $wert => $zeichen) { $b = floor($input / $wert); if ($b > 0){ $out .= str_repeat($zeichen, $b); } $input = $input % $wert; } return $out; } } if ($mvars['max_items']>=$limit2-1 && $mvars['navallways']!='true') $mvars['max_items']=0; // navigation if max_items set if ($mvars['max_items']!=0) { // Paginator-class for simple page-calculation if(! class_exists(Paginator)){ class Paginator { //all variables are pivate. var $previous; var $current; var $next; var $page; var $total_pages; var $link_arr; var $range1; var $range2; var $num_rows; var $first; var $last; var $first_of; var $second_of; var $limit; var $prev_next; var $base_page_num; var $extra_page_num; var $total_items; var $pagename; //Constructor for Paginator. Takes the current page and the number of items //in the source data and sets the current page ($this->page) and the total //items in the source ($this->total_items). function Paginator($page,$num_rows) { if(!$page) { $this->page=1; } else { $this->page=$page; } $this->num_rows=$num_rows; $this->total_items = $this->num_rows; } //Takes $limit and sets $this->limit. Calls private mehods //setBasePage() and setExtraPage() which use $this->limit. function set_Limit($limit=5) { $this->limit = $limit; $this->setBasePage(); $this->setExtraPage(); } //This method creates a number that setExtraPage() uses to if there are //and extra pages after limit has divided the total number of pages. function setBasePage() { $div=$this->num_rows/$this->limit; $this->base_page_num=floor($div); } function setExtraPage() { $this->extra_page_num=$this->num_rows - ($this->base_page_num*$this->limit); } //Used in making numbered links. Sets the number of links behind and //ahead of the current page. For example if there were a possiblity of //20 numbered links and this was set to 5 and the current link was 10 //the result would be this 5 6 7 8 9 10 11 12 13 14 15. function set_Links($prev_next=5) { $this->prev_next = $prev_next; } //method to get the total items. function getTotalItems() { $this->total_items = $this->num_rows; return $this->total_items; } //method to get the base number to use in queries and such. function getRange1() { $this->range1=($this->limit*$this->page)-$this->limit; return $this->range1; } //method to get the offset. function getRange2() { if($this->page==$this->base_page_num + 1) { $this->range2=$this->extra_page_num; } else { $this->range2=$this->limit; } return $this->range2; } //method to get the first of number as in 5 of . function getFirstOf() { $this->first_of=$this->range1 + 1; return $this->first_of; } //method to get the second number in a series as in 5 of 8. function getSecondOf() { if($this->page==$this->base_page_num + 1) { $this->second_of=$this->range1 + $this->extra_page_num; } else { $this->second_of=$this->range1 + $this->limit; } return $this->second_of; } //method to get the total number of pages. function getTotalPages() { if($this->extra_page_num) { $this->total_pages = $this->base_page_num + 1; } else { $this->total_pages = $this->base_page_num; } return $this->total_pages; } //method to get the first link number. function getFirst() { $this->first=1; return $this->first; } //method to get the last link number. function getLast() { if($this->page == $this->total_pages) { $this->last=0; }else { $this->last = $this->total_pages; } return $this->last; } function getPrevious() { if($this->page > 1) { $this->previous = $this->page - 1; } return $this->previous; } //method to get the number of the link previous to the current link. function getCurrent() { $this->current = $this->page; return $this->current; } //method to get the current page name. Is mostly used in links to the next //page. function getPageName() { $this->pagename = $_SERVER['PHP_SELF'];; return $this->pagename; } //method to get the number of the link after the current link. function getNext() { $this->getTotalPages(); if($this->total_pages != $this->page) { $this->next = $this->page + 1; } return $this->next; } //method that returns an array of the numbered links that should be //displayed. function getLinkArr() { //gets the top range $top = $this->getTotalPages()- $this->getCurrent(); if($top <= $this->prev_next) { $top = $top; $top_range = $this->getCurrent() + $top; } else { $top = $this->prev_next; $top_range = $this->getCurrent() + $top; } //gets the bottom range $bottom = $this->getCurrent() -1; if($bottom <= $this->prev_next) { $bottom = $bottom; $bottom_range = $this->getCurrent() - $bottom; } else { $bottom = $this->prev_next; $bottom_range = $this->getCurrent() - $bottom; } $j=0; foreach(range($bottom_range, $top_range) as $i) { $this->link_arr[$j] = $i; $j++; } return $this->link_arr; } }//ends Paginator class } $a =& new Paginator($page,($mvars["entries"])); //sets the number of records displayed //defaults to five $a->set_Limit($mvars['max_items']); //if using numbered links this will set the number before and behind //the current page. $a->set_Links(floor($mvars['maxpagenumbers']/2)); //gets starting point. $limit1 = $a->getRange1(); //gets number of items displayed on page. $limit2 = $a->getRange2(); $links = $a->getLinkArr(); $current=$a->getCurrent(); //prev link - only if prev-tag if ( strpos($mvars['tpl_nav'],'{prev}')!==false ) { if($a->getPrevious()) { if (!empty($mvars['linkstyle'])) $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; else $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{prev}', $mvars['repl_prev_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{prev}', $mvars['nextprevstylein'].$mvars['repl_prev_string'].$mvars['nextprevstyleout'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{prev}', '', $mvars['tpl_nav']); } } // next link - only if next-tag if ( strpos($mvars['tpl_nav'],'{next}')!==false ) { if($a->getNext()) { if (!empty($mvars['linkstyle'])) $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; else $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{next}', '', $mvars['tpl_nav']); } } // page rotation // gen page number links $displayedpages=count($links); $c=0; foreach($links as $link) { $pagenumber=$link; if ($mvars['nav_roman_no']=='true') $pagenumber=arab2rom($pagenumber); if($link == $current) { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; } else { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; } if ($c<$displayedpages-1) $mvars['tpl_nav_pages_string'] = $mvars['tpl_nav_pages_string'].$mvars['nav_split_string']; $c++; } $mvars['tpl_nav'] = str_replace('{page}', $mvars['tpl_nav_pages_string'], $mvars['tpl_nav']); // number conversion if ($mvars['nav_roman_no']=='true') { $mvars['str_currentpage']=arab2rom($page); $mvars['str_pagestotal']=arab2rom($a->getTotalPages()); } else { $mvars['str_currentpage']=$page; $mvars['str_pagestotal']=$a->getTotalPages(); } } // the output // add new link at the top $new_at_top_temp=''.''.''; if($sess->name=='sefrengo' && $view == 'edit' && $mvars['add_entry_top'] == 'true') { $allcontents .=str_replace('{button}',$new_at_top_temp,$mvars['tpl_edit']); } // number format definition for the leading zero no. element $leadingzeronoformat="%0".(strlen(''.$mvars["entries"].'')+1)."d"; for ($c=$limit1;$c<$limit1 + $limit2;$c++) { // if {colswap} detected if ($colswap===true) { if ( $c%2 ) { $entries[$c] = str_replace('{colswap}', 1, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 1, $duplentries[$c]); } else { $entries[$c] = str_replace('{colswap}', 0, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 0, $duplentries[$c]); } } // insert entry number $entries[$c] =str_replace('{no}',$c+1,$entries[$c]); $entries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$entries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_inner'],'{chop}') !== false && strpos($mvars['tpl_inner'],'{/chop}') !== false) { $strparts=getstringparts( $entries[$c] , "{chop}", "{/chop}"); $allcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allcontents .=$entries[$c]; // duplicate list dependent from max entries per page if ($mvars['dupl_page_nav'] === 'true' && $mvars['tpl_dupl_flag']) { $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[floor($c/$mvars['max_items'])],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // duplicate list independent from max entries per page if ($mvars['dupl_page_nav'] !== 'true' && $mvars['tpl_dupl_flag']) { $counter=0; $subcounter=0; for ($c=0;$c$mvars['max_items']-1) { $counter++; $subcounter=0; } $subcounter++; $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0 && !empty($links[$counter])) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[$counter],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // html intro if ( strpos($mvars['tpl_intro'],'{new}')!==false) if($sess->name=='sefrengo' && $view == 'edit') { $mvars['tpl_intro']=str_replace('{new}',$new_at_top_temp,$mvars['tpl_intro']); } else $mvars['tpl_intro']=str_replace('{new}','',$mvars['tpl_intro']); // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_intro']=str_replace('{list}',$allduplcontents, $mvars['tpl_intro']); // {nav} found? if ( strpos($mvars['tpl_intro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_intro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_intro']); else $mvars['tpl_intro']=str_replace('{nav}','', $mvars['tpl_intro']); // nav at top if ($nocontentsflag!=1 && !empty($mvars['tpl_intro'])) { $introstring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_intro']); $introstring=str_replace('{currentpage}',$mvars['str_currentpage'], $introstring); $allcontents = $introstring.$allcontents; } // html outro // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_outro']=str_replace('{list}',$allduplcontents, $mvars['tpl_outro']); // {nav} found? if ( strpos($mvars['tpl_outro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_outro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_outro']); else $mvars['tpl_outro']=str_replace('{nav}','', $mvars['tpl_outro']); // nav at bottom if ($nocontentsflag!=1 && !empty($mvars['tpl_outro'])) { $outrostring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_outro']); $outrostring=str_replace('{currentpage}',$mvars['str_currentpage'], $outrostring); $allcontents = $allcontents.$outrostring; } // nav on top if ($mvars['nav_above_list'] == 'true' && $mvars['max_items']!=0 ) $allcontents = $mvars['tpl_nav'].$allcontents; // nav on bottom if ($mvars['nav_below_list'] == 'true' && $mvars['max_items']!=0) $allcontents = $allcontents.$mvars['tpl_nav']; // the end eval('?>'.stripslashes($allcontents)); ; unset( $entries, $duplentries, $duplentries, $allduplcontents, $duplentry, $allcontents, $allentries, $colswap, $nocontentsflag, $entries, $outrostring, $introstring, $a, $limit1, $limit2, $links, $current, $onetimeflag, $autozeronoformat ); } unset($mvars); ?>1 ) { if ( strpos( $mvars['tpl_inner'] ,'{edit}')!==false ) { $mvars['tpl_inner'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_inner']); $mvars['tpl_inner'] = str_replace('{noedit}', '', $mvars['tpl_inner']); $entries[]= $mvars['tpl_inner']; } elseif (strpos( $mvars['tpl_inner'] ,'{noedit}') ===false) { if ($mvars['edit_tpl_pos']!=='true') $entries[]= $mvars['tpl_inner'].$mvars['typegroup']; else $entries[]= $mvars['typegroup'].$mvars['tpl_inner']; } else { $entries[]= str_replace('{noedit}','',$mvars['tpl_inner']); } if ( strpos( $mvars['tpl_dupl'] ,'{edit}')!==false ) { $mvars['tpl_dupl'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_dupl']); $mvars['tpl_dupl'] = str_replace('{noedit}', '', $mvars['tpl_dupl']); $duplentries[]= $mvars['tpl_dupl']; } elseif (strpos( $mvars['tpl_dupl'] ,'{noedit}')===false ) { if ($mvars['edit_tpl_pos']!=='true') $duplentries[]= $mvars['tpl_dupl'].$mvars['typegroup']; else $duplentries[]= $mvars['typegroup'].$mvars['tpl_dupl']; } else { $duplentries[]= str_replace('{noedit}','',$mvars['tpl_dupl']); } } else { if (strpos( $mvars['tpl_inner'] ,'{noedit}')===false ) $entries[]= $mvars['typegroup']; if (strpos( $mvars['tpl_dupl'] ,'{noedit}') ===false) $duplentries[]= $mvars['typegroup']; $nocontentsflag=1; } // if the last entry is reached the output will be generated if ($mvars['is_last']) { // define current-page format-tags if ( strpos($mvars['tpl_nav'],'{page}')!==false ) { // format of the current page if ( $mvars['cpageformat'] == '1' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '2' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '3' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '4' ) { $mvars['tagin']=''; $mvars['tagout']=''; } else { $mvars['tagin']=''; $mvars['tagout']=''; } } if (!empty($mvars['currentpagestyle']) || !empty($mvars['currentpageattr']) ){ $mvars['currentpagestylein']=''; $mvars['currentpagestyleout']=''; } if (!empty($mvars['nextprevstyle']) || !empty($mvars['nextprevattr'])){ $mvars['nextprevstylein']=''; $mvars['nextprevstyleout']=''; } if (!empty($mvars['pagestyle']) || !empty($mvars['pageattr'])){ $mvars['pagestylein']=''; $mvars['pagestyleout']=''; } if ($mvars['maxpagenumbers']<'3') $mvars['maxpagenumbers']=3; if ( strpos($mvars['tpl_checkup'],'{colswap}')!==false ) $colswap=true; // get the number of entries $mvars["entries"] = count($entries); // default if no page switch $limit1=0; $limit2=$mvars["entries"]; if(! function_exists(str_chop)){ /** * Chop a string into a smaller string. * * @author Aidan Lister * @author2 Alexander M. Korn * @version ? * @link http://aidanlister.com/repos/v/function.str_chop.php * @param mixed $string The string you want to shorten * @param int $length The length you want to shorten the string to * @param bool $center If true, chop in the middle of the string * @param mixed $append String appended if it is shortened */ function str_chop($string, $length = 60, $center = true, $append = null) { $string=strip_tags($string); // Set the default append string if ($append === null) { $append = ($center === true) ? ' ... ' : ' ...'; } preg_match_all('#\&(.*)\;#sU',$string,$entities); $entities[0]=array_unique($entities[0]); if (is_array($entities[0]) && !empty($entities[0])) foreach($entities[0] as $v) $string=(str_replace( $v,utf8_encode(html_entity_decode( $v)),$string)); if ($center==="true") $center=true; // Get some measurements $len_string = strlen($string); $len_append = strlen($append); if ($len_string > $length) { // If the string is longer than the maximum length, we need to chop it // Check if we want to chop it in half if ($center === true) { // Get the lengths of each segment $len_start = $length / 2; $len_end = $len_start - $len_append; // Get each segment $seg_start = substr($string, 0, $len_start); $seg_end = substr($string, $len_string - $len_end, $len_end); $seg_start = substr( $seg_start, 0, strrpos ( $seg_start, " ")); $seg_end = substr( $seg_end, strpos ( $seg_end, " ")+1); // Stick them together $string = $seg_start . $append . $seg_end; } else { // Otherwise, just chop the end off $string = substr($string, 0, $length - $len_append); $string = substr($string, 0, strrpos ($string, " ")) . $append; } } return $string; } } if(! function_exists(getstringparts)) { function getstringparts($string, $tagin, $tagout) { /** * Splits a string into 3 parts dependent on tagin & tagout. * * @author Alexander M. Korn * @version 1.0.0 */ $tagin_pos = strpos($string,$tagin); $tagout_pos = strpos($string,$tagout); if ( $tagin_pos !== false || $tagout_pos !== false || $tagout_pos > $tagin_pos ) { $tagin_len = strlen($tagin); $tagout_len = strlen($tagout); $strparts['first'] = substr($string,0,$tagin_pos); $strparts['middle'] = substr($string,$tagin_pos+$tagin_len,$tagout_pos-($tagin_pos+$tagin_len)); $strparts['last'] = substr($string,$tagout_pos+$tagout_len); } else { $strparts['first'] = $string; $strparts['middle'] = ''; $strparts['last'] = ''; } return $strparts; } } // function for number conversion if(! function_exists(arab2rom)){ function arab2rom($input) { if ( $input<=0 ) return " "; //Römische Zeichen $rz = array( 1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD', 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ); //Berechnung $out = ''; foreach ($rz as $wert => $zeichen) { $b = floor($input / $wert); if ($b > 0){ $out .= str_repeat($zeichen, $b); } $input = $input % $wert; } return $out; } } if ($mvars['max_items']>=$limit2-1 && $mvars['navallways']!='true') $mvars['max_items']=0; // navigation if max_items set if ($mvars['max_items']!=0) { // Paginator-class for simple page-calculation if(! class_exists(Paginator)){ class Paginator { //all variables are pivate. var $previous; var $current; var $next; var $page; var $total_pages; var $link_arr; var $range1; var $range2; var $num_rows; var $first; var $last; var $first_of; var $second_of; var $limit; var $prev_next; var $base_page_num; var $extra_page_num; var $total_items; var $pagename; //Constructor for Paginator. Takes the current page and the number of items //in the source data and sets the current page ($this->page) and the total //items in the source ($this->total_items). function Paginator($page,$num_rows) { if(!$page) { $this->page=1; } else { $this->page=$page; } $this->num_rows=$num_rows; $this->total_items = $this->num_rows; } //Takes $limit and sets $this->limit. Calls private mehods //setBasePage() and setExtraPage() which use $this->limit. function set_Limit($limit=5) { $this->limit = $limit; $this->setBasePage(); $this->setExtraPage(); } //This method creates a number that setExtraPage() uses to if there are //and extra pages after limit has divided the total number of pages. function setBasePage() { $div=$this->num_rows/$this->limit; $this->base_page_num=floor($div); } function setExtraPage() { $this->extra_page_num=$this->num_rows - ($this->base_page_num*$this->limit); } //Used in making numbered links. Sets the number of links behind and //ahead of the current page. For example if there were a possiblity of //20 numbered links and this was set to 5 and the current link was 10 //the result would be this 5 6 7 8 9 10 11 12 13 14 15. function set_Links($prev_next=5) { $this->prev_next = $prev_next; } //method to get the total items. function getTotalItems() { $this->total_items = $this->num_rows; return $this->total_items; } //method to get the base number to use in queries and such. function getRange1() { $this->range1=($this->limit*$this->page)-$this->limit; return $this->range1; } //method to get the offset. function getRange2() { if($this->page==$this->base_page_num + 1) { $this->range2=$this->extra_page_num; } else { $this->range2=$this->limit; } return $this->range2; } //method to get the first of number as in 5 of . function getFirstOf() { $this->first_of=$this->range1 + 1; return $this->first_of; } //method to get the second number in a series as in 5 of 8. function getSecondOf() { if($this->page==$this->base_page_num + 1) { $this->second_of=$this->range1 + $this->extra_page_num; } else { $this->second_of=$this->range1 + $this->limit; } return $this->second_of; } //method to get the total number of pages. function getTotalPages() { if($this->extra_page_num) { $this->total_pages = $this->base_page_num + 1; } else { $this->total_pages = $this->base_page_num; } return $this->total_pages; } //method to get the first link number. function getFirst() { $this->first=1; return $this->first; } //method to get the last link number. function getLast() { if($this->page == $this->total_pages) { $this->last=0; }else { $this->last = $this->total_pages; } return $this->last; } function getPrevious() { if($this->page > 1) { $this->previous = $this->page - 1; } return $this->previous; } //method to get the number of the link previous to the current link. function getCurrent() { $this->current = $this->page; return $this->current; } //method to get the current page name. Is mostly used in links to the next //page. function getPageName() { $this->pagename = $_SERVER['PHP_SELF'];; return $this->pagename; } //method to get the number of the link after the current link. function getNext() { $this->getTotalPages(); if($this->total_pages != $this->page) { $this->next = $this->page + 1; } return $this->next; } //method that returns an array of the numbered links that should be //displayed. function getLinkArr() { //gets the top range $top = $this->getTotalPages()- $this->getCurrent(); if($top <= $this->prev_next) { $top = $top; $top_range = $this->getCurrent() + $top; } else { $top = $this->prev_next; $top_range = $this->getCurrent() + $top; } //gets the bottom range $bottom = $this->getCurrent() -1; if($bottom <= $this->prev_next) { $bottom = $bottom; $bottom_range = $this->getCurrent() - $bottom; } else { $bottom = $this->prev_next; $bottom_range = $this->getCurrent() - $bottom; } $j=0; foreach(range($bottom_range, $top_range) as $i) { $this->link_arr[$j] = $i; $j++; } return $this->link_arr; } }//ends Paginator class } $a =& new Paginator($page,($mvars["entries"])); //sets the number of records displayed //defaults to five $a->set_Limit($mvars['max_items']); //if using numbered links this will set the number before and behind //the current page. $a->set_Links(floor($mvars['maxpagenumbers']/2)); //gets starting point. $limit1 = $a->getRange1(); //gets number of items displayed on page. $limit2 = $a->getRange2(); $links = $a->getLinkArr(); $current=$a->getCurrent(); //prev link - only if prev-tag if ( strpos($mvars['tpl_nav'],'{prev}')!==false ) { if($a->getPrevious()) { if (!empty($mvars['linkstyle'])) $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; else $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{prev}', $mvars['repl_prev_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{prev}', $mvars['nextprevstylein'].$mvars['repl_prev_string'].$mvars['nextprevstyleout'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{prev}', '', $mvars['tpl_nav']); } } // next link - only if next-tag if ( strpos($mvars['tpl_nav'],'{next}')!==false ) { if($a->getNext()) { if (!empty($mvars['linkstyle'])) $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; else $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{next}', '', $mvars['tpl_nav']); } } // page rotation // gen page number links $displayedpages=count($links); $c=0; foreach($links as $link) { $pagenumber=$link; if ($mvars['nav_roman_no']=='true') $pagenumber=arab2rom($pagenumber); if($link == $current) { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; } else { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; } if ($c<$displayedpages-1) $mvars['tpl_nav_pages_string'] = $mvars['tpl_nav_pages_string'].$mvars['nav_split_string']; $c++; } $mvars['tpl_nav'] = str_replace('{page}', $mvars['tpl_nav_pages_string'], $mvars['tpl_nav']); // number conversion if ($mvars['nav_roman_no']=='true') { $mvars['str_currentpage']=arab2rom($page); $mvars['str_pagestotal']=arab2rom($a->getTotalPages()); } else { $mvars['str_currentpage']=$page; $mvars['str_pagestotal']=$a->getTotalPages(); } } // the output // add new link at the top $new_at_top_temp=''.''.''; if($sess->name=='sefrengo' && $view == 'edit' && $mvars['add_entry_top'] == 'true') { $allcontents .=str_replace('{button}',$new_at_top_temp,$mvars['tpl_edit']); } // number format definition for the leading zero no. element $leadingzeronoformat="%0".(strlen(''.$mvars["entries"].'')+1)."d"; for ($c=$limit1;$c<$limit1 + $limit2;$c++) { // if {colswap} detected if ($colswap===true) { if ( $c%2 ) { $entries[$c] = str_replace('{colswap}', 1, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 1, $duplentries[$c]); } else { $entries[$c] = str_replace('{colswap}', 0, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 0, $duplentries[$c]); } } // insert entry number $entries[$c] =str_replace('{no}',$c+1,$entries[$c]); $entries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$entries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_inner'],'{chop}') !== false && strpos($mvars['tpl_inner'],'{/chop}') !== false) { $strparts=getstringparts( $entries[$c] , "{chop}", "{/chop}"); $allcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allcontents .=$entries[$c]; // duplicate list dependent from max entries per page if ($mvars['dupl_page_nav'] === 'true' && $mvars['tpl_dupl_flag']) { $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[floor($c/$mvars['max_items'])],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // duplicate list independent from max entries per page if ($mvars['dupl_page_nav'] !== 'true' && $mvars['tpl_dupl_flag']) { $counter=0; $subcounter=0; for ($c=0;$c$mvars['max_items']-1) { $counter++; $subcounter=0; } $subcounter++; $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0 && !empty($links[$counter])) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[$counter],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // html intro if ( strpos($mvars['tpl_intro'],'{new}')!==false) if($sess->name=='sefrengo' && $view == 'edit') { $mvars['tpl_intro']=str_replace('{new}',$new_at_top_temp,$mvars['tpl_intro']); } else $mvars['tpl_intro']=str_replace('{new}','',$mvars['tpl_intro']); // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_intro']=str_replace('{list}',$allduplcontents, $mvars['tpl_intro']); // {nav} found? if ( strpos($mvars['tpl_intro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_intro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_intro']); else $mvars['tpl_intro']=str_replace('{nav}','', $mvars['tpl_intro']); // nav at top if ($nocontentsflag!=1 && !empty($mvars['tpl_intro'])) { $introstring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_intro']); $introstring=str_replace('{currentpage}',$mvars['str_currentpage'], $introstring); $allcontents = $introstring.$allcontents; } // html outro // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_outro']=str_replace('{list}',$allduplcontents, $mvars['tpl_outro']); // {nav} found? if ( strpos($mvars['tpl_outro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_outro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_outro']); else $mvars['tpl_outro']=str_replace('{nav}','', $mvars['tpl_outro']); // nav at bottom if ($nocontentsflag!=1 && !empty($mvars['tpl_outro'])) { $outrostring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_outro']); $outrostring=str_replace('{currentpage}',$mvars['str_currentpage'], $outrostring); $allcontents = $allcontents.$outrostring; } // nav on top if ($mvars['nav_above_list'] == 'true' && $mvars['max_items']!=0 ) $allcontents = $mvars['tpl_nav'].$allcontents; // nav on bottom if ($mvars['nav_below_list'] == 'true' && $mvars['max_items']!=0) $allcontents = $allcontents.$mvars['tpl_nav']; // the end eval('?>'.stripslashes($allcontents)); ; unset( $entries, $duplentries, $duplentries, $allduplcontents, $duplentry, $allcontents, $allentries, $colswap, $nocontentsflag, $entries, $outrostring, $introstring, $a, $limit1, $limit2, $links, $current, $onetimeflag, $autozeronoformat ); } unset($mvars); ?>1 ) { if ( strpos( $mvars['tpl_inner'] ,'{edit}')!==false ) { $mvars['tpl_inner'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_inner']); $mvars['tpl_inner'] = str_replace('{noedit}', '', $mvars['tpl_inner']); $entries[]= $mvars['tpl_inner']; } elseif (strpos( $mvars['tpl_inner'] ,'{noedit}') ===false) { if ($mvars['edit_tpl_pos']!=='true') $entries[]= $mvars['tpl_inner'].$mvars['typegroup']; else $entries[]= $mvars['typegroup'].$mvars['tpl_inner']; } else { $entries[]= str_replace('{noedit}','',$mvars['tpl_inner']); } if ( strpos( $mvars['tpl_dupl'] ,'{edit}')!==false ) { $mvars['tpl_dupl'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_dupl']); $mvars['tpl_dupl'] = str_replace('{noedit}', '', $mvars['tpl_dupl']); $duplentries[]= $mvars['tpl_dupl']; } elseif (strpos( $mvars['tpl_dupl'] ,'{noedit}')===false ) { if ($mvars['edit_tpl_pos']!=='true') $duplentries[]= $mvars['tpl_dupl'].$mvars['typegroup']; else $duplentries[]= $mvars['typegroup'].$mvars['tpl_dupl']; } else { $duplentries[]= str_replace('{noedit}','',$mvars['tpl_dupl']); } } else { if (strpos( $mvars['tpl_inner'] ,'{noedit}')===false ) $entries[]= $mvars['typegroup']; if (strpos( $mvars['tpl_dupl'] ,'{noedit}') ===false) $duplentries[]= $mvars['typegroup']; $nocontentsflag=1; } // if the last entry is reached the output will be generated if ($mvars['is_last']) { // define current-page format-tags if ( strpos($mvars['tpl_nav'],'{page}')!==false ) { // format of the current page if ( $mvars['cpageformat'] == '1' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '2' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '3' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '4' ) { $mvars['tagin']=''; $mvars['tagout']=''; } else { $mvars['tagin']=''; $mvars['tagout']=''; } } if (!empty($mvars['currentpagestyle']) || !empty($mvars['currentpageattr']) ){ $mvars['currentpagestylein']=''; $mvars['currentpagestyleout']=''; } if (!empty($mvars['nextprevstyle']) || !empty($mvars['nextprevattr'])){ $mvars['nextprevstylein']=''; $mvars['nextprevstyleout']=''; } if (!empty($mvars['pagestyle']) || !empty($mvars['pageattr'])){ $mvars['pagestylein']=''; $mvars['pagestyleout']=''; } if ($mvars['maxpagenumbers']<'3') $mvars['maxpagenumbers']=3; if ( strpos($mvars['tpl_checkup'],'{colswap}')!==false ) $colswap=true; // get the number of entries $mvars["entries"] = count($entries); // default if no page switch $limit1=0; $limit2=$mvars["entries"]; if(! function_exists(str_chop)){ /** * Chop a string into a smaller string. * * @author Aidan Lister * @author2 Alexander M. Korn * @version ? * @link http://aidanlister.com/repos/v/function.str_chop.php * @param mixed $string The string you want to shorten * @param int $length The length you want to shorten the string to * @param bool $center If true, chop in the middle of the string * @param mixed $append String appended if it is shortened */ function str_chop($string, $length = 60, $center = true, $append = null) { $string=strip_tags($string); // Set the default append string if ($append === null) { $append = ($center === true) ? ' ... ' : ' ...'; } preg_match_all('#\&(.*)\;#sU',$string,$entities); $entities[0]=array_unique($entities[0]); if (is_array($entities[0]) && !empty($entities[0])) foreach($entities[0] as $v) $string=(str_replace( $v,utf8_encode(html_entity_decode( $v)),$string)); if ($center==="true") $center=true; // Get some measurements $len_string = strlen($string); $len_append = strlen($append); if ($len_string > $length) { // If the string is longer than the maximum length, we need to chop it // Check if we want to chop it in half if ($center === true) { // Get the lengths of each segment $len_start = $length / 2; $len_end = $len_start - $len_append; // Get each segment $seg_start = substr($string, 0, $len_start); $seg_end = substr($string, $len_string - $len_end, $len_end); $seg_start = substr( $seg_start, 0, strrpos ( $seg_start, " ")); $seg_end = substr( $seg_end, strpos ( $seg_end, " ")+1); // Stick them together $string = $seg_start . $append . $seg_end; } else { // Otherwise, just chop the end off $string = substr($string, 0, $length - $len_append); $string = substr($string, 0, strrpos ($string, " ")) . $append; } } return $string; } } if(! function_exists(getstringparts)) { function getstringparts($string, $tagin, $tagout) { /** * Splits a string into 3 parts dependent on tagin & tagout. * * @author Alexander M. Korn * @version 1.0.0 */ $tagin_pos = strpos($string,$tagin); $tagout_pos = strpos($string,$tagout); if ( $tagin_pos !== false || $tagout_pos !== false || $tagout_pos > $tagin_pos ) { $tagin_len = strlen($tagin); $tagout_len = strlen($tagout); $strparts['first'] = substr($string,0,$tagin_pos); $strparts['middle'] = substr($string,$tagin_pos+$tagin_len,$tagout_pos-($tagin_pos+$tagin_len)); $strparts['last'] = substr($string,$tagout_pos+$tagout_len); } else { $strparts['first'] = $string; $strparts['middle'] = ''; $strparts['last'] = ''; } return $strparts; } } // function for number conversion if(! function_exists(arab2rom)){ function arab2rom($input) { if ( $input<=0 ) return " "; //Römische Zeichen $rz = array( 1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD', 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ); //Berechnung $out = ''; foreach ($rz as $wert => $zeichen) { $b = floor($input / $wert); if ($b > 0){ $out .= str_repeat($zeichen, $b); } $input = $input % $wert; } return $out; } } if ($mvars['max_items']>=$limit2-1 && $mvars['navallways']!='true') $mvars['max_items']=0; // navigation if max_items set if ($mvars['max_items']!=0) { // Paginator-class for simple page-calculation if(! class_exists(Paginator)){ class Paginator { //all variables are pivate. var $previous; var $current; var $next; var $page; var $total_pages; var $link_arr; var $range1; var $range2; var $num_rows; var $first; var $last; var $first_of; var $second_of; var $limit; var $prev_next; var $base_page_num; var $extra_page_num; var $total_items; var $pagename; //Constructor for Paginator. Takes the current page and the number of items //in the source data and sets the current page ($this->page) and the total //items in the source ($this->total_items). function Paginator($page,$num_rows) { if(!$page) { $this->page=1; } else { $this->page=$page; } $this->num_rows=$num_rows; $this->total_items = $this->num_rows; } //Takes $limit and sets $this->limit. Calls private mehods //setBasePage() and setExtraPage() which use $this->limit. function set_Limit($limit=5) { $this->limit = $limit; $this->setBasePage(); $this->setExtraPage(); } //This method creates a number that setExtraPage() uses to if there are //and extra pages after limit has divided the total number of pages. function setBasePage() { $div=$this->num_rows/$this->limit; $this->base_page_num=floor($div); } function setExtraPage() { $this->extra_page_num=$this->num_rows - ($this->base_page_num*$this->limit); } //Used in making numbered links. Sets the number of links behind and //ahead of the current page. For example if there were a possiblity of //20 numbered links and this was set to 5 and the current link was 10 //the result would be this 5 6 7 8 9 10 11 12 13 14 15. function set_Links($prev_next=5) { $this->prev_next = $prev_next; } //method to get the total items. function getTotalItems() { $this->total_items = $this->num_rows; return $this->total_items; } //method to get the base number to use in queries and such. function getRange1() { $this->range1=($this->limit*$this->page)-$this->limit; return $this->range1; } //method to get the offset. function getRange2() { if($this->page==$this->base_page_num + 1) { $this->range2=$this->extra_page_num; } else { $this->range2=$this->limit; } return $this->range2; } //method to get the first of number as in 5 of . function getFirstOf() { $this->first_of=$this->range1 + 1; return $this->first_of; } //method to get the second number in a series as in 5 of 8. function getSecondOf() { if($this->page==$this->base_page_num + 1) { $this->second_of=$this->range1 + $this->extra_page_num; } else { $this->second_of=$this->range1 + $this->limit; } return $this->second_of; } //method to get the total number of pages. function getTotalPages() { if($this->extra_page_num) { $this->total_pages = $this->base_page_num + 1; } else { $this->total_pages = $this->base_page_num; } return $this->total_pages; } //method to get the first link number. function getFirst() { $this->first=1; return $this->first; } //method to get the last link number. function getLast() { if($this->page == $this->total_pages) { $this->last=0; }else { $this->last = $this->total_pages; } return $this->last; } function getPrevious() { if($this->page > 1) { $this->previous = $this->page - 1; } return $this->previous; } //method to get the number of the link previous to the current link. function getCurrent() { $this->current = $this->page; return $this->current; } //method to get the current page name. Is mostly used in links to the next //page. function getPageName() { $this->pagename = $_SERVER['PHP_SELF'];; return $this->pagename; } //method to get the number of the link after the current link. function getNext() { $this->getTotalPages(); if($this->total_pages != $this->page) { $this->next = $this->page + 1; } return $this->next; } //method that returns an array of the numbered links that should be //displayed. function getLinkArr() { //gets the top range $top = $this->getTotalPages()- $this->getCurrent(); if($top <= $this->prev_next) { $top = $top; $top_range = $this->getCurrent() + $top; } else { $top = $this->prev_next; $top_range = $this->getCurrent() + $top; } //gets the bottom range $bottom = $this->getCurrent() -1; if($bottom <= $this->prev_next) { $bottom = $bottom; $bottom_range = $this->getCurrent() - $bottom; } else { $bottom = $this->prev_next; $bottom_range = $this->getCurrent() - $bottom; } $j=0; foreach(range($bottom_range, $top_range) as $i) { $this->link_arr[$j] = $i; $j++; } return $this->link_arr; } }//ends Paginator class } $a =& new Paginator($page,($mvars["entries"])); //sets the number of records displayed //defaults to five $a->set_Limit($mvars['max_items']); //if using numbered links this will set the number before and behind //the current page. $a->set_Links(floor($mvars['maxpagenumbers']/2)); //gets starting point. $limit1 = $a->getRange1(); //gets number of items displayed on page. $limit2 = $a->getRange2(); $links = $a->getLinkArr(); $current=$a->getCurrent(); //prev link - only if prev-tag if ( strpos($mvars['tpl_nav'],'{prev}')!==false ) { if($a->getPrevious()) { if (!empty($mvars['linkstyle'])) $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; else $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{prev}', $mvars['repl_prev_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{prev}', $mvars['nextprevstylein'].$mvars['repl_prev_string'].$mvars['nextprevstyleout'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{prev}', '', $mvars['tpl_nav']); } } // next link - only if next-tag if ( strpos($mvars['tpl_nav'],'{next}')!==false ) { if($a->getNext()) { if (!empty($mvars['linkstyle'])) $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; else $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{next}', '', $mvars['tpl_nav']); } } // page rotation // gen page number links $displayedpages=count($links); $c=0; foreach($links as $link) { $pagenumber=$link; if ($mvars['nav_roman_no']=='true') $pagenumber=arab2rom($pagenumber); if($link == $current) { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; } else { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; } if ($c<$displayedpages-1) $mvars['tpl_nav_pages_string'] = $mvars['tpl_nav_pages_string'].$mvars['nav_split_string']; $c++; } $mvars['tpl_nav'] = str_replace('{page}', $mvars['tpl_nav_pages_string'], $mvars['tpl_nav']); // number conversion if ($mvars['nav_roman_no']=='true') { $mvars['str_currentpage']=arab2rom($page); $mvars['str_pagestotal']=arab2rom($a->getTotalPages()); } else { $mvars['str_currentpage']=$page; $mvars['str_pagestotal']=$a->getTotalPages(); } } // the output // add new link at the top $new_at_top_temp=''.''.''; if($sess->name=='sefrengo' && $view == 'edit' && $mvars['add_entry_top'] == 'true') { $allcontents .=str_replace('{button}',$new_at_top_temp,$mvars['tpl_edit']); } // number format definition for the leading zero no. element $leadingzeronoformat="%0".(strlen(''.$mvars["entries"].'')+1)."d"; for ($c=$limit1;$c<$limit1 + $limit2;$c++) { // if {colswap} detected if ($colswap===true) { if ( $c%2 ) { $entries[$c] = str_replace('{colswap}', 1, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 1, $duplentries[$c]); } else { $entries[$c] = str_replace('{colswap}', 0, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 0, $duplentries[$c]); } } // insert entry number $entries[$c] =str_replace('{no}',$c+1,$entries[$c]); $entries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$entries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_inner'],'{chop}') !== false && strpos($mvars['tpl_inner'],'{/chop}') !== false) { $strparts=getstringparts( $entries[$c] , "{chop}", "{/chop}"); $allcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allcontents .=$entries[$c]; // duplicate list dependent from max entries per page if ($mvars['dupl_page_nav'] === 'true' && $mvars['tpl_dupl_flag']) { $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[floor($c/$mvars['max_items'])],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // duplicate list independent from max entries per page if ($mvars['dupl_page_nav'] !== 'true' && $mvars['tpl_dupl_flag']) { $counter=0; $subcounter=0; for ($c=0;$c$mvars['max_items']-1) { $counter++; $subcounter=0; } $subcounter++; $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0 && !empty($links[$counter])) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[$counter],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // html intro if ( strpos($mvars['tpl_intro'],'{new}')!==false) if($sess->name=='sefrengo' && $view == 'edit') { $mvars['tpl_intro']=str_replace('{new}',$new_at_top_temp,$mvars['tpl_intro']); } else $mvars['tpl_intro']=str_replace('{new}','',$mvars['tpl_intro']); // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_intro']=str_replace('{list}',$allduplcontents, $mvars['tpl_intro']); // {nav} found? if ( strpos($mvars['tpl_intro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_intro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_intro']); else $mvars['tpl_intro']=str_replace('{nav}','', $mvars['tpl_intro']); // nav at top if ($nocontentsflag!=1 && !empty($mvars['tpl_intro'])) { $introstring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_intro']); $introstring=str_replace('{currentpage}',$mvars['str_currentpage'], $introstring); $allcontents = $introstring.$allcontents; } // html outro // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_outro']=str_replace('{list}',$allduplcontents, $mvars['tpl_outro']); // {nav} found? if ( strpos($mvars['tpl_outro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_outro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_outro']); else $mvars['tpl_outro']=str_replace('{nav}','', $mvars['tpl_outro']); // nav at bottom if ($nocontentsflag!=1 && !empty($mvars['tpl_outro'])) { $outrostring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_outro']); $outrostring=str_replace('{currentpage}',$mvars['str_currentpage'], $outrostring); $allcontents = $allcontents.$outrostring; } // nav on top if ($mvars['nav_above_list'] == 'true' && $mvars['max_items']!=0 ) $allcontents = $mvars['tpl_nav'].$allcontents; // nav on bottom if ($mvars['nav_below_list'] == 'true' && $mvars['max_items']!=0) $allcontents = $allcontents.$mvars['tpl_nav']; // the end eval('?>'.stripslashes($allcontents)); ; unset( $entries, $duplentries, $duplentries, $allduplcontents, $duplentry, $allcontents, $allentries, $colswap, $nocontentsflag, $entries, $outrostring, $introstring, $a, $limit1, $limit2, $links, $current, $onetimeflag, $autozeronoformat ); } unset($mvars); ?>1 ) { if ( strpos( $mvars['tpl_inner'] ,'{edit}')!==false ) { $mvars['tpl_inner'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_inner']); $mvars['tpl_inner'] = str_replace('{noedit}', '', $mvars['tpl_inner']); $entries[]= $mvars['tpl_inner']; } elseif (strpos( $mvars['tpl_inner'] ,'{noedit}') ===false) { if ($mvars['edit_tpl_pos']!=='true') $entries[]= $mvars['tpl_inner'].$mvars['typegroup']; else $entries[]= $mvars['typegroup'].$mvars['tpl_inner']; } else { $entries[]= str_replace('{noedit}','',$mvars['tpl_inner']); } if ( strpos( $mvars['tpl_dupl'] ,'{edit}')!==false ) { $mvars['tpl_dupl'] = str_replace('{edit}', $mvars['typegroup'], $mvars['tpl_dupl']); $mvars['tpl_dupl'] = str_replace('{noedit}', '', $mvars['tpl_dupl']); $duplentries[]= $mvars['tpl_dupl']; } elseif (strpos( $mvars['tpl_dupl'] ,'{noedit}')===false ) { if ($mvars['edit_tpl_pos']!=='true') $duplentries[]= $mvars['tpl_dupl'].$mvars['typegroup']; else $duplentries[]= $mvars['typegroup'].$mvars['tpl_dupl']; } else { $duplentries[]= str_replace('{noedit}','',$mvars['tpl_dupl']); } } else { if (strpos( $mvars['tpl_inner'] ,'{noedit}')===false ) $entries[]= $mvars['typegroup']; if (strpos( $mvars['tpl_dupl'] ,'{noedit}') ===false) $duplentries[]= $mvars['typegroup']; $nocontentsflag=1; } // if the last entry is reached the output will be generated if ($mvars['is_last']) { // define current-page format-tags if ( strpos($mvars['tpl_nav'],'{page}')!==false ) { // format of the current page if ( $mvars['cpageformat'] == '1' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '2' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '3' ) { $mvars['tagin']=''; $mvars['tagout']=''; } elseif ( $mvars['cpageformat'] == '4' ) { $mvars['tagin']=''; $mvars['tagout']=''; } else { $mvars['tagin']=''; $mvars['tagout']=''; } } if (!empty($mvars['currentpagestyle']) || !empty($mvars['currentpageattr']) ){ $mvars['currentpagestylein']=''; $mvars['currentpagestyleout']=''; } if (!empty($mvars['nextprevstyle']) || !empty($mvars['nextprevattr'])){ $mvars['nextprevstylein']=''; $mvars['nextprevstyleout']=''; } if (!empty($mvars['pagestyle']) || !empty($mvars['pageattr'])){ $mvars['pagestylein']=''; $mvars['pagestyleout']=''; } if ($mvars['maxpagenumbers']<'3') $mvars['maxpagenumbers']=3; if ( strpos($mvars['tpl_checkup'],'{colswap}')!==false ) $colswap=true; // get the number of entries $mvars["entries"] = count($entries); // default if no page switch $limit1=0; $limit2=$mvars["entries"]; if(! function_exists(str_chop)){ /** * Chop a string into a smaller string. * * @author Aidan Lister * @author2 Alexander M. Korn * @version ? * @link http://aidanlister.com/repos/v/function.str_chop.php * @param mixed $string The string you want to shorten * @param int $length The length you want to shorten the string to * @param bool $center If true, chop in the middle of the string * @param mixed $append String appended if it is shortened */ function str_chop($string, $length = 60, $center = true, $append = null) { $string=strip_tags($string); // Set the default append string if ($append === null) { $append = ($center === true) ? ' ... ' : ' ...'; } preg_match_all('#\&(.*)\;#sU',$string,$entities); $entities[0]=array_unique($entities[0]); if (is_array($entities[0]) && !empty($entities[0])) foreach($entities[0] as $v) $string=(str_replace( $v,utf8_encode(html_entity_decode( $v)),$string)); if ($center==="true") $center=true; // Get some measurements $len_string = strlen($string); $len_append = strlen($append); if ($len_string > $length) { // If the string is longer than the maximum length, we need to chop it // Check if we want to chop it in half if ($center === true) { // Get the lengths of each segment $len_start = $length / 2; $len_end = $len_start - $len_append; // Get each segment $seg_start = substr($string, 0, $len_start); $seg_end = substr($string, $len_string - $len_end, $len_end); $seg_start = substr( $seg_start, 0, strrpos ( $seg_start, " ")); $seg_end = substr( $seg_end, strpos ( $seg_end, " ")+1); // Stick them together $string = $seg_start . $append . $seg_end; } else { // Otherwise, just chop the end off $string = substr($string, 0, $length - $len_append); $string = substr($string, 0, strrpos ($string, " ")) . $append; } } return $string; } } if(! function_exists(getstringparts)) { function getstringparts($string, $tagin, $tagout) { /** * Splits a string into 3 parts dependent on tagin & tagout. * * @author Alexander M. Korn * @version 1.0.0 */ $tagin_pos = strpos($string,$tagin); $tagout_pos = strpos($string,$tagout); if ( $tagin_pos !== false || $tagout_pos !== false || $tagout_pos > $tagin_pos ) { $tagin_len = strlen($tagin); $tagout_len = strlen($tagout); $strparts['first'] = substr($string,0,$tagin_pos); $strparts['middle'] = substr($string,$tagin_pos+$tagin_len,$tagout_pos-($tagin_pos+$tagin_len)); $strparts['last'] = substr($string,$tagout_pos+$tagout_len); } else { $strparts['first'] = $string; $strparts['middle'] = ''; $strparts['last'] = ''; } return $strparts; } } // function for number conversion if(! function_exists(arab2rom)){ function arab2rom($input) { if ( $input<=0 ) return " "; //Römische Zeichen $rz = array( 1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD', 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ); //Berechnung $out = ''; foreach ($rz as $wert => $zeichen) { $b = floor($input / $wert); if ($b > 0){ $out .= str_repeat($zeichen, $b); } $input = $input % $wert; } return $out; } } if ($mvars['max_items']>=$limit2-1 && $mvars['navallways']!='true') $mvars['max_items']=0; // navigation if max_items set if ($mvars['max_items']!=0) { // Paginator-class for simple page-calculation if(! class_exists(Paginator)){ class Paginator { //all variables are pivate. var $previous; var $current; var $next; var $page; var $total_pages; var $link_arr; var $range1; var $range2; var $num_rows; var $first; var $last; var $first_of; var $second_of; var $limit; var $prev_next; var $base_page_num; var $extra_page_num; var $total_items; var $pagename; //Constructor for Paginator. Takes the current page and the number of items //in the source data and sets the current page ($this->page) and the total //items in the source ($this->total_items). function Paginator($page,$num_rows) { if(!$page) { $this->page=1; } else { $this->page=$page; } $this->num_rows=$num_rows; $this->total_items = $this->num_rows; } //Takes $limit and sets $this->limit. Calls private mehods //setBasePage() and setExtraPage() which use $this->limit. function set_Limit($limit=5) { $this->limit = $limit; $this->setBasePage(); $this->setExtraPage(); } //This method creates a number that setExtraPage() uses to if there are //and extra pages after limit has divided the total number of pages. function setBasePage() { $div=$this->num_rows/$this->limit; $this->base_page_num=floor($div); } function setExtraPage() { $this->extra_page_num=$this->num_rows - ($this->base_page_num*$this->limit); } //Used in making numbered links. Sets the number of links behind and //ahead of the current page. For example if there were a possiblity of //20 numbered links and this was set to 5 and the current link was 10 //the result would be this 5 6 7 8 9 10 11 12 13 14 15. function set_Links($prev_next=5) { $this->prev_next = $prev_next; } //method to get the total items. function getTotalItems() { $this->total_items = $this->num_rows; return $this->total_items; } //method to get the base number to use in queries and such. function getRange1() { $this->range1=($this->limit*$this->page)-$this->limit; return $this->range1; } //method to get the offset. function getRange2() { if($this->page==$this->base_page_num + 1) { $this->range2=$this->extra_page_num; } else { $this->range2=$this->limit; } return $this->range2; } //method to get the first of number as in 5 of . function getFirstOf() { $this->first_of=$this->range1 + 1; return $this->first_of; } //method to get the second number in a series as in 5 of 8. function getSecondOf() { if($this->page==$this->base_page_num + 1) { $this->second_of=$this->range1 + $this->extra_page_num; } else { $this->second_of=$this->range1 + $this->limit; } return $this->second_of; } //method to get the total number of pages. function getTotalPages() { if($this->extra_page_num) { $this->total_pages = $this->base_page_num + 1; } else { $this->total_pages = $this->base_page_num; } return $this->total_pages; } //method to get the first link number. function getFirst() { $this->first=1; return $this->first; } //method to get the last link number. function getLast() { if($this->page == $this->total_pages) { $this->last=0; }else { $this->last = $this->total_pages; } return $this->last; } function getPrevious() { if($this->page > 1) { $this->previous = $this->page - 1; } return $this->previous; } //method to get the number of the link previous to the current link. function getCurrent() { $this->current = $this->page; return $this->current; } //method to get the current page name. Is mostly used in links to the next //page. function getPageName() { $this->pagename = $_SERVER['PHP_SELF'];; return $this->pagename; } //method to get the number of the link after the current link. function getNext() { $this->getTotalPages(); if($this->total_pages != $this->page) { $this->next = $this->page + 1; } return $this->next; } //method that returns an array of the numbered links that should be //displayed. function getLinkArr() { //gets the top range $top = $this->getTotalPages()- $this->getCurrent(); if($top <= $this->prev_next) { $top = $top; $top_range = $this->getCurrent() + $top; } else { $top = $this->prev_next; $top_range = $this->getCurrent() + $top; } //gets the bottom range $bottom = $this->getCurrent() -1; if($bottom <= $this->prev_next) { $bottom = $bottom; $bottom_range = $this->getCurrent() - $bottom; } else { $bottom = $this->prev_next; $bottom_range = $this->getCurrent() - $bottom; } $j=0; foreach(range($bottom_range, $top_range) as $i) { $this->link_arr[$j] = $i; $j++; } return $this->link_arr; } }//ends Paginator class } $a =& new Paginator($page,($mvars["entries"])); //sets the number of records displayed //defaults to five $a->set_Limit($mvars['max_items']); //if using numbered links this will set the number before and behind //the current page. $a->set_Links(floor($mvars['maxpagenumbers']/2)); //gets starting point. $limit1 = $a->getRange1(); //gets number of items displayed on page. $limit2 = $a->getRange2(); $links = $a->getLinkArr(); $current=$a->getCurrent(); //prev link - only if prev-tag if ( strpos($mvars['tpl_nav'],'{prev}')!==false ) { if($a->getPrevious()) { if (!empty($mvars['linkstyle'])) $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; else $mvars['repl_prev_string'] = ''.$mvars['nextprevstylein'].$mvars['label_prev'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{prev}', $mvars['repl_prev_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{prev}', $mvars['nextprevstylein'].$mvars['repl_prev_string'].$mvars['nextprevstyleout'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{prev}', '', $mvars['tpl_nav']); } } // next link - only if next-tag if ( strpos($mvars['tpl_nav'],'{next}')!==false ) { if($a->getNext()) { if (!empty($mvars['linkstyle'])) $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; else $mvars['repl_next_string'] = ''.$mvars['nextprevstylein'].$mvars['label_next'].$mvars['nextprevstyleout'].''; $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); } else { // show me if i'm useless or not if ($mvars['nav_show_labels'] == 'true') $mvars['tpl_nav'] = str_replace('{next}', $mvars['repl_next_string'], $mvars['tpl_nav']); else $mvars['tpl_nav'] = str_replace('{next}', '', $mvars['tpl_nav']); } } // page rotation // gen page number links $displayedpages=count($links); $c=0; foreach($links as $link) { $pagenumber=$link; if ($mvars['nav_roman_no']=='true') $pagenumber=arab2rom($pagenumber); if($link == $current) { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['currentpagestylein'].$mvars['tagin'].$pagenumber.$mvars['tagout'].$mvars['currentpagestyleout'].''; } else { if (!empty($mvars['linkstyle'])) $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; else $mvars['tpl_nav_pages_string'] .= ''.$mvars['pagestylein'].$pagenumber.$mvars['pagestyleout'].''; } if ($c<$displayedpages-1) $mvars['tpl_nav_pages_string'] = $mvars['tpl_nav_pages_string'].$mvars['nav_split_string']; $c++; } $mvars['tpl_nav'] = str_replace('{page}', $mvars['tpl_nav_pages_string'], $mvars['tpl_nav']); // number conversion if ($mvars['nav_roman_no']=='true') { $mvars['str_currentpage']=arab2rom($page); $mvars['str_pagestotal']=arab2rom($a->getTotalPages()); } else { $mvars['str_currentpage']=$page; $mvars['str_pagestotal']=$a->getTotalPages(); } } // the output // add new link at the top $new_at_top_temp=''.''.''; if($sess->name=='sefrengo' && $view == 'edit' && $mvars['add_entry_top'] == 'true') { $allcontents .=str_replace('{button}',$new_at_top_temp,$mvars['tpl_edit']); } // number format definition for the leading zero no. element $leadingzeronoformat="%0".(strlen(''.$mvars["entries"].'')+1)."d"; for ($c=$limit1;$c<$limit1 + $limit2;$c++) { // if {colswap} detected if ($colswap===true) { if ( $c%2 ) { $entries[$c] = str_replace('{colswap}', 1, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 1, $duplentries[$c]); } else { $entries[$c] = str_replace('{colswap}', 0, $entries[$c]); if ($mvars['tpl_dupl_flag']) $duplentries[$c] = str_replace('{colswap}', 0, $duplentries[$c]); } } // insert entry number $entries[$c] =str_replace('{no}',$c+1,$entries[$c]); $entries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$entries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_inner'],'{chop}') !== false && strpos($mvars['tpl_inner'],'{/chop}') !== false) { $strparts=getstringparts( $entries[$c] , "{chop}", "{/chop}"); $allcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allcontents .=$entries[$c]; // duplicate list dependent from max entries per page if ($mvars['dupl_page_nav'] === 'true' && $mvars['tpl_dupl_flag']) { $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[floor($c/$mvars['max_items'])],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); // search for {chop} {/chop} and shorten the stuff between if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // duplicate list independent from max entries per page if ($mvars['dupl_page_nav'] !== 'true' && $mvars['tpl_dupl_flag']) { $counter=0; $subcounter=0; for ($c=0;$c$mvars['max_items']-1) { $counter++; $subcounter=0; } $subcounter++; $duplentries[$c]= str_replace('{no}',$c+1,$duplentries[$c]); $duplentries[$c]= str_replace('{zero_no}',sprintf ($leadingzeronoformat,$c+1 ) ,$duplentries[$c]); if ($mvars['max_items']!=0 && !empty($links[$counter])) $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'].'&'.$cms_mod['key'].'page='.$links[$counter],$duplentries[$c]); else $duplentries[$c]=str_replace('{url}',$con_side[$idcatside]['link'],$duplentries[$c]); if (strpos($mvars['tpl_dupl'],'{chop}') !== false && strpos($mvars['tpl_dupl'],'{/chop}') !== false) { $strparts=getstringparts( $duplentries[$c] , "{chop}", "{/chop}"); $allduplcontents .= $strparts['first'].str_chop($strparts['middle'], $mvars['chop_length'], $mvars['chop_middle_cut'], $mvars['chop_cut_string']).$strparts['last']; } else $allduplcontents .=$duplentries[$c]; } } // html intro if ( strpos($mvars['tpl_intro'],'{new}')!==false) if($sess->name=='sefrengo' && $view == 'edit') { $mvars['tpl_intro']=str_replace('{new}',$new_at_top_temp,$mvars['tpl_intro']); } else $mvars['tpl_intro']=str_replace('{new}','',$mvars['tpl_intro']); // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_intro']=str_replace('{list}',$allduplcontents, $mvars['tpl_intro']); // {nav} found? if ( strpos($mvars['tpl_intro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_intro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_intro']); else $mvars['tpl_intro']=str_replace('{nav}','', $mvars['tpl_intro']); // nav at top if ($nocontentsflag!=1 && !empty($mvars['tpl_intro'])) { $introstring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_intro']); $introstring=str_replace('{currentpage}',$mvars['str_currentpage'], $introstring); $allcontents = $introstring.$allcontents; } // html outro // {list} found? replace with duplicate list if ( $mvars['tpl_dupl_flag'] ) $mvars['tpl_outro']=str_replace('{list}',$allduplcontents, $mvars['tpl_outro']); // {nav} found? if ( strpos($mvars['tpl_outro'],'{nav}') !== false && $mvars['max_items']!=0 ) $mvars['tpl_outro']=str_replace('{nav}',$mvars['tpl_nav'], $mvars['tpl_outro']); else $mvars['tpl_outro']=str_replace('{nav}','', $mvars['tpl_outro']); // nav at bottom if ($nocontentsflag!=1 && !empty($mvars['tpl_outro'])) { $outrostring=str_replace('{pagestotal}',$mvars['str_pagestotal'], $mvars['tpl_outro']); $outrostring=str_replace('{currentpage}',$mvars['str_currentpage'], $outrostring); $allcontents = $allcontents.$outrostring; } // nav on top if ($mvars['nav_above_list'] == 'true' && $mvars['max_items']!=0 ) $allcontents = $mvars['tpl_nav'].$allcontents; // nav on bottom if ($mvars['nav_below_list'] == 'true' && $mvars['max_items']!=0) $allcontents = $allcontents.$mvars['tpl_nav']; // the end eval('?>'.stripslashes($allcontents)); ; unset( $entries, $duplentries, $duplentries, $allduplcontents, $duplentry, $allcontents, $allentries, $colswap, $nocontentsflag, $entries, $outrostring, $introstring, $a, $limit1, $limit2, $links, $current, $onetimeflag, $autozeronoformat ); } unset($mvars); ?>