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

classes/class.ilMetaTechnical.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 
00034 class ilMetaTechnical
00035 {
00036         var $ilias;
00037 
00038         var $meta_data;
00039         var $tech_id;
00040 
00041         var $formats;
00042         var $size;
00043         var $locations;
00044         var $requirement_sets;
00045         var $install_lang;
00046         var $install_remarks;
00047         var $other_req;
00048         var $other_req_lang;
00049         var $duration;
00050 
00051 
00057         function ilMetaTechnical(&$a_meta_data)
00058         {
00059                 global $ilias;
00060 
00061                 $this->ilias =& $ilias;
00062                 $this->meta_data =& $a_meta_data;
00063                 $this->locations = array();
00064                 $this->formats = array();
00065                 $this->requirement_sets = array();
00066         }
00067 
00068 
00069         function getId()
00070         {
00071                 return $this->meta_data->getId();
00072         }
00073 
00074         function getType()
00075         {
00076                 return $this->meta_data->getType();
00077         }
00078 
00085         function delete($a_id, $a_type)
00086         {
00087                 // get locations and delete them
00088                 $q = "SELECT * FROM meta_technical WHERE ".
00089                         " obj_id='$a_id' AND obj_type='$a_type'";
00090                 $tech_set = $this->ilias->db->query($q);
00091                 while ($tech_rec = $tech_set->fetchRow(DB_FETCHMODE_ASSOC))
00092                 {
00093                         $q = "DELETE FROM meta_techn_loc WHERE tech_id = '".$tech_rec["tech_id"]."'";
00094                         $this->ilias->db->query($q);
00095 
00096                         $q = "DELETE FROM meta_techn_format WHERE tech_id = '".$tech_rec["tech_id"]."'";
00097                         $this->ilias->db->query($q);
00098                 }
00099 
00100                 // delete technical db records
00101                 $q = "DELETE FROM meta_technical WHERE ".
00102                         " obj_id='$a_id' AND obj_type='$a_type'";
00103                 $this->ilias->db->query($q);
00104         }
00105 
00109         function create()
00110         {
00111                 $q = "INSERT INTO meta_technical ".
00112                         "(obj_id, obj_type, size, install_remarks, install_remarks_lang,".
00113                         "other_requirements, other_requirements_lang, duration) ".
00114                         " VALUES ('".$this->getId()."','".$this->getType()."',".
00115                         "'".$this->getSize()."',".
00116                         "'".$this->getInstallationRemarks()."',".
00117                         "'".$this->getInstallationRemarksLanguage()."',".
00118                         "'".$this->getOtherRequirements()."',".
00119                         "'".$this->getOtherRequirementsLanguage()."',".
00120                         "'".$this->getDuration()."')";
00121 //echo "MetaTechnical::create:$q<br>";
00122                 $this->ilias->db->query($q);
00123 
00124                 $q = "SELECT LAST_INSERT_ID() AS tech_id FROM meta_technical";
00125                 $row = $this->ilias->db->getRow($q, DB_FETCHMODE_ASSOC);
00126 
00127                 $this->tech_id =  $row["tech_id"];
00128 //echo "saving...tech_id:".$row["tech_id"].":<br>";
00129                 $i = 1;
00130                 foreach ($this->locations as $location)
00131                 {
00132 //echo "INSERT INTO meta_techn_loc<br>";
00133                         $q = "INSERT INTO meta_techn_loc (tech_id, type, location, nr) VALUES".
00134                                 " ('".$this->tech_id."','".$location["type"]."', '".
00135                                 $location["loc"]."', '".$i++."')";
00136                         $this->ilias->db->query($q);
00137                 }
00138 
00139                 $i = 1;
00140                 foreach ($this->formats as $format)
00141                 {
00142 //echo "INSERT INTO meta_techn_loc<br>";
00143                         $q = "INSERT INTO meta_techn_format (tech_id, format, nr) VALUES
00144                                 ('".$this->tech_id."','".$format."', '".$i++."')";
00145                         $this->ilias->db->query($q);
00146                 }
00147 
00148         }
00149 
00155         function readTechnicalSections(&$a_meta_obj)
00156         {
00157 //echo "ilMetaTechnical_read:".$a_meta_obj->getId().":".$a_meta_obj->getType().":<br>";
00158                 $query = "SELECT * FROM meta_technical WHERE obj_id='".$a_meta_obj->getId()."' ".
00159                         "AND obj_type='".$a_meta_obj->getType()."'";
00160                 $tech_set = $this->ilias->db->query($query);
00161                 while ($tech_rec = $tech_set->fetchRow(DB_FETCHMODE_ASSOC))
00162                 {
00163 //echo "---tech---";
00164                         $tech_obj =& new ilMetaTechnical($a_meta_obj);
00165                         $tech_obj->setSize($tech_rec["size"]);
00166                         $tech_obj->setInstallationRemarks($tech_rec["install_remarks"]);
00167                         $tech_obj->setInstallationRemarksLanguage($tech_rec["install_remarks_lang"]);
00168                         $tech_obj->setOtherRequirements($tech_rec["other_requirements"]);
00169                         $tech_obj->setOtherRequirementsLanguage($tech_rec["other_requirements_lang"]);
00170                         $tech_obj->setDuration($tech_rec["duration"]);
00171 
00172                         // get formats
00173                         $query = "SELECT * FROM meta_techn_format WHERE tech_id='".$tech_rec["tech_id"]."'".
00174                                 " ORDER BY nr";
00175                         $format_set = $this->ilias->db->query($query);
00176                         while ($format_rec = $format_set->fetchRow(DB_FETCHMODE_ASSOC))
00177                         {
00178                                 $tech_obj->addFormat($format_rec["format"]);
00179                         }
00180 
00181                         // get locations
00182                         $query = "SELECT * FROM meta_techn_loc WHERE tech_id='".$tech_rec["tech_id"]."'".
00183                                 " ORDER BY nr";
00184                         $loc_set = $this->ilias->db->query($query);
00185                         while ($loc_rec = $loc_set->fetchRow(DB_FETCHMODE_ASSOC))
00186                         {
00187                                 $tech_obj->addLocation($loc_rec["type"], $loc_rec["location"]);
00188                         }
00189 
00190                         $a_meta_obj->addTechnicalSection($tech_obj);
00191                 }
00192 //echo "count techs:".count($a_meta_obj->technicals).":<br>";
00193         }
00194 
00200         function addFormat($a_format)
00201         {
00202                 $this->formats[] = $a_format;
00203         }
00204 
00205         function getFormats()
00206         {
00207                 return $this->formats;
00208         }
00209 
00213         function setSize($a_size)
00214         {
00215                 $this->size = $a_size;
00216         }
00217 
00218         function getSize()
00219         {
00220                 return $this->size;
00221         }
00222 
00223 
00227         function addLocation($a_type, $a_loc)
00228         {
00229                 $this->locations[] = array("type" => $a_type, "loc" => $a_loc);
00230         }
00231 
00232         function getLocations()
00233         {
00234                 return $this->locations;
00235         }
00236 
00237 
00243         function addRequirementSet($a_requirement_set)
00244         {
00245                 $this->requirement_sets[] = $a_requirement_set;
00246         }
00247 
00248         function getRequirementSets()
00249         {
00250                 return $this->requirement_sets;
00251         }
00252 
00253 
00260         function setInstallationRemarks($a_remarks)
00261         {
00262                 $this->install_remarks = $a_remarks;
00263         }
00264 
00265         function setInstallationRemarksLanguage($a_lang)
00266         {
00267                 $this->install_lang = $a_lang;
00268         }
00269 
00270         function getInstallationRemarksLanguage()
00271         {
00272                 return $this->install_lang;
00273         }
00274 
00275         function getInstallationRemarks()
00276         {
00277                 return $this->install_remarks;
00278         }
00279 
00280 
00286         function setOtherRequirements($a_requirements)
00287         {
00288                 $this->other_req = $a_requirements;
00289         }
00290 
00291         function setOtherRequirementsLanguage($a_lang)
00292         {
00293                 $this->other_req_lang = $a_lang;
00294         }
00295 
00296         function getOtherRequirementsLanguage()
00297         {
00298                 return $this->other_req_lang;
00299         }
00300 
00301         function getOtherRequirements()
00302         {
00303                 return $this->other_req;
00304         }
00305 
00306 
00312         function setDuration($a_duration)
00313         {
00314                 $this->duration = $a_duration;
00315         }
00316 
00317         function getDuration()
00318         {
00319                 return $this->duration;
00320         }
00321 
00322         // get xml string of this meta technical section
00323         function getXML()
00324         {
00325                 $xml = "<Technical>\n";
00326                 foreach ($this->formats as $format)
00327                 {
00328                         $xml.= "<Format>".$format."</Format>\n";
00329                 }
00330                 $xml.= "<Size>".$this->getSize()."</Size>\n";
00331                 foreach ($this->locations as $location)
00332                 {
00333                         $xml.= "<Location Type=\"".$location["type"]."\">".$location["loc"]."</Location>\n";
00334                 }
00335                 $req_sets =& $this->getRequirementSets();
00336                 foreach ($req_sets as $req_set)
00337                 {
00338                         $xml.= $req_set->getXML();
00339                 }
00340                 $xml.= "</Technical>";
00341 
00342                 return $xml;
00343         }
00344 
00345 }
00346 ?>

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