concrete5/concrete5 — pull request #367 by macek (2011-12-16 19:14:57+00:00)
Title: Remove unneccessary php eval() calls

Found these little beauties

# libraries/file/types.php
eval('$width = AL_THUMBNAIL_WIDTH_LEVEL' . $level . ';');
eval('$height = AL_THUMBNAIL_HEIGHT_LEVEL' . $level . ';');

This is a bad way of getting a value from a dynamic constant name. PHP has a function for this called (drumroll please...) [`constant()`](http://php.net/manual/en/function.constant.php). We can achieve the same thing using

$width = constant("AL_THUMBNAIL_WIDTH_LEVEL{$level}");
$height = constant("AL_THUMBNAIL_HEIGHT_LEVEL{$level}");

--------------------

Found another gem here:

# models/file_version.php
eval('$hasThumbnail = $this->fvHasThumbnail' . $level . ';');

This is another bad way of getting a value of a dynamic property. This can easily be accomplished with:

# simple way
$key = "fvHasThumbnail{$level}";
$this->$key

# shortcut
$this->{"fvHasThumbnail{$level}"};

This mistake appears multiple places in this file; all instances have been replaced.

This patch does not address the abundant use of `eval` in concrete5 .js files.