作者 SHW\戥岁。。

商品详情规格购物车数量

... ... @@ -7,6 +7,11 @@ use app\api\model\Goods;
use app\common\controller\Backend;
use app\admin\model\litestore\Litestorespec as SpecModel;
use app\admin\model\litestore\Litestorespecvalue as SpecValueModel;
use PHPExcel;
use PHPExcel_Style;
use PHPExcel_Style_Alignment;
use PHPExcel_Style_Border;
use PHPExcel_Style_Fill;
use think\Db;
/**
... ... @@ -273,22 +278,20 @@ class Litestoregoods extends Backend
/**
* 导出
*/
public function clubpeople()
public function export()
{
//1.从数据库中导出需要进行要导出的数据
// $list = Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
// ,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
// where club_branch.club_id=:acc order by club_branch.club_branch_name ', ['acc' => $clubid]);
$goods = new Goods();
$list = $goods->select()->each(function (&$item){
// $;
});
if (empty($list)){
$list = Db::name('litestore_goods_spec')->alias('c')
->join('fa_litestore_goods g', 'g.goods_id = c.goods_id', 'LEFT')
->select();
// ->each(function (&$item) {
// $item['goods'] = Db::name('litestore_goods')
// ->where('goods_id', $item['goods_id'])->find();
// });
if (empty($list)) {
$this->error('没有可导出的数据');
}
// foreach ()
//重要补助
//2.加载PHPExcle类库
vendor('PHPExcel.PHPExcel');
... ... @@ -298,14 +301,15 @@ class Litestoregoods extends Backend
$objPHPExcel->setActiveSheetIndex(0);
//5.设置表格头(即excel表格的第一行)
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '部门')
->setCellValue('B1', '职位')
->setCellValue('C1', '学号')
->setCellValue('D1', '学生姓名')
->setCellValue('E1', '联系方式')
->setCellValue('F1', '邮箱')
->setCellValue('G1', '院系')
->setCellValue('H1', '专业');
->setCellValue('A1', '商品ID')
->setCellValue('B1', '商品名称')
->setCellValue('C1', '商品原价')
->setCellValue('D1', '折扣')
->setCellValue('E1', '商品现价')
->setCellValue('F1', '已销数量')
->setCellValue('G1', '导出时间');
// ->setCellValue('G1', '院系')
// ->setCellValue('H1', '专业');
//设置A列水平居中
$objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
... ... @@ -313,32 +317,164 @@ class Litestoregoods extends Backend
//6.循环刚取出来的数组,将数据逐一添加到excel表格。
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(10);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20);
for ($i = 0; $i < count($list); $i++) {
$objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $list[$i]['club_branch_name']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $list[$i]['club_position']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $list[$i]['stu_number']);//防伪码
$objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $list[$i]['stu_name']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $list[$i]['stu_phone']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $list[$i]['stu_email']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $list[$i]['stu_department']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $list[$i]['stu_profess']);//防伪码
$objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $list[$i]['goods_id']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $list[$i]['goods_name']);//商品名称
$objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $list[$i]['line_price']);//原价
$objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $list[$i]['discount']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $list[$i]['goods_price']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $list[$i]['goods_sales']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), datetime(time()));//标签码
}
//7.设置保存的Excel表格名称
$filename = $club_name . '人员名单' . date('ymd', time()) . '.xls';
//8.设置当前激活的sheet表格名称;
$objPHPExcel->getActiveSheet()->setTitle('人员名单');
//9.设置浏览器窗口下载表格
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="' . $filename . '"');
//生成excel文件
// $filename = '商品信息' . date('ymd', time()) . '.xls';
// //8.设置当前激活的sheet表格名称;
// $objPHPExcel->getActiveSheet()->setTitle('商品信息');
// //9.设置浏览器窗口下载表格
ob_end_clean();
ob_start();
// header("Content-Type: application/force-download");
// header("Content-Type: application/octet-stream");
// header("Content-Type: application/download");
// header('Content-Disposition:inline;filename="' . $filename . '"');
//// header("Pragma: public");
//// header("Expires: 0");
////// header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
////// header("Content-Type:application/force-download");
////// header("Content-Type:application/vnd.ms-execl");
////// header("Content-Type:application/octet-stream");
////// header("Content-Type:application/download");;
////// header('Content-Disposition:attachment;filename='.$filename.'');
////// header("Content-Transfer-Encoding:binary");
////// //生成excel文件
////// $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
////// ini_set('display_errors', TRUE);
////// ini_set('display_startup_errors', TRUE);
//// header('pragma:public');
//// header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $filename . '.xls"');
//// header("Content-Disposition:inline;filename=$filename.xls"); //attachment新窗口打印inline本窗口打印
// $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
// $objWriter->save('php://output');
$title = 'ahhah';
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $title . '.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
//下载文件在浏览器窗口
$objWriter->save('php://output');
exit;
$objWriter->save('php://output'); //文件通过浏览器下载
exit();
}
// public function export()
// {
// if ($this->request->isPost()) {
// set_time_limit(0);
// $search = $this->request->post('search');
// $ids = $this->request->post('ids');
// $filter = $this->request->post('filter');
// $op = $this->request->post('op');
// $columns = $this->request->post('columns');
//
// $excel = new PHPExcel();
//
// $excel->getProperties()
// ->setCreator("FastAdmin")
// ->setLastModifiedBy("FastAdmin")
// ->setTitle("标题")
// ->setSubject("Subject");
// $excel->getDefaultStyle()->getFont()->setName('Microsoft Yahei');
// $excel->getDefaultStyle()->getFont()->setSize(12);
//
// $this->sharedStyle = new PHPExcel_Style();
// $this->sharedStyle->applyFromArray(
// array(
// 'fill' => array(
// 'type' => PHPExcel_Style_Fill::FILL_SOLID,
// 'color' => array('rgb' => '000000'),
// ),
// 'font' => array(
// 'color' => array('rgb' => "000000"),
// ),
// 'alignment' => array(
// 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
// 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
// 'indent' => 1,
// ),
// 'borders' => array(
// 'allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
// ),
// ));
//
// $worksheet = $excel->setActiveSheetIndex(0);
// $worksheet->setTitle('标题');
//
// $whereIds = $ids == 'all' ? '1=1' : ['id' => ['in', explode(',', $ids)]];
// $this->request->get(['search' => $search, 'ids' => $ids, 'filter' => $filter, 'op' => $op]);
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
//
// $line = 1;
// $list = [];
// $this->model
// ->field($columns)
// ->where($where)
// ->where($whereIds)
// ->chunk(100, function ($items) use (&$list, &$line, &$worksheet) {
// $styleArray = array(
// 'font' => array(
// 'bold' => true,
// 'color' => array('rgb' => 'FF0000'),
// 'size' => 15,
// 'name' => 'Verdana',
// ));
// $list = $items = collection($items)->toArray();
// foreach ($items as $index => $item) {
// $line++;
// $col = 0;
// foreach ($item as $field => $value) {
//
// $worksheet->setCellValueByColumnAndRow($col, $line, $value);
// $worksheet->getStyleByColumnAndRow($col, $line)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
// $worksheet->getCellByColumnAndRow($col, $line)->getStyle()->applyFromArray($styleArray);
// $col++;
// }
// }
// });
// $first = array_keys($list[0]);
// foreach ($first as $index => $item) {
// $worksheet->setCellValueByColumnAndRow($index, 1, __($item));
// }
//
// $excel->createSheet();
// // Redirect output to a client’s web browser (Excel2007)
// $title = date("YmdHis");
// header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// header('Content-Disposition: attachment;filename="' . $title . '.xlsx"');
// header('Cache-Control: max-age=0');
// // If you're serving to IE 9, then the following may be needed
// header('Cache-Control: max-age=1');
//
// // If you're serving to IE over SSL, then the following may be needed
// header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
// header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
// header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
// header('Pragma: public'); // HTTP/1.0
//
// $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
// $objWriter->save('php://output');
// return;
// }
// }
}
... ...
... ... @@ -23,8 +23,10 @@
data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i>
{:__('Import')}</a>
<a href="javascript:;"
class="btn btn-info btn-edit btn-sync"
class="btn btn-info btn-change btn-export btn-disable" data-params="action=export"
data-url="litestore/litestoregoods/export"
title="{:__('批量导出')}"><i class="fa fa-download"></i>{:__('批量导出')}</a>
<!-- <a href="javascript:;" class="btn btn-info btn-export {:$auth->check('litestore/litestoregoods/export')?'':'hide'}" title="{:__('Export')}" id="btn-export-file"><i class="fa fa-download"></i> {:__('Export')}</a>-->
<!-- <div class="dropdown btn-group {:$auth->check('litestore/litestoregoods/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
... ...
... ... @@ -150,6 +150,15 @@ class Goods extends Api
}
$goods_spec = GoodsSpec::all(['goods_id' => $goods_id]);
foreach ($goods_spec as &$value) {
//规格下的购物车数量
if ($this->auth->isLogin()) {
$number = Db::name('cart')
->where(['goods_id' => $value['goods_id'], 'sku_id' => $value['goods_spec_id'], 'user_id' => $this->auth->id])
->value('number');
$value['cart_number'] = $number ?? 0;
} else {
$value['cart_number'] = 0;
}
//判断是否打折
$value['is_discount'] = 'is';
if ($value['goods_price'] == $value['line_price']) {
... ...
... ... @@ -32,7 +32,8 @@
"ext-bcmath": "*",
"txthinking/mailer": "^2.0",
"workerman/phpsocket.io": "^1.1",
"phpoffice/phpexcel": "^1.8"
"phpoffice/phpexcel": "^1.8",
"ext-iconv": "*"
},
"config": {
"preferred-install": "dist"
... ...
... ... @@ -94,23 +94,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
// 为表格绑定事件
Table.api.bindevent(table);
$('.btn-sync').click(function () {
var index = Layer.load();
$.ajax({
type: "POST",
msg: "确认导出吗?导出过程请勿关闭",
url: "litestore/litestoregoods/zdy_export",
datatype: "json",
success: function (data) {
Layer.close(index);
Layer.alert(data.msg);
},
error: function () {
Layer.close(index);
console.log('btn-course-scheduling setInterval error');
}
});
});
$(document).on("click", ".btn-export", function () {
var all = table.bootstrapTable('getOptions').totalRows;
// Fast.api.fixurl("litestore/litestoregoods/export")
Table.api.multi("changestatus", all.join(","), table, this);
}
);
table.on('load-success.bs.table', function (data) {
$(".btn-editone").data("area", ["1000px", "800px"]);
});
... ... @@ -205,7 +194,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
});
},
}
,
edit: function () {
//Controller.api.bindevent();
... ... @@ -294,7 +284,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
$goodsSpecMany.show() && $goodsSpecSingle.hide();
}
});
},
}
,
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
... ... @@ -302,4 +293,5 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
}
};
return Controller;
});
\ No newline at end of file
})
;
\ No newline at end of file
... ...
... ... @@ -21,69 +21,69 @@
/**
* Array for storing OLE instances that are accessed from
* OLE_ChainedBlockStream::stream_open().
* @var array
*/
* Array for storing OLE instances that are accessed from
* OLE_ChainedBlockStream::stream_open().
* @var array
*/
$GLOBALS['_OLE_INSTANCES'] = array();
/**
* OLE package base class.
*
* @author Xavier Noguer <xnoguer@php.net>
* @author Christian Schmidt <schmidt@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
* OLE package base class.
*
* @author Xavier Noguer <xnoguer@php.net>
* @author Christian Schmidt <schmidt@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE
{
const OLE_PPS_TYPE_ROOT = 5;
const OLE_PPS_TYPE_DIR = 1;
const OLE_PPS_TYPE_FILE = 2;
const OLE_PPS_TYPE_ROOT = 5;
const OLE_PPS_TYPE_DIR = 1;
const OLE_PPS_TYPE_FILE = 2;
const OLE_DATA_SIZE_SMALL = 0x1000;
const OLE_LONG_INT_SIZE = 4;
const OLE_PPS_SIZE = 0x80;
const OLE_LONG_INT_SIZE = 4;
const OLE_PPS_SIZE = 0x80;
/**
* The file handle for reading an OLE container
* @var resource
*/
*/
public $_file_handle;
/**
* Array of PPS's found on the OLE container
* @var array
*/
* Array of PPS's found on the OLE container
* @var array
*/
public $_list = array();
/**
* Root directory of OLE container
* @var OLE_PPS_Root
*/
*/
public $root;
/**
* Big Block Allocation Table
* @var array (blockId => nextBlockId)
*/
*/
public $bbat;
/**
* Short Block Allocation Table
* @var array (blockId => nextBlockId)
*/
*/
public $sbat;
/**
* Size of big blocks. This is usually 512.
* @var int number of octets per block.
*/
*/
public $bigBlockSize;
/**
* Size of small blocks. This is usually 64.
* @var int number of octets per block
*/
*/
public $smallBlockSize;
/**
... ... @@ -92,7 +92,7 @@ class PHPExcel_Shared_OLE
* @acces public
* @param string $file
* @return mixed true on success, PEAR_Error on failure
*/
*/
public function read($file)
{
$fh = fopen($file, "r");
... ... @@ -111,8 +111,8 @@ class PHPExcel_Shared_OLE
throw new PHPExcel_Reader_Exception("Only Little-Endian encoding is supported.");
}
// Size of blocks and short blocks in bytes
$this->bigBlockSize = pow(2, self::_readInt2($fh));
$this->smallBlockSize = pow(2, self::_readInt2($fh));
$this->bigBlockSize = pow(2, self::_readInt2($fh));
$this->smallBlockSize = pow(2, self::_readInt2($fh));
// Skip UID, revision number and version number
fseek($fh, 44);
... ... @@ -134,7 +134,7 @@ class PHPExcel_Shared_OLE
$mbatFirstBlockId = self::_readInt4($fh);
// Number of blocks in Master Block Allocation Table
$mbbatBlockCount = self::_readInt4($fh);
$this->bbat = array();
$this->bbat = array();
// Remaining 4 * 109 bytes of current block is beginning of Master
// Block Allocation Table
... ... @@ -165,9 +165,9 @@ class PHPExcel_Shared_OLE
}
// Read short block allocation table (SBAT)
$this->sbat = array();
$this->sbat = array();
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
$sbatFh = $this->getStream($sbatFirstBlockId);
$sbatFh = $this->getStream($sbatFirstBlockId);
for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) {
$this->sbat[$blockId] = self::_readInt4($sbatFh);
}
... ... @@ -179,8 +179,8 @@ class PHPExcel_Shared_OLE
}
/**
* @param int block id
* @param int byte offset from beginning of file
* @param int block id
* @param int byte offset from beginning of file
* @access public
*/
public function _getBlockOffset($blockId)
... ... @@ -189,11 +189,11 @@ class PHPExcel_Shared_OLE
}
/**
* Returns a stream for use with fread() etc. External callers should
* use PHPExcel_Shared_OLE_PPS_File::getStream().
* @param int|PPS block id or PPS
* @return resource read-only stream
*/
* Returns a stream for use with fread() etc. External callers should
* use PHPExcel_Shared_OLE_PPS_File::getStream().
* @param int|PPS block id or PPS
* @return resource read-only stream
*/
public function getStream($blockIdOrPps)
{
static $isRegistered = false;
... ... @@ -206,7 +206,7 @@ class PHPExcel_Shared_OLE
// in OLE_ChainedBlockStream::stream_open().
// Object is removed from self::$instances in OLE_Stream::close().
$GLOBALS['_OLE_INSTANCES'][] = $this;
$instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES']));
$instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES']));
$path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId;
if ($blockIdOrPps instanceof PHPExcel_Shared_OLE_PPS) {
... ... @@ -220,7 +220,7 @@ class PHPExcel_Shared_OLE
/**
* Reads a signed char.
* @param resource file handle
* @param resource file handle
* @return int
* @access public
*/
... ... @@ -232,7 +232,7 @@ class PHPExcel_Shared_OLE
/**
* Reads an unsigned short (2 octets).
* @param resource file handle
* @param resource file handle
* @return int
* @access public
*/
... ... @@ -244,7 +244,7 @@ class PHPExcel_Shared_OLE
/**
* Reads an unsigned long (4 octets).
* @param resource file handle
* @param resource file handle
* @return int
* @access public
*/
... ... @@ -255,27 +255,27 @@ class PHPExcel_Shared_OLE
}
/**
* Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one.
*
* @access public
* @param integer the block id of the first block
* @return mixed true on success, PEAR_Error on failure
*/
* Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one.
*
* @access public
* @param integer the block id of the first block
* @return mixed true on success, PEAR_Error on failure
*/
public function _readPpsWks($blockId)
{
$fh = $this->getStream($blockId);
for ($pos = 0;; $pos += 128) {
for ($pos = 0; ; $pos += 128) {
fseek($fh, $pos, SEEK_SET);
$nameUtf16 = fread($fh, 64);
$nameUtf16 = fread($fh, 64);
$nameLength = self::_readInt2($fh);
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
// Simple conversion from UTF-16LE to ISO-8859-1
$name = str_replace("\x00", "", $nameUtf16);
$type = self::_readInt1($fh);
switch ($type) {
case self::OLE_PPS_TYPE_ROOT:
$pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array());
$pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array());
$this->root = $pps;
break;
case self::OLE_PPS_TYPE_DIR:
... ... @@ -285,7 +285,7 @@ class PHPExcel_Shared_OLE
$pps = new PHPExcel_Shared_OLE_PPS_File($name);
break;
default:
continue;
break;
}
fseek($fh, 1, SEEK_CUR);
$pps->Type = $type;
... ... @@ -294,12 +294,12 @@ class PHPExcel_Shared_OLE
$pps->NextPps = self::_readInt4($fh);
$pps->DirPps = self::_readInt4($fh);
fseek($fh, 20, SEEK_CUR);
$pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
$pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
$pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
$pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
$pps->_StartBlock = self::_readInt4($fh);
$pps->Size = self::_readInt4($fh);
$pps->No = count($this->_list);
$this->_list[] = $pps;
$pps->Size = self::_readInt4($fh);
$pps->No = count($this->_list);
$this->_list[] = $pps;
// check if the PPS tree (starting from root) is complete
if (isset($this->root) && $this->_ppsTreeComplete($this->root->No)) {
... ... @@ -311,14 +311,14 @@ class PHPExcel_Shared_OLE
// Initialize $pps->children on directories
foreach ($this->_list as $pps) {
if ($pps->Type == self::OLE_PPS_TYPE_DIR || $pps->Type == self::OLE_PPS_TYPE_ROOT) {
$nos = array($pps->DirPps);
$nos = array($pps->DirPps);
$pps->children = array();
while ($nos) {
$no = array_pop($nos);
if ($no != -1) {
$childPps = $this->_list[$no];
$nos[] = $childPps->PrevPps;
$nos[] = $childPps->NextPps;
$childPps = $this->_list[$no];
$nos[] = $childPps->PrevPps;
$nos[] = $childPps->NextPps;
$pps->children[] = $childPps;
}
}
... ... @@ -329,33 +329,33 @@ class PHPExcel_Shared_OLE
}
/**
* It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root)
*
* @access public
* @param integer $index The index of the PPS from which we are checking
* @return boolean Whether the PPS tree for the given PPS is complete
*/
* It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root)
*
* @access public
* @param integer $index The index of the PPS from which we are checking
* @return boolean Whether the PPS tree for the given PPS is complete
*/
public function _ppsTreeComplete($index)
{
return isset($this->_list[$index]) &&
($pps = $this->_list[$index]) &&
($pps->PrevPps == -1 ||
($pps = $this->_list[$index]) &&
($pps->PrevPps == -1 ||
$this->_ppsTreeComplete($pps->PrevPps)) &&
($pps->NextPps == -1 ||
($pps->NextPps == -1 ||
$this->_ppsTreeComplete($pps->NextPps)) &&
($pps->DirPps == -1 ||
($pps->DirPps == -1 ||
$this->_ppsTreeComplete($pps->DirPps));
}
/**
* Checks whether a PPS is a File PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS
* @return bool true if it's a File PPS, false otherwise
*/
* Checks whether a PPS is a File PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS
* @return bool true if it's a File PPS, false otherwise
*/
public function isFile($index)
{
if (isset($this->_list[$index])) {
... ... @@ -365,13 +365,13 @@ class PHPExcel_Shared_OLE
}
/**
* Checks whether a PPS is a Root PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS.
* @return bool true if it's a Root PPS, false otherwise
*/
* Checks whether a PPS is a Root PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS.
* @return bool true if it's a Root PPS, false otherwise
*/
public function isRoot($index)
{
if (isset($this->_list[$index])) {
... ... @@ -381,48 +381,48 @@ class PHPExcel_Shared_OLE
}
/**
* Gives the total number of PPS's found in the OLE container.
*
* @access public
* @return integer The total number of PPS's found in the OLE container
*/
* Gives the total number of PPS's found in the OLE container.
*
* @access public
* @return integer The total number of PPS's found in the OLE container
*/
public function ppsTotal()
{
return count($this->_list);
}
/**
* Gets data from a PPS
* If there is no PPS for the index given, it will return an empty string.
*
* @access public
* @param integer $index The index for the PPS
* @param integer $position The position from which to start reading
* (relative to the PPS)
* @param integer $length The amount of bytes to read (at most)
* @return string The binary string containing the data requested
* @see OLE_PPS_File::getStream()
*/
* Gets data from a PPS
* If there is no PPS for the index given, it will return an empty string.
*
* @access public
* @param integer $index The index for the PPS
* @param integer $position The position from which to start reading
* (relative to the PPS)
* @param integer $length The amount of bytes to read (at most)
* @return string The binary string containing the data requested
* @see OLE_PPS_File::getStream()
*/
public function getData($index, $position, $length)
{
// if position is not valid return empty string
if (!isset($this->_list[$index]) || ($position >= $this->_list[$index]->Size) || ($position < 0)) {
return '';
}
$fh = $this->getStream($this->_list[$index]);
$fh = $this->getStream($this->_list[$index]);
$data = stream_get_contents($fh, $length, $position);
fclose($fh);
return $data;
}
/**
* Gets the data length from a PPS
* If there is no PPS for the index given, it will return 0.
*
* @access public
* @param integer $index The index for the PPS
* @return integer The amount of bytes in data the PPS has
*/
* Gets the data length from a PPS
* If there is no PPS for the index given, it will return 0.
*
* @access public
* @param integer $index The index for the PPS
* @return integer The amount of bytes in data the PPS has
*/
public function getDataLength($index)
{
if (isset($this->_list[$index])) {
... ... @@ -432,13 +432,13 @@ class PHPExcel_Shared_OLE
}
/**
* Utility function to transform ASCII text to Unicode
*
* @access public
* @static
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
* Utility function to transform ASCII text to Unicode
*
* @access public
* @static
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
public static function Asc2Ucs($ascii)
{
$rawname = '';
... ... @@ -449,14 +449,14 @@ class PHPExcel_Shared_OLE
}
/**
* Utility function
* Returns a string for the OLE container with the date given
*
* @access public
* @static
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
* Utility function
* Returns a string for the OLE container with the date given
*
* @access public
* @static
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
public static function LocalDate2OLE($date = null)
{
if (!isset($date)) {
... ... @@ -469,7 +469,7 @@ class PHPExcel_Shared_OLE
// days from 1-1-1601 until the beggining of UNIX era
$days = 134774;
// calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H", $date), date("i", $date), date("s", $date), date("m", $date), date("d", $date), date("Y", $date));
$big_date = $days * 24 * 3600 + gmmktime(date("H", $date), date("i", $date), date("s", $date), date("m", $date), date("d", $date), date("Y", $date));
// multiply just to make MS happy
$big_date *= 10000000;
... ... @@ -481,26 +481,26 @@ class PHPExcel_Shared_OLE
$res = '';
for ($i = 0; $i < 4; ++$i) {
$hex = $low_part % 0x100;
$res .= pack('c', $hex);
$hex = $low_part % 0x100;
$res .= pack('c', $hex);
$low_part /= 0x100;
}
for ($i = 0; $i < 4; ++$i) {
$hex = $high_part % 0x100;
$res .= pack('c', $hex);
$hex = $high_part % 0x100;
$res .= pack('c', $hex);
$high_part /= 0x100;
}
return $res;
}
/**
* Returns a timestamp from an OLE container's date
*
* @access public
* @static
* @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string
*/
* Returns a timestamp from an OLE container's date
*
* @access public
* @static
* @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string
*/
public static function OLE2LocalDate($string)
{
if (strlen($string) != 8) {
... ...