Changeset 15759 for trunk/templates
- Timestamp:
- 12/14/11 01:11:37 (6 months ago)
- Location:
- trunk/templates
- Files:
-
- 4 edited
-
base/css/common.css (modified) (1 diff)
-
base/scripts/BxBaseFunctions.php (modified) (19 diffs)
-
base/scripts/BxBaseGrid.php (modified) (3 diffs)
-
tmpl_uni/scripts/BxTemplFunctions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/templates/base/css/common.css
r15752 r15759 311 311 } 312 312 313 314 313 /* --------------- button at the end of cut string */ 314 315 .bx-str-limit { 316 height:10px; 317 width:14px; 318 margin-left:3px; 319 320 border-radius:3px; 321 -moz-border-radius:3px; 322 -webkit-border-radius:3px; 323 324 -moz-box-shadow:0px 0px 1px rgba(92, 92, 92, 0.8); 325 -webkit-box-shadow:0px 0px 1px rgba(92, 92, 92, 0.8); 326 box-shadow:0px 0px 1px rgba(92, 92, 92, 0.8); 327 328 cursor:pointer; 329 } 330 331 /* --------------- */ -
trunk/templates/base/scripts/BxBaseFunctions.php
r15750 r15759 7 7 defined('BX_DOL') or die('hack attempt'); 8 8 9 bx_import('BxDolTemplate'); 10 9 11 class BxBaseFunctions extends BxDol { 10 12 11 var $aSpecialKeys; 12 13 function BxBaseFunctions() { 13 protected $_aSpecialKeys; 14 protected $_oTemplate; 15 16 function BxBaseFunctions($oTemplate) { 14 17 15 18 if (isset($GLOBALS['bxDolClasses'][get_class($this)])) 16 19 trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR); 17 20 18 parent::BxDol(); 19 $this -> aSpecialKeys = array('rate' => '', 'rate_cnt' => ''); 21 parent::BxDol(); 22 23 if ($oTemplate) 24 $this->_oTemplate = $oTemplate; 25 else 26 $this->_oTemplate = BxDolTemplate::getInstance(); 27 28 $this->_aSpecialKeys = array('rate' => '', 'rate_cnt' => ''); 20 29 } 21 30 … … 82 91 $sKeyValue = trim($sKeyValue, '{}'); 83 92 84 if ( array_key_exists($sKeyValue, $this ->aSpecialKeys) ) {93 if ( array_key_exists($sKeyValue, $this->_aSpecialKeys) ) { 85 94 return $aRow['Eval']; 86 95 } else { … … 105 114 'extended_action' => $sScriptAction, 106 115 ); 107 108 bx_import('BxDolTemplate'); 109 $sOutputHtml .= BxDolTemplate::getInstance() -> parseHtmlByName( $aUsedTemplate['action'], $aTemplateKeys ); 116 117 $sOutputHtml .= $this->_oTemplate->parseHtmlByName( $aUsedTemplate['action'], $aTemplateKeys ); 110 118 } 111 119 } … … 128 136 // replace all founded markers ; 129 137 foreach( $aMatches[3] as $iMarker => $sMarkerValue ) { 130 if ( is_array($aMemberSettings) and array_key_exists($sMarkerValue, $aMemberSettings) and !array_key_exists($sMarkerValue, $this ->aSpecialKeys) ){138 if ( is_array($aMemberSettings) and array_key_exists($sMarkerValue, $aMemberSettings) and !array_key_exists($sMarkerValue, $this->_aSpecialKeys) ){ 131 139 $sTransformText = str_replace( '{' . $sMarkerValue . '}', $aMemberSettings[$sMarkerValue], $sTransformText); 132 140 } else if ( $sMarkerValue == 'evalResult' and $sExecuteCode ) { … … 136 144 } else { 137 145 // if isset into special keys ; 138 if ( array_key_exists($sMarkerValue, $this ->aSpecialKeys) ) {146 if ( array_key_exists($sMarkerValue, $this->_aSpecialKeys) ) { 139 147 return $aMemberSettings[$sMarkerValue]; 140 148 } else { … … 159 167 $iId = mktime() . mt_rand(1, 1000); 160 168 161 bx_import('BxDolTemplate'); 162 return BxDolTemplate::getInstance()->parseHtmlByName('messageBox.html', array( 169 return $this->_oTemplate->parseHtmlByName('messageBox.html', array( 163 170 'id' => $iId, 164 171 'msgText' => $sText, … … 175 182 176 183 function loadingBox($sName) { 177 bx_import('BxDolTemplate'); 178 return BxDolTemplate::getInstance()->parseHtmlByName('loading.html', array( 184 return $this->_oTemplate->parseHtmlByName('loading.html', array( 179 185 'name' => $sName, 180 186 )); … … 219 225 ); 220 226 221 bx_import('BxDolTemplate'); 222 return BxDolTemplate::getInstance()->parseHtmlByName('popup_box.html', array( 227 return $this->_oTemplate->parseHtmlByName('popup_box.html', array( 223 228 'id' => $iId, 224 229 'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '', … … 230 235 231 236 function transBox($content, $isPlaceInCenter = false) { 232 bx_import('BxDolTemplate');233 237 return 234 238 ($isPlaceInCenter ? '<div class="login_ajax_wrap">' : '') . 235 BxDolTemplate::getInstance()->parseHtmlByName('popup_trans.html', array('content' => $content)) .239 $this->_oTemplate->parseHtmlByName('popup_trans.html', array('content' => $content)) . 236 240 ($isPlaceInCenter ? '</div>' : ''); 237 241 } … … 349 353 } 350 354 351 bx_import('BxDolTemplate'); 352 return BxDolTemplate::getInstance()->parseHtmlByName($bCouple ? "thumbnail_couple.html" : "thumbnail_single.html", $aVariables); 355 return $this->_oTemplate->parseHtmlByName($bCouple ? "thumbnail_couple.html" : "thumbnail_single.html", $aVariables); 353 356 } 354 357 … … 367 370 } 368 371 369 function getTemplateIcon($sName) { 370 bx_import('BxDolTemplate'); 371 $oSysTemplate = BxDolTemplate::getInstance(); 372 373 $sUrl = $oSysTemplate->getIconUrl($sName); 374 return !empty($sUrl) ? $sUrl : $oSysTemplate->getIconUrl('spacer.gif'); 372 function getTemplateIcon($sName) { 373 $sUrl = $this->_oTemplate->getIconUrl($sName); 374 return !empty($sUrl) ? $sUrl : $this->_oTemplate->getIconUrl('spacer.gif'); 375 375 } 376 376 377 377 function getTemplateImage($sName) { 378 bx_import('BxDolTemplate'); 379 $oSysTemplate = BxDolTemplate::getInstance(); 380 381 $sUrl = $oSysTemplate->getImageUrl($sName); 382 return !empty($sUrl) ? $sUrl : $oSysTemplate->getImageUrl('spacer.gif'); 378 $sUrl = $this->_oTemplate->getImageUrl($sName); 379 return !empty($sUrl) ? $sUrl : $this->_oTemplate->getImageUrl('spacer.gif'); 383 380 } 384 381 … … 391 388 */ 392 389 function genObjectsActions( &$aKeys, $sActionsType, $bSubMenuMode = false ) { 393 bx_import('BxDolTemplate');394 $oSysTemplate = BxDolTemplate::getInstance();395 390 396 391 // ** init some needed variables ; … … 491 486 // is there any value to having this template even if the ID is empty? 492 487 if ( !empty($aKeys['ID']) ) { 493 $sResponceBlock = $ oSysTemplate ->parseHtmlByName( $aUsedTemplate['ajaxy_popup'], array('object_id' => $aKeys['ID']) );488 $sResponceBlock = $this->_oTemplate->parseHtmlByName( $aUsedTemplate['ajaxy_popup'], array('object_id' => $aKeys['ID']) ); 494 489 } 495 490 … … 499 494 ); 500 495 501 $sActionsList = $ oSysTemplate ->parseHtmlByName( $aUsedTemplate['actions'], $aTemplateKeys );496 $sActionsList = $this->_oTemplate->parseHtmlByName( $aUsedTemplate['actions'], $aTemplateKeys ); 502 497 } 503 498 … … 577 572 ); 578 573 579 bx_import('BxDolTemplate'); 580 $sOutputHtml = BxDolTemplate::getInstance() -> parseHtmlByName( 'menu_bottom.html', $aTemplateKeys ); 574 $sOutputHtml = $this->_oTemplate->parseHtmlByName( 'menu_bottom.html', $aTemplateKeys ); 581 575 582 576 if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->endMenu('Bottom Menu'); … … 613 607 * @param $iRssNum - numbr of rss items to disolay 614 608 * @param $iMemberId - optional member id 615 * @param $oTemplate - optional template object, BxDolTemplate singleton is used by default616 609 */ 617 function getRssHolder ($mixedRssId, $iRssNum, $iMemberId = 0, $oTemplate = false) { 618 619 if (!$oTemplate) 620 $oTemplate = BxDolTemplate::getInstance(); 610 function getRssHolder ($mixedRssId, $iRssNum, $iMemberId = 0) { 611 621 612 622 613 if (!isset($GLOBALS['gbBxSysIsRssInitialized']) || !$GLOBALS['gbBxSysIsRssInitialized']) { 623 614 624 $ oTemplate->addCss(array(615 $this->_oTemplate->addCss(array( 625 616 'rss.css', 626 617 )); 627 618 628 $ oTemplate->addJs(array(619 $this->_oTemplate->addJs(array( 629 620 'jquery.dolRSSFeed.js', 630 621 'jquery.jfeed.js' 631 622 )); 632 623 633 $ oTemplate->addInjection ('injection_head', 'text', '624 $this->_oTemplate->addInjection ('injection_head', 'text', ' 634 625 <script type="text/javascript" language="javascript"> 635 626 $(document).ready( function() { … … 641 632 } 642 633 643 return $ oTemplate->parseHtmlByName('rss_holder.html', array (634 return $this->_oTemplate->parseHtmlByName('rss_holder.html', array ( 644 635 'rss_id' => $mixedRssId, 645 636 'rss_num' => $iRssNum, … … 659 650 return ''; 660 651 661 bx_import('BxDolTemplate');662 $oTemplate = BxDolTemplate::getInstance();663 664 652 $sOutputCode = ''; 665 653 foreach( $aLangs as $sName => $sLang ) { 666 $sFlag = $ oTemplate->getIconUrl('sys_fl_' . $sName . '.gif');654 $sFlag = $this->_oTemplate->getIconUrl('sys_fl_' . $sName . '.gif'); 667 655 $aTemplateKeys = array ( 668 656 'bx_if:item_img' => array ( … … 681 669 ); 682 670 683 $sOutputCode .= $ oTemplate->parseHtmlByName( 'member_menu_sub_item.html', $aTemplateKeys );671 $sOutputCode .= $this->_oTemplate->parseHtmlByName( 'member_menu_sub_item.html', $aTemplateKeys ); 684 672 } 685 673 686 674 return $sOutputCode; 687 675 } 676 677 /** 678 * functions for limiting maximal string length 679 */ 680 function getStringWithLimitedLength($sString, $iWidth = 45, $isPopupOnOverflow = false) { 681 if (empty($sString) || mb_strlen($sString, 'UTF-8') <= $iWidth) 682 return $sString; 683 684 $sResult = ''; 685 $aWords = mb_split("[\s\r\n]", $sString); 686 $iPosition = 0; 687 $iWidthReal = $iWidth - 3; 688 $iWidthMin = $iWidth - 15; 689 foreach($aWords as $sWord) { 690 $sWord = trim($sWord); 691 $iWord = mb_strlen($sWord, 'UTF-8'); 692 if ($iPosition + $iWord <= $iWidthReal) { 693 // add word and continue 694 $sResult .= ' ' . $sWord; 695 $iPosition += 1 + $iWord; 696 continue; 697 } 698 699 // stop adding words 700 701 if (!$iPosition || $iPosition < $iWidthMin) { 702 // last word is too long, cut it 703 $sResult .= ' ' . mb_substr($sWord, 0, $iWidthReal - $iPosition - $iWord, 'UTF-8'); 704 } 705 706 if (!$isPopupOnOverflow) { 707 // add tripple dot 708 $sResult .= '...'; 709 } else { 710 711 // add button width popup 712 $sId = 'bx-str-limit-' . rand(1, PHP_INT_MAX ); 713 $sResult .= '<img class="bx-str-limit" onclick="$(\'#' . $sId . '\').dolPopup({pointer:{el:$(this)}})" src="' . $this->getTemplateImage('str-limit.png') . '"/>'; 714 $sResult .= '<div id="' . $sId . '" style="display:none;">' . BxTemplFunctions::getInstance()->transBox('<div class="bx-def-padding bx-def-color-bg-block">'.$sString.'</div>') . '</div>'; 715 } 716 717 break; 718 } 719 720 return trim($sResult); 721 } 688 722 } -
trunk/templates/base/scripts/BxBaseGrid.php
r15744 r15759 20 20 protected $_aPopupOptions = false; 21 21 protected $_aQueryAppend = false; 22 protected $_isDisplayPopupOnTextOverflow = true; 22 23 23 24 public function __construct ($aOptions, $oTemplate) { … … 357 358 358 359 $mixedValue = $this->_getCellData($sKey, $aField, $aRow); 360 $mixedValue = $this->_limitMaxLength($mixedValue, $sKey, $aField, $aRow, $this->_isDisplayPopupOnTextOverflow); 359 361 return $this->$sMethod($mixedValue, $sKey, $aField, $aRow); 360 362 } … … 479 481 } 480 482 483 protected function _limitMaxLength ($mixedValue, $sKey, $aField, $aRow, $isDisplayPopupOnTextOverflow) { 484 if ($aField['chars_limit'] > 0) { 485 bx_import('BxTemplFunctions'); 486 $mixedValue = BxTemplFunctions::getInstance()->getStringWithLimitedLength($mixedValue, $aField['chars_limit'], $isDisplayPopupOnTextOverflow); 487 } 488 return $mixedValue; 489 } 490 481 491 protected function _convertAttrs ($aField, $sAttrName, $sClasses = false, $sStyles = false) { 482 492 return bx_convert_array2attrs( -
trunk/templates/tmpl_uni/scripts/BxTemplFunctions.php
r15211 r15759 13 13 * class constructor 14 14 */ 15 function BxTemplFunctions() {16 parent:: BxBaseFunctions();15 function __construct($oTemplate = null) { 16 parent::__construct($oTemplate); 17 17 } 18 18 }
Note: See TracChangeset
for help on using the changeset viewer.