original_string: public static function prepare_listing($listing) {
          $wasobject = false;
          if (is_object($listing)) {
              $listing = (array) $listing;
              $wasobject = true;
          }
  
          // Prepare the breadcrumb, passed as 'path'.
          if (isset($listing['path']) && is_array($listing['path'])) {
              $listing['path'] = self::prepare_breadcrumb($listing['path']);
          }
  
          // Prepare the listing of objects.
          if (isset($listing['list']) && is_array($listing['list'])) {
              $listing['list'] = self::prepare_list($listing['list']);
          }
  
          // Convert back to an object.
          if ($wasobject) {
              $listing = (object) $listing;
          }
          return $listing;
      }
code: public static function prepare_listing($listing) {
          $wasobject = false;
          if (is_object($listing)) {
              $listing = (array) $listing;
              $wasobject = true;
          }
  
          // Prepare the breadcrumb, passed as 'path'.
          if (isset($listing['path']) && is_array($listing['path'])) {
              $listing['path'] = self::prepare_breadcrumb($listing['path']);
          }
  
          // Prepare the listing of objects.
          if (isset($listing['list']) && is_array($listing['list'])) {
              $listing['list'] = self::prepare_list($listing['list']);
          }
  
          // Convert back to an object.
          if ($wasobject) {
              $listing = (object) $listing;
          }
          return $listing;
      }
code_tokens: public static function prepare_listing ( $ listing ) { $ wasobject = false ; if ( is_object ( $ listing ) ) { $ listing = ( array ) $ listing ; $ wasobject = true ; } // Prepare the breadcrumb, passed as 'path'. if ( isset ( $ listing [ 'path' ] ) && is_array ( $ listing [ 'path' ] ) ) { $ listing [ 'path' ] = self :: prepare_breadcrumb ( $ listing [ 'path' ] ) ; } // Prepare the listing of objects. if ( isset ( $ listing [ 'list' ] ) && is_array ( $ listing [ 'list' ] ) ) { $ listing [ 'list' ] = self :: prepare_list ( $ listing [ 'list' ] ) ; } // Convert back to an object. if ( $ wasobject ) { $ listing = ( object ) $ listing ; } return $ listing ; }
docstring: Prepares list of files before passing it to AJAX, makes sure data is in the correct
  format and stores formatted values.
  
  @param array|stdClass $listing result of get_listing() or search() or file_get_drafarea_files()
  @return array
docstring_tokens: Prepares list of files before passing it to AJAX makes sure data is in the correct format and stores formatted values .