public function DoCheck() { AssetLoadManager::register('tableList'); // Search engine $vo_search_config_settings = SearchEngine::checkPluginConfiguration(); $this->view->setVar('search_config_settings', $vo_search_config_settings); $this->view->setVar('search_config_engine_name', SearchEngine::getPluginEngineName()); // Media $t_media = new Media(); $va_plugin_names = $t_media->getPluginNames(); $va_plugins = array(); foreach ($va_plugin_names as $vs_plugin_name) { if ($va_plugin_status = $t_media->checkPluginStatus($vs_plugin_name)) { $va_plugins[$vs_plugin_name] = $va_plugin_status; } } $this->view->setVar('media_config_plugin_list', $va_plugins); // PDF Rendering $t_pdf_renderer = new PDFRenderer(); $va_plugin_names = PDFRenderer::getAvailablePDFRendererPlugins(); $va_plugins = array(); foreach ($va_plugin_names as $vs_plugin_name) { if ($va_plugin_status = $t_pdf_renderer->checkPluginStatus($vs_plugin_name)) { $va_plugins[$vs_plugin_name] = $va_plugin_status; } } $this->view->setVar('pdf_renderer_config_plugin_list', $va_plugins); // Application plugins $va_plugin_names = ApplicationPluginManager::getPluginNames(); $va_plugins = array(); foreach ($va_plugin_names as $vs_plugin_name) { if ($va_plugin_status = ApplicationPluginManager::checkPluginStatus($vs_plugin_name)) { $va_plugins[$vs_plugin_name] = $va_plugin_status; } } $this->view->setVar('application_config_plugin_list', $va_plugins); // Barcode generation $vb_gd_is_available = caMediaPluginGDInstalled(true); $va_barcode_components = array(); $va_gd = array('name' => 'GD', 'description' => _t('GD is a graphics processing library required for all barcode generation.')); if (!$vb_gd_is_available) { $va_gd['errors'][] = _t('Is not installed; barcode printing will not be possible.'); } $va_gd['available'] = $vb_gd_is_available; $va_barcode_components['GD'] = $va_gd; $this->view->setVar('barcode_config_component_list', $va_barcode_components); // General system configuration issues if (!(bool) $this->request->config->get('dont_do_expensive_configuration_checks_in_web_ui')) { ConfigurationCheck::performExpensive(); if (ConfigurationCheck::foundErrors()) { $this->view->setVar('configuration_check_errors', ConfigurationCheck::getErrors()); } } $this->render('config_check_html.php'); }
/** * Set page size and orientation * * @param string Page size (ex. A4, letter, legal) * @param string Page orientation (ex. portrait, landscape) * * @return bool True on success, false if parameters are invalid */ public function setPage($ps_size, $ps_orientation, $ps_margin_top = 0, $ps_margin_right = 0, $ps_margin_bottom = 0, $ps_margin_left = 0) { if (!PDFRenderer::isValidPageSize($ps_size) || !PDFRenderer::isValidOrientation($ps_orientation)) { return false; } $this->ops_page_size = $ps_size; $this->ops_page_orientation = $ps_orientation; $this->ops_margin_top = caConvertMeasurement($ps_margin_top, 'mm') . 'mm'; $this->ops_margin_right = caConvertMeasurement($ps_margin_right, 'mm') . 'mm'; $this->ops_margin_bottom = caConvertMeasurement($ps_margin_bottom, 'mm') . 'mm'; $this->ops_margin_left = caConvertMeasurement($ps_margin_left, 'mm') . 'mm'; return true; }
/** * Generate export file of current result */ protected function _genExport($po_result, $ps_output_type, $ps_output_filename, $ps_title = null) { $this->view->setVar('criteria_summary', $vs_criteria_summary = $this->getCriteriaForDisplay()); // add displayable description of current search/browse parameters $this->view->setVar('criteria_summary_truncated', mb_substr($vs_criteria_summary, 0, 60) . (mb_strlen($vs_criteria_summary) > 60 ? '...' : '')); $po_result->seek(0); // reset result before exporting anything $this->opo_result_context->setParameter('last_export_type', $ps_output_type); $this->opo_result_context->saveContext(); if (substr($ps_output_type, 0, 4) !== '_pdf') { switch ($ps_output_type) { case '_xlsx': require_once __CA_LIB_DIR__ . "/core/Parsers/PHPExcel/PHPExcel.php"; require_once __CA_LIB_DIR__ . "/core/Parsers/PHPExcel/PHPExcel/Writer/Excel2007.php"; $this->render('Results/xlsx_results.php'); return; case '_docx': require_once __CA_LIB_DIR__ . "/core/Parsers/PHPWord/Autoloader.php"; \PhpOffice\PhpWord\Autoloader::register(); $this->render('Results/docx_results.php'); return; case '_csv': $vs_delimiter = ","; $vs_output_file_name = mb_substr(preg_replace("/[^A-Za-z0-9\\-]+/", '_', $ps_output_filename . '_csv'), 0, 30); $vs_file_extension = 'txt'; $vs_mimetype = "text/plain"; break; case '_tab': $vs_delimiter = "\t"; $vs_output_file_name = mb_substr(preg_replace("/[^A-Za-z0-9\\-]+/", '_', $ps_output_filename . '_tab'), 0, 30); $vs_file_extension = 'txt'; $vs_mimetype = "text/plain"; default: break; } header("Content-Disposition: attachment; filename=export_" . $vs_output_file_name . "." . $vs_file_extension); header("Content-type: " . $vs_mimetype); // get display list self::Index(null, null); $va_display_list = $this->view->getVar('display_list'); $va_rows = array(); // output header $va_row = array(); foreach ($va_display_list as $va_display_item) { $va_row[] = $va_display_item['display']; } $va_rows[] = join($vs_delimiter, $va_row); $po_result->seek(0); $t_display = $this->view->getVar('t_display'); while ($po_result->nextHit()) { $va_row = array(); foreach ($va_display_list as $vn_placement_id => $va_display_item) { $vs_value = html_entity_decode($t_display->getDisplayValue($po_result, $vn_placement_id, array('convert_codes_to_display_text' => true, 'convertLineBreaks' => false)), ENT_QUOTES, 'UTF-8'); $vs_value = preg_replace("![\r\n\t]+!", " ", $vs_value); // quote values as required if (preg_match("![^A-Za-z0-9 .;]+!", $vs_value)) { $vs_value = '"' . str_replace('"', '""', $vs_value) . '"'; } $va_row[] = $vs_value; } $va_rows[] = join($vs_delimiter, $va_row); } $this->opo_response->addContent(join("\n", $va_rows), 'view'); } else { // // PDF output // $va_template_info = caGetPrintTemplateDetails('results', substr($ps_output_type, 5)); if (!is_array($va_template_info)) { $this->postError(3110, _t("Could not find view for PDF"), "BaseFindController->PrintSummary()"); return; } try { $this->view->setVar('base_path', $vs_base_path = pathinfo($va_template_info['path'], PATHINFO_DIRNAME) . '/'); $this->view->addViewPath(array($vs_base_path, "{$vs_base_path}/local")); $o_pdf = new PDFRenderer(); $va_page_size = PDFRenderer::getPageSize(caGetOption('pageSize', $va_template_info, 'letter'), 'mm', caGetOption('pageOrientation', $va_template_info, 'portrait')); $vn_page_width = $va_page_size['width']; $vn_page_height = $va_page_size['height']; $this->view->setVar('pageWidth', "{$vn_page_width}mm"); $this->view->setVar('pageHeight', "{$vn_page_height}mm"); $this->view->setVar('marginTop', caGetOption('marginTop', $va_template_info, '0mm')); $this->view->setVar('marginRight', caGetOption('marginRight', $va_template_info, '0mm')); $this->view->setVar('marginBottom', caGetOption('marginBottom', $va_template_info, '0mm')); $this->view->setVar('marginLeft', caGetOption('marginLeft', $va_template_info, '0mm')); $this->view->setVar('PDFRenderer', $o_pdf->getCurrentRendererCode()); $vs_content = $this->render($va_template_info['path']); $o_pdf->setPage(caGetOption('pageSize', $va_template_info, 'letter'), caGetOption('pageOrientation', $va_template_info, 'portrait'), caGetOption('marginTop', $va_template_info, '0mm'), caGetOption('marginRight', $va_template_info, '0mm'), caGetOption('marginBottom', $va_template_info, '0mm'), caGetOption('marginLeft', $va_template_info, '0mm')); $o_pdf->render($vs_content, array('stream' => true, 'filename' => caGetOption('filename', $va_template_info, 'export_results.pdf'))); } catch (Exception $e) { $this->postError(3100, _t("Could not generate PDF"), "BaseFindController->PrintSummary()"); } return; } }
/** * Get page width and height for a specific page type * * @param string $ps_size A valid page size (eg. A4, letter, legal) * @param string $ps_units Units to return measurements in (eg. mm, cm, in) * @param string $ps_orientation Orientation of page (eg. portrait, landscape) * * @return array Array with width and height keys */ public static function getPageSize($ps_size, $ps_units = 'mm', $ps_orientation = 'portrait') { $ps_orientation = strtolower($ps_orientation); if (!PDFRenderer::isValidOrientation($ps_orientation)) { $ps_orientation = 'portrait'; } $va_page_size = CPDF_Adapter::$PAPER_SIZES[$ps_size]; $vn_page_width = caConvertMeasurement($va_page_size[2] - $va_page_size[0] . 'px', $ps_units); $vn_page_height = caConvertMeasurement($va_page_size[3] - $va_page_size[1] . 'px', $ps_units); return $ps_orientation == 'portrait' ? array('width' => $vn_page_width, 'height' => $vn_page_height) : array('width' => $vn_page_height, 'height' => $vn_page_width); }
/** * Generates display for specific bundle or (optionally) a specific repetition in a bundle * ** Right now only attribute bundles are supported for printing ** * * @param array $pa_options Array of options passed through to _initView */ public function PrintBundle($pa_options = null) { list($vn_subject_id, $t_subject) = $this->_initView($pa_options); if (!$this->_checkAccess($t_subject)) { return false; } // // PDF output // $vs_template = substr($this->request->getParameter('template', pString), 5); // get rid of _pdf_ prefix if (!is_array($va_template_info = caGetPrintTemplateDetails('bundles', $vs_template))) { $this->postError(3110, _t("Could not find view for PDF"), "BaseEditorController->PrintBundle()"); return; } // Element code to display $vs_element = $this->request->getParameter('element_code', pString); $vn_attribute_id = $this->request->getParameter('attribute_id', pString); // Does user have access to this element? if ($this->request->user->getBundleAccessLevel($t_subject->tableName(), $vs_element) == __CA_BUNDLE_ACCESS_NONE__) { $this->postError(2320, _t("No access to element"), "BaseEditorController->PrintBundle()"); return; } // Add raw array of values to view if ($vn_attribute_id > 0) { $o_attr = $t_subject->getAttributeByID($vn_attribute_id); if ((int) $o_attr->getRowID() !== (int) $vn_subject_id || (int) $o_attr->getTableNum() !== (int) $t_subject->tableNum()) { $this->postError(2320, _t("Element is not part of current item"), "BaseEditorController->PrintBundle()"); return; } $this->view->setVar('valuesAsAttributeInstances', $va_values = array($o_attr)); } else { $this->view->setVar('valuesAsAttributeInstances', $va_values = $t_subject->getAttributesByElement($vs_element)); } // Extract values into array for easier view processing $va_extracted_values = array(); foreach ($va_values as $o_value) { $va_extracted_values[] = $o_value->getDisplayValues(); } $this->view->setVar('valuesAsElementCodeArrays', $va_extracted_values); $va_barcode_files_to_delete = array(); try { $this->view->setVar('base_path', $vs_base_path = pathinfo($va_template_info['path'], PATHINFO_DIRNAME)); $this->view->addViewPath(array($vs_base_path, "{$vs_base_path}/local")); $va_barcode_files_to_delete += caDoPrintViewTagSubstitution($this->view, $t_subject, $va_template_info['path'], array('checkAccess' => $this->opa_access_values)); $o_pdf = new PDFRenderer(); $this->view->setVar('PDFRenderer', $o_pdf->getCurrentRendererCode()); $va_page_size = PDFRenderer::getPageSize(caGetOption('pageSize', $va_template_info, 'letter'), 'mm', caGetOption('pageOrientation', $va_template_info, 'portrait')); $vn_page_width = $va_page_size['width']; $vn_page_height = $va_page_size['height']; $this->view->setVar('pageWidth', "{$vn_page_width}mm"); $this->view->setVar('pageHeight', "{$vn_page_height}mm"); $this->view->setVar('marginTop', caGetOption('marginTop', $va_template_info, '0mm')); $this->view->setVar('marginRight', caGetOption('marginRight', $va_template_info, '0mm')); $this->view->setVar('marginBottom', caGetOption('marginBottom', $va_template_info, '0mm')); $this->view->setVar('marginLeft', caGetOption('marginLeft', $va_template_info, '0mm')); $vs_content = $this->render($va_template_info['path']); $o_pdf->setPage(caGetOption('pageSize', $va_template_info, 'letter'), caGetOption('pageOrientation', $va_template_info, 'portrait'), caGetOption('marginTop', $va_template_info, '0mm'), caGetOption('marginRight', $va_template_info, '0mm'), caGetOption('marginBottom', $va_template_info, '0mm'), caGetOption('marginLeft', $va_template_info, '0mm')); $o_pdf->render($vs_content, array('stream' => true, 'filename' => caGetOption('filename', $va_template_info, 'print_bundles.pdf'))); $vb_printed_properly = true; foreach ($va_barcode_files_to_delete as $vs_tmp) { @unlink($vs_tmp); @unlink("{$vs_tmp}.png"); } } catch (Exception $e) { foreach ($va_barcode_files_to_delete as $vs_tmp) { @unlink($vs_tmp); @unlink("{$vs_tmp}.png"); } $vb_printed_properly = false; $this->postError(3100, _t("Could not generate PDF"), "BaseEditorController->PrintBundle()"); } }