注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

天上人间*bobo之家

有阳光的时段,就有他(她)的博客文章。也许天气并非晴空万里,博主的“博物钟”却是

 
 
 

日志

 
 

typo3文件操作类  

2010-03-02 16:05:22|  分类: typo3 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
                $file1 = t3lib_div::tempnam('file');
                t3lib_div::writeFile($file1,$sFileContent);
                t3lib_div::upload_copy_move($file1,'../../../../fileadmin/export_user/feusers.'.$export_type);
                unlink($file1);

附xls,csv,export方法:
   /**
     * write the file for export
     *
     * @return    file data
     */
    function writeFile()
    {
        global $LANG;

        $sSelectCol = array();
        $sSelectUsg = array();
        $sFirstLine = array();
        $sFileContent = '';

        foreach ($this->getColumns() as $sCol){
            if (t3lib_div::GPvar('col_'.$sCol)){
                array_push($sSelectCol, $sCol);
                array_push($sFirstLine, 'col_'.$sCol);
            }
        }

        foreach ($this->getUsergroups() as $sUsg){
            if (t3lib_div::GPvar('usg_'.$sUsg['uid'])){
                array_push($sSelectUsg, $sUsg['uid']);
            }
        }

        if (count($sSelectCol) > 0 && count($sSelectUsg)>0 && t3lib_div::GPvar('export_type') != ''){

            $aResult = $this->getSqlQueryData(implode(',', $sSelectCol), 'fe_users', 'usergroup='.implode(',', $sSelectUsg));

            if (!empty($aResult)){

                if (t3lib_div::GPvar('export_type') == 'csv'){
                    foreach ($sFirstLine as $sF){
                        $colname = ($LANG->getLL($sF)) ? $LANG->getLL($sF) : '['.$sF.']';
                        $sFileContent .= '"'.$colname.'";';
                    }
                    $sFileContent .= "\n";
                    foreach ($aResult as $aR) $sFileContent .= '"'.implode('";"', array_values($aR)).'";'."\n";
                    $export_type = 'csv';
                } elseif (t3lib_div::GPvar('export_type') == 'xls'){
                    $sFileContent .=
                        '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
                            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                            <html>
                                <head>
                                    <meta http-equiv="Content-type" content="text/html;charset=utf-8" />
                                    <style id="Classeur1_16681_Styles">
                                    </style>
                                </head>
                                <body>
                                    <div id="Classeur1_16681" align=center x:publishsource="Excel">
                                        <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse"><tr>';

                    foreach ($sFirstLine as $sF){
                        $colname = ($LANG->getLL($sF)) ? $LANG->getLL($sF) : '['.$sF.']';
                        $sFileContent .= '<td class=xl2216681 nowrap>'.$colname.'</td>';
                    }
                    $sFileContent .= '</tr>';
                    foreach ($aResult as $aR) $sFileContent .= '<tr><td class=xl2216681 nowrap>'.implode('</td><td class=xl2216681 nowrap>', array_values($aR)).'</td></tr>';
                    $sFileContent .= '</table></div></body></html>';
                    $export_type = 'xls';
                }

                $file1 = t3lib_div::tempnam('file');
                t3lib_div::writeFile($file1,$sFileContent);
                t3lib_div::upload_copy_move($file1,'../../../../fileadmin/export_user/feusers.'.$export_type);
                unlink($file1);

                $output =
                    '<table cellpadding="0" cellspcing="0">
                        <tr>
                            <td style="padding-right: 5px;"><img src="moduleicon.gif" alt="Download" /></td>
                            <td style="font-size: 14px; font-weight: bold;">'.$LANG->getLL('download_file').':</td>
                            <td style="padding-left: 10px;" colspan="2"><a style="text-decoration: underline; font-size: 14px; font-weight: bold;" href="../../../../fileadmin/export_user/feusers.'.$export_type.'" >feusers.'.$export_type.'</a></td>
                        </tr>
                    </table>';

                return $output;

            } else return '<span style="color: red; font-weight: bold; font-size: 14px;">'.$LANG->getLL('error').': '.$LANG->getLL('error_nofeuser').'</span>';

        } else return '<span style="color: red; font-weight: bold; font-size: 14px;">'.$LANG->getLL('error').': '.$LANG->getLL('error_nodata').'</span>';

    }
  评论这张
 
阅读(107)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018