Source for file class.resources.php
Documentation is available at class.resources.php
* @package linea21.modules
* @see workshop, publication
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
var $M_UPLOAD_MAX_MO = 1024000; // taille maximale d'upload des fichiers en octets
var $M_URI_INPUT = "multimedia/input/"; // dossier racine de stockage des elements multimedias
var $M_URI_OUTPUT = "multimedia/output/"; // dossier racine de diffusion des elements multimedias
public function __call($method, $arguments)
$event = $this->dispatcher->notifyUntil(new sfEvent($this, 'resources.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();
* resources::CheckDataIntegrity()
* vérifie l'integrité d'un ressource avant Insertion
* @param array $table : contient les composants d'une ressource
* @param string $type : 'LINK', 'BIBLIO', 'MULTI'
* si verifié, sinon string 'message d'erreur'
if (strlen($table[0]) < 2) return _t('resources','no_url');
if (strlen($table[0]) < 3) return _t('resources','biblio_no_author');
if (strlen($table[1]) < 3) return _t('resources','biblio_no_title');
if (strlen($table[0]) < 3) return _t('resources','multi_no_name');
if (strlen($table[1]) < 5) return _t('resources','multi_no_description');
if (strlen($table[2]) < 2) return _t('resources','no_url');
* resources::CheckOnlineFile()
* vérifie l'existence d'un fichier en ligne
$file_pt = @fopen($path, 'r');
if (!$file_pt) return false;
* resources::IsValidProtocol()
* vérifie si une url donnée a un protocole reconnu par un client web standard
* @param array $url : chemin absolu
if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://' && substr($url, 0, 6) != 'ftp://' && substr($url, 0, 7) != 'ftps://') return false;
* détermine les tables de la bdd en action
* @param string $type : type de la ressource Workshop ou publication
* @param string $resources : type de la ressource
function _wichType($type, $resources)
* resources::AddBiblioRes()
* Ajout d'une nouvelle ressource bibliographique
* @param array $res_table tableau contenant les infos resources
* @param int $ID identifiant du père (rattachement)
* @param string $type 'PUBLICATION' ou 'WORKSHOP'
* @param object $sql_object
* @return integer $last_id
$res_table= $sql_object->DBescape($res_table);
if ($this->_wichType($type, 'BIBLIO') == "error") exit();
$requete = "INSERT INTO " . $this->ACTIVE_TABLE . " (bibliores_author, bibliores_title, bibliores_sub_title, bibliores_editor, bibliores_date, bibliores_range, bibliores_date_crea, bibliores_validity) " . "VALUES('" . $this->B_AUTHOR . "', '" . $this->B_TITLE . "', '" . $this->B_SUBTITLE . "', '" . $this->B_EDITOR . "', '" . $this->B_DATE . "', " . $this->B_RANGE . ", NOW(), '" . $this->B_VALIDITY . "');";
$last_id = $sql_object->DBInsert ($requete, 1);
$requete = "INSERT INTO " . $this->TDB_LIAISON . " VALUES(" . $ID . "," . $last_id . ", '" . $this->ACTIVE_TYPE . "');";
$result = $sql_object->DBInsert ($requete);
* resources::ModifyBiblioRes()
* modification d'une ressource bibliographique
* @param int $ID identifiant de la ressource
* @param object $sql_object
* @param array $res_table tableau contenant les infos resources
$res_table= $sql_object->DBescape($res_table);
$requete = "UPDATE " . $this->TDB_BIBLIO . " SET bibliores_author='" . $this->B_AUTHOR . "' , bibliores_title='" . $this->B_TITLE . "', bibliores_sub_title='" . $this->B_SUBTITLE . "', bibliores_editor='" . $this->B_EDITOR . "', bibliores_date='" . $this->B_DATE . "' WHERE bibliores_id='" . $this->B_ID . "';";
$result = $sql_object->DBQuery($requete);
* resources::DeleteBiblioRes()
* suppression d'une ressource bibliographique
* @param int $ID identifiant de la ressource a supprimer
* @param object $sql_object
$requete = "UPDATE " . $this->TDB_BIBLIO . " SET bibliores_validity='N' WHERE bibliores_id=" . $this->B_ID . ";";
$result = $sql_object->DBQuery($requete);
* resources::AddLinkRes()
* Ajout d'une ressource de type lien
* @param int $ID identifiant du père (rattachement)
* @param array $res_table tableau contenant les infos ressources
* @param string $type 'PUBLICATION' ou 'WORKSHOP'
* @param object $sql_object
* @return integer $last_id
function AddLinkRes($ID, $res_table, $type, $sql_object)
$res_table= $sql_object->DBescape($res_table);
$notvalidlink = _t('resources','invalid_link');
if ($this->_wichType($type, 'LINK') == "error") exit;
if ($res_table[1] == '') {
$requete = "INSERT INTO " . $this->ACTIVE_TABLE . " (linkres_text, linkres_mask, linkres_range, linkres_date_crea, linkres_validity) VALUES('" . $this->L_TEXT . "', '" . $this->L_MASK . "', " . $this->L_RANGE . ", NOW(), '" . $this->L_VALIDITY . "');";
$last_id = $sql_object->DBInsert ($requete, 1);
$requete = "INSERT INTO " . $this->TDB_LIAISON . " VALUES(" . $ID . "," . $last_id . ", '" . $this->ACTIVE_TYPE . "');";
$result = $sql_object->DBInsert ($requete);
* resources::ModifyLinkRes()
* modification d'une ressource de type lien
* @param int $ID identifiant de la ressource
* @param array $res_table tableau contenant les infos ressources
* @param object $sql_object
$res_table= $sql_object->DBescape($res_table);
if ($res_table[1] == '') {
$requete = "UPDATE " . $this->TDB_LINK . " SET linkres_text='" . $this->L_TEXT . "' , linkres_mask='" . $this->L_MASK . "' WHERE linkres_id='" . $this->L_ID . "';";
$result = $sql_object->DBQuery($requete);
* resources::DeleteLinkRes()
* suppression d'une ressource de type lien
* @param int $ID identifiant de la ressource a supprimer
* @param object $sql_object
$requete = "UPDATE " . $this->TDB_LINK . " SET linkres_validity='N' WHERE linkres_id=" . $this->B_ID . ";";
$result = $sql_object->DBQuery($requete);
* resources::AddMultiRes()
* Ajout d'une ressource de type multimedia
* @param int $ID identifiant du père (rattachement)
* @param array $res_table tableau contenant les infos ressources
* @param string $type 'PUBLICATION' ou 'WORKSHOP'
* @param object $sql_object
* @return integer $last_id
function AddMultiRes($ID, $res_table, $type, $sql_object)
$res_table= $sql_object->DBescape($res_table);
if ($this->_wichType($type, 'MULTI') == "error") exit;
$requete = "INSERT INTO " . $this->ACTIVE_TABLE . " (multires_name, multires_description, multires_media_uri, multires_range, multires_date_crea, multires_validity) VALUES('" . $this->M_NAME . "', '" . $this->M_DESC . "', '" . $this->M_URI . "', " . $this->M_RANGE . ", NOW(), '" . $this->M_VALIDITY . "');";
$last_id = $sql_object->DBInsert ($requete, 1);
$requete = "INSERT INTO " . $this->TDB_LIAISON . " VALUES(" . $ID . "," . $last_id . ", '" . $this->ACTIVE_TYPE . "');";
$result = $sql_object->DBInsert ($requete);
* resources::ModifyMultiRes()
* modification d'une ressource de type multimedia
* @param int $ID identifiant de la ressource
* @param array $res_table tableau contenant les infos ressources
* @param object $sql_object
$res_table= $sql_object->DBescape($res_table);
$requete = "UPDATE " . $this->TDB_MULTI . " SET multires_name='" . $this->M_NAME . "' , multires_description='" . $this->M_DESC . "' , multires_media_uri='" . $this->M_URI . "' WHERE multires_id='" . $this->M_ID . "';";
$result = $sql_object->DBQuery($requete);
* resources::changeRanges()
* changes Resources range
* @param array : Id (key) and ranges (value)
* @param object $sql_object
foreach ($array as $key => $value) {
$query = "UPDATE " . $table . " set ". $element. "res_range ='". $value. "' WHERE ". $element. "res_id ='" . $key . "';";
$result = $sql_object->DBQuery($query);
* resources::DeleteMultiRes()
* suppression d'une ressource multimedia
* @param int $ID identifiant de la ressource a supprimer
* @param object $sql_object
$requete = "UPDATE " . $this->TDB_MULTI . " SET multires_validity='N' WHERE multires_id=" . $this->M_ID . ";";
$result = $sql_object->DBQuery($requete);
|