本文整理汇总了PHP中collection::import方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::import方法的具体用法?PHP collection::import怎么用?PHP collection::import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::import方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
static function import($data)
{
// cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
// $data['name'] Nom de la collection
// $data['coll_parent'] id de l'éditeur parent de la collection
// $data['issn'] numéro ISSN de la collection
// $data['statut'] statut de la collection
global $dbh;
// check sur le type de la variable passée en paramètre
if (!sizeof($data) || !is_array($data)) {
// si ce n'est pas un tableau ou un tableau vide, on retourne 0
return 0;
}
// check sur les éléments du tableau (data['name'] est requis).
$long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT sub_coll_name FROM sub_collections limit 1"), 0);
$data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
//si on a pas d'id, on peut avoir les infos de la collection
if (!$data['coll_parent']) {
if ($data['collection']) {
//on les a, on crée l'éditeur
$data['coll_parent'] = collection::import($data['collection']);
}
}
if ($data['name'] == "" || $data['coll_parent'] == 0) {
/* il nous faut impérativement une collection parente */
return 0;
}
// préparation de la requête
$key0 = addslashes($data['name']);
$key1 = $data['coll_parent'];
$key2 = addslashes($data['issn']);
/* vérification que la collection existe bien ! */
$query = "SELECT collection_id FROM collections WHERE collection_id='{$key1}' LIMIT 1 ";
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT colections " . $query);
}
if (pmb_mysql_num_rows($result) == 0) {
return 0;
}
/* vérification que la sous-collection existe */
$query = "SELECT sub_coll_id FROM sub_collections WHERE sub_coll_name='{$key0}' AND sub_coll_parent='{$key1}' LIMIT 1 ";
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT sub_collections " . $query);
}
$subcollection = pmb_mysql_fetch_object($result);
/* la sous-collection existe, on retourne l'ID */
if ($subcollection->sub_coll_id) {
return $subcollection->sub_coll_id;
}
// id non-récupérée, il faut créer la forme.
$query = 'INSERT INTO sub_collections SET sub_coll_name="' . $key0 . '", ';
$query .= 'sub_coll_parent="' . $key1 . '", ';
$query .= 'sub_coll_issn="' . $key2 . '", ';
$query .= 'subcollection_web="' . addslashes($data['subcollection_web']) . '", ';
$query .= 'subcollection_comment="' . addslashes($data['comment']) . '", ';
$query .= 'index_sub_coll=" ' . strip_empty_words($key0) . ' ' . strip_empty_words($key2) . ' " ';
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't INSERT into sub_collections" . $query);
}
$id = pmb_mysql_insert_id($dbh);
audit::insert_creation(AUDIT_SUB_COLLECTION, $id);
//update authority informations
$authority = new authority(0, $id, AUT_TABLE_SUB_COLLECTIONS);
$authority->set_num_statut($data['statut']);
$authority->update();
subcollection::update_index($id);
return $id;
}
示例2: insert_authority_infos
function insert_authority_infos($authority_number, $type, $id_origin_authority, $authority_infos = array())
{
global $opac_enrichment_bnf_sparql;
//on a un numéro d'autorité, on regarde si on l'a déjà rencontré
$num_authority = $authority_infos['id'];
$query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $id_origin_authority . "' and authority_type = '" . $type . "'";
$result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query);
if (pmb_mysql_num_rows($result)) {
$row = pmb_mysql_fetch_object($result);
$num_authority = $row->num_authority;
$num_authority_source = $row->id_authority_source;
// on cherche la préférence... dès fois que...
$query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1";
$result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query);
if (pmb_mysql_num_rows($result)) {
$row = pmb_mysql_fetch_object($result);
$num_authority = $row->num_authority;
$num_authority_source = $row->id_authority_source;
}
} else {
// on importe l'autorité dans la base si elle n'a pas d'id
if ($num_authority == 0) {
switch ($type) {
case "author":
$num_authority = auteur::import($authority_infos);
break;
case "uniform_title":
$num_authority = titre_uniforme::import($authority_infos);
break;
case "category":
$num_authority = category::import($authority_infos);
break;
case "collection":
$num_authority = collection::import($authority_infos);
break;
case "subcollection":
$num_authority = subcollection::import($authority_infos);
break;
case "serie":
break;
}
}
// on intègre la source de l'autorité
$query = "insert into authorities_sources set\n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $id_origin_authority . ",\n\t\t\timport_date = now()";
pmb_mysql_query($query) or die("can't insert authorities_sources :" . $query);
$num_authority_source = pmb_mysql_insert_id();
////////////////////////////////////////////////////////////////
if ($opac_enrichment_bnf_sparql && $type == 'author') {
auteur::author_enrichment($num_authority);
}
}
return $num_authority;
}
示例3: create_authority
public function create_authority()
{
switch ($this->notice->type) {
case "author":
$this->authority_id = auteur::import($this->notice->specifics_data);
break;
case "uniform_title":
$this->authority_id = titre_uniforme::import($this->notice->specifics_data);
break;
case "collection":
$this->authority_id = collection::import($this->notice->specifics_data);
if ($this->authority_id != 0 && $this->notice->specifics_data['subcollections']) {
for ($i = 0; $i < count($this->notice->specifics_data['subcollections']); $i++) {
$this->notice->specifics_data['subcollections'][$i]['coll_parent'] = $this->authority_id;
$subcoll_id = subcollection::check_if_exists($this->notice->specifics_data['subcollections'][$i]);
if ($subcoll_id != 0 && $this->notice->specifics_data['subcollections'][$i]['authority_number']) {
$query = "insert into authorities_sources set \n\t\t\t\t\t\t\t\t\tnum_authority = " . $subcoll_id . ",\n\t\t\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['subcollections'][$i]['authority_number'] . "',\t\n\t\t\t\t\t\t\t\t\tauthority_type = 'subcollection',\n\t\t\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\t\t\timport_date = now()";
mysql_query($query);
}
}
}
break;
case "subcollection":
$this->authority_id = subcollection::import($this->notice->specifics_data);
if ($this->authority_id != 0 && $this->notice->specifics_data['collection'] && $this->notice->specifics_data['collection']['authority_number']) {
$coll_id = collection::check_if_exists($this->notice->specifics_data['collection']);
$query = "insert into authorities_sources set \n\t\t\t\t\t\t\tnum_authority = " . $coll_id . ",\n\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['collection']['authority_number'] . "',\t\n\t\t\t\t\t\t\tauthority_type = 'collection',\n\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\timport_date = now()";
mysql_query($query);
}
break;
case "category":
$this->authority_id = category::import($this->notice->specifics_data, $this->id_thesaurus, $this->get_parent_category(), $this->notice->common_data['lang']);
break;
default:
// on fait rien...
break;
}
if ($this->authority_id) {
$query = "insert into authorities_sources set \n\t\t\t\tnum_authority = " . $this->authority_id . ",\n\t\t\t\tauthority_number = '" . $this->notice->common_data['authority_number'] . "',\t\n\t\t\t\tauthority_type = '" . $this->notice->type . "',\n\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\tauthority_favorite = 1,\n\t\t\t\timport_date = now(),\n\t\t\t\tupdate_date = now()";
mysql_query($query);
} else {
return false;
}
}
示例4: keep_authority_infos
function keep_authority_infos($authority_number, $type, $origin_authority, $notice_id, $authority_infos = array())
{
//on a un numéro d'autorité, on regarde si on l'a déjà rencontré
$query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $origin_authority . "' and authority_type = '" . $type . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$row = mysql_fetch_object($result);
$num_authority = $row->num_authority;
$num_authority_source = $row->id_authority_source;
// on cherche la préférence... dès fois que...
$query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$row = mysql_fetch_object($result);
$num_authority = $row->num_authority;
$num_authority_source = $row->id_authority_source;
}
} else {
// c'est un petit nouveau
switch ($type) {
case "author":
$num_authority = auteur::import($authority_infos);
break;
case "uniform_title":
$num_authority = titre_uniforme::import($authority_infos);
break;
case "category":
$num_authority = category::import($authority_infos);
break;
case "collection":
$num_authority = collection::import($authority_infos);
break;
case "subcollection":
$num_authority = subcollection::import($authority_infos);
break;
case "serie":
break;
}
$query = "insert into authorities_sources set \n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $origin_authority . ",\n\t\t\timport_date = now()";
mysql_query($query);
$num_authority_source = mysql_insert_id();
}
//certaines autorités sont créés avant la notice...
if ($notice_id != 0) {
$query = "insert into notices_authorities_sources set \n\t\tnum_authority_source = " . $num_authority_source . ",\n\t\tnum_notice = " . $notice_id;
mysql_query($query);
}
return $num_authority;
}
示例5: buildNotice
/**
* @param array $entry le tableau $entry généré par la fonction buildEntry()
*
* Fonction d'import d'une notice formaté par la fonction buildEntry()
* Ajoute les informations d'audit
* Ajoute les champs personnalisés
* Ajoute les tables annexes [responsability], [notices_categories] et [notices_langues]
* Met à jours l'indexation de la notice
*/
static function buildNotice(&$entry)
{
global $pmb_type_audit;
global $webdav_current_user_name, $webdav_current_user_id;
//la notice existe déjà ? si oui, on renvoi l'id trouvé
if ($entry['niveau_biblio'] . $entry['niveau_hierar'] == 'a2') {
$query = '
SELECT n1.* FROM notices AS n1
JOIN analysis ON n1.notice_id=analysis_notice
JOIN bulletins ON bulletin_id=analysis_bulletin
JOIN notices AS n2 ON n2.notice_id=bulletin_notice
WHERE n1.tit1="' . addslashes($entry['tit1']) . '"
AND n1.niveau_biblio="' . addslashes($entry['niveau_biblio']) . '"
AND n1.niveau_hierar="' . addslashes($entry['niveau_hierar']) . '"
AND bulletin_numero="' . addslashes($entry['bulletin']['bulletin_numero']) . '"
AND mention_date="' . addslashes($entry['bulletin']['mention_date']) . '"
AND date_date="' . addslashes($entry['bulletin']['date_date']) . '"
AND n2.tit1="' . addslashes($entry['periodique']['tit1']) . '"
AND n2.niveau_biblio="' . addslashes($entry['periodique']['niveau_biblio']) . '"
AND n2.niveau_hierar="' . addslashes($entry['periodique']['niveau_hierar']) . '"
';
$result = mysql_query($query);
} else {
$query = 'SELECT * FROM notices WHERE tit1="' . addslashes($entry['tit1']) . '" AND niveau_biblio="' . addslashes($entry['niveau_biblio']) . '" AND niveau_hierar="' . addslashes($entry['niveau_hierar']) . '"';
$result = mysql_query($query);
}
if (mysql_num_rows($result)) {
// La notice existe
$entry = array_merge(mysql_fetch_array($result, MYSQL_ASSOC), $entry);
//TODO : A vérifier
$first = true;
$query = 'UPDATE notices SET ';
foreach (array_keys($entry) as $fieldName) {
if (!is_array($entry[$fieldName]) && $entry[$fieldName] != '' && $fieldName != 'ancien_num_name') {
if (!$first) {
$query .= ',';
}
$query .= $fieldName . '="' . addslashes($entry[$fieldName]) . '"';
$first = false;
}
}
$query .= ' WHERE notice_id="' . addslashes($entry['notice_id']) . '"';
mysql_query($query) or die('echec de la requete : ' . $query . '<br/>' . mysql_error() . "\n");
} else {
//les éditeurs
if (sizeof($entry['publishers'])) {
foreach ($entry['publishers'] as $id => $publisher) {
if ($id < 2) {
if ($id === 0) {
$entry['ed1_id'] = \editeur::import($publisher);
} elseif ($id === 1) {
$entry['ed2_id'] = \editeur::import($publisher);
}
}
}
}
//la collection
if (sizeof($entry['collections']) && $entry['ed1_id']) {
$entry['collections']['parent'] = $entry['ed1_id'];
$entry['coll_id'] = \collection::import($entry['collections']);
}
$first = true;
$query = 'INSERT INTO notices SET ';
foreach ($entry as $fieldName => $value) {
if (!is_array($value) && $value != '') {
if (!$first) {
$query .= ',';
}
$query .= $fieldName . '="' . addslashes(trim($value)) . '"';
$first = false;
}
}
mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error());
$entry['notice_id'] = mysql_insert_id();
if ($pmb_type_audit && ($webdav_current_user_id || $webdav_current_user_name) && $entry['create_date']) {
//ajout des informations d'audit
$query = 'INSERT INTO audit (type_obj,object_id,user_id,user_name,type_modif,quand) VALUES (1,' . $entry['notice_id'] . ',' . $webdav_current_user_id . ',"' . addslashes($webdav_current_user_name) . '",1,"' . $entry['create_date'] . '")';
mysql_query($query) or die('Echec d\'execution de la requete ' . $query . ' : ' . mysql_error());
}
}
//les champs persos
if (sizeof($entry['cp'])) {
foreach ($entry['cp'] as $cp) {
\parametres_perso::import($entry['notice_id'], $cp['field'], $cp['value'], 'notices');
}
}
//ajout dans les tables annexes a la notice
if (sizeof($entry['annexes'])) {
foreach ($entry['annexes'] as $typeAnnexe => $annexes) {
foreach ($annexes as $id => $annexe) {
switch ($typeAnnexe) {
//.........这里部分代码省略.........