Pulling objects out of an array of objects based on a value name within the Document_Library

Permalink
Description of the Document_Library View page:
What's happening: The view page "Edit" prop link _Posts the ($fv) File Version to properties.php which generates the overlay. The FileAttributeKey::getUserAddedList() pulls the attribute values for that $fv into an array ($attribs) of objects - itself an array of property values. (note: I can't find the actual FileAttributeKey methods as the API says it's in the "models/file_attributes.php" but that file does not exist.) Nevertheless, this is all good.

What I'd like to do: I would like to sort the $attribs array of objects based on the akHandle value (which I have named in a way so that I could use a string call to separate them) before sending the $attribs array to the foreach { printFileAttributeRow($attribs, $fv);} which prints out the section within the properties.php. This would enable me to create two sections within this overlay with specific properties under each section.

Question (if this seems doable): How would you pull the appropriate objects out of the $fv array based on the akHandle value? Say you had three items with names q02Level, q03Level and b02Level, b03Level for akHandle names. How would you grab just the handles with "q" in their name - leaving the "02, 03" as a means for the iterator to "sort" their position?

Any help would be greatly appreciated!

Rick

Ricalsin
 
Ricalsin replied on at Permalink Reply
Ricalsin
Okay, I went the way of database queries to do this, but I ran into a GetOne / GetAll bind. It has to do with the Pear function querying the database. The GetOne finds the first occurrence and stops. The GetAll does not accept booleans in the call. Inside the FileAttributekey class I created this function:
public static function getAttributeBreakdown($akHandle) {
      $db = Loader::db();
      $akID = $db->GetAll('select akID from AttributeKeys WHERE akHandle LIKE ?',$akHandle);
      if ($akID > 0) {
         $ak = FileAttributeKey::getByID($akID);
         return $ak;
      } else {
         echo "None found!";
      }   
   }

Then passing the wildcard search function of 'q%' inside $akHandle. Works with GetOne, not with GetAll. I've tried "execute", "query". Surely, there's an easy fix, right? It's got to be something simple.

Rick