Skip to content

Commit

Permalink
Cleaned up alignment of braces and indentation for deprecated functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
willynilly committed Apr 30, 2009
1 parent 1ba2690 commit 1f53e6b
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions application/helpers/DeprecatedFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* @param mixed
* @return mixed
**/
function not_empty_or($value, $default) {
function not_empty_or($value, $default)
{
return !empty($value) ? $value : $default;
}

Expand All @@ -33,7 +34,8 @@ function current_user_tags($item)
/**
* @deprecated
*/
function h($str, $allowedTags = "i|em|b|strong|del|span") {
function h($str, $allowedTags = "i|em|b|strong|del|span")
{

$html = htmlentities($str,ENT_QUOTES,"UTF-8");

Expand All @@ -49,7 +51,8 @@ function h($str, $allowedTags = "i|em|b|strong|del|span") {
* @param string
* @return string
**/
function unescapeTags($matches) {
function unescapeTags($matches)
{
return str_replace( array("&gt;", "&lt;", "&quot;", "&amp;"), array(">", "<", "\"", "&"), $matches[0]);
}

Expand All @@ -58,23 +61,23 @@ function unescapeTags($matches) {
**/
function thumbnail($record, $props=array(), $width=null, $height=null)
{
return archive_image($record, $props, $width, $height, 'thumbnail');
return archive_image($record, $props, $width, $height, 'thumbnail');
}

/**
* @deprecated
**/
function fullsize($record, $props=array(), $width=null, $height=null)
{
return archive_image($record, $props, $width, $height, 'fullsize');
return archive_image($record, $props, $width, $height, 'fullsize');
}

/**
* @deprecated
**/
function square_thumbnail($record, $props=array(), $width=null, $height=null)
{
return archive_image($record, $props, $width, $height, 'square_thumbnail');
return archive_image($record, $props, $width, $height, 'square_thumbnail');
}

/**
Expand All @@ -88,42 +91,37 @@ function archive_image( $record, $props, $width, $height, $format)
return false;
}

if($record instanceof File) {
$filename = $record->getDerivativeFilename();
$file = $record;
}elseif($record instanceof Item) {
$file = get_db()->getTable('File')->getRandomFileWithImage($record->id);
if(!$file) return false;
$filename = $file->getDerivativeFilename();
}
if($record instanceof File) {
$filename = $record->getDerivativeFilename();
$file = $record;
} elseif($record instanceof Item) {
$file = get_db()->getTable('File')->getRandomFileWithImage($record->id);
if(!$file) return false;
$filename = $file->getDerivativeFilename();
}

$path = $file->getPath($format);
$uri = file_display_uri($file, $format);
if(!file_exists($path)) {
return false;
}
$path = $file->getPath($format);
$uri = file_display_uri($file, $format);

if(!file_exists($path)) {
return false;
}

list($oWidth, $oHeight) = getimagesize( $path );
if(!$width && !$height)
{
$width = $oWidth;
$height = $oHeight;
}
elseif( $oWidth > $width && !$height )
{
$ratio = $width / $oWidth;
$height = $oHeight * $ratio;
}
elseif( !$width && $oHeight > $height)
{
$ratio = $height / $oHeight;
$width = $oWidth * $ratio;
}
$props['width'] = $width;
$props['height'] = $height;
list($oWidth, $oHeight) = getimagesize( $path );
if(!$width && !$height) {
$width = $oWidth;
$height = $oHeight;
} elseif( $oWidth > $width && !$height ) {
$ratio = $width / $oWidth;
$height = $oHeight * $ratio;
} elseif( !$width && $oHeight > $height) {
$ratio = $height / $oHeight;
$width = $oWidth * $ratio;
}
$props['width'] = $width;
$props['height'] = $height;

$html = '<img src="' . $uri . '" '._tag_attributes($props) . '/>' . "\n";
return $html;
$html = '<img src="' . $uri . '" '._tag_attributes($props) . '/>' . "\n";
return $html;
}

0 comments on commit 1f53e6b

Please sign in to comment.