/
Gallery.php
76 lines (69 loc) · 1.93 KB
/
Gallery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* RokGallery_Model_Gallery
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package RokGallery
* @subpackage models
* @author RocketTheme LLC <support@rockettheme.com>
* @version SVN: $Id: Gallery.php 39322 2011-07-02 05:20:22Z btowles $
*/
class RokGallery_Model_Gallery extends RokGallery_Model_Base_Gallery
{
public function postDelete(Doctrine_Event $event)
{
//Make sure all linked tables are clean
$q = Doctrine_Query::create()
->update('RokGallery_Model_Slice')
->set('gallery_id', 'NULL')
->andWhere('gallery_id NOT IN (SELECT g.id from RokGallery_Model_Gallery g)');
$q->execute();
$q->free();
}
public function preUpdate(Doctrine_Event $event)
{
// set background color to transparent
if (empty($this->thumb_background)) {
$this->thumb_background = 'transparent';
}
}
public function preInsert(Doctrine_Event $event)
{
// set background color to transparent
if (empty($this->thumb_background)) {
$this->thumb_background = 'transparent';
}
}
/**
* Check to see if a gallery is for a particular filetag
* @param $tag
* @return bool
*/
public function hasTag($tag)
{
foreach($this->filetags as $filetag)
{
if ($tag == $filetag) {
return true;
}
}
return false;
}
public function setSliceOrder(array $slice_order)
{
$this->Slices->setKeyColumn('id');
foreach ($slice_order as $position => $slice_id)
{
foreach($this->Slices as &$slice) {
{
if ($slice->id == $slice_id) {
$slice->ordering = $position;
$slice->save();
break;
}
}
}
}
}
}