array_contains -> in_array

This commit is contained in:
Shish Moom 2009-06-05 12:53:00 -07:00
parent de0164647e
commit f77c6e64cd
8 changed files with 9 additions and 18 deletions

View file

@ -41,7 +41,7 @@ class ArchiveFileHandler extends SimpleExtension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("zip"); $exts = array("zip");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
// copied from bulk add extension // copied from bulk add extension

View file

@ -41,7 +41,7 @@ class FlashFileHandler extends SimpleExtension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("swf"); $exts = array("swf");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {
@ -124,7 +124,7 @@ class FlashFileHandler extends SimpleExtension {
$fp = fopen($file, "r"); $fp = fopen($file, "r");
$head = fread($fp, 3); $head = fread($fp, 3);
fclose($fp); fclose($fp);
if(!array_contains(array("CWS", "FWS"), $head)) return false; if(!in_array($head, array("CWS", "FWS"))) return false;
return true; return true;
} }

View file

@ -49,7 +49,7 @@ class IcoFileHandler extends SimpleExtension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("ico", "ani", "cur"); $exts = array("ico", "ani", "cur");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {

View file

@ -37,7 +37,7 @@ class MP3FileHandler implements Extension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("mp3"); $exts = array("mp3");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {

View file

@ -63,7 +63,7 @@ class SVGFileHandler implements Extension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("svg"); $exts = array("svg");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {

View file

@ -256,15 +256,6 @@ function array_add($array, $element) {
return $array; return $array;
} }
function array_contains($array, $target) {
foreach($array as $element) {
if($target == $element) {
return true;
}
}
return false;
}
// case insensetive uniqueness // case insensetive uniqueness
function array_iunique($array) { function array_iunique($array) {
$ok = array(); $ok = array();

View file

@ -37,7 +37,7 @@ class PixelFileHandler implements Extension {
private function supported_ext($ext) { private function supported_ext($ext) {
$exts = array("jpg", "jpeg", "gif", "png"); $exts = array("jpg", "jpeg", "gif", "png");
return array_contains($exts, strtolower($ext)); return in_array(strtolower($ext), $exts);
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {
@ -66,7 +66,7 @@ class PixelFileHandler implements Extension {
if(!file_exists($file)) return false; if(!file_exists($file)) return false;
$info = getimagesize($file); $info = getimagesize($file);
if(is_null($info)) return false; if(is_null($info)) return false;
if(array_contains($valid, $info[2])) return true; if(in_array($info[2], $valid)) return true;
return false; return false;
} }

View file

@ -45,7 +45,7 @@ try {
$m = array(); $m = array();
foreach($custom_themelets as $filename) { foreach($custom_themelets as $filename) {
if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m) if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m)
&& array_contains($themelets, "ext/{$m[1]}/theme.php")) { && in_array("ext/{$m[1]}/theme.php", $themelets)) {
require_once $filename; require_once $filename;
} }
} }