BxDolXMLRPCProfileView.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once( BX_DIRECTORY_PATH_BASE . 'scripts/BxBaseProfileView.php' );
  3. class BxDolXMLRPCProfileView extends BxBaseProfileGenerator
  4. {
  5. function BxDolXMLRPCProfileView($iProfileId)
  6. {
  7. BxBaseProfileGenerator::BxBaseProfileGenerator ((int)$iProfileId);
  8. }
  9. function getProfileInfoExtra()
  10. {
  11. $aRet = array();
  12. $r = db_res ("SELECT `pc`.`Caption`, `pc`.`Content` FROM `sys_profile_fields` AS `pf` INNER JOIN `sys_page_compose` AS `pc` ON (`pc`.`Func` = 'PFBlock' AND `pc`.`Content` = `pf`.`ID`) WHERE `pc`.`Page` = 'profile' AND `pf`.`Type` = 'block' AND `pc`.`Column` != 0 ORDER BY `pc`.`Column`, `pc`.`Order`");
  13. while ($a = mysql_fetch_array($r))
  14. {
  15. $aBlock = $this->getProfileInfoBlock ($a['Caption'], $a['Content']);
  16. if (false === $aBlock) continue;
  17. $aRet[] = $aBlock;
  18. }
  19. return new xmlrpcval ($aRet, "array");
  20. }
  21. function getProfileInfoBlock($sCaption, $sContent) {
  22. $iBlockID = (int)$sContent;
  23. if( !isset( $this->aPFBlocks[$iBlockID] ) or empty( $this->aPFBlocks[$iBlockID]['Items'] ) )
  24. return false;
  25. $aItems = $this->aPFBlocks[$iBlockID]['Items'];
  26. $aRet = array ();
  27. foreach( $aItems as $aItem ) {
  28. $sValue1 = $this->oPF->getViewableValue( $aItem, $this->_aProfile[ $aItem['Name'] ] );
  29. if ($aItem['Name'] == 'Age')
  30. {
  31. $sValue1 = (isset($this->_aProfile['DateOfBirth'])) ? age($this->_aProfile['DateOfBirth']) : _t("_uknown");
  32. }
  33. if( !$sValue1 ) //if empty, do not draw
  34. continue;
  35. $aStruct = array ();
  36. $aStruct['Caption'] = new xmlrpcval (strip_tags(_t($aItem['Caption'])));
  37. $aStruct['Type'] = new xmlrpcval ($aItem['Type']);
  38. $aStruct['Value1'] = new xmlrpcval (strip_tags($sValue1));
  39. if ($this->bCouple)
  40. {
  41. if (!in_array( $aItem['Name'], $this->aCoupleMutualItems))
  42. {
  43. $sValue2 = $this->oPF->getViewableValue($aItem, $this->_aCouple[$aItem['Name']]);
  44. $aStruct['Value2'] = new xmlrpcval (strip_tags($sValue2));
  45. }
  46. }
  47. $aRet[] = new xmlrpcval ($aStruct, "struct");
  48. }
  49. return new xmlrpcval (array (
  50. 'Info' => new xmlrpcval ($aRet, "array"),
  51. 'Title' => new xmlrpcval (_t($sCaption)),
  52. ), "struct");
  53. }
  54. }
  55. ?>