Advertisement
Guest User

Reader.php

a guest
Aug 8th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.66 KB | None | 0 0
  1. <?php  
  2. if(($isPage)) {
  3.     global $previousPage, $previousLink, $nextPage, $nextLink, $kommiku, $theimage;
  4.     if($kommiku['series_chapter']) {
  5.         foreach ($kommiku['series_chapter'] as $chapterList) { $h++;
  6.             $chapterLists[$h] = $chapterList->slug;
  7.             $chapterListID[$h] = $chapterList->id;
  8.             if($select) {
  9.                 $nextChapter = $chapterList->slug;
  10.                 $nextChapterID = $chapterList->id;
  11.             }
  12.             unset($select);
  13.             if($chapterList->slug == $chapter["slug"]) {
  14.                 $select = "selected=selected ";
  15.                 $chapterSelected = $h;
  16.             }
  17.             unset($chapterTitle);
  18.             if ($chapterList->title) $chapterTitle = ' - '.stripslashes($chapterList->title);
  19.             $chapter_items[$chapterList->number] = '<option '.$select.'value="'.$chapterList->slug.'">'.$chapterList->slug.$chapterTitle.'</option>';          
  20.             if($select) {
  21.                 $pass = $h-1;
  22.                 if(isset($chapterListID[$pass])) $previousChapter = $chapterLists[$pass];
  23.                 if(isset($chapterListID[$pass])) $previousChapterID = $chapterListID[$pass];
  24.             }
  25.         }
  26.         natsort($chapter_items);
  27.         krsort($chapter_items);
  28.         foreach($chapter_items as $chapter_item){
  29.             $kommiku['chapterOption'] .= $chapter_item;
  30.         }
  31.         $chapterOption = $kommiku['chapterOption'];
  32.     }
  33.    
  34.     if($chapter_pages) {
  35.     foreach ($chapter_pages as $pageList) { $i++;
  36.         $pageLists[$i] = $pageList->number;
  37.         if(isset($select)) $nextPage = $pageList->slug;
  38.         unset($select);
  39.         if($pageList->number == $page["number"]) {
  40.             $select = "selected=selected ";
  41.             $pageSelected = $pageList->number;
  42.         }
  43.         $kommiku['pageOption'] .= '<option '.$select.'value="'.$pageList->slug.'">'.$pageList->slug.'</option>';
  44.         $lastPage = $pageList->number;
  45.         if($select) $previousPage = $pageLists[$i-1];
  46.         }
  47.     }  
  48.     $pageOption = $kommiku['pageOption'];
  49.    
  50.     if(isset($chapter["number"])){
  51.         $chapter["next"] = $chapter["slug"].'/';
  52.         $chapter["previous"] = $chapter["slug"].'/';
  53.     }
  54.    
  55.     if($lastPage == $pageSelected && $nextChapterID) {
  56.         $number = $wpdb->get_var("SELECT min(number) FROM `".$wpdb->prefix."comic_page` WHERE chapter_id = '".$nextChapterID."'");
  57.         $nextPage = $wpdb->get_var("SELECT min(slug) FROM `".$wpdb->prefix."comic_page` WHERE chapter_id = '".$nextChapterID."' AND number = '".$number."'");
  58.         $chapter["next"] = $nextChapter.'/';
  59.         } else if ($lastPage == $pageSelected) {
  60.             unset($nextPage);  
  61.         }
  62.                    
  63.     if(is_null($previousPage) && $previousChapterID) {
  64.         $number = $wpdb->get_var("SELECT max(number) FROM `".$wpdb->prefix."comic_page` WHERE chapter_id = '".$previousChapterID."'"); 
  65.         $previousPage = $wpdb->get_var("SELECT slug FROM `".$wpdb->prefix."comic_page` WHERE chapter_id = '".$previousChapterID."' AND number = '".$number."'");   
  66.         $chapter["previous"] = $previousChapter.'/';
  67.     }  
  68.                
  69.     if(KOMMIKU_URL_FORMAT)
  70.         $komUrlDash = KOMMIKU_URL_FORMAT.'/';
  71.        
  72.     if(!$kommiku['one_comic'])
  73.         $seriesUrl = $series["slug"].'/';
  74.                    
  75.     if($chapter) {
  76.         if(isset($previousPage)) $previousLink = HTTP_HOST.$komUrlDash.$seriesUrl.$chapter["previous"].$previousPage.'/';
  77.         if(isset($nextPage)) $nextLink = HTTP_HOST.$komUrlDash.$seriesUrl.$chapter["next"].$nextPage.'/';
  78.     } else {
  79.         if(isset($previousPage)) $previousLink = HTTP_HOST.$komUrlDash.$seriesUrl.$previousPage.'/';
  80.         if(isset($nextPage)) $nextLink = HTTP_HOST.$komUrlDash.$seriesUrl.$nextPage.'/';
  81.     }
  82.            
  83.     function prevPage($link = false,$wrapper = '',$class = NULL,$title = NULL) {
  84.         global $previousPage, $previousLink;
  85.        
  86.         if($link && isset($previousLink)) {
  87.             if($class) $class = 'class="'.$class.'" ';
  88.             if($title) {
  89.                 $title = 'title="'.$title.'" ';
  90.             } else {
  91.                 $title =  'title="'.__("Read the previous page", 'kommiku').'"';
  92.             }                  
  93.             echo '<a '.$class.$title.'href="'.$previousLink.'">'.$wrapper.'</a>';
  94.         } else if($link) {
  95.             echo $wrapper;
  96.         } else {
  97.             echo $previousLink;
  98.         }
  99.            
  100.     }
  101.  
  102.     function checkPrevPage() {
  103.         global $previousPage, $previousLink;
  104.                    
  105.         if(isset($previousPage) && isset($previousLink))
  106.             return true;
  107.            
  108.         return false;
  109.                    
  110.     }
  111.  
  112.     function checkNextPage() {
  113.         global $nextPage, $nextLink;
  114.        
  115.         if(isset($nextLink) && isset($nextPage))
  116.             return true;
  117.            
  118.         return false;
  119.  
  120.     }
  121.            
  122.     function nextPage($link = false,$wrapper = '',$class = NULL,$title = NULL) {
  123.         global $nextPage, $nextLink;
  124.        
  125.         if($link && isset($nextLink)) {
  126.             if($class) $class = 'class="'.$class.'" ';
  127.             if($title) {
  128.                 $title = 'title="'.$title.'" ';
  129.             } else {
  130.                 $title = 'title="'.__("Read the next page", 'kommiku').'"';
  131.             }
  132.             echo '<a '.$class.$title.'href="'.$nextLink.'">'.$wrapper.'</a>';
  133.         } else if($link) {
  134.             echo $wrapper;
  135.         } else {
  136.             echo $nextLink;
  137.         }
  138.            
  139.     }
  140.        
  141.     function img($echo = true,$class = NULL,$title = NULL) {
  142.             global $nextPage, $nextLink, $series, $chapter, $page, $imageWidth;
  143.                    
  144.         if($chapter["folder"]) {
  145.             $url = $chapter["folder"]; 
  146.         } else if($series['chapterless'] != 0) {
  147.             $url = '/'.$series["slug"].'/';
  148.         } else {
  149.             die('Something is wrong here!');
  150.         }
  151.  
  152.         $theimage = UPLOAD_URLPATH.$url.$page["img"];
  153.         $theimage_abs = UPLOAD_FOLDER.$url.$page["img"];
  154.        
  155.         if($width > 950) {
  156.             $class = 'class="constraintImage"';
  157.             $imageWidth = $width;
  158.             }
  159.  
  160.             $wrapper = '<img id="theBigImage" src="'.$imagePath.'"'.$class.'/>';
  161.            
  162.         if(file_exists($theimage_abs) && $echo == true) {
  163.             $wrapper = '<img src="'.$theimage.'" />';
  164.                        
  165.         } else {
  166.             return $theimage;  
  167.         }
  168.        
  169.         if(isset($nextLink)) {
  170.             if($class) $class = 'class="'.$class.'" ';
  171.             if($title) {
  172.                 $title = 'title="'.$title.'" ';
  173.             } else {
  174.                 $title = 'title="'.__("Read the next page", 'kommiku').'"';
  175.             }
  176.             echo '<a '.$class.$title.'href="'.$nextLink.'">'.$wrapper.'</a>';
  177.         } else {
  178.             echo $wrapper;
  179.         }
  180.        
  181.     }
  182.    
  183. }
  184.  
  185.  
  186. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement