Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
  protected function addSortQuery($query)
2
  {
3
    if (array(null, null) == ($sort = $this->getSort()))
4
    {
5
      return;
6
    }
7
 
8
    if (!in_array(strtolower($sort[1]), array('asc', 'desc')))
9
    {
10
      $sort[1] = 'asc';
11
    }
12
 
13
    $query->addOrderBy($sort[0] . ' ' . $sort[1]);
14
  }
15
 
16
  protected function getSort()
17
  {
18
    if (null !== $sort = $this->getUser()->getAttribute('<?php echo $this->getModuleName() ?>.sort', null, 'admin_module'))
19
    {
20
      return $sort;
21
    }
22
 
23
    $this->setSort($this->configuration->getDefaultSort());
24
 
25
    return $this->getUser()->getAttribute('<?php echo $this->getModuleName() ?>.sort', null, 'admin_module');
26
  }
27
 
28
  protected function setSort(array $sort)
29
  {
30
    if (null !== $sort[0] && null === $sort[1])
31
    {
32
      $sort[1] = 'asc';
33
    }
34
 
35
    $this->getUser()->setAttribute('<?php echo $this->getModuleName() ?>.sort', $sort, 'admin_module');
36
  }
37
 
38
  protected function isValidSortColumn($column)
39
  {
40
    return Doctrine_Core::getTable('<?php echo $this->getModelClass() ?>')->hasColumn($column);
41
  }