/** * Register a pipeline in the global pipeline collector. * * @param Pipeline $pipeline the pipeline to be registered * * @throws PipelineException a pipeline with the same name already eexists */ public static function registerPipeline(Pipeline &$pipeline) { //register the current pipeline only if a pipeline with the same name doesn't exists if (self::checkPipelineByName($pipeline->getName())) { throw new PipelineException('A pipeline with the same name already exists', 0); } self::$pipelines[] =& $pipeline; }
/** * @inheritdoc */ public function __invoke($uri) { $this->assertUriObject($uri); static $modifier; if (!$modifier instanceof Pipeline) { $modifier = new Pipeline([new HostToAscii(), new RemoveDotSegments(), new KsortQuery()]); } return $modifier->process($uri)->withScheme(mb_strtolower($uri->getScheme(), 'UTF-8')); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.default.header.html') . file_get_contents(HTML2PS_DIR . 'default.css') . file_get_contents(dirname(__FILE__) . '/test.default.footer.html')); $pipeline = new Pipeline(); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $input_rules = $css->tag_filtered['input']; $this->assertEquals(count($input_rules), 10); }
public function testPipeline_MatchCallable() { $pipeline = new Pipeline($this->collection); $pipeline->match(function ($expression) { /* @var $expression \Sokil\Mongo\Expression */ $expression->where('a', 1)->whereLess('b', 12); }); $this->assertEquals('[{"$match":{"a":1,"b":{"$lt":12}}}]', (string) $pipeline); }
function test() { $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $style = 'background:url(/intl/en_com/images/logo_plain.png) no-repeat;height:110px;width:276px'; $css_processor =& new CSSProcessor(); $css_processor->set_pipeline($pipeline); $property_collection = $css_processor->import_source_ruleset($style, $pipeline->get_base_url()); $this->assertEquals(count($property_collection->_properties), 3); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.class.case.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(array(SELECTOR_ID, 'quickSummary'), $rule->selector[1][0]); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.2.html')); $pipeline = new Pipeline(); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $selector = $rule->selector; $this->assertEquals($selector[1][0][0], SELECTOR_CLASS); $this->assertEquals($selector[1][0][1], 'test'); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.margin.left.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $margin = $rule->body->_properties[0]->_value; $this->assertEquals(UNIT_PX, $margin->_units->_unit); $this->assertEquals(600, $margin->_units->_number); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.7.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(count($rule->body->_properties), 1); $property = $rule->body->_properties[0]; $this->assertEquals($property->_code, CSS_BACKGROUND); $this->assertEquals($property->_value->_image->_url, 'http://localhost/intl/en_com/images/logo_plain.png'); }
public function __construct($name, $type, $vars) { $this->name = $name; $this->type = $type; $this->vars = $vars; $this->locator = Pipeline::getCurrentInstance()->getLocator(); $this->path = $this->locator->getDirectory($name, $type); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.8.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(count($rule->body->_properties), 1); $property = $rule->body->_properties[0]; $this->assertEquals($property->_code, CSS_BACKGROUND_COLOR); $this->assertEquals($property->_value->r, 1); $this->assertEquals($property->_value->g, 1); $this->assertEquals($property->_value->b, 1); $this->assertEquals($property->_value->transparent, false); }
private function run() { // Note that a pipeline must be started prior to being picked up by this task $runningPipelines = Pipeline::get()->filter('Status', array('Running', 'Rollback')); printf("%s Checking status of %d pipelines... ", "[" . date("Y-m-d H:i:s") . "]", $runningPipelines->count()); foreach ($runningPipelines as $pipeline) { $pipeline->checkPipelineStatus(); } echo "done!" . PHP_EOL; }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.padding.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $padding = $rule->body->_properties[1]->_value; $this->assertEquals(UNIT_PX, $padding->top->_units->_unit); $this->assertEquals(0, $padding->top->_units->_number); $this->assertEquals(UNIT_PX, $padding->right->_units->_unit); $this->assertEquals(175, $padding->right->_units->_number); $this->assertEquals(UNIT_PX, $padding->bottom->_units->_unit); $this->assertEquals(0, $padding->bottom->_units->_number); $this->assertEquals(UNIT_PX, $padding->left->_units->_unit); $this->assertEquals(110, $padding->left->_units->_number); }
/** * Create input box using DOM tree data * * @param Object $root DOM tree node corresponding to the box being created * @param Pipeline $pipeline reference to current pipeline object (unused) * * @return input box */ function &create(&$root, &$pipeline) { /** * If no "value" attribute is specified, display the default button text. * Note the difference between displayed text and actual field value! */ if ($root->has_attribute("value")) { $text = $root->get_attribute("value"); } else { $text = DEFAULT_SUBMIT_TEXT; } $field = $root->get_attribute('name'); $value = $root->get_attribute('value'); $css_state =& $pipeline->get_current_css_state(); $box =& new ButtonSubmitBox($field, $value, $css_state->get_property(CSS_HTML2PS_FORM_ACTION)); $box->readCSS($css_state); $box->_setup($text, $pipeline); return $box; }
/** * Constructor. Additionally, it fetches the SessionInfo object from * the session information * * */ function BlogAction($actionInfo, $request) { $this->Action($actionInfo, $request); // we use the HttpVars package since then we can access the session object // independently wether we're using php ver. < 4.1.0 or not $session = HttpVars::getSession(); $this->_session = $session['SessionInfo']; $this->_config =& Config::getConfig(); $this->_getBlogInfo(); // save the blogid in the session $this->_session->setValue('blogId', $this->_blogInfo->getId()); $this->checkDateParameter(); // initialize the plugin manager $this->_pm =& PluginManager::getPluginManager(); $this->_pm->setBlogInfo($this->_blogInfo); $this->_pm->setUserInfo($this->_userInfo); // locale $this->_locale = $this->_blogInfo->getLocale(); // // security stuff // $pipeline = new Pipeline($request, $this->_blogInfo); $result = $pipeline->process(); // // if the pipeline blocked the request, then we have // to let the user know if (!$result->isValid()) { $message = $this->_locale->tr('error_you_have_been_blocked') . '<br/><br/>'; $message .= $result->getErrorMessage(); $this->_view = new ErrorView($this->_blogInfo, $message); $this->setCommonData(); $this->_view->render(); die; } // update the referrers, if needed $this->_updateReferrer(); $this->articles = new Articles(); }
if ($GLOBALS['g_config']['pagewidth'] == 0) { die("Please specify non-zero value for the pixel width!"); } // 110723, dwildt + if ($this->b_drs_perform) { $endTime = $this->TT->getDifferenceToStarttime(); t3lib_div::devLog('[INFO/PERFORMANCE] html2ps is starting the process: ' . ($endTime - $this->startTime) . ' ms', $this->extKey, 0); } // 110723, dwildt + // begin processing $g_media = Media::predefined($GLOBALS['g_config']['media']); $g_media->set_landscape($GLOBALS['g_config']['landscape']); $g_media->set_margins($GLOBALS['g_config']['margins']); $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); // Initialize the coversion pipeline $pipeline = new Pipeline(); $pipeline->configure($GLOBALS['g_config']); // Configure the fetchers if (extension_loaded('curl')) { require_once HTML2PS_DIR . 'fetcher.url.curl.class.php'; $pipeline->fetchers = array(new FetcherUrlCurl()); if ($proxy != '') { $pipeline->fetchers[0]->set_proxy($proxy); } } else { require_once HTML2PS_DIR . 'fetcher.url.class.php'; $pipeline->fetchers[] = new FetcherURL(); } // Configure the data filters $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array()) { define("MAX_FREE_FRACTION", 1); define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/'); G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true); require_once PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php'; require_once PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php'; parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config'); $GLOBALS['g_config'] = array('cssmedia' => 'screen', 'media' => 'Letter', 'scalepoints' => false, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => 800, 'landscape' => $sLandscape, 'method' => 'fpdf', 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15), 'encoding' => '', 'ps2pdf' => false, 'compress' => true, 'output' => 2, 'pdfversion' => '1.3', 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true); $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties); $g_media = Media::predefined($GLOBALS['g_config']['media']); $g_media->set_landscape($GLOBALS['g_config']['landscape']); $g_media->set_margins($GLOBALS['g_config']['margins']); $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); if (isset($GLOBALS['g_config']['pdfSecurity'])) { if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "") { $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID); } if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "") { $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID); } $g_media->set_security($GLOBALS['g_config']['pdfSecurity']); require_once HTML2PS_DIR . 'pdf.fpdf.encryption.php'; } $pipeline = new Pipeline(); if (extension_loaded('curl')) { require_once HTML2PS_DIR . 'fetcher.url.curl.class.php'; $pipeline->fetchers = array(new FetcherURLCurl()); if (isset($proxy)) { if ($proxy != '') { $pipeline->fetchers[0]->set_proxy($proxy); } } } else { require_once HTML2PS_DIR . 'fetcher.url.class.php'; $pipeline->fetchers[] = new FetcherURL(); } $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']); if ($GLOBALS['g_config']['html2xhtml']) { $pipeline->data_filters[] = new DataFilterHTML2XHTML(); } else { $pipeline->data_filters[] = new DataFilterXHTML2XHTML(); } $pipeline->parser = new ParserXHTML(); $pipeline->pre_tree_filters = array(); $header_html = ''; $footer_html = ''; $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html); $pipeline->pre_tree_filters[] = $filter; if ($GLOBALS['g_config']['renderfields']) { $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); } if ($GLOBALS['g_config']['method'] === 'ps') { $pipeline->layout_engine = new LayoutEnginePS(); } else { $pipeline->layout_engine = new LayoutEngineDefault(); } $pipeline->post_tree_filters = array(); if ($GLOBALS['g_config']['pslevel'] == 3) { $image_encoder = new PSL3ImageEncoderStream(); } else { $image_encoder = new PSL2ImageEncoderStream(); } switch ($GLOBALS['g_config']['method']) { case 'fastps': if ($GLOBALS['g_config']['pslevel'] == 3) { $pipeline->output_driver = new OutputDriverFastPS($image_encoder); } else { $pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder); } break; case 'pdflib': $pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']); break; case 'fpdf': $pipeline->output_driver = new OutputDriverFPDF(); break; case 'png': $pipeline->output_driver = new OutputDriverPNG(); break; case 'pcl': $pipeline->output_driver = new OutputDriverPCL(); break; default: die('Unknown output method'); } if (isset($GLOBALS['g_config']['watermarkhtml'])) { $watermark_text = $GLOBALS['g_config']['watermarkhtml']; } else { $watermark_text = ''; } $pipeline->output_driver->set_watermark($watermark_text); if ($watermark_text != '') { $dispatcher =& $pipeline->getDispatcher(); } if ($GLOBALS['g_config']['debugbox']) { $pipeline->output_driver->set_debug_boxes(true); } if ($GLOBALS['g_config']['draw_page_border']) { $pipeline->output_driver->set_show_page_border(true); } if ($GLOBALS['g_config']['ps2pdf']) { $pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']); } if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') { $pipeline->output_filters[] = new OutputFilterGZip(); } if (!isset($GLOBALS['g_config']['process_mode'])) { $GLOBALS['g_config']['process_mode'] = ''; } if ($GLOBALS['g_config']['process_mode'] == 'batch') { $filename = 'batch'; } else { $filename = $sFilename; } switch ($GLOBALS['g_config']['output']) { case 0: $pipeline->destination = new DestinationBrowser($filename); break; case 1: $pipeline->destination = new DestinationDownload($filename); break; case 2: $pipeline->destination = new DestinationFile($filename); break; } copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); try { $status = $pipeline->process((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media); copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); } catch (Exception $e) { if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') { include_once 'classes/model/AppDocument.php'; $dataDocument = explode('_', $sFilename); if (!isset($dataDocument[1])) { $dataDocument[1] = 1; } $oAppDocument = new AppDocument(); $oAppDocument->remove($dataDocument[0], $dataDocument[1]); G::SendTemporalMessage(G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error'); } } }
/** * Returns a {@link Pipeline} object that is linked to this environment, but isn't saved into the database. This * shouldn't be saved into the database unless you plan on starting an actual pipeline. * * @return Pipeline */ public function GenericPipeline() { $pipeline = Pipeline::create(); $pipeline->EnvironmentID = $this->ID; return $pipeline; }
{ return new FetchedDataURL($this->_content, array(), ""); } function get_base_url() { return ""; } } $media = Media::predefined("A4"); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $GLOBALS['g_config'] = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'renderfields' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; $pipeline = new Pipeline(); $pipeline->configure($GLOBALS['g_config']); $pipeline->fetchers[] = new MyFetcherLocalFile(); // $pipeline->destination = new MyDestinationFile($pdf); $pipeline->destination = new MyDestinationDownload($pdf); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->pre_tree_filters = array(); $header_html = "test"; $footer_html = "test"; $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html); $pipeline->pre_tree_filters[] = $filter; $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->process('', $media);
<?php require_once 'pipeline.class.php'; parse_config_file('html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; $pipeline = new Pipeline(); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->destination = new DestinationFile(null); $pipeline->process('http://localhost:81/testing/ww.html', $media);
parse_config_file(dirname(__FILE__) . '/../html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => true, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); require_once dirname(__FILE__) . '/../config.inc.php'; require_once HTML2PS_DIR . 'pipeline.class.php'; require_once HTML2PS_DIR . 'fetcher.url.class.php'; parse_config_file(HTML2PS_DIR . 'html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; foreach ($urls as $url) { $url_file = str_replace('http://', '', $url); $url_file = str_replace(':', '_', $url_file); $url_file = str_replace('/', '_', $url_file); $url_file = str_replace('.', '_', $url_file); $pipeline = new Pipeline(); $pipeline->configure($g_config); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->destination = new DestinationFile($url_file); if (!file_exists(dirname(__FILE__) . '/../out/' . $url_file . '.pdf')) { print $url . "\n"; $pipeline->process($url, $media); } }
} /*****************************************************************************/ /** Configuration */ $GLOBALS['g_config'] = array('cssmedia' => "screen", 'media' => "A4", 'scalepoints' => true, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => $pw, 'landscape' => false, 'method' => "fpdf", 'margins' => array('left' => $ml, 'right' => $mr, 'top' => $mt, 'bottom' => $mb), 'encoding' => "", 'ps2pdf' => false, 'compress' => false, 'output' => 1, 'pdfversion' => "1.2", 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => false, 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true); /*****************************************************************************/ /** Inizializza pipeline */ // ** Parse configuration file parse_config_file(HTML2PS_BASEDIR . "html2ps.config"); // ** Media $g_media = Media::predefined($GLOBALS['g_config']['media']); $g_media->set_landscape($GLOBALS['g_config']['landscape']); $g_media->set_margins($GLOBALS['g_config']['margins']); $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); // ** Pipeline // *** Initialize the coversion pipeline $pipeline = new Pipeline(); // *** Fetchers $pipeline->fetchers[] = new FetcherUrl(); // *** Data filters $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8(""); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); // *** Parser $pipeline->parser = new ParserXHTML(); // *** Pre-tree filters $pipeline->pre_tree_filters = array(); $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); // *** Layout engine $pipeline->layout_engine = new LayoutEngineDefault(); // *** Post-tree filters $pipeline->post_tree_filters = array();
<?php require_once dirname(__FILE__) . '/../config.inc.php'; require_once HTML2PS_DIR . 'pipeline.class.php'; require_once HTML2PS_DIR . 'fetcher.url.class.php'; parse_config_file(HTML2PS_DIR . 'html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; $pipeline = new Pipeline(); $pipeline->configure($g_config); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->destination = new DestinationFile(null); $pipeline->process('http://tests.office/html2ps/sample.html', $media);
die("Please specify non-zero value for the pixel width!"); } // begin processing $g_media = Media::predefined($g_config['media']); $g_media->set_landscape($g_config['landscape']); $g_media->set_margins($g_config['margins']); $g_media->set_pixels($g_config['pagewidth']); $g_px_scale = mm2pt($g_media->width() - $g_media->margins['left'] - $g_media->margins['right']) / $g_media->pixels; if ($g_config['scalepoints']) { $g_pt_scale = $g_px_scale * 1.43; // This is a magic number, just don't touch it, or everything will explode! } else { $g_pt_scale = 1.0; } // Initialize the coversion pipeline $pipeline = new Pipeline(); // Configure the fetchers $pipeline->fetchers[] = new FetcherURL(); // Configure the data filters $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8($g_config['encoding']); if ($g_config['html2xhtml']) { $pipeline->data_filters[] = new DataFilterHTML2XHTML(); } else { $pipeline->data_filters[] = new DataFilterXHTML2XHTML(); } $pipeline->parser = new ParserXHTML(); // "PRE" tree filters $pipeline->pre_tree_filters = array(); $header_html = isset($_REQUEST['headerhtml']) ? $_REQUEST['headerhtml'] : ""; $footer_html = isset($_REQUEST['footerhtml']) ? $_REQUEST['footerhtml'] : "";
<?php require_once dirname(__FILE__) . '/../config.inc.php'; require_once HTML2PS_DIR . 'pipeline.class.php'; require_once HTML2PS_DIR . 'fetcher.url.class.php'; parse_config_file(HTML2PS_DIR . 'html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; $pipeline = new Pipeline(); $pipeline->configure($g_config); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->destination = new DestinationFile(null); $pipeline->process('http://localhost:81/testing/ww.html', $media);
<?php error_reporting(E_ALL); ini_set("display_errors", "1"); @set_time_limit(600); $urls = array('http://247realmedia.com', 'http://888.com', 'http://abetterinternet.com', 'http://adsense.google.com', 'http://alphadg.com', 'http://allwomencentral.com/?r=sub', 'http://aol.com', 'http://www.articlehub.com/add.html', 'http://aur.archlinux.org', 'http://bbc.co.uk', 'http://benews.net', 'http://casalemedia.com', 'http://cnn.com', 'http://www.codeguru.com/register.php', 'http://cra-arc.gc.ca/menu-e.html', 'http://crux.nu', 'http://cs.wisc.edu/~ghost/', 'http://distrowatch.com', 'http://dmoz.org/cgi-bin/apply.cgi?submit=Proceed&where=Business%2FEmployment%2FCareers&id=&lk=&loc=', 'http://download.com', 'http://ebay.com', 'http://ewizard.com', 'http://exactsearch.net', 'http://exitexchange.com', 'http://ezinearticles.com/submit', 'http://falkag.net', 'http://fedora.redhat.com', 'http://freebsd.org', 'http://freewho.com/expired/index.php', 'http://gentoo.org', 'http://geocities.com', 'http://www.getafreelancer.com/users/signup.php', 'http://gmail.com', 'http://go.com', 'http://google.co.in', 'http://google.com/about.html', 'http://google.com/froogle', 'http://google.com/services/', 'http://google.fi/fi', 'http://guru.com/pro/post_profile.cfm', 'http://hamster.sazco.net', 'http://www-128.ibm.com/developerworks/linux/library/l-proc.html', 'http://hotmail.com', 'http://indianrail.gov.in', 'http://internet-optimizer.com', 'http://jakpsatweb.cz/css/css-vertical-center-solution.html', 'http://jobsearch.monsterindia.com/advanced_job_search.html', 'http://johnlewis.com', 'http://kubuntu.org', 'http://lyrc.com.ar/en/add/add.php', 'http://microsoft.com', 'http://msn.com', 'http://myblog.de', 'http://myway.com', 'http://mywebsearch.com', 'http://net-offers.net', 'http://netscape.com', 'http://netvenda.com', 'http://offeroptimizer.com', 'http://onet.pl', 'http://opensuse.org', 'http://osnews.com', 'http://papajohns.com', 'http://partypoker.com', 'http://passport.com', 'http://php.net', 'http://pilger.carlton.com', 'http://priyank.one09.net', 'http://python.org/~guido/', 'http://realmedia.com', 'http://rentacoder.com', 'http://revenue.net', 'http://rubixlinux.org', 'http://sage.com/local/regionNorthAmerica.aspx', 'http://searchscout.com', 'http://search.ebay.in/ws/search/AdvSearch?sofindtype=13', 'http://services.princetonreview.com/register.asp?RUN=%2FstudentTools%2FstudentTool%2Easp&RCN=auth&RDN=1&ALD=http%3A%2F%2Ftestprep%2Eprincetonreview%2Ecom', 'http://smarty.php.net', 'http://stallman.org', 'http://stanton-finley.net/fedora_core_5_installation_notes.html', 'http://thefacebook.com', 'http://tickle.com', 'http://trafficmp.com', 'http://tufat.com', 'http://ubuntu.com', 'http://user.it.uu.se/~jan/html2ps.html', 'http://vianet.com.pl', 'http://website.in/domain.php', 'http://whenu.com', 'http://whitehouse.gov', 'http://whois.org/', 'http://en.wikipedia.org', 'http://en.wikipedia.org/w/index.php?title=Spangenhelm&action=edit', 'http://wolfram.com', 'http://www.xe.com/ucc', 'http://yahoo.com', 'http://yahoomail.com', 'http://edit.yahoo.com/config/eval_register', 'http://zango.com'); require_once '../pipeline.class.php'; parse_config_file('../html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => true, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 10, 'right' => 10, 'top' => 10, 'bottom' => 10)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; $pipeline = new Pipeline(); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8(""); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->pre_tree_filters = array(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->post_tree_filters = array(); $pipeline->output_driver = new OutputDriverFPDF(); $time = time(); foreach ($urls as $url) { $pipeline->destination = new DestinationFile($url); $pipeline->process($url, $media); $message = sprintf("<br/>Processing of '%s' completed in %u seconds", $url, time() - $time); error_log($message);
function validate() { // before we do anything, let's find out the blogId and if there isn't any, quit $this->_getBlogInfo(); if ($this->_blogInfo == false) { // return 404 not found because the blog id is not correct! $this->_view = new ResourceServerView(); $this->_view->addHeaderResponse("HTTP/1.1 404 Not Found"); $this->_view->addHeaderResponse("Status: 404 Not Found"); $this->_view->addHeaderResponse("X-pLog-Error: Blog {$resId} is not correct"); return false; } // // security stuff // // :KLUDGE: the problem with the security Pipeline and the PluginManager in this // action is that we need to reimplement the whole stuff because... this action does not // inherit from BlogAction and therefore nobody is doing these things for us! I don't really // like to do it like this but while I think of a better way, let's leave like it // $pipeline = new Pipeline($this->_request, $this->_blogInfo); $result = $pipeline->process(); // if the pipeline blocked the request, then we have to let the user know and quit // processing if (!$result->isValid()) { $this->_view = new ResourceServerView(); $this->_view->addHeaderResponse("HTTP/1.1 403 Forbidden"); $this->_view->addHeaderResponse("Status: 403 Forbidden"); $this->_view->addHeaderResponse("X-pLog-Error: Access is blocked"); return false; } // now if the blog id was correct, then we can proceed to get the rest of the parameters $this->_resName = $this->_request->getValue("resource"); $this->_resId = $this->_request->getValue("resId"); $this->_albumId = $this->_request->getValue("albumId"); $this->_albumName = $this->_request->getValue("albumName"); $this->_mode = $this->_request->getValue("mode"); // check if we need to load the album to figure out the correct album id // because we got an album name instead of an album id if (!empty($this->_albumId) || !empty($this->_albumName)) { if ($this->_albumName) { $albums = new GalleryAlbums(); $album = $albums->getAlbumByName($this->_albumName); if (!$album) { $this->_view = new ResourceServerView(); $this->_view->addHeaderResponse("HTTP/1.1 404 Not Found"); $this->_view->addHeaderResponse("Status: 404 Not Found"); $this->_view->addHeaderResponse("X-pLog-Error: Album {$albumId} not found"); return false; } $this->_albumId = $album->getId(); } } return true; }
private static function processFilters($path, $dir, $filters, $vars) { $pipeline = Pipeline::getCurrentInstance(); $content = file_get_contents($path); if (false === $content) { throw new Exception\FileNotFound($path); } foreach ($filters as $filter) { $content = $pipeline->applyFilter($content, $filter, $path, $dir, $vars); } return $content; }
/** * @param SS_HTTPRequest $request * * @return SS_HTTPResponse * @throws SS_HTTPResponse_Exception */ public function pipeline(SS_HTTPRequest $request) { $params = $request->params(); $pipeline = Pipeline::get()->byID($params['Identifier']); if (!$pipeline || !$pipeline->ID || !$pipeline->Environment()) { throw new SS_HTTPResponse_Exception('Pipeline not found', 404); } if (!$pipeline->Environment()->canView()) { return Security::permissionFailure(); } $environment = $pipeline->Environment(); $project = $pipeline->Environment()->Project(); if ($environment->Name != $params['Environment']) { throw new LogicException("Environment in URL doesn't match this pipeline"); } if ($project->Name != $params['Project']) { throw new LogicException("Project in URL doesn't match this pipeline"); } // Delegate to sub-requesthandler return PipelineController::create($this, $pipeline); }
$outputdir = $argv[3]; $articlePath = $argv[4]; $author = $argv[5]; $headerFile = $argv[6]; $footerFile = $argv[7]; $date = date($_CONFIG['DateFormat']); $g_css_index = 0; $g_stylesheet_title = ""; $g_baseurl = $_CONFIG['BaseUrl']; $g_config = array('cssmedia' => 'print', 'renderimages' => $_CONFIG['RenderImages'], 'renderforms' => $_CONFIG['RenderForms'], 'renderlinks' => $_CONFIG['RenderLinks'], 'mode' => "html", 'debugbox' => false, 'pagewidth' => $_CONFIG['PageWidth'], 'draw_page_border' => false, 'smartpagebreak' => true, 'media' => $_CONFIG['MediaType'], 'pdfversion' => '1.6', 'method' => 'fpdf', 'transparency_workaround' => false, 'scalepoints' => false, 'pslevel' => 3, 'output' => "", 'landscape' => false); ob_start(); $g_media = Media::predefined($g_config['media']); $g_media->set_pixels($g_config['pagewidth']); $g_media->set_margins(array('left' => 10, 'right' => 10, 'top' => 25, 'bottom' => 10)); $g_media->set_landscape($g_config['landscape']); $pipeline = new Pipeline(); $pipeline->configure($g_config); global $g_px_scale; $g_px_scale = mm2pt($g_media->width() - $g_media->margins['left'] - $g_media->margins['right']) / $g_media->pixels; global $g_pt_scale; $g_pt_scale = $g_px_scale * 1.43; // for fetching the css files require_once HTML2PS_DIR . 'fetcher.local.class.php'; $pipeline->fetchers[] = new FetcherLocalfile($sourcefn); //require_once(HTML2PS_DIR.'fetcher.url.curl.class.php'); //$pipeline->fetchers[] = new FetcherUrlCurl(); #toc! if ($_CONFIG['CreateTOC']) { $pipeline->add_feature('toc', array('location', 'before')); } $header_html = file_get_contents($headerFile);