Source for file class.news.php
Documentation is available at class.news.php
* @package linea21.modules
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
public $TDB_NEWS = T_NEWS; // nom de la table.
public function __call($method, $arguments)
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'news.extensible_function', array(
'arguments' => $arguments
if (!$event->isProcessed())
throw new Exception(sprintf('Call to undefined method %s::%s.', get_class($this), $method));
return $event->getReturnValue();
* @param int $m chiffre des mois
* @param int $d chiffre des jours
* @param int $y chiffre des années
* @return string $format_date
private function _getDate($m = 0, $d = 0, $y = 0)
$format_date = strftime('%Y-%m-%d %H:%M:%S', $format_date);
* news::CheckDataIntegrity()
* Vérification intégrité des données
* @param array $table : contient les composants Nécessaires d'une news
* si verifié, sinon string 'message d'erreur'
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'news.before_datacheck', array('data' => $table)), $table);
$table = $r->getReturnValue();
if (strlen($table[0]) < 3) return _t('news','no_title');
if (strlen($table[1]) < 3) return _t('news','no_header');
if (strlen($table[2]) < 3) return _t('news','no_body');
if ($table[3] <= 0 || !is_numeric($table[3])) return _t('news','no_theme');
if ($table[4] <= 0 || !is_numeric($table[4])) return _t('news','no_scale');
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'news.after_datacheck', array('data' => $table)));
* @param array $a : contient les composants d'une news
* @param object $sql_object
* @return integer $last_id
public function AddNews($a, $sql_object)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'news.before_add', array('data' => $a)), $a);
$a = $r->getReturnValue();
$a= $sql_object->DBescape($a);
$q = "INSERT INTO " . $this->TDB_NEWS . " (news_title, news_header, news_body, news_theme, news_scale, " . "news_level, news_range, news_posted_by, news_published_date, " . "news_perempt_date, news_is_national, news_statut, news_date_crea) " . "VALUES('" . $this->TITLE . "', '" . $this->HEADER . "', '" . $this->BODY . "', " . $this->THEME . ", " . $this->SCALE . ", " . $this->LEVEL . ", " . $this->RANGE . ", " . $this->POSTED_BY . ", '" . $this->PUBLISHED_DATE . "' , '" . $this->PEREMPT_DATE . "', '" . $this->IS_NATIONAL . "', '" . $this->STATUT . "', now());";
$last_id = $sql_object->DBInsert ($q, 1);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'news.after_add', array('data' => $a, 'id' => $last_id)));
* @param int $ID : identifiant de la news
* @param object $sql_object
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'news.delete', array('id' => $ID)));
$q = "UPDATE " . $this->TDB_NEWS . " set news_statut='E', news_last_modify=NOW() WHERE news_id='" . $this->ID . "';";
$result = $sql_object->DBQuery($q);
* modification d'une news
* @param integer $ID : identifiant de la news
* @param object $sql_object
* @param array $a : contient les composants d'une news
* @return boolean $result
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'news.before_modify', array('data' => $a, 'id' => $ID)), $a);
$a = $r->getReturnValue();
$a= $sql_object->DBescape($a);
$mask = $this->_HavePublishedDate($a[7]);
$q = "UPDATE " . $this->TDB_NEWS . " set news_title='" . $this->TITLE . "', news_header='" . $this->HEADER . "', news_body='" . $this->BODY . "' , news_theme='" . $this->THEME . "', news_scale='" . $this->SCALE . "', news_level='" . $this->LEVEL . "', news_statut='" . $this->STATUT . "', news_last_modify=NOW() " . $mask . " WHERE news_id='" . $this->ID . "';";
$result = $sql_object->DBQuery($q);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'news.after_modify', array('data' => $a, 'id' => $this->ID)));
* @param array : Id (key) and ranges (value)
* @param object $sql_object
foreach ($array as $key => $value) {
$query = "UPDATE " . $this->TDB_NEWS . " set news_range='". $value. "' WHERE news_id='" . $key . "';";
$result = $sql_object->DBQuery($query);
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'news.change_ranges', array('data' => $array)));
* news::_HavePublishedDate()
* Détermine la date de publication a inserer dans la bdd
* @param string $current_status : statut actuel de l'actualité
* @return string $sql_mask
private function _HavePublishedDate($current_status)
if ($current_status == 'D') $sql_mask = ", news_published_date= NOW()";
$sql_mask = ", news_published_date= '0001-01-01'";
|