Source for file class.page.php
Documentation is available at class.page.php
* @package linea21.modules
* @author Simon Georget <simon@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
public $TDB_PAGE = T_PAGE; // nom de la table.
public function __call($method, $arguments)
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'page.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);
* Vérification intégrité des données
* @param array $array : contient les composants nécessaires d'une page
* si verifié, sinon string 'message d'erreur'
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'page.before_datacheck', array('data' => $array)), $array);
$array = $r->getReturnValue();
if (strlen($array[0]) < 3) return _t('page','no_title');
if (strlen($array[1]) < 3) return _t('page','no_header');
if (strlen($array[2]) < 3) return _t('page','no_body');
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.after_datacheck', array('data' => $array)));
* @param array $array : contient les composants d'une page
* @param object $sql_object
* @return integer $last_id
public function addPage($array, $sql_object)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'page.before_add', array('data' => $array)), $array);
$array = $r->getReturnValue();
$array= $sql_object->DBescape($array);
$q = "INSERT INTO " . $this->TDB_PAGE . " (page_title, page_header, page_body, page_posted_by, page_published_date, page_status, page_date_crea) " . "VALUES('" . $this->TITLE . "', '" . $this->HEADER . "', '" . $this->BODY . "', " . $this->POSTED_BY . ", '" . $this->PUBLISHED_DATE . "', '" . $this->STATUS . "', now());";
$last_id = $sql_object->DBInsert ($q, 1);
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.after_add', array('data' => $array, 'id' => $last_id)));
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'page.before_homepage_update', array('id' => $this->ID )), $array);
$array = $r->getReturnValue();
// we update only the current record without modifying others
$q = "UPDATE " . $this->TDB_PAGE . " SET page_homepage = 'N' WHERE page_id = '" . $this->ID . "' ";
$sql_object->DBQuery($q);
// first, we remove the current homepage
$q = "UPDATE " . $this->TDB_PAGE . " SET page_homepage = 'N'";
$r = $sql_object->DBQuery($q);
// and we set the new homepage with given ID
$q = "UPDATE " . $this->TDB_PAGE . " SET page_homepage = 'Y' WHERE page_id = '" . $this->ID . "' ";
$sql_object->DBQuery($q);
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.after_homepage_update', array('id' => $this->ID )));
* @param int $ID : identifiant de la page
* @param object $sql_object
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.delete', array('id' => $ID)));
$q = "UPDATE " . $this->TDB_PAGE . " set page_status='E', page_last_modify=NOW() WHERE page_id='" . $this->ID . "';";
$result = $sql_object->DBQuery($q);
* modification d'une page
* @param integer $ID : identifiant de la page
* @param object $sql_object
* @param array $array : contient les composants d'une page
* @return boolean $result
public function modifyPage($ID, $array, $sql_object)
// Filter data event + return value
$r = $this->dispatcher->filter(new sfEvent($this, 'page.before_modify', array('data' => $array, 'id' => $ID)), $array);
$array = $r->getReturnValue();
$array= $sql_object->DBescape($array);
$mask = $this->_HavePublishedDate($array[5]);
$q = "UPDATE " . $this->TDB_PAGE . " set page_title='" . $this->TITLE . "', page_header='" . $this->HEADER . "', page_body='" . $this->BODY . "' , page_posted_by=" . $this->POSTED_BY . ", page_status ='" . $this->STATUS . "', page_last_modify=NOW() " . $mask . " WHERE page_id='" . $this->ID . "';";
$result = $sql_object->DBQuery($q);
// we update the homepage
// Notify the end of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.after_modify', array('data' => $array, 'id' => $this->ID)));
* check if homepage exists
// Notify the beginning of the current method
$this->dispatcher->notify(new sfEvent($this, 'page.homepage_exists'));
$q = "SELECT * FROM " . $this->TDB_PAGE . " WHERE page_homepage = 'Y' AND page_status='P';";
$r = $sql_object->DBSelect($q);
* @return int $ID : identifiant de la page
$q = "SELECT * FROM " . $this->TDB_PAGE . " WHERE page_homepage = 'Y' AND page_status='P';";
$r = $sql_object->DBSelect($q);
if(isset ($r[0])) return $r[0]['page_id'];
* 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 = ", page_published_date= NOW()";
$sql_mask = ", page_published_date= '0001-01-01'";
|