/trunk/modules/0011-News/admin/include/Object/News.class.php
http://antilophpe.googlecode.com/ · PHP · 454 lines · 229 code · 17 blank · 208 comment · 0 complexity · 25e67f12f4a86e1cd2959500ddde6388 MD5 · raw file
- <?php
- /**
- * File News.class.php
- *
- * This file contains the definition of the class object
- * type News and at the end of the file,
- * a way to test the class (simply passing sending test = 1
- * via GET or POST ).
- * @author Marco Novo <mnovo@ncfsistemi.com>
- * @version 1.0
- */
- /**
- * This class defines fields and methods of News
- */
- class News {
- /**
- * $resourceLinkID
- * @access private
- * @var resource
- */
- private $resourceLinkID;
- /**
- * id
- * @access private
- * @var integer
- */
- private $id;
- /**
- * data
- * @access private
- * @var date
- */
- private $data;
- /**
- * primoPiano
- * @access private
- * @var integer
- */
- private $primoPiano;
- /**
- * titolo
- * @access private
- * @var string
- */
- private $titolo;
- /**
- * sottotitolo
- * @access private
- * @var string
- */
- private $sottotitolo;
- /**
- * testoBreve
- * @access private
- * @var string
- */
- private $testoBreve;
- /**
- * testo
- * @access private
- * @var string
- */
- private $testo;
- /**
- * autore
- * @access private
- * @var string
- */
- private $autore;
- /**
- * active
- * @access private
- * @var integer
- */
- private $active;
- /**
- * deleted
- * @access private
- * @var integer
- */
- private $deleted;
- /**
- * Set the value of resourceLinkID
- * @param resource $resourceLinkID
- */
- function setResourceLinkID($resourceLinkID){
- $this->resourceLinkID=$resourceLinkID;
- }
- /**
- * Get the value of resourceLinkID
- * @return resource
- */
- function getResourceLinkID(){
- return $this->resourceLinkID;
- }
- /**
- * Sets the value of field id
- * @param integer $id
- */
- function setId($id){
- $this->id=$id;
- }
- /**
- * Gets the value of field id
- * @return integer
- */
- function getId(){
- return $this->id;
- }
- /**
- * Sets the value of field data
- * @param date $data
- */
- function setData($data){
- $this->data=$data;
- }
- /**
- * Gets the value of field data
- * @return date
- */
- function getData(){
- return $this->data;
- }
- /**
- * Sets the value of field primoPiano
- * @param integer $primoPiano
- */
- function setPrimoPiano($primoPiano){
- $this->primoPiano=$primoPiano;
- }
- /**
- * Gets the value of field primoPiano
- * @return integer
- */
- function getPrimoPiano(){
- return $this->primoPiano;
- }
- /**
- * Sets the value of field titolo
- * @param string $titolo
- */
- function setTitolo($titolo){
- $this->titolo=$titolo;
- }
- /**
- * Gets the value of field titolo
- * @return string
- */
- function getTitolo(){
- return $this->titolo;
- }
- /**
- * Sets the value of field sottotitolo
- * @param string $sottotitolo
- */
- function setSottotitolo($sottotitolo){
- $this->sottotitolo=$sottotitolo;
- }
- /**
- * Gets the value of field sottotitolo
- * @return string
- */
- function getSottotitolo(){
- return $this->sottotitolo;
- }
- /**
- * Sets the value of field testoBreve
- * @param string $testoBreve
- */
- function setTestoBreve($testoBreve){
- $this->testoBreve=$testoBreve;
- }
- /**
- * Gets the value of field testoBreve
- * @return string
- */
- function getTestoBreve(){
- return $this->testoBreve;
- }
- /**
- * Sets the value of field testo
- * @param string $testo
- */
- function setTesto($testo){
- $this->testo=$testo;
- }
- /**
- * Gets the value of field testo
- * @return string
- */
- function getTesto(){
- return $this->testo;
- }
- /**
- * Sets the value of field autore
- * @param string $autore
- */
- function setAutore($autore){
- $this->autore=$autore;
- }
- /**
- * Gets the value of field autore
- * @return string
- */
- function getAutore(){
- return $this->autore;
- }
- /**
- * Sets the value of field active
- * @param integer $active
- */
- function setActive($active){
- $this->active=$active;
- }
- /**
- * Gets the value of field active
- * @return integer
- */
- function getActive(){
- return $this->active;
- }
- /**
- * Sets the value of field deleted
- * @param integer $deleted
- */
- function setDeleted($deleted){
- $this->deleted=$deleted;
- }
- /**
- * Gets the value of field deleted
- * @return integer
- */
- function getDeleted(){
- return $this->deleted;
- }
- /**
- * Constructor of the class
- */
- function __construct($resourceLinkID='',
- $id='',
- $data='',
- $primoPiano='',
- $titolo='',
- $sottotitolo='',
- $testoBreve='',
- $testo='',
- $autore='',
- $active='',
- $deleted='') {
- $this->resourceLinkID = $resourceLinkID;
- $this->id = $id;
- $this->data = $data;
- $this->primoPiano = $primoPiano;
- $this->titolo = $titolo;
- $this->sottotitolo = $sottotitolo;
- $this->testoBreve = $testoBreve;
- $this->testo = $testo;
- $this->autore = $autore;
- $this->active = $active;
- $this->deleted = $deleted;
- }
- /**
- * Destructor of the class
- */
- function __destruct() {
- }
- /**
- * Get the value of descriptive field
- * @return string
- */
- function getDescriptiveFields(){
- return trim($this->getData().' '.$this->getTitolo().' '.' (id: '.$this->getId().')');
- }
- /**
- * Get the name and the value of mail fields
- * @return string
- */
- function getMailFields(){
- return trim("Id: ".$this->getId()."\n"."Data: ".$this->getData()."\n"."Primo piano: ".$this->getPrimoPiano()."\n"."Titolo: ".$this->getTitolo()."\n"."Sottotitolo: ".$this->getSottotitolo()."\n"."Testo breve: ".$this->getTestoBreve()."\n"."Testo: ".$this->getTesto()."\n"."Autore: ".$this->getAutore()."\n"."Active: ".$this->getActive()."\n"."Deleted: ".$this->getDeleted()."\n"."");
- }
- /**
- * Persistence selectById method (try to select)
- * @return true|false
- */
- function selectById(){
- $query="SELECT ant_News.*
- FROM ant_News
- WHERE ant_News.id = '".$this->getId()."'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- while($news_array=mysql_fetch_assoc($result)){
- $this->id = $news_array['id'];
- $this->data = $news_array['data'];
- $this->primoPiano = $news_array['primoPiano'];
- $this->titolo = $news_array['titolo'];
- $this->sottotitolo = $news_array['sottotitolo'];
- $this->testoBreve = $news_array['testoBreve'];
- $this->testo = $news_array['testo'];
- $this->autore = $news_array['autore'];
- $this->active = $news_array['active'];
- $this->deleted = $news_array['deleted'];
- }
- }
- /**
- * Persistence listSelectablesByAndFields method (try to select)
- * @param array with filedName as key and fieldValue as value
- * @return list/array
- */
- function listSelectablesByAndFields($fieldsArray){
- foreach($fieldsArray as $key => $value)
- $whereString.=" AND $key = '".str_replace("'","''",$value)."'";
- $query="SELECT ant_News.*
- FROM ant_News
- WHERE ant_News.active=1
- AND ant_News.deleted=0
- ".$whereString."
- ORDER BY data DESC;";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $listRow=array();
- while($arrayRow=mysql_fetch_assoc($result)){
- array_push($listRow,$arrayRow);
- }
- return $listRow;
- }
- /**
- * Persistence listSelectablesByOrFields method (try to select)
- * @param array with filedName as key and fieldValue as value
- * @return list/array
- */
- function listSelectablesByOrFields($fieldsArray){
- foreach($fieldsArray as $key => $value)
- $whereString.=" OR $key = '".str_replace("'","''",$value)."'";
- $query="SELECT ant_News.*
- FROM ant_News
- WHERE ant_News.active=1
- AND ant_News.deleted=0
- AND (0 ".$whereString.")
- ORDER BY data DESC;";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $listRow=array();
- while($arrayRow=mysql_fetch_assoc($result)){
- array_push($listRow,$arrayRow);
- }
- return $listRow;
- }
- /**
- * Persistence selectFiles method (try to select)
- * @return array
- */
- function selectFiles(){
- $query="SELECT ant_News_File.*
- FROM ant_News_File
- WHERE ant_News_File.idTableObject= '".$this->getId()."'
- AND ant_News_File.tableObject='ant_News'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News_File`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $filesList=array();
- while($news_File_array=mysql_fetch_assoc($result)){
- array_push($filesList, $news_File_array);
- }
- return $filesList;
- }
- /**
- * Persistence selectCopertina method (try to select)
- * @return array
- * ADDED
- */
- function selectCopertina(){
- $query="SELECT ant_News_File.*
- FROM ant_News_File
- WHERE ant_News_File.idTableObject= '".$this->getId()."'
- AND ant_News_File.tableObject='ant_News'
- AND ant_News_File.type = 'copertina'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News_File`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- return mysql_fetch_assoc($result);
- }
- /**
- * Persistence selectFileById method (try to select)
- * @return array
- */
- function selectFileById($fileId){
- $query="SELECT ant_News_File.*
- FROM ant_News_File
- WHERE ant_News_File.id='$fileId'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection file in table `ant_News_File`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $news_File_array=mysql_fetch_assoc($result);
- return $news_File_array;
- }
- /**
- * Persistence selectCountFiles method (try to select)
- * @return array
- */
- function selectCountFiles(){
- $query="SELECT COUNT(*)
- FROM ant_News_File
- WHERE ant_News_File.idTableObject= '".$this->getId()."'
- AND ant_News_File.tableObject='ant_News'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News_File`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $news_File_array=mysql_fetch_array($result);
- return $news_File_array[0];
- }
- /**
- * Persistence selectCountLogs method (try to select count)
- * @return integer
- */
- function selectCountLogs(){
- $query="SELECT COUNT(*)
- FROM ant_News_Log";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during select count from table `ant_News_Log`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $news_Log_array=mysql_fetch_array($result);
- return $news_Log_array[0];
- }
- /**
- * Persistence selectCountTrashes method (try to select count)
- * @return integer
- */
- function selectCountTrashes(){
- $query="SELECT COUNT(*)
- FROM ant_News
- WHERE deleted = 1";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during select count from table `ant_News`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- $news_array=mysql_fetch_array($result);
- return $news_array[0];
- }
- /**
- * Persistence selectByFileId method (try to select)
- * @return true|false
- */
- function selectByFileId($idFile){
- $query="SELECT ant_News_File.*
- FROM ant_News_File
- WHERE ant_News_File.id = '$idFile'";
- $result = mysql_query($query, $this->getResourceLinkId()) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_News_File`: '.mysql_errno($this->getResourceLinkId()).' - '.mysql_error($this->getResourceLinkId()));
- return mysql_fetch_array($result);
- }
- }
- ?>