Esempio n. 1
0
 public function __get($field_name)
 {
     //check cached value
     if (is_array($this->qd_cached_attr) && isset($this->qd_cached_attr[$field_name])) {
         return $this->qd_cached_attr[$field_name];
     }
     //calculate field value
     if (static::ISFLOWFIELD($field_name)) {
         //CALC FlowField First
         return $this->CALCFIELDS($field_name);
     } else {
         if (static::ISSYSTEMFIELD($field_name)) {
             $class_name = $this->getCalledClassName();
             //system preserved field
             if ($field_name == '__sys_note_url') {
                 $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('note', array('model' => $class_name, 'model_id' => $this->id));
                 //COUNT
                 $record = new QdNote();
                 $record->SETRANGE('model', $this->getCalledClassName());
                 $record->SETRANGE('model_id', $this->id);
                 $count = $record->COUNTLIST();
                 return add_query_arg(array('item_count' => $count), $tmp);
             } else {
                 if ($field_name == '__sys_log_url') {
                     $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('log', array('model' => $class_name, 'model_id' => $this->id));
                     //COUNT
                     $record = new QdLog();
                     $record->SETRANGE('model', $this->getCalledClassName());
                     $record->SETRANGE('model_id', $this->id);
                     $count = $record->COUNTLIST();
                     return add_query_arg(array('item_count' => $count), $tmp);
                 } else {
                     if ($field_name == '__sys_image_url') {
                         $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('image', array('model' => $class_name, 'model_id' => $this->id));
                         //COUNT
                         $record = new QdImage();
                         $record->SETRANGE('model', $this->getCalledClassName());
                         $record->SETRANGE('model_id', $this->id);
                         $count = $record->COUNTLIST();
                         return add_query_arg(array('item_count' => $count), $tmp);
                     } else {
                         if ($field_name == '__lasteditor_name') {
                             if ($this->lasteditor_id > 0) {
                                 $user_info = get_userdata($this->lasteditor_id);
                                 return $this->qd_cached_attr[$field_name] = $user_info->user_login;
                             }
                             return Qdmvc_Helper::getNoneText();
                         } else {
                             if ($field_name == '__owner_name') {
                                 if ($this->owner_id > 0) {
                                     $user_info = get_userdata($this->owner_id);
                                     return $this->qd_cached_attr[$field_name] = $user_info->user_login;
                                 }
                                 return Qdmvc_Helper::getNoneText();
                             } else {
                                 if ($field_name == 'date_created' || $field_name == 'date_modified' || $field_name == 'owner_id') {
                                     return parent::__get($field_name);
                                 } else {
                                     // if ($field_name == '__sys_lines_url') {//Default system Lines Field
                                     return $this->getLinesURL($field_name);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return parent::__get($field_name);
 }