DataAccess/mysql/Spotlight.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026 
00027 // }}}
00028 // {{{ class FF_DataAccess_Spotlight_mysql 
00029 
00040 // }}}
00041 class FF_DataAccess_Spotlight_mysql extends FF_DataAccess {
00042     // {{{ constructor
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     // {{{ update()
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     // {{{ add()
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     // {{{ getDataByPrimaryKey()
00094 
00104     function getDataByPrimaryKey($in_id, $in_fields = '*')
00105     {
00106         return parent::getDataByPrimaryKey($in_id, $this->_getSelectFields());
00107     }
00108 
00109     // }}}
00110     // {{{ getListData()
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     // {{{ getFrontpageId()
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     // {{{ getImageData()
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     // {{{ getNextId()
00165 
00172     function getNextId()
00173     {
00174         // change sequence name since we give it the full table name
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     // {{{ _updateFrontpage()
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     // {{{ _fixImageData()
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     // {{{ _getSelectFields()
00231 
00239     function _getSelectFields()
00240     {
00241         return 'id, title, text1, text2, text3, footer, frontpage, UNIX_TIMESTAMP(timestamp) AS timestamp';
00242     }
00243 
00244     // }}}
00245 }
00246 ?>

Generated on Fri Jun 23 11:38:18 2006 for FastFrame by  doxygen 1.4.4