function test($name, $lc, $lp)
{
    static $i = 0;
    echo "==={$i}===\n";
    $i++;
    $o = new SplFileInfo($name);
    var_dump($o);
    $c = clone $o;
    var_dump($c);
    var_dump($o === $c);
    var_dump($o == $c);
    var_dump($o->getPathname() == $c->getPathname());
    try {
        $f = new SplFileObject($name);
        var_dump($name);
        var_dump($f->getPathName());
        $l = substr($f->getPathName(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lc);
        var_dump($f->getFileName());
        $l = substr($f->getFileName(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lc);
        var_dump($f->getPath());
        $l = substr($f->getPath(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lp);
    } catch (LogicException $e) {
        echo "LogicException: " . $e->getMessage() . "\n";
    }
    try {
        $fo = $o->openFile();
        var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
    } catch (LogicException $e) {
        echo "LogicException: " . $e->getMessage() . "\n";
    }
}
Ejemplo n.º 2
0
 /**
  * Construct CSV reader
  *
  * @param \SplFileObject $file            Excel file
  * @param int            $headerRowNumber Optional number of header row
  * @param int            $activeSheet     Index of active sheet to read from
  */
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null)
 {
     $reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $reader->setReadDataOnly(true);
     $excel = $reader->load($file->getPathname());
     if (null !== $activeSheet) {
         $excel->setActiveSheetIndex($activeSheet);
     }
     $this->worksheet = $excel->getActiveSheet()->toArray();
     if (null !== $headerRowNumber) {
         $this->setHeaderRowNumber($headerRowNumber);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param \SplFileObject $file            Excel file
  * @param integer        $headerRowNumber Optional number of header row
  * @param integer        $activeSheet     Index of active sheet to read from
  * @param boolean        $readOnly        If set to false, the reader take care of the excel formatting (slow)
  */
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true)
 {
     $reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $reader->setReadDataOnly($readOnly);
     /** @var \PHPExcel $excel */
     $excel = $reader->load($file->getPathname());
     if (null !== $activeSheet) {
         $excel->setActiveSheetIndex($activeSheet);
     }
     $this->worksheet = $excel->getActiveSheet();
     $this->maxColumn = $this->worksheet->getHighestColumn();
     $this->maxRow = $this->worksheet->getHighestRow();
     if (null !== $headerRowNumber) {
         $this->setHeaderRowNumber($headerRowNumber);
     }
 }
Ejemplo n.º 4
0
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true, $maxRows = null, $maxCol = null)
 {
     $this->file = $file;
     $this->activeSheet = $activeSheet;
     $this->reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $this->reader->setReadDataOnly($readOnly);
     if (!is_null($headerRowNumber)) {
         $this->headerRowNumber = $headerRowNumber;
         $headerReader = clone $this->reader;
         $headerReader->setReadFilter(new ReadFilter($headerRowNumber + 1));
         /** @var \PHPExcel $excel */
         $excel = $headerReader->load($file->getPathname());
         if (null !== $activeSheet) {
             $excel->setActiveSheetIndex($activeSheet);
         }
         $rows = $excel->getActiveSheet()->toArray();
         $this->columnHeaders = $rows[$headerRowNumber];
         //set max col from header length if not already given
         if (is_null($maxCol)) {
             $maxCol = \PHPExcel_Cell::stringFromColumnIndex(count($this->columnHeaders) - 1);
         }
     }
     $this->setBoundaries($maxRows, $maxCol);
 }
Ejemplo n.º 5
0
function outputImage($pic)
{
    if (!is_object($pic)) {
        $pic = new SplFileObject($pic);
    }
    $picPath = $pic->getPathName();
    $picExt = strtolower(substr($picPath, -3));
    //jeko moved strtolower only used for preg_match and mime type
    // IE gets paths to images, cool kids get base64 image data
    if (preg_match('%(jpg|png|gif)%', $picExt)) {
        //sm_com preg_match once
        if (isIE()) {
            return $picPath;
        } else {
            //sm_com removed if !isIE()
            $picData = base64_encode(file_get_contents($picPath));
            return "data:image/" . $picExt . ";base64," . $picData;
            //sm_com removed switch:
        }
    } else {
        return false;
        //sm_com or throw an error (it's not an acceptable image type or not an image)
    }
}