/** * This will become a Smarty function. * I am writting this to eliminate the possiblitles * of distort pictures */ function getFileSmarty($p) { global $Cbucket; $details = $p['details']; $output = $p['output']; if (empty($details)) { return $this->default_thumb($size, $output); } else { //Calling Custom Functions if (count($Cbucket->custom_get_photo_funcs) > 0) { foreach ($Cbucket->custom_get_photo_funcs as $funcs) { if (function_exists($funcs)) { $func_returned = $funcs($p); if ($func_returned) { return $func_returned; } } } } if (empty($p['size'])) { $p['size'] = 't'; } if (!empty($p['code'])) { $p['size'] = $p['code']; } if ($details['is_mature'] == 'yes' && !userid()) { return get_mature_thumb($details, $size, $output); } if ($p['with_path'] === FALSE) { $p['with_path'] = FALSE; } else { $p['with_path'] = TRUE; } $with_path = $p['with_path']; $with_orig = $p['with_orig'] ? $p['with_orig'] : FALSE; if (!is_array($details)) { $photo = $this->get_photo($details); } else { $photo = $details; } if (empty($photo['photo_id']) || empty($photo['photo_key'])) { return $this->default_thumb($size, $output); } else { if (!empty($photo['filename']) && !empty($photo['ext'])) { /* Enhacing the code to work with date folder structure */ $date_dir = get_photo_date_folder($photo); if ($date_dir) { $date_dir .= '/'; } $files = glob(PHOTOS_DIR . "/" . $date_dir . $photo['filename'] . "*." . $photo['ext']); if (!empty($files) && is_array($files)) { foreach ($files as $file) { $file_parts = explode("/", $file); $thumb_name = $file_parts[count($file_parts) - 1]; $type = $this->get_image_type($thumb_name); if ($with_orig) { if ($with_path) { $thumbs[] = PHOTOS_URL . "/" . $date_dir . $thumb_name; } else { $thumbs[] = $thumb_name; } } elseif (!empty($type)) { if ($with_path) { $thumbs[] = PHOTOS_URL . "/" . $date_dir . $thumb_name; } else { $thumbs[] = $thumb_name; } } } if (!$thumbs) { return $this->default_thumb($size, $output); } if (empty($p['output']) || $p['output'] == 'non_html') { if ($p['assign'] && $p['multi']) { assign($p['assign'], $thumbs); } elseif (!$p['assign'] && $p['multi']) { return $thumbs; } else { $size = "_" . $p['size']; $return_thumb = array_find($photo['filename'] . $size, $thumbs); if (empty($return_thumb)) { $this->default_thumb($size, $output); } else { if ($p['assign'] != NULL) { assign($p['assign'], $return_thumb); } else { return $return_thumb; } } } } if ($p['output'] == 'html') { /* Creating output here is dropped. Now we'll create an array of * attributes and pass to cb_output_img_tag, that function will * create the actual HTML IMG tag */ $size = "_" . $p['size']; $src = array_find($photo['filename'] . $size, $thumbs); $attrs = array(); if (empty($src)) { return $this->default_thumb($size, $output); } else { $src = $src; } if (phpversion < '5.2.0') { global $json; $js = $json; } if (!empty($js)) { $imgDetails = $js->json_decode($photo['photo_details'], true); } else { $imgDetails = json_decode($photo['photo_details'], true); } if (empty($imgDetails) || empty($imgDetails[$p['size']])) { $dem = getimagesize(str_replace(PHOTOS_URL, PHOTOS_DIR, $src)); $width = $dem[0]; $height = $dem[1]; /* UPDATEING IMAGE DETAILS */ $this->update_image_details($details); } else { $width = $imgDetails[$p['size']]['width']; $height = $imgDetails[$p['size']]['height']; } if (USE_PHOTO_TAGGING && THIS_PAGE == 'view_item') { $id = $this->get_selector_id() . "_" . $photo['photo_id']; } else { if ($p['id']) { $id = mysql_clean($p['id']) . "_" . $photo['photo_id']; } else { $id = $this->get_selector_id() . "_" . $photo['photo_id']; } } $attrs['id'] = $id; if ($p['class']) { $attrs['class'] = mysql_clean($p['class']); } if ($p['align']) { $attrs['align'] = $p['align']; } if ($p['width'] && is_numeric($p['width']) && ($p['height'] && is_numeric($p['height']))) { $height = $p['height']; $width = $p['width']; } elseif ($p['width'] && is_numeric($p['width'])) { $height = round($p['width'] / $width * $height); $width = $p['width']; } elseif ($p['height'] && is_numeric($p['height'])) { $width = round($p['height'] * $width / $height); $height = $p['height']; } $attrs['width'] = $width; $attrs['height'] = $height; if ($p['title']) { $title = mysql_clean($p['title']); } else { $title = $photo['photo_title']; } $attrs['title'] = $title; if ($p['alt']) { $alt = mysql_clean($p['alt']); } else { $alt = mysql_clean(TITLE . ' - ' . $photo['photo_title']); } $attrs['alt'] = $alt; $anchor_p = array("place" => 'photo_thumb', "data" => $photo); ANCHOR($anchor_p); if ($p['style']) { $attrs['style'] = $p['style']; } if ($p['extra']) { $attrs['extra'] = $p['extra']; } $img = cb_output_img_tag($src, $attrs); if ($p['assign']) { assign($p['assign'], $img); } else { return $img; } } } else { return $this->default_thumb($size, $output); } } } } }
/** * * @global OBJECT $cbphoto * @param array $array * @return string */ function is_collection_cover_mature($array) { $photo = $array['photo']; if ($photo['is_collection_cover'] == true && !$photo['is_mature']) { global $cbphoto; $is_mature = $cbphoto->get_photo_field($photo['photo_id'], 'is_mature'); if ($is_mature == 'yes' && !userid()) { return get_mature_thumb($photo); } } }