Beispiel #1
0
 /**
  * test dimension checking
  * 
  * @return void
  */
 function testAssetCheckDimensions()
 {
     $result = assetCheckDimensions(null, null, null);
     $this->assertTrue($result);
     $result = assetCheckDimensions(null, null, 'greater');
     $this->assertTrue($result);
     $result = assetCheckDimensions(null, null, 'less');
     $this->assertTrue($result);
     $result = assetCheckDimensions(100, 500, null);
     $this->assertFalse($result);
     $result = assetCheckDimensions(100, 500, 'greater');
     $this->assertFalse($result);
     $result = assetCheckDimensions(100, 50, 'less');
     $this->assertFalse($result);
 }
Beispiel #2
0
 /**
 * Validates the file dimensions (if image or swf) against the configuration settings
 * 
 * @param array $dimensions Contains an un-indexed array with the first value being the dimension to work against
 * @access private
 */
 function validateFileDimensions(&$model, $fieldData, $fieldName, $dimensions)
 {
     if (empty($fieldData[$fieldName]['tmp_name'])) {
         return true;
     }
     if (!empty($dimensions)) {
         $info = array();
         if (list($info['w'], $info['h'], $info['t']) = getimagesize($fieldData[$fieldName]['tmp_name'])) {
             $tmpGeometry = $dimensions;
             $tmpGeometry = str_replace('<', '', $tmpGeometry);
             $tmpGeometry = str_replace('>', '', $tmpGeometry);
             list($geometry['w'], $geometry['h']) = explode('x', $tmpGeometry);
             foreach ($geometry as $k => $v) {
                 $geometry[$k] = str_replace('*', '', $geometry[$k]);
                 if ($geometry[$k] == '') {
                     unset($geometry[$k]);
                 }
             }
             $geometry['gtlt'] = 'equal';
             if (strpos($dimensions, '>') > 0) {
                 $geometry['gtlt'] = 'greater';
             } elseif (strpos($dimensions, '<') > 0) {
                 $geometry['gtlt'] = 'less';
             }
             if (!empty($geometry['w']) && !assetCheckDimensions($info['w'], $geometry['w'], $geometry['gtlt'])) {
                 return false;
             }
             if (!empty($geometry['h']) && !assetCheckDimensions($info['h'], $geometry['h'], $geometry['gtlt'])) {
                 return false;
             }
         } else {
             return false;
         }
     }
     return true;
 }