public function make_panel($image, $iwidth, $width, $height, $share = null, $add_name = null) { /* BENCHMARK */ $this->benchmark->mark('func_make_panel_start'); // tag dimensions for resizing the image in the panel $tag_width = 0; $tag_height = 0; $rp = 0; $lp = 0; $tp = 0; $bp = 0; // get the actual dimensions of the image $actual_width = $this->get_width($_SERVER['DOCUMENT_ROOT'] . image_url($image, $iwidth)); $actual_height = $this->get_height($_SERVER['DOCUMENT_ROOT'] . image_url($image, $iwidth)); if ($actual_width > 0 && $actual_height > 0) { if ($actual_width == $width && $actual_height == $height) { // skip any complicated calculations, this image is the same size as the panel $tag_width = $actual_width; $tag_height = $actual_height; } else { // get the ratio between width and height $image_ratio = $actual_width / $actual_height; $panel_ratio = $width / $height; if ($image_ratio == $panel_ratio) { // again skip calculations, just resize image to the panel size as no padding is needed // the image ratio is the same as the panel ratio $tag_width = $width; $tag_height = $height; } else { // here we need to work out padding sizes if ($image_ratio > $panel_ratio) { // the ratio of width divided by height is greater for the image than it is for the panel // the result will be an image with padding at the top and the bottom // reduce the width down to the panel width $tag_width = $width; // get a ratio image width / panel width $width_ratio = $width / $actual_width; // use this ratio to adjust the height $tag_height = floor($actual_height * $width_ratio); // subtract the new height from the panel height and divide by two to get the padding size $pad_height = floor(($height - $tag_height) / 2); $tp = $pad_height; if (0 == ($height - $tag_height) % 2 ? $bp = $tp : ($bp = $tp++)) { } // bulk out padding $lp = $tag_width; $rp = $tag_width; } else { // the ratio of width divided by height is greater for the panel than it is for the image // the result will be an image with padding at the left and the right // reduce the height down to the panel height $tag_height = $height; // get a ratio image height / panel height $height_ratio = $height / $actual_height; // use this ratio to ajudt the width $tag_width = floor($actual_width * $height_ratio); // subtract the new width from the panel width and divide by two to get the padding size $pad_width = floor(($width - $tag_width) / 2); $lp = $pad_width; if (0 == ($width - $tag_width) % 2 ? $rp = $lp : ($rp = $lp++)) { } // bulk out padding $tp = $tag_height; $bp = $tag_height; } } } // output image - here we set the onclick functionality $fsi = "<div class='img_panel' style='width:" . $width . "px;height:" . $height . "px'>"; $fsi .= "<div class='img_pad' style='width:" . $lp . "px;height:" . $tp . "px;'></div>"; //"<img itemprop='image' class='fs_image' src='".image_url($image,$iwidth)."' width='".$tag_width."' height='".$tag_height."' alt='".$image['image_name']."'/>"; $fsi .= image_tag($image, $iwidth, $tag_width); $fsi .= "<div class='img_pad' style='width:" . $rp . "px;height:" . $bp . "px;'></div>"; $fsi .= "</div>"; // add an image name if (1 == $add_name) { $fsi .= "<span class='panel_image_name'>" . $image['image_name'] . "</span>"; } // add in the share buttons if (1 == $share) { $fsi .= "<div class='image_panel_share'>"; // create image and image node $image_node = $this->node_model->get_node($image['node_id']); $node_and_image = array('individual_image' => $image, 'image_node' => $image_node); /*$this->load->model('share_model'); $this->load->helper('image_helper'); // get the sites to share to from this node $sites=$this->config->item('social_sites'); // open social_buttons $fsi.="<div id='image_share_buttons'>"; // iterate - we can add extra ones in here as and when foreach ($sites as $site=>$config) { switch ($site) { case 'facebook': $fsi.=$this->share_model->facebook_like($config,null,$node_and_image); break; case 'twitter': $fsi.=$this->share_model->tweet_button($config,null,$node_and_image); break; } } // close social_buttons $fsi.="</div>";*/ // pinterest $fsi .= pinterest_button($image_node['url'], image_url($image, $this->config->item('base_image_width')), str_replace("'", "", $image['image_name'])); $fsi .= "</div>"; } } else { $fsi = "probable missing image: http://" . $this->config->item('full_domain') . image_url($image, $iwidth) . " - most likely a config path issue or an olf test image saved before the default save image sizes were set for this site"; } /* BENCHMARK */ $this->benchmark->mark('func_make_panel_end'); return $fsi; }
public function page_specific_data($data, $user, $node) { /* BENCHMARK */ $this->benchmark->mark('func_admin_page_data_start'); $user = $user; // BASKET if ('basket' == $node['url']) { $this->load->model('basket_model'); // cart library and postage model required $this->load->library('cart'); $this->load->model('postage_model'); // data $data['basket'] = $this->cart->contents(); $data['paypal_form'] = $this->basket_model->paypal_form(); $data['pclasses'] = $this->postage_model->get_postage_classes(10); $data['total'] = $this->basket_model->total(); $data['postage_total'] = number_format(0, 2); $data['show_voucher'] = 0; $data['vprice'] = 0; } // DISPLAY INDIVIDUAL IMAGE if ('individual_image' == $node['url']) { // the actual image to display $img = $this->data['individual_image']; $width = $this->config->item('display_individual_width'); if (count($img) > 0) { $data['individual_image_tag'] = image_tag($img, $width); $data['pin_button'] = pinterest_button("image/" . $img['image_id'], image_url($img, $width), str_replace("'", "", $img['image_name'])); } else { $data['individual_image'] = null; } } // ORDER FAILED if ('order-failed' == $node['url']) { $this->load->model('basket_model'); $data['paypal_form'] = $this->basket_model->paypal_form(); } return $data; /* BENCHMARK */ $this->benchmark->mark('func_admin_page_data_end'); }