Ignore:
Timestamp:
Oct 19, 2013, 7:43:04 PM (11 years ago)
Author:
mistic100
Message:

remove all array_push (50% slower than []) + some changes missing for feature:2978

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/photos_add_direct_process.inc.php

    r19703 r25018  
    3535  if (!isset($_POST['submit_upload']))
    3636  {
    37     array_push(
    38       $page['errors'],
    39       sprintf(
    40         l10n('The uploaded files exceed the post_max_size directive in php.ini: %sB'),
    41         ini_get('post_max_size')
    42         )
     37    $page['errors'][] = l10n(
     38      'The uploaded files exceed the post_max_size directive in php.ini: %sB',
     39      ini_get('post_max_size')
    4340      );
    4441  }
     
    5249    foreach ($_POST['onUploadError'] as $error)
    5350    {
    54       array_push($page['errors'], $error);
     51      $page['errors'][] = $error;
    5552    }
    5653  }
     
    9895            if (is_valid_image_extension(pathinfo($node['filename'], PATHINFO_EXTENSION)))
    9996            {
    100               array_push($indexes_to_extract, $node['index']);
     97              $indexes_to_extract[] = $node['index'];
    10198             
    102               array_push(
    103                 $images_to_add,
    104                 array(
    105                   'source_filepath' => $upload_dir.'/'.$temporary_archive_name.'/'.$node['filename'],
    106                   'original_filename' => basename($node['filename']),
    107                   )
     99              $images_to_add[] = array(
     100                'source_filepath' => $upload_dir.'/'.$temporary_archive_name.'/'.$node['filename'],
     101                'original_filename' => basename($node['filename']),
    108102                );
    109103            }
     
    122116      elseif (is_valid_image_extension($extension))
    123117      {
    124         array_push(
    125           $images_to_add,
    126           array(
    127             'source_filepath' => $_FILES['image_upload']['tmp_name'][$idx],
    128             'original_filename' => $_FILES['image_upload']['name'][$idx],
    129             )
     118        $images_to_add[] = array(
     119          'source_filepath' => $_FILES['image_upload']['tmp_name'][$idx],
     120          'original_filename' => $_FILES['image_upload']['name'][$idx],
    130121          );
    131122      }
     
    140131          );
    141132
    142         array_push($image_ids, $image_id);
     133        $image_ids[] = $image_id;
    143134
    144135        // TODO: if $image_id is not an integer, something went wrong
     
    149140      $error_message = file_upload_error_message($error);
    150141     
    151       array_push(
    152         $page['errors'],
    153         sprintf(
    154           l10n('Error on file "%s" : %s'),
    155           $_FILES['image_upload']['name'][$idx],
    156           $error_message
    157           )
     142      $page['errors'][] = l10n(
     143        'Error on file "%s" : %s',
     144        $_FILES['image_upload']['name'][$idx],
     145        $error_message
    158146        );
    159147    }
     
    173161      foreach ($_SESSION['uploads_error'][ $_POST['upload_id'] ] as $error)
    174162      {
    175         array_push($page['errors'], $error);
     163        $page['errors'][] = $error;
    176164      }
    177165    }
     
    217205    $thumbnail['link'] = get_root_url().'admin.php?page=photo-'.$image_id.'&cat_id='.$category_id;
    218206
    219     array_push($page['thumbnails'], $thumbnail);
     207    $page['thumbnails'][] = $thumbnail;
    220208  }
    221209 
    222210  if (!empty($page['thumbnails']))
    223211  {
    224     array_push(
    225       $page['infos'],
    226       sprintf(
    227         l10n('%d photos uploaded'),
    228         count($page['thumbnails'])
    229         )
    230       );
     212    $page['infos'][] = l10n('%d photos uploaded', count($page['thumbnails']));
    231213   
    232214    if (0 != $_POST['level'])
    233215    {
    234       array_push(
    235         $page['infos'],
    236         sprintf(
    237           l10n('Privacy level set to "%s"'),
    238           l10n(
    239             sprintf('Level %d', $_POST['level'])
    240             )
    241           )
     216      $page['infos'][] = l10n(
     217        'Privacy level set to "%s"',
     218        l10n(sprintf('Level %d', $_POST['level']))
    242219        );
    243220    }
     
    253230   
    254231    // information
    255     array_push(
    256       $page['infos'],
    257       sprintf(
    258         l10n('Album "%s" now contains %d photos'),
    259         '<em>'.$category_name.'</em>',
    260         $count
    261         )
     232    $page['infos'][] = l10n(
     233      'Album "%s" now contains %d photos',
     234      '<em>'.$category_name.'</em>',
     235      $count
    262236      );
    263237   
Note: See TracChangeset for help on using the changeset viewer.