当前位置: 首页>>代码示例>>PHP>>正文


PHP JApplicationWeb::clearHeaders方法代码示例

本文整理汇总了PHP中JApplicationWeb::clearHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationWeb::clearHeaders方法的具体用法?PHP JApplicationWeb::clearHeaders怎么用?PHP JApplicationWeb::clearHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JApplicationWeb的用法示例。


在下文中一共展示了JApplicationWeb::clearHeaders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: download

 public function download()
 {
     // turn off all error reporting to prevent errors showing in download file
     error_reporting(0);
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.archive.zip');
     jimport('joomla.application.web');
     JApplicationWeb::clearHeaders();
     $path = JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/templates/';
     $folder = JRequest::getVar('template', '', '', 'string');
     $fullPath = JPath::clean($path . '/' . $folder);
     $files = JFolder::files($fullPath, '.', false, false);
     $archive = $path . $folder . '.zip';
     $filesData = array();
     for ($i = 0; $i < count($files); $i++) {
         $filesData[$i]['name'] = $files[$i];
         $filesData[$i]['data'] = file_get_contents($fullPath . '/' . $files[$i]);
     }
     // delete file if it already exists
     @chmod($path . '/' . $folder . '.zip', 0777);
     @unlink($path . '/' . $folder . '.zip');
     $JArchiveZip = JArchive::getAdapter('zip');
     $JArchiveZip->create($archive, $filesData);
     // push download
     ob_end_clean();
     ob_start();
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header("Content-Description: File Transfer");
     header("Content-type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"{$folder}.zip\"");
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . filesize($archive));
     readfile($archive);
     ob_end_flush();
 }
开发者ID:rodhoff,项目名称:MNW,代码行数:38,代码来源:templates.php

示例2: display


//.........这里部分代码省略.........
					$params->set('marker_mobile', $image6);
					$params->set('marker_class', 'jicons-icons');
					break;
			}
		}

		$params->set('prepare_content', '0');

		// Setup the category parameters.
		$cparams          = $category->getParams();
		$category->params = clone $params;
		$category->params->merge($cparams);
		$children = [$category->id => $children];
		$maxLevel = $params->get('maxLevel', -1);
		$items    = $renderHelper->groupit(['items' => & $items, 'field' => 'lname']);

		if (0)
		{
			foreach ($items as $s1)
			{
				$items[$s1] = $renderHelper->groupit(['items' => $items[$s1], 'field' => 'suburb']);
			}
		}

		$this->renderHelper = $renderHelper;
		$this->maxLevel     = & $maxLevel;
		$this->state        = & $state;
		$this->items        = $items;
		$this->category     = & $category;
		$this->children     = & $children;
		$this->params       = & $params;
		$this->pagination   = & $pagination;

		// Escape strings for HTML output
		$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));

		$menus = $app->getMenu();
		$title = 'directory_prent_out';

		// Because the application sets a default page title,
		// we need to get it from the menu item itself
		$menu = $menus->getActive();

		// Clean the output buffer
		@ob_end_clean();

		// Create new PDF document
		$this->pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

		// Set document information
		$this->pdf->SetCreator(PDF_CREATOR);
		$this->pdf->SetAuthor('NFSDA Church');
		$this->pdf->SetTitle($this->params->get('page_title', ''));
		$this->pdf->SetSubject('Church Directory');
		$this->pdf->SetKeywords('Directory, PDF, Members');

		// Set default header data
		$this->pdf->setHeaderData(
			$params->get('pdf_logo'),
			$params->get('pdf_logo_width'),
			$this->params->get('page_heading'),
			$params->get('pdf_header_string')
		);

		// Remove default header/footer
		$this->pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
		$this->pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

		// Set default monospaced font
		$this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

		// Set margins
		$this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
		$this->pdf->setHeaderMargin(PDF_MARGIN_HEADER);
		$this->pdf->setFooterMargin(PDF_MARGIN_FOOTER);

		// Set auto page breaks
		$this->pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);

		$this->pdf->setCellHeightRatio(1.25);

		// Set image scale factor
		$this->pdf->setImageScale(2.5);

		// ---------------------------------------------------------

		// Set font
		$this->pdf->SetFont('times', 'BI', 8, '', 'false');

		// Set some text to print
		$html = $this->loadTemplate($tpl);

		$jweb  = new JApplicationWeb;
		$jweb->clearHeaders();

		// Close and output PDF document
		$this->pdf->Output($title . '.pdf', 'I');

		return null;
	}
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:101,代码来源:view.pdf.php

示例3: getCsv

 /**
  * CVS Dump
  *
  * @param   object  $items   Items to pass through
  * @param   string  $report  Name of report to return.
  *
  * @return bool
  *
  * @since    1.7.0
  */
 public function getCsv($items, $report)
 {
     $date = new JDate('now');
     $jWeb = new JApplicationWeb();
     $csv = fopen('php://output', 'w');
     $jWeb->clearHeaders();
     // Clean the output buffer,
     @ob_end_clean();
     @ob_start();
     header("Content-type: text/csv");
     header("Content-Disposition: attachment; filename=report." . $report . '.' . $date->format('Y-m-d-His') . ".csv");
     header("Pragma: no-cache");
     header("Expires: 0");
     $count = 0;
     foreach ($items as $line) {
         foreach ($line as $c => $item) {
             if ($c == 'params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'attribs') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 $params_att = new stdClass();
                 foreach ($params as $p => $item_p) {
                     $p = 'att_' . $p;
                     if ($p == 'sex') {
                         switch ($item_p) {
                             case 0:
                                 $params_att->{$p} = 'M';
                                 break;
                             case 1:
                                 $params_att->{$p} = 'F';
                                 break;
                         }
                     } else {
                         $params_att->{$p} = $item_p;
                     }
                 }
                 unset($line->attribs);
                 $line = (object) array_merge((array) $line, (array) $params_att);
             } elseif ($c == 'kml_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->kml_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'category_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->category_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'metadata') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->metadata);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'con_position') {
                 $pos = [];
                 if ($item != 0) {
                     $positions = explode(',', $item);
                     foreach ($positions as $p => $position) {
                         $query = $this->db->getQuery(true);
                         // Join on Position.
                         $query->select('name');
                         $query->from('#__churchdirectory_position');
                         $query->where('id =' . $position);
                         $this->db->setQuery($query);
                         $pos[] = $this->db->loadResult();
                     }
                 } else {
                     $pos[] = null;
                 }
                 unset($line->con_position);
                 $line = (object) array_merge((array) $line, ['con_position' => implode(",", $pos)]);
             } elseif ($c == 'image') {
                 $line->{$c} = JUri::root() . $item;
             }
         }
         if ($count == 0) {
             $array = get_object_vars($line);
             fputcsv($csv, array_keys($array));
         }
         $count = 1;
         fputcsv($csv, (array) $line);
//.........这里部分代码省略.........
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:101,代码来源:reportbuild.php


注:本文中的JApplicationWeb::clearHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。