attr_name = $attr_name; $this->obj = $obj; $full_type = $obj->attrs[$attr_name]['type']; $arr = explode("|", $full_type); $lobj_name = $arr[1]; //if ($lobj_name == $obj->obj_name ) cdie('recursion'); $this->lobj_name = $lobj_name; //$this->linked_obj = new cobject( $lobj_name, $this->obj->recursion_depth ); } function getDBType() { return "varchar(255)"; } function getLinkedObj() { if ( !$this->linked_obj ) { $this->linked_obj = new cobject( $this->lobj_name, $this->obj->recursion_depth ); } return $this->linked_obj; } function lPost() { if (is_array($_POST[$this->attr_name])) { $this->obj->set($this->attr_name,implode(",",$_POST[$this->attr_name])); } else { $this->obj->set($this->attr_name,$_POST[$this->attr_name]); } } function render_text( $crop = false ) { $id = $this->getCurVal(); if ( $id ) $ids = explode( ",", $id ); $tpl = $this->obj->attrs[$this->attr_name]['templ']; $outa = array(); if ( $ids ) { foreach( $ids as $id ) { $this->getLinkedObj()->byId( $id ); // Показывать удаленные $outa[] = $this->getLinkedObj()->assign( $tpl ); } if ($outa ) { sort($outa); } } return implode("; ", $outa); } function render_input() { global $core; $db = $this->getLinkedObj()->getDB(); $db2 = $db->q( $this->getLinkedObj()->getSelect( $this->sql_where ) ); $out = ''; $id = $this->getCurVal(); if ( $id ) $ids = explode( ",", $id ); $tpl = $this->obj->attrs[$this->attr_name]['templ']; while ( $db2->r() ) { $this->getLinkedObj()->lRow( $db2 ); $tt = $this->getLinkedObj()->assign( $tpl ); if ( $ids && in_array( $db2->f( 'id' ), $ids ) ) $checked = 'checked'; else $checked = ''; $out .= '
'; } return $out; } function getFilter( $sql_where = '' ) { $db = $this->getLinkedObj()->getDB(); $fname = $this->obj->obj_name . '_' . $this->attr_name; $uniq_ids = array(); if ( $this->obj->obj_name ) { $db3 = $this->obj->getDB()->q( $this->obj->getSelectEx( ' DISTINCT(`'.$this->attr_name.'`) as `'.$this->attr_name.'` ', '' ) ); while ( $db3->nr() ) { $uniq_ids[] = $db3->f($this->attr_name); } } else { $uniq_ids = array(); } if (!$_GET[$fname]) { $tmp = array(''); $tmp_s = array('Все'); } else { $tmp = array(''); $tmp_s = array('Все'); } $db2 = $db->q( $this->getLinkedObj()->getSelect( $sql_where) ); $c = 0; while ( $db2->r() ) { if ( $this->obj->obj_name && !in_array( $db2->f('id'), $uniq_ids ) ) continue; $tpl = strip_tags( $this->getAttrTempl() ); $this->getLinkedObj()->lRow($db2); $tpl = $this->getLinkedObj()->assign($tpl, true); if ( strlen($tpl) > 100 ) $tpl = substr($tpl,0,100) . '...'; if ($_GET[$fname] != $db2->f('id')) { $tplh = ''; $tplh_s = '' .$tpl . ''; } else { $tplh = ''; $tplh_s = '' .$tpl . ''; $ret['sql'] = " AND FIND_IN_SET( ".$db2->f('id').",`" . $this->obj->obj_name . "`.`" . $this->attr_name . "`)" ; } $tmp[] = $tplh; $tmp_s[] = $tplh_s; $c++; } if ($c > 10 ) { $ret['html'] = '"; } else { $ret['html'] .= implode(' | ', $tmp_s); } return $ret; } } ?>