HomeHelpTrac

source: trunk/xmlrpc/BxDolXMLRPCProfileView.php @ 15393

Revision 15393, 2.4 KB checked in by Alexander Trofimov, 7 months ago (diff)

Ticket #2523

Line 
1<?php
2
3require_once( BX_DIRECTORY_PATH_BASE . 'scripts/BxBaseProfileView.php' );
4
5class BxDolXMLRPCProfileView extends BxBaseProfileGenerator
6{
7    function BxDolXMLRPCProfileView($iProfileId)
8    {
9        BxBaseProfileGenerator::BxBaseProfileGenerator ((int)$iProfileId);
10    }
11
12    function getProfileInfoExtra()
13    {
14        $aRet = array();
15        $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`");
16        while ($a = mysql_fetch_array($r))
17        {
18            $aBlock = $this->getProfileInfoBlock ($a['Caption'], $a['Content']);
19            if (false === $aBlock) continue;
20            $aRet[] = $aBlock;
21        }
22        return new xmlrpcval ($aRet, "array");
23    }
24
25    function getProfileInfoBlock($sCaption, $sContent) {
26        $iBlockID = (int)$sContent;
27
28        if( !isset( $this->aPFBlocks[$iBlockID] ) or empty( $this->aPFBlocks[$iBlockID]['Items'] ) )
29            return false;
30
31        $aItems = $this->aPFBlocks[$iBlockID]['Items'];
32
33
34        $aRet = array ();
35        foreach( $aItems as $aItem ) {
36
37            $sValue1 = $this->oPF->getViewableValue( $aItem, $this->_aProfile[ $aItem['Name'] ] );
38
39            if ($aItem['Name'] == 'Age')
40            {
41                $sValue1 = (isset($this->_aProfile['DateOfBirth'])) ? age($this->_aProfile['DateOfBirth']) : _t("_uknown");
42            }
43
44            if( !$sValue1 ) //if empty, do not draw
45                continue;
46
47            $aStruct = array ();
48
49            $aStruct['Caption'] = new xmlrpcval (strip_tags(_t($aItem['Caption'])));
50            $aStruct['Type'] = new xmlrpcval ($aItem['Type']);
51            $aStruct['Value1'] = new xmlrpcval (strip_tags($sValue1));
52
53            if ($this->bCouple)
54            {
55                if (!in_array( $aItem['Name'], $this->aCoupleMutualItems))
56                {
57                    $sValue2 = $this->oPF->getViewableValue($aItem, $this->_aCouple[$aItem['Name']]);
58                    $aStruct['Value2'] = new xmlrpcval (strip_tags($sValue2));
59                }
60            }
61
62            $aRet[] = new xmlrpcval ($aStruct, "struct");
63        }
64
65        return new xmlrpcval (array (
66            'Info' => new xmlrpcval ($aRet, "array"),
67            'Title' => new xmlrpcval (_t($sCaption)),
68        ), "struct");
69    }
70}
71
72?>
Note: See TracBrowser for help on using the repository browser.