• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilBibItem.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once ("classes/class.ilMetaData.php");
00025 
00036 class ilBibItem
00037 {
00038         var $nested_obj;
00039         var $content_obj;
00040         var $xml;
00041 
00042         var $bibliography_attr;
00043         var $abstract;
00044 
00045         var $id = 0;
00046         var $type = "bib";
00047         
00048         var $meta;
00049 
00050         var $language;
00051 
00056         function ilBibItem($content_obj = 0)
00057         {
00058                 global $ilias;
00059 
00060                 $this->ilias =& $ilias;
00061 
00062                 $this->import_id = array();
00063                 $this->title = "";
00064                 $this->language = array();
00065                 $this->description = array();
00066                 $this->keyword = array();
00067                 $this->technicals = array();    // technical sections
00068                 $this->coverage = "";
00069                 $this->structure = "";
00070 
00071                 $this->content_obj =& $content_obj;
00072                 if(is_object($content_obj))
00073                 {
00074                         $this->setID($this->content_obj->getId());
00075                         $this->readXML();
00076 #                       $this->read();
00077                 }
00078         }
00079 
00080         // SET METHODS
00086         function setBibliographyAttributes($a_data)
00087         {
00088                 $this->bibliography_attr = $a_data;
00089         }
00090 
00098         function setAbstract($a_data)
00099         {
00100                 $this->abstract = $a_data;
00101         }
00102 
00110         function setBibItemData($a_key,$a_value,$a_bib_item_nr)
00111         {
00112                 $this->bib_item_data[$a_bib_item_nr]["$a_key"] = $a_value;
00113                 
00114                 return true;
00115         }
00116 
00124         function appendBibItemData($a_key,$a_value,$a_bib_item_nr)
00125         {
00126                 $this->bib_item_data[$a_bib_item_nr]["$a_key"] = array_merge($this->bib_item_data[$a_bib_item_nr]["$a_key"],array($a_value));
00127         }
00128 
00129         // GET MEHODS
00130         function getBibItemData()
00131         {
00132                 return $this->bib_item_data;
00133         }
00134 
00140         function getBibliographyAttributes()
00141         {
00142                 return $this->bibliography_attr ? $this->bibliography_attr : array();
00143         }
00149         function getAbstract()
00150         {
00151                 return $this->abstract;
00152         }
00153 
00161         function getTitle()
00162         {
00163                 return $this->title;
00164         }
00165 
00173         function getXML()
00174         {
00175                 return $this->xml;
00176         }
00177 
00185         function readXML()
00186         {
00187                 if(!$this->__initNestedSet())
00188                 {
00189                         return false;
00190                 }
00191                 $this->xml = $this->nested_obj->export($this->content_obj->getId(),"bib");
00192         }
00193 
00194 
00203         function setXMLContent($a_xml, $a_encoding = "UTF-8")
00204         {
00205                 $this->encoding = $a_encoding;
00206                 $this->xml = $a_xml;
00207         }
00208 
00209 
00216         function appendXMLContent($a_xml)
00217         {
00218                 $this->xml.= $a_xml;
00219         }
00220 
00221 
00225         function getXMLContent()/*$a_incl_head = false*/
00226         {
00227 
00228         return $this->xml;
00229         }
00230 
00231         // PRIVATE METHODS
00232         function __initNestedSet()
00233         {
00234                 include_once("classes/class.ilNestedSetXML.php");
00235 
00236                 $this->nested_obj =& new ilNestedSetXML();
00237                 $this->nested_obj->init($this->getID(), "bib");
00238 
00239                 return $this->nested_obj->initDom();
00240         }
00241 
00242         function setBooktitle($a_booktitle)
00243         {
00244                 if ($a_booktitle == "")
00245                 {
00246                         $a_booktitle = "NO TITLE";
00247                 }
00248 
00249                 $this->booktitle = $a_booktitle;
00250         }
00251 
00252         function getBooktitle()
00253         {
00254                 return $this->booktitle;
00255         }
00256 
00257         function setEdition($a_edition)
00258         {
00259                 $this->edition = $a_edition;
00260         }
00261 
00262         function getEdition()
00263         {
00264                 return $this->edition;
00265         }
00266 
00267         function setPublisher($a_publisher)
00268         {
00269                 $this->publisher = $a_publisher;
00270         }
00271 
00272         function getPublisher()
00273         {
00274                 return $this->publisher;
00275         }
00276 
00277         function setYear($a_year)
00278         {
00279                 $this->year = $a_year;
00280         }
00281 
00282         function getYear()
00283         {
00284                 return $this->year;
00285         }
00286 
00290         function setMeta($a_data)
00291         {
00292                 $this->meta = $a_data;
00293         }
00294 
00298         function getMeta()
00299         {
00300                 return $this->meta;
00301         }
00305         function setID($a_id)
00306         {
00307                 $this->id = $a_id;
00308         }
00309 
00310         function getID()
00311         {
00312                 return $this->id;
00313         }
00314 
00315         function setType($a_type)
00316         {
00317                 $this->type = $a_type;
00318         }
00319 
00320         function getType()
00321         {
00322                 return $this->type;
00323         }
00324 
00329         function setElement($a_name, $a_data)
00330         {
00331                 $this->$a_name = $a_data;
00332         }
00333 
00338         function getElement($a_name, $a_path = "", $a_index = 0)
00339         {
00340                 if(!$this->__initNestedSet())
00341                 {
00342                         return false;
00343                 }
00344 
00345                 $p = "//Bibliography";
00346                 if ($a_path != "")
00347                 {
00348                         $p .= "/" . $a_path;
00349                 }
00350                 $nodes = $this->nested_obj->getDomContent($p, $a_name, $a_index);
00351                 $this->setElement($a_name, $nodes);
00352 /*              if ($a_name == "Author" ||
00353                         $a_name == "FirstName" ||
00354                         $a_name == "MiddleName" ||
00355                         $a_name == "LastName")
00356                 {
00357                         echo "Index: " . $a_index . " | Path: " . $p . " | Name: " . $a_name . "<br>\n";
00358                         vd($this->$a_name);
00359                 }
00360 */
00361                 return $this->$a_name;
00362         }
00363 
00364         function read()
00365         {
00366                 if(!$this->__initNestedSet())
00367                 {
00368                         $bibData = $this->create();
00369                 }
00370                 else
00371                 {
00372                         $bibData["booktitle"] = $this->nested_obj->getFirstDomContent("//Bibliography/BibItem/Booktitle");
00373                         $bibData["edition"] = $this->nested_obj->getFirstDomContent("//Bibliography/BibItem/Edition");
00374                         $bibData["publisher"] = $this->nested_obj->getFirstDomContent("//Bibliography/BibItem/Publisher");
00375                         $bibData["year"] = $this->nested_obj->getFirstDomContent("//Bibliography/BibItem/Year");
00376                 }
00377 
00378                 $this->setBooktitle($bibData["booktitle"]);
00379                 $this->setEdition($bibData["edition"]);
00380                 $this->setPublisher($bibData["publisher"]);
00381                 $this->setYear($bibData["year"]);
00382         }
00383 
00387         function create()
00388         {
00389                 $this->__initNestedSet();
00390 
00391 /*              if (is_object($this->obj))
00392                 {
00393                         $bibData["booktitle"] = $this->obj->getTitle();
00394                 }
00395                 else
00396                 {*/
00397                         $bibData["booktitle"] = "NO TITLE";
00398 /*              }*/
00399                 $bibData["edition"] = "N/A";
00400                 $bibData["publisher"] = "";
00401                 $bibData["year"] = "N/A";
00402 
00403                 $xml = '
00404                         <Bibliography>
00405                                 <BibItem Type="" Label="">
00406                                         <Identifier Catalog="ILIAS" Entry="il__' . $this->getType() . '_' . $this->getID() . '"></Identifier>
00407                                         <Language Language="' . $this->ilias->account->getLanguage() . '"></Language>
00408                                         <Booktitle Language="' . $this->ilias->account->getLanguage() . '">'. $bibData["booktitle"] . '</Booktitle>
00409                                         <Edition>'. $bibData["edition"] . '</Edition>
00410                                         <HowPublished Type=""></HowPublished>
00411                                         <Publisher>'. $bibData["publisher"] . '</Publisher>
00412                                         <Year>'. $bibData["year"] . '</Year>
00413                                         <URL></URL>
00414                                 </BibItem>
00415                         </Bibliography>
00416                 ';
00417                 $this->nested_obj->import($xml, $this->getID(), "bib");
00418 
00419                 return $bibData;
00420         }
00421 
00425         function delete($a_name, $a_path, $a_index)
00426         {
00427                 if(!$this->__initNestedSet())
00428                 {
00429                         return false;
00430                 }
00431 
00432                 if ($a_name != "")
00433                 {
00434                         $p = "//Bibliography";
00435                         if ($a_path != "")
00436                         {
00437                                 $p .= "/" . $a_path;
00438                         }
00439                         $this->nested_obj->deleteDomNode($p, $a_name, $a_index);
00440                         $this->nested_obj->updateFromDom();
00441                 }
00442         }
00443 
00447         function add($a_name, $a_path, $a_index = 0)
00448         {
00449                 if(!$this->__initNestedSet())
00450                 {
00451                         return false;
00452                 }
00453 
00454                 $p = "//Bibliography";
00455                 if ($a_path != "")
00456                 {
00457                         $p .= "/" . $a_path;
00458                 }
00459                 $attributes = array();
00460 #               echo "Index: " . $a_index . " | Path: " . $p . " | Name: " . $a_name . "<br>\n";
00461                 switch ($a_name)
00462                 {
00463                         case "BibItem"          :       $xml = '
00464                                                                                 <BibItem Type="" Label="">
00465                                                                                         <Identifier Catalog="ILIAS" Entry="il__' . $this->getType() . '_' . $this->getID() . '"></Identifier>
00466                                                                                         <Language Language="' . $this->ilias->account->getLanguage() . '"></Language>
00467                                                                                         <Booktitle Language="' . $this->ilias->account->getLanguage() . '">NO TITLE</Booktitle>
00468                                                                                         <Edition>N/A</Edition>
00469                                                                                         <HowPublished Type=""></HowPublished>
00470                                                                                         <Publisher></Publisher>
00471                                                                                         <Year>N/A</Year>
00472                                                                                         <URL></URL>
00473                                                                                 </BibItem>
00474                                                                         ';
00475                                                                         $this->nested_obj->addXMLNode($p, $xml, $a_index);
00476                                                                         break;
00477                         case "Identifier"       :       $value = "";
00478                                                                         $attributes[0] = array("name" => "Catalog", "value" => "");
00479                                                                         $attributes[1] = array("name" => "Entry", "value" => "");
00480                                                                         $this->nested_obj->addDomNode($p, $a_name, $value, $attributes, $a_index);
00481                                                                         break;
00482                         case "Keyword"          :       ;
00483                         case "Booktitle"        :       ;
00484                         case "Language"         :       $value = "";
00485                                                                         $attributes[0] = array("name" => "Language", value => $this->ilias->account->getLanguage());
00486                                                                         $this->nested_obj->addDomNode($p, $a_name, $value, $attributes, $a_index);
00487                                                                         break;
00488                         case "Author"           :       $xml = '
00489                                                                                 <Author>
00490                                                                                         <Lastname></Lastname>
00491                                                                                 </Author>
00492                                                                         ';
00493                                                                         $this->nested_obj->addXMLNode($p, $xml, $a_index);
00494                                                                         break;
00495                         case "HowPublished"     :       $value = "";
00496                                                                         $attributes[0] = array("name" => "Type", value => "");
00497                                                                         $this->nested_obj->addDomNode($p, $a_name, $value, $attributes, $a_index);
00498                                                                         break;
00499                         case "Series"           :       $xml = '
00500                                                                                 <Series>
00501                                                                                         <SeriesTitle></SeriesTitle>
00502                                                                                 </Series>
00503                                                                         ';
00504                                                                         $this->nested_obj->addXMLNode($p, $xml, $a_index);
00505                                                                         break;
00506                         default                         :       $value = "";
00507                                                                         $attributes = "";
00508                                                                         $this->nested_obj->addDomNode($p, $a_name, $value, $attributes, $a_index);
00509                                                                         break;
00510                 }
00511                 $this->nested_obj->updateFromDom();
00512         }
00513 
00514         function getCountries()
00515         {
00516                 global $lng;
00517 
00518                 $lng->loadLanguageModule("meta");
00519 
00520                 $cntcodes = array ("DE","ES","FR","GB","AT","CH","AF","AL","DZ","AS","AD","AO",
00521                         "AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY",
00522                         "BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","BN","BG","BF",
00523                         "BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM",
00524                         "CG","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","TP","EC",
00525                         "EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","FX","GF","PF",
00526                         "TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GN",
00527                         "GW","GY","HT","HM","HN","HU","IS","IN","ID","IR","IQ","IE","IL","IT",
00528                         "JM","JP","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS",
00529                         "LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH",
00530                         "MQ","MR","MU","YT","MX","FM","MD","MC","MN","MS","MA","MZ","MM","NA",
00531                         "NR","NP","NL","AN","NC","NZ","NI","NE","NG","NU","NF","MP","NO","OM",
00532                         "PK","PW","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RE","RO",
00533                         "RU","RW","KN","LC","VC","WS","SM","ST","SA","CH","SN","SC","SL","SG",
00534                         "SK","SI","SB","SO","ZA","GS","ES","LK","SH","PM","SD","SR","SJ","SZ",
00535                         "SE","SY","TW","TJ","TZ","TH","TG","TK","TO","TT","TN","TR","TM","TC",
00536                         "TV","UG","UA","AE","GB","UY","US","UM","UZ","VU","VA","VE","VN","VG",
00537                         "VI","WF","EH","YE","ZR","ZM","ZW");
00538                 $cntrs = array();
00539                 foreach($cntcodes as $cntcode)
00540                 {
00541                         $cntrs[$cntcode] = $lng->txt("meta_c_".$cntcode);
00542                 }
00543                 asort($cntrs);
00544                 return $cntrs;
00545 
00546         }
00547 
00548         // GENERAL: Language
00549         function setLanguage($a_lang)
00550         {
00551                 $this->language = $a_lang;
00552         }
00553 
00554         function getLanguage()
00555         {
00556                 return $this->language;
00557         }
00558 
00563         function getLanguages()
00564         {
00565                 global $lng;
00566 
00567                 $lng->loadLanguageModule("meta");
00568 
00569                 $lngcodes = array("aa","ab","af","am","ar","as","ay","az","ba","be","bg","bh",
00570                         "bi","bn","bo","br","ca","co","cs","cy","da","de","dz","el","en","eo",
00571                         "es","et","eu","fa","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu",
00572                         "ha","he","hi","hr","hu","hy","ia","ie","ik","id","is","it","iu","ja",
00573                         "jv","ka","kk","kl","km","kn","ko","ks","ku","ky","la","ln","ru","rw",
00574                         "sa","sd","sg","sh","si","sk","sl","sm","sn","so","sq","sr","ss","st",
00575                         "su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts",
00576                         "tt","tw","ug","uk","ur","uz","vi","vo","wo","xh","yi","yo","za","zh",
00577                         "zu");
00578                 $langs = array();
00579                 foreach($lngcodes as $lngcode)
00580                 {
00581                         $langs[$lngcode] = $lng->txt("meta_l_".$lngcode);
00582                 }
00583                 asort($langs);
00584                 return $langs;
00585         }
00586 
00587 }
00588 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1