function actionDefault()
 {
     // Get the weblog items
     $items = $this->weblog->getItems();
     // Convert to a nested array
     $items = YDArrayUtil::convertToNested($items, 'yearmonth');
     // Add them to the template
     $this->tpl->assign('items', $items);
     // Display the template
     $this->display();
 }
 function actionDefault()
 {
     // Get the weblog items
     $items = $this->weblog->getPublicItems();
     // Convert to a nested array
     $items = YDArrayUtil::convertToNested($items, 'yearmonth');
     // Assign the variables to the template
     $this->tpl->assign('items', $items);
     $this->tpl->assign('title', t('archives'));
     // Display the template
     $this->display();
 }
 function actionDefault()
 {
     // Convert to nested
     $array = array(array('id' => 1, 'name' => 'Pieter', 'group' => 'admin'), array('id' => 2, 'name' => 'Fiona', 'group' => 'admin'), array('id' => 3, 'name' => 'Bert', 'group' => 'user'), array('id' => 3, 'name' => 'Jan', 'group' => 'guest'));
     YDDebugUtil::dump($array, 'Original array');
     // Convert to nested array
     YDDebugUtil::dump(YDArrayUtil::convertToNested($array, 'group'), 'YDArrayUtil::convertToNested( $array, \'group\' )');
     // The original array
     $array = array(1, 2, 3, 4, 5, 6, 7);
     YDDebugUtil::dump($array, 'Original array');
     // Convert to a three column table
     YDDebugUtil::dump(YDArrayUtil::convertToTable($array, 3), 'YDArrayUtil::convertToTable( $array, 3 )');
     // Convert to a three column table
     YDDebugUtil::dump(YDArrayUtil::convertToTable($array, 3, true), 'YDArrayUtil::convertToTable( $array, 3, true )');
     // Convert to a three column table
     YDDebugUtil::dump(YDArrayUtil::convertToTable($array, 2), 'YDArrayUtil::convertToTable( $array, 2 )');
     // Convert to a three column table
     YDDebugUtil::dump(YDArrayUtil::convertToTable($array, 2, true), 'YDArrayUtil::convertToTable( $array, 2, true )');
     // Test for errors
     YDDebugUtil::dump(YDArrayUtil::convertToTable($array, 'a', true), 'YDArrayUtil::convertToTable( $array, "a", true )');
 }
 /**
  *  This method returns all elements
  *
  *  @param $category_id  (optional) Category to search.
  *  @param $use_cache    (optional) Use result cache. True by default.
  *
  *  @returns    Elements as array
  */
 function getElements($category_id = null, $use_cache = true)
 {
     // if we want to use cache, we must get topics from cache instead of querying db again
     if ($use_cache) {
         // get all forums and convert to an associative array using category_id as key
         if (is_null($this->_elements)) {
             $this->_elements = YDArrayUtil::convertToNested($this->getElements(null, false), 'forum_category_id');
         }
         // check if category exists
         if (isset($this->_elements[intval($category_id)])) {
             return $this->_elements[$category_id];
         } else {
             return array();
         }
     }
     // reset previous values
     $this->reset();
     // check if category_id is an array
     if (is_array($category_id) && isset($category_id['category_id']) && is_numeric($category_id['category_id'])) {
         $category_id = intval($category_id['category_id']);
     }
     // check if we want a specific category
     if (is_numeric($category_id)) {
         $this->set('forum_category_id', intval($category_id));
         $this->order($this->getTable() . '.forum_position ASC');
     }
     // get elements
     $this->findAll();
     // return results
     return $this->getResults();
 }
 function initImageMetaData()
 {
     // Get the image metadata if not there yet
     if (is_null($this->imagemetadata)) {
         $this->imagemetadata = $this->db->getRecords('SELECT * FROM #_imagemetadata');
         $this->imagemetadata = YDArrayUtil::convertToNested($this->imagemetadata, 'img_path');
         foreach ($this->imagemetadata as $key => $val) {
             $this->imagemetadata[$key] = $val[0];
         }
     }
 }