예제 #1
0
 public function __get($name)
 {
     if ($name == 'url' && !empty($this->id)) {
         if (empty($this->url)) {
             $this->url = ormPages::getPageUrlById($this->id);
         }
         //echo $this->id.'|'.$this->url.'<br/>';
         return $this->url;
     } else {
         if ($name == '_url' && !empty($this->id)) {
             if (empty($this->_url)) {
                 if ($this->__get('other_link') != '') {
                     $link = $this->__get('other_link');
                     if ($link == '/first_subsection') {
                         $sel = new ormSelect();
                         /// $sel->fields('id');
                         $sel->findInPages();
                         $sel->where('parents', '=', $this->id);
                         $sel->orderBy('position');
                         $sel->limit(1);
                         if ($subsection = $sel->getObject()) {
                             $this->_url = $subsection->__get('_url');
                         }
                     } else {
                         $this->_url = $link;
                     }
                 } else {
                     $this->_url = ormPages::getPageUrlById($this->id);
                 }
             }
             return $this->_url;
         } else {
             if ($name == 'first_children_id' && !empty($this->id)) {
                 $sel = new ormSelect();
                 $sel->findInPages();
                 $sel->where('parents', '=', $this->id);
                 $sel->fields('id');
                 $sel->limit(1);
                 $order_by = $this->__get('order_by');
                 if (!empty($order_by)) {
                     $pos = strpos($order_by, ' ');
                     if ($pos) {
                         $parram = substr($order_by, $pos + 1);
                         $order_by = substr($order_by, 0, $pos);
                     } else {
                         $parram = '';
                     }
                     $sel->orderBy($order_by, $parram);
                 }
                 return $sel->getObject()->id;
             } else {
                 if ($name == 'count_children' && !empty($this->id)) {
                     return $this->countChildren();
                 } else {
                     if ($this->isSysField($name) && isset($this->cur_prop[$name])) {
                         return $this->cur_prop[$name];
                     } else {
                         if ($this->isSysField($name) && isset($this->new_prop[$name])) {
                             return $this->new_prop[$name];
                         } else {
                             return parent::__get($name);
                         }
                     }
                 }
             }
         }
     }
 }