Пример #1
0
 /**
  * Generate rss feed using any custom data fields
  * but you need to describe fields in $aFields array.
  *
  * Required fileds:
  *  Link
  *  Title
  *  DateTimeUTS
  *  Desc
  *
  * Optional fields:
  *  Photo
  */
 function GenRssByCustomData($aRssData, $sUnitTitleC, $sMainLink, $aFields, $sImage = '', $iPID = 0)
 {
     $sRSSLast = '';
     if (isset($aRssData[0])) {
         $sRSSLast = bx_time_utc($aRssData[0][$aFields['DateTimeUTS']]);
     }
     if ($iPID > 0) {
         $aPIDOwnerInfo = getProfileInfo($iPID);
     }
     $iUnitLimitChars = 2000;
     //(int)getParam('max_blog_preview');
     $sUnitRSSFeed = '';
     if ($aRssData) {
         foreach ($aRssData as $aUnitInfo) {
             $sUnitUrl = $aUnitInfo[$aFields['Link']];
             $sUnitGuid = $aUnitInfo[$aFields['Guid']];
             $sUnitTitle = strip_tags($aUnitInfo[$aFields['Title']]);
             $sUnitDate = bx_time_utc($aUnitInfo[$aFields['DateTimeUTS']]);
             $sLinkMore = '';
             if (strlen($aUnitInfo[$aFields['Desc']]) > $iUnitLimitChars) {
                 $sLinkMore = "... <a href=\"" . $sUnitUrl . "\">" . _t('_Read more') . "</a>";
             }
             $sUnitDescVal = mb_substr(strip_tags($aUnitInfo[$aFields['Desc']]), 0, $iUnitLimitChars) . $sLinkMore;
             $sUnitDesc = $sUnitDescVal;
             $sUnitRSSFeed .= "<item><title><![CDATA[{$sUnitTitle}]]></title><link><![CDATA[{$sUnitUrl}]]></link><guid><![CDATA[{$sUnitGuid}]]></guid><description><![CDATA[{$sUnitDesc}]]></description><pubDate>{$sUnitDate}</pubDate></item>";
         }
     }
     $sRSSTitle = _t('_RSS_Feed_Title_Common', $sUnitTitleC);
     if ($iPID > 0) {
         $sRSSTitle = _t('_RSS_Feed_Title_Profile', $aPIDOwnerInfo['NickName'], $sUnitTitleC);
     }
     if (substr($sMainLink, 0, 7) != 'http://' && substr($sMainLink, 0, 8) != 'https://') {
         $sMainLink = BX_DOL_URL_ROOT . $sMainLink;
     }
     $sRSSImage = '';
     if ($sImage) {
         $sRSSImage = "<image><url>{$sImage}</url><title>{$sRSSTitle}</title><link>{$sMainLink}</link></image>";
     }
     return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"><channel><title>{$sRSSTitle}</title><link><![CDATA[{$sMainLink}]]></link><description>{$sRSSTitle}</description><lastBuildDate>{$sRSSLast}</lastBuildDate>{$sRSSImage}{$sUnitRSSFeed}</channel></rss>";
 }
Пример #2
0
 /**
  * Output time wrapped in <time> tag in HTML.
  * Then time is autoformatted using JS upon page load, this is aumatically converted to user's timezone and
  * updated in realtime in case of short periods of 'from now' time format.
  *
  * Short version of this function:
  * @see bx_time_js
  *
  * @param $iUnixTimestamp time as unixtimestamp
  * @param $sFormatIdentifier output format identifier
  *     @see BX_FORMAT_DATE
  *     @see BX_FORMAT_TIME
  *     @see BX_FORMAT_DATE_TIME
  * @param $bForceFormat force provided format and don't use "from now" time autoformat.
  */
 function timeForJs($iUnixTimestamp, $sFormatIdentifier = BX_FORMAT_DATE, $bForceFormat = false)
 {
     $sDateUTC = bx_time_utc($iUnixTimestamp);
     return '<time datetime="' . $sDateUTC . '" data-bx-format="' . getParam($sFormatIdentifier) . '" data-bx-autoformat="' . ($bForceFormat ? 0 : getParam('sys_format_timeago')) . '">' . $sDateUTC . '</time>';
 }