Example #1
0
 /**
  * @return HTML
  * @param int $obj_id - ID раздела, для которого необходимо вывести теги.
  * @param string $templ_name - Шаблон оформления.
  * @desc МАКРОС: Выводит список тегов для указанной страницы.
  */
 public function tags($obj_id, $templ_name = 'tags')
 {
     $templ_file = '/search/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('search.tags', $templ_file);
     }
     $tags = tags::getTagsForObject($obj_id);
     $list = '';
     while (list($num, $tag) = each($tags)) {
         page::assign('obj.id', $tag['id']);
         page::assign('obj.name', $tag['name']);
         page::assign('obj.count', $tag['count']);
         page::assign('obj.url', '/search/tag/' . $tag['id']);
         $list .= !empty($num) ? page::parse($TEMPLATE['separator']) : '';
         $list .= page::parse($TEMPLATE['list']);
     }
     if (!empty($list)) {
         page::assign('list', $list);
         return page::parse($TEMPLATE['frame']);
     } else {
         return page::parse($TEMPLATE['empty']);
     }
 }
Example #2
0
 public function __get($name)
 {
     if ($name == 'name') {
         return $this->name;
     } else {
         if ($name == 'id') {
             return $this->id;
         } else {
             if ($name == 'create_date') {
                 return $this->create_date;
             } else {
                 if ($name == 'change_date') {
                     return $this->change_date;
                 } else {
                     if ($name == 'parents') {
                         return $this->getParents();
                     } else {
                         if ($name == 'parent_id') {
                             return $this->getParentId();
                         } else {
                             if ($name == 'children') {
                                 return $this->getChildren();
                             } else {
                                 if ($name == 'first_children_id') {
                                     return $this->getChildren(0);
                                 } else {
                                     if ($name == 'count_children') {
                                         return count($this->getChildren());
                                     } else {
                                         // Смотрим, есть ли флаг для справочников, о получении имени
                                         if (substr($name, 0, 1) == '_') {
                                             $name = substr($name, 1, strlen($name) - 1);
                                             $get_name = true;
                                         } else {
                                             $get_name = false;
                                         }
                                         // echo '='.$name.'=';
                                         $this->loadFields();
                                         if (isset($this->fields[$name])) {
                                             $this->loadData($this->next_prinud, $name);
                                             $this->next_prinud = false;
                                             // $values2 = (empty($this->cur_prop)) ? 1 : 2;
                                             // Если текущих значений у объекта нет, считаем временные значения текущими
                                             // и делаем из них выборку
                                             $values = empty($this->cur_prop) ? $this->new_prop : $this->cur_prop;
                                             //if ($name == 'tags')
                                             //  print_r($values);
                                             //   echo $values2.'!';
                                             if (isset($values[$name]) || $get_name && isset($values['_' . $name])) {
                                                 // Если значение не прогружено, загружаем все данные объекта
                                                 if (!$get_name) {
                                                     if ($values[$name] === $this->empty) {
                                                         $this->loadData(true, $name);
                                                         $values = $this->cur_prop;
                                                     }
                                                     // Отбрасываем лишние нули после запятой для поля типа "Цена"
                                                     if ($this->fields[$name]['f_type'] == 47) {
                                                         $values[$name] += 0;
                                                     }
                                                     //if (isset($values[$name]))
                                                     return $values[$name];
                                                 } else {
                                                     if (isset($values['_' . $name])) {
                                                         return $values['_' . $name];
                                                     }
                                                 }
                                             } else {
                                                 // Теги
                                                 if ($this->fields[$name]['f_type'] == 105 && !empty($this->id)) {
                                                     $this->cur_prop[$name] = tags::getTagsForObject($this->id);
                                                     $this->cur_prop['_' . $name] = '';
                                                     if (!empty($this->cur_prop[$name])) {
                                                         while (list($num, $tag) = each($this->cur_prop[$name])) {
                                                             $zpt = empty($num) ? '' : ', ';
                                                             $this->cur_prop['_' . $name] .= $zpt . $tag['name'];
                                                         }
                                                         reset($this->cur_prop[$name]);
                                                     }
                                                     if ($get_name) {
                                                         if (isset($this->cur_prop['_' . $name])) {
                                                             return $this->cur_prop['_' . $name];
                                                         }
                                                     } else {
                                                         if (isset($this->cur_prop[$name])) {
                                                             return $this->cur_prop[$name];
                                                         }
                                                     }
                                                     // Справочник "Выбор родителя"
                                                 } else {
                                                     if ($this->fields[$name]['f_relation'] == 2) {
                                                         // Ищем родителя нужного класса
                                                         $this->getParents();
                                                         $ret_mas = array();
                                                         if (count($this->parents) > 0) {
                                                             reset($this->parents);
                                                             while (list($obj_id, $val) = each($this->parents)) {
                                                                 if (empty($val['parent_class']) || $val['parent_class'] == $this->fields[$name]['f_list_id']) {
                                                                     $ret_mas[] = $val;
                                                                 }
                                                             }
                                                         }
                                                         return $ret_mas;
                                                         // Выпадающий список
                                                     } else {
                                                         if ($this->fields[$name]['f_type'] == 90) {
                                                             /*
                                                                         $this->cur_prop['_'.$name] = '';
                                                                         $this->cur_prop[$name] = 0;
                                                             */
                                                             if ($this->fields[$name]['f_relation'] > 0) {
                                                                 $this->getLinks2();
                                                                 if (isset($this->links2[$this->fields[$name]['f_id']][0])) {
                                                                     $this->cur_prop[$name] = $this->links2[$this->fields[$name]['f_id']][0]['id'];
                                                                     $this->cur_prop['_' . $name] = $this->links2[$this->fields[$name]['f_id']][0]['name'];
                                                                 }
                                                             } else {
                                                                 $this->getLinks();
                                                                 if (isset($this->links[$this->fields[$name]['f_id']][0])) {
                                                                     $this->cur_prop[$name] = $this->links[$this->fields[$name]['f_id']][0]['id'];
                                                                     $this->cur_prop['_' . $name] = $this->links[$this->fields[$name]['f_id']][0]['name'];
                                                                 }
                                                             }
                                                             if ($get_name) {
                                                                 if (isset($this->cur_prop['_' . $name])) {
                                                                     return $this->cur_prop['_' . $name];
                                                                 }
                                                             } else {
                                                                 if (isset($this->cur_prop[$name])) {
                                                                     return $this->cur_prop[$name];
                                                                 }
                                                             }
                                                             // Вып. список с множ. выбором
                                                         } else {
                                                             if ($this->fields[$name]['f_type'] == 95 || $this->fields[$name]['f_type'] == 100) {
                                                                 /*
                                                                 
                                                                            $this->cur_prop[$name] = array();
                                                                 */
                                                                 if ($this->fields[$name]['f_relation'] > 0) {
                                                                     $this->getLinks2();
                                                                     $links = $this->links2;
                                                                 } else {
                                                                     $this->getLinks();
                                                                     $links = $this->links;
                                                                 }
                                                                 if (isset($links[$this->fields[$name]['f_id']])) {
                                                                     $this->cur_prop['_' . $name] = '';
                                                                     while (list($num, $val) = each($links[$this->fields[$name]['f_id']])) {
                                                                         $this->cur_prop[$name][] = $val['id'];
                                                                         if (!empty($this->cur_prop['_' . $name])) {
                                                                             $this->cur_prop['_' . $name] .= ', ';
                                                                         }
                                                                         $this->cur_prop['_' . $name] .= $val['name'];
                                                                     }
                                                                 }
                                                                 if ($get_name) {
                                                                     if (isset($this->cur_prop['_' . $name])) {
                                                                         return $this->cur_prop['_' . $name];
                                                                     }
                                                                 } else {
                                                                     if (isset($this->cur_prop[$name])) {
                                                                         return $this->cur_prop[$name];
                                                                     }
                                                                 }
                                                                 // Зависимый справочник
                                                             } else {
                                                                 if ($this->fields[$name]['f_type'] == 97) {
                                                                     if ($get_name) {
                                                                         return '';
                                                                     } else {
                                                                         return array();
                                                                     }
                                                                     // Связь с объектом
                                                                 } else {
                                                                     if ($this->fields[$name]['f_type'] == 100) {
                                                                         if ($get_name) {
                                                                             return '';
                                                                         } else {
                                                                             return array();
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         } else {
                                             return false;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }