/** * Returns href to thumbnail. Uses load-balancer system. * * @author Woxxy * @param boolean|$full if set to true, the function returns the full image * @return string href to thumbnail. */ public function get_thumb($full = FALSE) { if ($this->thumbnail != "") return balance_url() . "content/comics/" . $this->stub . "_" . $this->uniqid . "/" . ($full ? "" : "thumb_") . $this->thumbnail; return false; }
/** * Creates the href to the image. Set * * @author woxxy * @param boolean|$thumbnail if TRUE function returns thumbnail * @return string href to the image */ public function page_url($thumbnail = FALSE) { // Make sure we loaded chapter and comic $this->get_chapter(); return balance_url() . "content/comics/" . $this->chapter->comic->directory() . "/" . $this->chapter->directory() . "/" . ($thumbnail ? $this->thumbnail : "") . $this->filename; }
/** * Returns all the pages in a complete array, useful for displaying or sending * to a json function. * * @author Woxxy * @return array all pages with their data */ public function get_pages() { // if we already used the function, no need to recalc it if (isset($this->pages)) return $this->pages; // Check that the comic is loaded, else load it. $this->get_comic(); // Get the pages in filename order. Without order_by it would get them by ID which doesn't really work nicely. $pages = new Page(); $pages->where('chapter_id', $this->id)->order_by('filename')->get(); // Create the array with all page details for simple return. $return = array(); foreach ($pages->all as $key => $item) { $return[$key] = $item->to_array(); // Let's add to it the object itelf? Uncomment next line to do so. // $return[$key]['object'] = $item; // The URLs need to be completed. This function will also trigger the load balancing if enabled. $return[$key]['url'] = balance_url() . "content/comics/" . $this->comic->directory() . "/" . $this->directory() . "/" . $item->filename; $return[$key]['thumb_url'] = balance_url() . "content/comics/" . $this->comic->directory() . "/" . $this->directory() . "/" . $item->thumbnail . $item->filename; } // Put the pages in a comfy variable. $this->pages = $return; return $return; }