コード例 #1
0
ファイル: AutoloaderTest.php プロジェクト: hxsam/Common
 /**
  * Autoload
  */
 public function testAutoload()
 {
     $declared = get_declared_classes();
     $declaredCount = count($declared);
     Autoloader::autoload('Foo');
     $this->assertEquals($declaredCount, count(get_declared_classes()), 'PhpOffice\\Common\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\Common namespace');
 }
コード例 #2
0
date_default_timezone_set('UTC');
// defining base dir for tests
if (!defined('PHPOFFICE_COMMON_TESTS_BASE_DIR')) {
    define('PHPOFFICE_COMMON_TESTS_BASE_DIR', realpath(__DIR__));
}
$vendor = realpath(__DIR__ . '/../vendor');
if (file_exists($vendor . "/autoload.php")) {
    require $vendor . "/autoload.php";
} else {
    $vendor = realpath(__DIR__ . '/../../../');
    if (file_exists($vendor . "/autoload.php")) {
        require $vendor . "/autoload.php";
    } else {
        throw new Exception("Unable to load dependencies");
    }
}
spl_autoload_register(function ($class) {
    $class = ltrim($class, '\\');
    $prefix = 'PhpOffice\\Common\\Tests';
    if (strpos($class, $prefix) === 0) {
        $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
        $class = join(DIRECTORY_SEPARATOR, array('Common', 'Tests', '_includes')) . substr($class, strlen($prefix));
        $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
        if (file_exists($file)) {
            require_once $file;
        }
    }
});
require_once __DIR__ . "/../src/Common/Autoloader.php";
\PhpOffice\Common\Autoloader::register();
コード例 #3
0
 public function generateSlidePhpPresentation()
 {
     $this->load->model('profile_model');
     $this->load->model('template_model');
     $poID = $this->session->userdata('poID');
     $po = $this->property_model->getOverview($poID);
     $property = $this->property_model->getProperty($po->property_id);
     $img = $this->property_module_model->getPropertyImage($po->property_id);
     $profile = $this->profile_model->getProfile($property->profile_id);
     $template = $_POST['slides'];
     $bg = $_POST['bg'];
     $templateNo = $_POST['templateNo'];
     require_once getcwd() . '/lib/PhpOffice/PhpPresentation/Autoloader.php';
     require_once getcwd() . '/lib/PhpOffice/Common/Autoloader.php';
     \PhpOffice\PhpPresentation\Autoloader::register();
     \PhpOffice\Common\Autoloader::register();
     $objPHPPowerPoint = new PhpOffice\PhpPresentation\PhpPresentation();
     @$objPHPPowerPoint->getLayout()->setDocumentLayout(\PhpOffice\PhpPresentation\DocumentLayout::LAYOUT_CUSTOM, true)->setCX(1280, \PhpOffice\PhpPresentation\DocumentLayout::UNIT_PIXEL)->setCY(720, \PhpOffice\PhpPresentation\DocumentLayout::UNIT_PIXEL);
     $slides = explode(',', $template);
     $size = sizeof($slides) + 1;
     for ($i = 0; $i < $size; $i++) {
         // Create templated slide
         if ($i == $size - 1) {
             $currentSlide = $this->createTemplatedSlide($objPHPPowerPoint, $img, null, $bg, $profile, true);
         } else {
             $currentSlide = $this->createTemplatedSlide($objPHPPowerPoint, $img, $slides[$i], $bg, $profile);
             // Title of Slide
             $shape = $currentSlide->createRichTextShape();
             $shape->setHeight(100)->setWidth(1240)->setOffsetX(20)->setOffsetY(10)->getActiveParagraph()->getAlignment()->setHorizontal(\PhpOffice\PhpPresentation\Style\Alignment::HORIZONTAL_CENTER);
             $textRun = $shape->createTextRun("{$po->name}, {$property->city} {$property->state_abbr} {$property->zipcode}");
             $textRun->getFont()->setBold(true)->setSize(30)->setColor(new \PhpOffice\PhpPresentation\Style\Color('FFFFFFFF'));
         }
         // Contact Information below owner image
         $shape = $currentSlide->createRichTextShape();
         $shape->setHeight(100)->setWidth(300)->setOffsetX(960)->setOffsetY(390)->getActiveParagraph()->getAlignment()->setHorizontal(\PhpOffice\PhpPresentation\Style\Alignment::HORIZONTAL_CENTER);
         $textRun = $shape->createTextRun("{$profile->firstname} {$profile->lastname}");
         $textRun->getFont()->setSize(20)->setBold(true)->setColor(new \PhpOffice\PhpPresentation\Style\Color('FFFFFFFF'));
         $shape->createBreak();
         $textRun = $shape->createTextRun("{$profile->company}");
         $textRun->getFont()->setSize(18)->setColor(new \PhpOffice\PhpPresentation\Style\Color('FFFFFFFF'));
         $shape->createBreak();
         $shape->createBreak();
         $textRun = $shape->createTextRun("{$profile->phone}");
         $textRun->getFont()->setSize(18)->setBold(true)->setColor(new \PhpOffice\PhpPresentation\Style\Color('FFFFFFFF'));
         $shape->createBreak();
         $textRun = $shape->createTextRun("{$profile->email}");
         $textRun->getFont()->setSize(16)->setColor(new \PhpOffice\PhpPresentation\Style\Color('FFFFFFFF'));
     }
     // Set properties
     $oProperties = $objPHPPowerPoint->getProperties();
     $oProperties->setCreator('Merlin Leads')->setLastModifiedBy('Merlin Leads')->setTitle($po->name)->setSubject($po->name)->setDescription($property->mls_description)->setKeywords(explode('|', $property->keywords)[0])->setCategory($property->property_type);
     // Removed first slide
     $objPHPPowerPoint->removeSlideByIndex(0);
     $oWriterPPTX = PhpOffice\PhpPresentation\IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
     $file = $this->user->id . "_" . $this->_getRandomString() . ".pptx";
     $savePath = $this->_getLocalDirPath(base_url() . OTHERS) . "slideshare/{$file}";
     $oWriterPPTX->save($savePath);
     $this->load->model('property_module_model');
     $this->property_module_model->updateSlidesharePost(array('ppt' => $file), $templateNo, $property->id);
     $result = array('result' => "OK", 'download_url' => base_url() . OTHERS . "slideshare/{$file}", 'title' => $this->getSlideshareRandomTitle());
     echo json_encode($result);
 }