public function addDescription(Description $description)
 {
     if ($description instanceof ThingDescription) {
         $this->isTrue = true;
         $this->descriptions = array();
         // no conditions any more
         $this->classDescription = null;
     }
     if (!$this->isTrue) {
         if ($description instanceof ClassDescription) {
             // combine class descriptions
             if (is_null($this->classDescription)) {
                 // first class description
                 $this->classDescription = $description;
                 $this->descriptions[] = $description;
             } else {
                 $this->classDescription->addDescription($description);
             }
         } elseif ($description instanceof Disjunction) {
             // absorb sub-disjunctions
             foreach ($description->getDescriptions() as $subdesc) {
                 $this->descriptions[] = $subdesc;
             }
             // } elseif ($description instanceof SMWSomeProperty) {
             ///TODO: use subdisjunct. for multiple SMWSomeProperty descs with same property
         } else {
             $this->descriptions[] = $description;
         }
     }
     // move print descriptions downwards
     ///TODO: This may not be a good solution, since it does modify $description and since it does not react to future cahges
     $this->m_printreqs = array_merge($this->m_printreqs, $description->getPrintRequests());
     $description->setPrintRequests(array());
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = ClassDescription::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Esempio n. 3
0
 public function getDescription()
 {
     // TODO: also, use the more yii-ish activerecord means of constraining instead of sql joins
     $found = ClassDescription::model()->findBySql('select class_description.* from class_description
                  where class_id = :cid 
                     and language_id = :lid', array('cid' => $this->id, 'lid' => Language::savedLanguageId()));
     return isset($found) ? $found : ClassDescription::model()->findBySql('select class_description.* from class_description
                  where class_id = :cid 
                     and language_id = :lid', array('cid' => $this->id, 'lid' => Language::DEFAULT_LANGUAGE_ID));
 }