Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
328 lines (290 sloc) 8.68 KB
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord;
use BadMethodCallException;
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Exception\Exception;
/**
* PHPWord main class.
*
* @method Collection\Titles getTitles()
* @method Collection\Footnotes getFootnotes()
* @method Collection\Endnotes getEndnotes()
* @method Collection\Charts getCharts()
* @method Collection\Comments getComments()
* @method int addBookmark(Element\Bookmark $bookmark)
* @method int addTitle(Element\Title $title)
* @method int addFootnote(Element\Footnote $footnote)
* @method int addEndnote(Element\Endnote $endnote)
* @method int addChart(Element\Chart $chart)
* @method int addComment(Element\Comment $comment)
* @method Style\Paragraph addParagraphStyle(string $styleName, mixed $styles)
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
* @method Style\Font addLinkStyle(string $styleName, mixed $styles)
* @method Style\Font addTitleStyle(mixed $depth, mixed $fontStyle, mixed $paragraphStyle = null)
* @method Style\Table addTableStyle(string $styleName, mixed $styleTable, mixed $styleFirstRow = null)
* @method Style\Numbering addNumberingStyle(string $styleName, mixed $styles)
*/
class PhpWord
{
/**
* Collection of sections.
*
* @var \PhpOffice\PhpWord\Element\Section[]
*/
private $sections = [];
/**
* Collections.
*
* @var array
*/
private $collections = [];
/**
* Metadata.
*
* @var array
*
* @since 0.12.0
*/
private $metadata = [];
/**
* Create new instance.
*
* Collections are created dynamically
*/
public function __construct()
{
// Reset Media and styles
Media::resetElements();
Style::resetStyles();
// Collection
$collections = ['Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts', 'Comments'];
foreach ($collections as $collection) {
$class = 'PhpOffice\\PhpWord\\Collection\\' . $collection;
$this->collections[$collection] = new $class();
}
// Metadata
$metadata = ['DocInfo', 'Settings', 'Compatibility'];
foreach ($metadata as $meta) {
$class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
$this->metadata[$meta] = new $class();
}
}
/**
* Dynamic function call to reduce static dependency.
*
* @since 0.12.0
*
* @param mixed $function
* @param mixed $args
*
* @return mixed
*/
public function __call($function, $args)
{
$function = strtolower($function);
$getCollection = [];
$addCollection = [];
$addStyle = [];
$collections = ['Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart', 'Comment'];
foreach ($collections as $collection) {
$getCollection[] = strtolower("get{$collection}s");
$addCollection[] = strtolower("add{$collection}");
}
$styles = ['Paragraph', 'Font', 'Table', 'Numbering', 'Link', 'Title'];
foreach ($styles as $style) {
$addStyle[] = strtolower("add{$style}Style");
}
// Run get collection method
if (in_array($function, $getCollection)) {
$key = ucfirst(str_replace('get', '', $function));
return $this->collections[$key];
}
// Run add collection item method
if (in_array($function, $addCollection)) {
$key = ucfirst(str_replace('add', '', $function) . 's');
/** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */
$collectionObject = $this->collections[$key];
return $collectionObject->addItem($args[0] ?? null);
}
// Run add style method
if (in_array($function, $addStyle)) {
return forward_static_call_array(['PhpOffice\\PhpWord\\Style', $function], $args);
}
// Exception
throw new BadMethodCallException("Method $function is not defined.");
}
/**
* Get document properties object.
*
* @return \PhpOffice\PhpWord\Metadata\DocInfo
*/
public function getDocInfo()
{
return $this->metadata['DocInfo'];
}
/**
* Get compatibility.
*
* @return \PhpOffice\PhpWord\Metadata\Compatibility
*
* @since 0.12.0
*/
public function getCompatibility()
{
return $this->metadata['Compatibility'];
}
/**
* Get compatibility.
*
* @return \PhpOffice\PhpWord\Metadata\Settings
*
* @since 0.14.0
*/
public function getSettings()
{
return $this->metadata['Settings'];
}
/**
* Get all sections.
*
* @return \PhpOffice\PhpWord\Element\Section[]
*/
public function getSections()
{
return $this->sections;
}
/**
* Returns the section at the requested position.
*
* @param int $index
*
* @return null|\PhpOffice\PhpWord\Element\Section
*/
public function getSection($index)
{
if (array_key_exists($index, $this->sections)) {
return $this->sections[$index];
}
return null;
}
/**
* Create new section.
*
* @param array $style
*
* @return \PhpOffice\PhpWord\Element\Section
*/
public function addSection($style = null)
{
$section = new Section(count($this->sections) + 1, $style);
$section->setPhpWord($this);
$this->sections[] = $section;
return $section;
}
/**
* Sorts the sections using the callable passed.
*
* @see http://php.net/manual/en/function.usort.php for usage
*
* @param callable $sorter
*/
public function sortSections($sorter): void
{
usort($this->sections, $sorter);
}
/**
* Get default font name.
*
* @return string
*/
public function getDefaultFontName()
{
return Settings::getDefaultFontName();
}
/**
* Set default font name.
*
* @param string $fontName
*/
public function setDefaultFontName($fontName): void
{
Settings::setDefaultFontName($fontName);
}
/**
* Get default font size.
*
* @return int
*/
public function getDefaultFontSize()
{
return Settings::getDefaultFontSize();
}
/**
* Set default font size.
*
* @param int $fontSize
*/
public function setDefaultFontSize($fontSize): void
{
Settings::setDefaultFontSize($fontSize);
}
/**
* Set default paragraph style definition to styles.xml.
*
* @param array $styles Paragraph style definition
*
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public function setDefaultParagraphStyle($styles)
{
return Style::setDefaultParagraphStyle($styles);
}
/**
* Save to file or download.
*
* All exceptions should already been handled by the writers
*
* @param string $filename
* @param string $format
* @param bool $download
*
* @return bool
*/
public function save($filename, $format = 'Word2007', $download = false)
{
$mime = [
'Word2007' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'ODText' => 'application/vnd.oasis.opendocument.text',
'RTF' => 'application/rtf',
'HTML' => 'text/html',
'PDF' => 'application/pdf',
];
$writer = IOFactory::createWriter($this, $format);
if ($download === true) {
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: ' . $mime[$format]);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
$filename = 'php://output'; // Change filename to force download
}
$writer->save($filename);
return true;
}
}
PHPWord/IOFactory.php at master · PHPOffice/PHPWord · GitHub
Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
105 lines (93 sloc) 2.89 KB
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Reader\ReaderInterface;
use PhpOffice\PhpWord\Writer\WriterInterface;
use ReflectionClass;
abstract class IOFactory
{
/**
* Create new writer.
*
* @param string $name
*
* @return WriterInterface
*/
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
{
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF'], true)) {
throw new Exception("\"{$name}\" is not a valid writer.");
}
$fqName = "PhpOffice\\PhpWord\\Writer\\{$name}";
return new $fqName($phpWord);
}
/**
* Create new reader.
*
* @param string $name
*
* @return ReaderInterface
*/
public static function createReader($name = 'Word2007')
{
return self::createObject('Reader', $name);
}
/**
* Create new object.
*
* @param string $type
* @param string $name
* @param \PhpOffice\PhpWord\PhpWord $phpWord
*
* @return \PhpOffice\PhpWord\Reader\ReaderInterface|\PhpOffice\PhpWord\Writer\WriterInterface
*/
private static function createObject($type, $name, $phpWord = null)
{
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
if (class_exists($class) && self::isConcreteClass($class)) {
return new $class($phpWord);
}
throw new Exception("\"{$name}\" is not a valid {$type}.");
}
/**
* Loads PhpWord from file.
*
* @param string $filename The name of the file
* @param string $readerName
*
* @return \PhpOffice\PhpWord\PhpWord $phpWord
*/
public static function load($filename, $readerName = 'Word2007')
{
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
$reader = self::createReader($readerName);
return $reader->load($filename);
}
/**
* Check if it's a concrete class (not abstract nor interface).
*
* @param string $class
*
* @return bool
*/
private static function isConcreteClass($class)
{
$reflection = new ReflectionClass($class);
return !$reflection->isAbstract() && !$reflection->isInterface();
}
}
Upload A Pic And See Your Face On Meth After 5 Years Of Drug Abuse | Bit Rebels

