Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ApalinesMM.php
1 <?php
2 
3 /**
4  * This is the model class for table "gportal_apalines_mm".
5  *
6  * The followings are the available columns in table 'gportal_apalines_mm':
7  * @property integer $id
8  * @property string $title
9  * @property integer $ndate
10  * @property string $channel
11  * @property string $docid
12  * @property integer $related_maindoc_id
13  * @property string $place
14  * @property string $source
15  * @property string $filename
16  * @property string $author
17  * @property string $keywords
18  * @property string $xml_filename
19  * @property integer $deleted
20  * @property integer $created
21  * @property integer $updated
22  * @property integer $type
23  * @property string $apa_id
24  */
26 {
27  const IMAGE = 0;
28  const VIDEO = 1;
29 
30  /**
31  * Returns the static model of the specified AR class.
32  * @param string $className active record class name.
33  * @return ApalinesMM the static model class
34  */
35  public static function model($className=__CLASS__)
36  {
37  return parent::model($className);
38  }
39 
40  /**
41  * @return string the associated database table name
42  */
43  public function tableName()
44  {
45  return 'gportal_apalines_mm';
46  }
47 
48  /**
49  * @return array validation rules for model attributes.
50  */
51  public function rules()
52  {
53  // NOTE: you should only define rules for those attributes that
54  // will receive user inputs.
55  return array(
56  array('ndate, related_maindoc_id, deleted, created, updated, type', 'numerical', 'integerOnly'=>true),
57  array('title, channel, docid, place, source, author, xml_filename, apa_id', 'length', 'max'=>255),
58  array('filename', 'length', 'max'=>64),
59  array('keywords', 'safe'),
60  // The following rule is used by search().
61  // Please remove those attributes that should not be searched.
62  array('id, title, ndate, channel, docid, related_maindoc_id, place, source, filename, author, keywords, xml_filename, deleted, created, updated, type', 'safe', 'on'=>'search'),
63  );
64  }
65 
66  /**
67  * @return array relational rules.
68  */
69  public function relations()
70  {
71  // NOTE: you may need to adjust the relation name and the related
72  // class name for the relations automatically generated below.
73  return array(
74  'files'=>array(self::HAS_MANY, 'ApalinesFile', 'parent_id'),
75  );
76  }
77 
78  /**
79  * @return array customized attribute labels (name=>label)
80  */
81  public function attributeLabels()
82  {
83  return array(
84  'id' => 'ID',
85  'title' => 'Title',
86  'ndate' => 'Ndate',
87  'channel' => 'Channel',
88  'docid' => 'Docid',
89  'related_maindoc_id' => 'Related Maindoc',
90  'place' => 'Place',
91  'source' => 'Source',
92  'filename' => 'Filename',
93  'author' => 'Author',
94  'keywords' => 'Keywords',
95  'xml_filename' => 'Xml Filename',
96  'deleted' => 'Deleted',
97  'created' => 'Created',
98  'updated' => 'Updated',
99  'type' => 'Type',
100  'apa_id' => 'APA id'
101  );
102  }
103 
104  /**
105  * Retrieves a list of models based on the current search/filter conditions.
106  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
107  */
108  public function search()
109  {
110  // Warning: Please modify the following code to remove attributes that
111  // should not be searched.
112 
113  $criteria=new CDbCriteria;
114 
115  $criteria->compare('id',$this->id);
116  $criteria->compare('title',$this->title,true);
117  $criteria->compare('ndate',$this->ndate);
118  $criteria->compare('channel',$this->channel,true);
119  $criteria->compare('docid',$this->docid,true);
120  $criteria->compare('related_maindoc_id',$this->related_maindoc_id);
121  $criteria->compare('place',$this->place,true);
122  $criteria->compare('source',$this->source,true);
123  $criteria->compare('filename',$this->filename,true);
124  $criteria->compare('author',$this->author,true);
125  $criteria->compare('keywords',$this->keywords,true);
126  $criteria->compare('xml_filename',$this->xml_filename,true);
127  $criteria->compare('deleted',$this->deleted);
128  $criteria->compare('created',$this->created);
129  $criteria->compare('updated',$this->updated);
130  $criteria->compare('type',$this->type);
131  $criteria->compare('apa_id',$this->apa_id, true);
132 
133  return new CActiveDataProvider($this, array(
134  'criteria'=>$criteria,
135  ));
136  }
137  /**
138  * Function removes multimedia records and files
139  */
140  public function deleteFiles() {
141  if (isset($this->files)) {
142  foreach ($this->files as $file) {
143  $file->delete();
144  }
145  }
146  }
147  /**
148  * Function removes files before record is deleted
149  */
150  public function beforeDelete() {
151  $this->deleteFiles();
152  return parent::beforeDelete();
153  }
154 }