Показать сообщение отдельно
Старый 17.01.2008, 16:07   #3
Sergey M Nikitin
Administrator
 
Аватар для Sergey M Nikitin
 
Регистрация: 10.07.2007
Адрес: Moscow
Сообщений: 181
Отправить сообщение для Sergey M Nikitin с помощью ICQ Отправить сообщение для Sergey M Nikitin с помощью Skype™
По умолчанию Вдруг кому понадобится.

Функция возвращает список всех дочерних узлов для pidInList в CONTENT
Код:
smCntnt = CONTENT
smCntnt{
  table = smTable
  select{
    pidInList.cObject = USER
    pidInList.cObject{
      userFunc = user_commonfuns->childNodes
    }
  }
}
PHP код:
class user_commonfuns extends tslib_pibase{
    
//getChilds properties
    
var $uidList = array();
    var 
$uidCheckList = array();
    
    function 
arrayToCommaList($arr,$sep ","){
        foreach (
$arr as $v){
            
$result .= $v.",";
        }
        
$result rtrim($result,",");
        return 
$result;
    }
    
    
//Call from TS user_commonfuns->childNodes
    
function childNodes($conf,$content){
        global 
$TSFE;
        
$this->uidCheckList[] = $TSFE->id;
        
$this->getChilds();
        return 
$this->arrayToCommaList($this->uidList);
    }
    
    function 
getChilds(){
        
$curUid array_pop($this->uidCheckList);
        
$this->uidList[] = $curUid;

        
$query "SELECT uid FROM pages WHERE pid = ".$curUid." AND deleted <> 1 AND hidden <> 1";
        
$res $GLOBALS['TYPO3_DB']->sql(TYPO3_db$query);
        while(
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)){
            
$tempUids[] = $row['uid'];
            
$this->uidCheckList[] = $row['uid'];
        }
        if(
count($this->uidCheckList) != 0){
            
$this->getChilds();
        }
    }

__________________
nikitinsm.ru
Sergey M Nikitin вне форума   Ответить с цитированием