Rewind arrays before foreach loops over all the elements.
(fixed a small typo as well)
This commit is contained in:
parent
cd1f5d9ed0
commit
3b028696a0
@ -24,6 +24,8 @@ class FavoritesTheme extends Themelet {
|
|||||||
$i_favorites = count($username_array);
|
$i_favorites = count($username_array);
|
||||||
$html = "$i_favorites people:";
|
$html = "$i_favorites people:";
|
||||||
|
|
||||||
|
reset($username_array); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($username_array as $row) {
|
foreach($username_array as $row) {
|
||||||
$username = html_escape($row);
|
$username = html_escape($row);
|
||||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||||
|
@ -41,6 +41,8 @@ class LogDatabaseTheme extends Themelet {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>\n";
|
<tbody>\n";
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
reset($events); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($events as $event) {
|
foreach($events as $event) {
|
||||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||||
$c = $this->pri_to_col($event['priority']);
|
$c = $this->pri_to_col($event['priority']);
|
||||||
|
@ -40,6 +40,9 @@ class Ratings implements Extension {
|
|||||||
while(true) {
|
while(true) {
|
||||||
$images = Image::find_images($n, 100, Tag::explode($_POST["query"]));
|
$images = Image::find_images($n, 100, Tag::explode($_POST["query"]));
|
||||||
if(count($images) == 0) break;
|
if(count($images) == 0) break;
|
||||||
|
|
||||||
|
reset($images); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
|
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,7 @@ class DatabaseConfig extends BaseConfig {
|
|||||||
*/
|
*/
|
||||||
public function save($name=null) {
|
public function save($name=null) {
|
||||||
if(is_null($name)) {
|
if(is_null($name)) {
|
||||||
|
reset($this->values); // rewind the array to the first element
|
||||||
foreach($this->values as $name => $value) {
|
foreach($this->values as $name => $value) {
|
||||||
$this->save($name);
|
$this->save($name);
|
||||||
}
|
}
|
||||||
|
@ -770,6 +770,8 @@ class Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset($terms); // rewind to first element in array.
|
||||||
|
|
||||||
// turn each term into a specific type of querylet
|
// turn each term into a specific type of querylet
|
||||||
foreach($terms as $term) {
|
foreach($terms as $term) {
|
||||||
$negative = false;
|
$negative = false;
|
||||||
@ -1002,8 +1004,15 @@ class Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function takes a list (array) of tags and changes any tags that have aliases
|
||||||
|
*
|
||||||
|
* @param $tags Array of tags
|
||||||
|
* @return Array of tags
|
||||||
|
*/
|
||||||
public static function resolve_list($tags) {
|
public static function resolve_list($tags) {
|
||||||
$tags = Tag::explode($tags);
|
$tags = Tag::explode($tags);
|
||||||
|
reset($tags); // rewind array to the first element.
|
||||||
$new = array();
|
$new = array();
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
$new_set = explode(' ', Tag::resolve_alias($tag));
|
$new_set = explode(' ', Tag::resolve_alias($tag));
|
||||||
|
@ -291,7 +291,7 @@ class Page {
|
|||||||
|
|
||||||
// store local copy for speed.
|
// store local copy for speed.
|
||||||
$autocache_css = $config->get_bool("autocache_css");
|
$autocache_css = $config->get_bool("autocache_css");
|
||||||
$autocache_js = config->get_bool("autocache_js");
|
$autocache_js = $config->get_bool("autocache_js");
|
||||||
|
|
||||||
if (!$autocache_css && !$autocache_js) {
|
if (!$autocache_css && !$autocache_js) {
|
||||||
return false; // caching disabled
|
return false; // caching disabled
|
||||||
@ -396,7 +396,7 @@ class Page {
|
|||||||
// Minify the JS if enabled.
|
// Minify the JS if enabled.
|
||||||
if ($config->get_bool("autocache_min_js")){
|
if ($config->get_bool("autocache_min_js")){
|
||||||
// not supported yet.
|
// not supported yet.
|
||||||
// TODO: add support for Minifying CSS files.
|
// TODO: add support for Minifying JS files.
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute the MD5 sum of the concatenated JavaScript files
|
// compute the MD5 sum of the concatenated JavaScript files
|
||||||
|
@ -152,12 +152,14 @@ class Upload extends SimpleExtension {
|
|||||||
$tags = ''; // Tags aren't changed when uploading. Set to null to stop PHP warnings.
|
$tags = ''; // Tags aren't changed when uploading. Set to null to stop PHP warnings.
|
||||||
|
|
||||||
if(count($_FILES)) {
|
if(count($_FILES)) {
|
||||||
|
reset($_FILES); // rewind to first element in array.
|
||||||
foreach($_FILES as $file) {
|
foreach($_FILES as $file) {
|
||||||
$ok = $this->try_upload($file, $tags, $source, $image_id);
|
$ok = $this->try_upload($file, $tags, $source, $image_id);
|
||||||
break; // leave the foreach loop.
|
break; // leave the foreach loop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
reset($_POST); // rewind to first element in array.
|
||||||
foreach($_POST as $name => $value) {
|
foreach($_POST as $name => $value) {
|
||||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||||
$ok = $this->try_transload($value, $tags, $source, $image_id);
|
$ok = $this->try_transload($value, $tags, $source, $image_id);
|
||||||
@ -188,9 +190,11 @@ class Upload extends SimpleExtension {
|
|||||||
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
||||||
$ok = true;
|
$ok = true;
|
||||||
foreach($_FILES as $file) {
|
foreach($_FILES as $file) {
|
||||||
|
reset($_FILES); // rewind to first element in array.
|
||||||
$ok = $ok & $this->try_upload($file, $tags, $source);
|
$ok = $ok & $this->try_upload($file, $tags, $source);
|
||||||
}
|
}
|
||||||
foreach($_POST as $name => $value) {
|
foreach($_POST as $name => $value) {
|
||||||
|
reset($_POST); // rewind to first element in array.
|
||||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||||
$ok = $ok & $this->try_transload($value, $tags, $source);
|
$ok = $ok & $this->try_transload($value, $tags, $source);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user