/** 
  * Loads sorted heads
  *
  * @param GitPHP_HeadList $headList head list
  * @param string $order list order
  * @param integer $count number to load
  * @param integer $skip number to skip
  */
 public function LoadOrdered($headList, $order, $count = 0, $skip = 0)
 {
     if (!$headList) {
         return;
     }
     if (empty($order)) {
         return;
     }
     if (GitPHP_DebugLog::GetInstance()->GetEnabled()) {
         $autotimer = new GitPHP_DebugAutoLog();
     }
     $heads = $headList->GetHeads();
     /* TODO add different orders */
     if ($order == '-committerdate') {
         @usort($heads, array('GitPHP_Head', 'CompareAge'));
     }
     if ($count > 0 && count($heads) > $count || $skip > 0) {
         if ($count > 0) {
             $heads = array_slice($heads, $skip, $count);
         } else {
             $heads = array_slice($heads, $skip);
         }
     }
     return $heads;
 }
Example #2
0
 /**
  * Sets the head list
  *
  * @param GitPHP_HeadList $headList head list
  */
 public function SetHeadList($headList)
 {
     if ($headList && $headList->GetProject() !== $this) {
         throw new Exception('Invalid headlist for this project');
     }
     $this->headList = $headList;
 }