Upload A Pic And See Your Face On Meth After 5 Years Of Drug Abuse

I learned early on that drugs could ruin a person’s life. When I was a kid, I remember getting annoyed at all the people who tried to teach me about that, but now that I’m an adult, I’m glad they did. I am one of the blessed people who never got caught up in that craziness. I think it’s important to write about the dangers of drug addiction every so often so we can teach today’s kids about it. In this article, I’ll explain how you can upload a pic and see your face on meth.

I’ve touched on this aspect of drug addiction before. Two years ago I wrote an article called Shocking: The Effects Of Drug Addiction On The Face. After that one published, I received a few emails and phone calls from people who had either gone through it or knew someone who had. Now you’ll get to see it on a more personal level. Through a new website, you can see your face on meth. Yup, your actual face. It’s disturbing to say the least.

When I wrote the original article a few years ago (the one linked above), I did quite a big of research. I leaned there is a reason why people who take meth have destroyed faces. Here is an excerpt from that article:

Often times meth users will feel like there are bugs crawling under their skin on their face, and they pick at it until it bleeds. Also, meth and heroin are often times cut with sugar, and when injected into the veins, sugar causes acne. It’s like an amplified effect of eating a bunch of candy bars. Meth also causes blood vessels to constrict, so part of the face shrinks, which gives the look of premature aging and sunken in features. Teeth can also be affected by turning black or even falling out. Also, since many drug addicts don’t eat or sleep well, that contributes to their face transformation.

Pretty scary, right? And remember, the face transformation is only one effect of many when it comes to drug use, or in this case, meth use. If you are ready to see what your face would look like if you became a meth user, just click over to Your Face On Meth.

It’s a visual interpretation of what your face would look like gradually over time if you were a user. It’s an eerie look into the future for anyone who is considering taking this dangerous drug. I tried the website myself, and you can see my face on meth below. I’ve always thought the saying “hugs not drugs” was cheesy, but seriously, consider a hug instead. You don’t want to look like this.

This Is My Face Normally…

your-face-on-meth

This Is My Face On Meth…

(Click Image To Enlarge)

your-face-on-meth

your-face-on-meth

Via: [Discovery News]

COMMENTS