00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026
00027
00028
00029
00040
00041 class FF_DataAccess_Spotlight_mysql extends FF_DataAccess {
00042
00043
00050 function FF_DataAccess_Spotlight_mysql()
00051 {
00052 FF_DataAccess::FF_DataAccess();
00053 $this->table = $this->o_registry->getConfigParam('data/spotlights_table');
00054 }
00055
00056
00057
00058
00067 function update($in_data)
00068 {
00069 $this->_fixImageData($in_data, true);
00070 $this->_updateFrontpage($in_data['frontpage']);
00071 return parent::update($in_data);
00072 }
00073
00074
00075
00076
00085 function add($in_data)
00086 {
00087 $this->_fixImageData($in_data, true);
00088 $this->_updateFrontpage($in_data['frontpage']);
00089 return parent::add($in_data);
00090 }
00091
00092
00093
00094
00104 function getDataByPrimaryKey($in_id, $in_fields = '*')
00105 {
00106 return parent::getDataByPrimaryKey($in_id, $this->_getSelectFields());
00107 }
00108
00109
00110
00111
00123 function getListData($in_where, $in_orderByField, $in_orderByDir, $in_fields = '*')
00124 {
00125 return parent::getListData($in_where, $in_orderByField, $in_orderByDir, $this->_getSelectFields());
00126 }
00127
00128
00129
00130
00137 function getFrontpageId()
00138 {
00139 $s_query = "SELECT id FROM $this->table WHERE frontpage = 1 LIMIT 1";
00140 return $this->o_data->getOne($s_query);
00141 }
00142
00143
00144
00145
00155 function getImageData($in_id, $in_num)
00156 {
00157 $tmp = 'image' . $in_num;
00158 $tmp2 = 'mime_type' . $in_num;
00159 return $this->o_data->getRow("SELECT $tmp, $tmp2 FROM $this->table WHERE id = ? LIMIT 1",
00160 array($in_id), DB_FETCHMODE_ORDERED);
00161 }
00162
00163
00164
00165
00172 function getNextId()
00173 {
00174
00175 $this->o_data->setOption('seqname_format', '%s');
00176 return $this->o_data->nextId($this->o_registry->getConfigParam('data/sequence_table'));
00177 }
00178
00179
00180
00181
00193 function _updateFrontpage($in_frontpage)
00194 {
00195 if ($in_frontpage) {
00196 $this->o_data->autoExecute($this->table, array('frontpage' => false), DB_AUTOQUERY_UPDATE);
00197 }
00198 }
00199
00200
00201
00202
00214 function _fixImageData(&$in_data, $in_isUpdate)
00215 {
00216 for ($i = 1; $i <= 3; $i++) {
00217 $s_imageField = 'image' . $i;
00218 $s_mimeField = 'mime_type' . $i;
00219 if (is_null($in_data[$s_imageField])) {
00220 unset($in_data[$s_imageField]);
00221 }
00222
00223 if (is_null($in_data[$s_mimeField])) {
00224 unset($in_data[$s_mimeField]);
00225 }
00226 }
00227 }
00228
00229
00230
00231
00239 function _getSelectFields()
00240 {
00241 return 'id, title, text1, text2, text3, footer, frontpage, UNIX_TIMESTAMP(timestamp) AS timestamp';
00242 }
00243
00244
00245 }
00246 ?>