예제 #1
0
$date_min = CValue::get("date_min");
$date_max = CValue::get("date_max");
$group_id = CValue::get("group_id");
$concept_search = CValue::get("concept_search");
CValue::setSession('reference_class', $reference_class);
CValue::setSession('reference_id', $reference_id);
if ($reference_class) {
    /** @var CMbObject $reference */
    $reference = new $reference_class();
    if ($reference_id) {
        $reference->load($reference_id);
    }
} else {
    $reference = null;
}
CExClassField::$_load_lite = true;
CExObject::$_multiple_load = true;
CExObject::$_load_lite = $detail < 2;
$group_id = $group_id ? $group_id : CGroups::loadCurrent()->_id;
$where = array("group_id = '{$group_id}' OR group_id IS NULL");
if ($ex_class_id) {
    $where['ex_class_id'] = "= '{$ex_class_id}'";
}
if (empty(CExClass::$_list_cache)) {
    $ex_class = new CExClass();
    /** @var CExClass[] $ex_classes */
    $ex_classes = $ex_class->loadList($where, "name");
    $categories = CStoredObject::massLoadFwdRef($ex_classes, "category_id");
    $categories = CStoredObject::naturalSort($categories, array("title"));
    $categories = array(new CExClassCategory()) + $categories;
    foreach ($ex_classes as $_ex_class) {
예제 #2
0
 /**
  * @param CMbObject $object
  *
  * @return CExObject[][]
  */
 static function getExObjectsOf(CMbObject $object)
 {
     CExClassField::$_load_lite = true;
     CExObject::$_multiple_load = true;
     $group_id = CGroups::loadCurrent()->_id;
     $where = array("group_id = '{$group_id}' OR group_id IS NULL");
     if (empty(CExClass::$_list_cache)) {
         $ex_class = new CExClass();
         CExClass::$_list_cache = $ex_class->loadList($where, "name");
         if (!CExObject::$_locales_cache_enabled) {
             foreach (CExClass::$_list_cache as $_ex_class) {
                 foreach ($_ex_class->loadRefsGroups() as $_group) {
                     $_group->loadRefsFields();
                     foreach ($_group->_ref_fields as $_field) {
                         $_field->updateTranslation();
                     }
                 }
             }
         }
     }
     $ex_objects = array();
     $limit = 1;
     $ref_objects_cache = array();
     foreach (CExClass::$_list_cache as $_ex_class_id => $_ex_class) {
         $_ex_object = new CExObject($_ex_class_id);
         $where = array("(reference_class  = '{$object->_class}' AND reference_id  = '{$object->_id}') OR\n         (reference2_class = '{$object->_class}' AND reference2_id = '{$object->_id}') OR\n         (object_class     = '{$object->_class}' AND object_id     = '{$object->_id}')");
         $ljoin = array();
         /** @var CExObject[] $_ex_objects */
         $_ex_objects = $_ex_object->loadList($where, "{$_ex_object->_spec->key} DESC", $limit, null, $ljoin);
         foreach ($_ex_objects as $_ex) {
             $_ex->_ex_class_id = $_ex_class_id;
             $_ex->load();
             $guid = "{$_ex->object_class}-{$_ex->object_id}";
             if (!isset($ref_objects_cache[$guid])) {
                 $_ex->loadTargetObject()->loadComplete();
                 // to get the view
                 $ref_objects_cache[$guid] = $_ex->_ref_object;
             } else {
                 $_ex->_ref_object = $ref_objects_cache[$guid];
             }
             if ($_ex->additional_id) {
                 $_ex->loadRefAdditionalObject();
             }
             $ex_objects[$_ex_class_id][$_ex->_id] = $_ex;
         }
         if (isset($ex_objects[$_ex_class_id])) {
             krsort($ex_objects[$_ex_class_id]);
         }
     }
     ksort($ex_objects);
     return $ex_objects;
 }