/** * Autoload */ public function testAutoload() { $declared = get_declared_classes(); $declaredCount = count($declared); Autoloader::autoload('Foo'); $this->assertEquals($declaredCount, count(get_declared_classes()), 'PhpOffice\\PhpPresentation\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\PhpPresentation namespace'); }
use PhpOffice\PhpPresentation\AbstractShape; use PhpOffice\PhpPresentation\DocumentLayout; use PhpOffice\PhpPresentation\Shape\Drawing; use PhpOffice\PhpPresentation\Shape\RichText; use PhpOffice\PhpPresentation\Shape\RichText\BreakElement; use PhpOffice\PhpPresentation\Shape\RichText\TextElement; use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Bullet; use PhpOffice\PhpPresentation\Style\Color; error_reporting(E_ALL); define('CLI', PHP_SAPI == 'cli' ? true : false); define('EOL', CLI ? PHP_EOL : '<br />'); define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php')); define('IS_INDEX', SCRIPT_FILENAME == 'index'); require_once __DIR__ . '/../src/PhpPresentation/Autoloader.php'; Autoloader::register(); require_once __DIR__ . '/../vendor/autoload.php'; // Set writers $writers = array('PowerPoint2007' => 'pptx', 'ODPresentation' => 'odp'); // Return to the caller script when runs by CLI if (CLI) { return; } // Set titles and names $pageHeading = str_replace('_', ' ', SCRIPT_FILENAME); $pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - "; $pageTitle .= 'PHPPresentation'; $pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>"; $oShapeDrawing = new Drawing\File(); $oShapeDrawing->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10); $oShapeDrawing->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
date_default_timezone_set('UTC'); // defining base dir for tests if (!defined('PHPPRESENTATION_TESTS_BASE_DIR')) { define('PHPPRESENTATION_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\\PhpPresentation\\Tests'; if (strpos($class, $prefix) === 0) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $class); $class = join(DIRECTORY_SEPARATOR, array('PhpPresentation', 'Tests', '_includes')) . substr($class, strlen($prefix)); $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; if (file_exists($file)) { require_once $file; } } }); require_once __DIR__ . "/../src/PhpPresentation/Autoloader.php"; \PhpOffice\PhpPresentation\Autoloader::register();
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); }