public static function FetchFromAssoc($assoc) { global $link_to_direction_images; global $link_to_service_images; if (!ArrayElemIsValidStr($assoc, 'author_id') || !ArrayElemIsValidStr($assoc, 'name') || !ArrayElemIsValidStr($assoc, 'text_block')) { return NULL; } $dir = new self(); if (ArrayElemIsValidStr($assoc, 'id')) { $dir->id = $assoc['id']; } else { $dir->id = id_undef; } $dir->author_id = $assoc['author_id']; $dir->name = $assoc['name']; $dir->text_block = $assoc['text_block']; if (ArrayElemIsValidStr($assoc, 'language')) { $dir->language = $assoc['language']; } try { if (ArrayElemIsValidStr($assoc, 'creating_date')) { $dir->creating_date = strtotime($assoc['creating_date']); } else { $dir->creating_date = time_undef; } } catch (Exception $e) { $dir->creating_date = time_undef; } if (ArrayElemIsValidStr($assoc, 'language')) { global $image_extensions; $dir->path_to_image = PathToImage($link_to_direction_images . $dir->id, 'cover', $link_to_service_images . 'Logo.png', $image_extensions, $dir->language); } else { $dir->path_to_image = PathToImage($link_to_direction_images . $dir->id, 'cover', $link_to_service_images . 'Logo.png'); } return $dir; }
function special_callback($kw, $rc) { extract($kw, EXTR_PREFIX_ALL, 't'); $special = array(); $is_assoc = false; $class_parent = NULL; if (isset($t_special)) { $special = $t_special; } if (isset($t_is_assoc)) { $is_assoc = $t_is_assoc; } if (isset($t_class_parent)) { $class_parent = $t_class_parent; } $res_count = count($rc); for ($i = 0, $count = count($special); $i < $count; ++$i) { switch ($special[$i]) { case 'author_link': if ($is_assoc === false) { break; } for ($j = 0; $j < $res_count; ++$j) { if (isset($rc[$j]['author_id'])) { $rc[$j]['author_link'] = User::FetchBy(['select_list' => 'id, name, surname', 'eq_conds' => ['id' => $rc[$j]['author_id']], 'is_unique' => true])->LinkToThis('btn-sm'); } } break; case 'link_to_full': if ($is_assoc === false) { break; } for ($j = 0; $j < $res_count; ++$j) { if (isset($rc[$j]['id']) && isset($rc[$j]['name'])) { $rc[$j]['link_to_full'] = $class_parent::LinkToThisUnsafe($rc[$j]['id'], $rc[$j]['name'], 'btn-sm', array('style' => 'color: black;')); } } break; case 'full_vers_link': if ($is_assoc === false) { break; } for ($j = 0; $j < $res_count; ++$j) { if (isset($rc[$j]['id'])) { $rc[$j]['full_vers_link'] = $class_parent::ToHTMLFullVersUnsafe($rc[$j]['id'], true); } } break; case 'path_to_image': global $image_extensions; global $link_to_article_images; global $link_to_service_images; if ($is_assoc) { for ($j = 0; $j < $res_count; ++$j) { if (!isset($rc[$j]['id'])) { continue; } $path = PathToImage($link_to_article_images . $rc[$j]['id'], 'cover', $link_to_service_images . 'Logo.png', $image_extensions, GetLanguage()); $rc[$j]['path_to_image'] = $path; } } else { for ($j = 0; $j < $res_count; ++$j) { $path = PathToImage($link_to_article_images . $rc[$j]->GetID(), 'cover', $link_to_service_images . 'Logo.png', $image_extensions, GetLanguage()); $rc[$j]['path_to_image'] = $path; } } break; default: break; } } return $rc; }
public static function FetchFromAssoc($assoc) { global $link_to_users_images; $ob = new self(); if (ArrayElemIsValidStr($assoc, 'id')) { $ob->SetID($assoc['id']); } if (ArrayElemIsValidStr($assoc, 'name')) { $ob->SetName($assoc['name']); } if (ArrayElemIsValidStr($assoc, 'surname')) { $ob->SetSurname($assoc['surname']); } if (ArrayElemIsValidStr($assoc, 'fathername')) { $ob->SetFathername($assoc['fathername']); } if (ArrayElemIsValidStr($assoc, 'login')) { $ob->SetLogin($assoc['login']); } if (ArrayElemIsValidStr($assoc, 'password')) { $ob->SetPassword($assoc['password']); } if (ArrayElemIsValidStr($assoc, 'position')) { $ob->SetPosition($assoc['position']); } if (isset($assoc['received_reports'])) { if (is_string($assoc['received_reports'])) { if ($assoc['received_reports'] === '') { $ob->received_reports = []; } else { $ob->SetReceivedReports(json_decode($assoc['received_reports'])); } } else { if ($assoc['received_reports'] != NULL) { $ob->SetReceivedReports($assoc['received_reports']); } else { $ob->received_reports = []; } } } else { $ob->received_reports = []; } if (isset($assoc['sended_reports'])) { if (is_string($assoc['sended_reports'])) { if ($assoc['sended_reports'] === '') { $ob->sended_reports = []; } else { $ob->SetSendedReports(json_decode($assoc['sended_reports'])); } } else { if ($assoc['sended_reports'] != NULL) { $ob->SetSendedReports($assoc['sended_reports']); } else { $ob->sended_reports = []; } } } else { $ob->sended_reports = []; } if (ArrayElemIsValidStr($assoc, 'email')) { $ob->SetEmail($assoc['email']); } if (ArrayElemIsValidStr($assoc, 'telephone')) { $ob->SetTelephone($assoc['telephone']); } try { if (ArrayElemIsValidStr($assoc, 'last_visit_time')) { $ob->SetLastVisitTime(strtotime($assoc['last_visit_time'])); } if (ArrayElemIsValidStr($assoc, 'register_time')) { $ob->SetRegisterTime(strtotime($assoc['register_time'])); } if (ArrayElemIsValidStr($assoc, 'birthday')) { $ob->SetBirthday(strtotime($assoc['birthday'])); } } catch (Exception $e) { $ob->last_visit_time = time_undef; $ob->register_time = time_undef; $ob->birthday = time_undef; } if (ArrayElemIsValidStr($assoc, 'id')) { $ob->SetPathToPhoto(PathToImage($link_to_users_images . $ob->id, 'avatar', $link_to_users_images . 'common/default_avatar.png')); } return $ob; }