/** * */ public function Info() { $o_dm = Datamodel::load(); $t_display = new ca_bundle_displays($vn_display_id = $this->_getDisplayID()); $this->view->setVar('bundle_displays', caExtractValuesByUserLocale($t_display->getBundleDisplays(array('user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_EDIT_ACCESS__)), null, array())); return $this->render('widget_bundle_display_info_html.php', true); }
/** * */ public function __construct(&$po_request, &$po_response, $pa_view_paths = null) { parent::__construct($po_request, $po_response, $pa_view_paths); // merge displays with drop-in print templates $va_export_options = caGetAvailablePrintTemplates('results', array('table' => $this->ops_tablename)); $this->view->setVar('export_formats', $va_export_options); //$this->view->setVar('current_export_format', $this->opo_result_context->getParameter('last_export_type')); $va_options = array(); foreach ($va_export_options as $vn_i => $va_format_info) { $va_options[$va_format_info['name']] = $va_format_info['code']; } // Get current display list $t_display = new ca_bundle_displays(); foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'checkAccess' => caGetUserAccessValues($this->request)))) as $va_display) { $va_options[$va_display['name']] = "_display_" . $va_display['display_id']; } ksort($va_options); $this->view->setVar('export_format_select', caHTMLSelect('export_format', $va_options, array('class' => 'searchToolsSelect'), array('value' => $this->view->getVar('current_export_format'), 'width' => '150px'))); }
/** * */ public function __call($ps_function, $pa_args) { AssetLoadManager::register("panel"); AssetLoadManager::register("mediaViewer"); AssetLoadManager::register("carousel"); AssetLoadManager::register("readmore"); AssetLoadManager::register("maps"); $ps_function = strtolower($ps_function); $ps_id = urldecode($this->request->getActionExtra()); if (!isset($this->opa_detail_types[$ps_function]) || !isset($this->opa_detail_types[$ps_function]['table']) || !($vs_table = $this->opa_detail_types[$ps_function]['table'])) { // invalid detail type – throw error die("Invalid detail type"); } $t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true); if (($vb_use_identifiers_in_urls = caUseIdentifiersInUrls()) && substr($ps_id, 0, 3) == "id:") { $va_tmp = explode(":", $ps_id); $ps_id = (int) $va_tmp[1]; $vb_use_identifiers_in_urls = false; } if (!$t_table->load($vb_use_identifiers_in_urls && $t_table->getProperty('ID_NUMBERING_ID_FIELD') ? $t_table->hasField('deleted') ? array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id, 'deleted' => 0) : array($t_table->getProperty('ID_NUMBERING_ID_FIELD') => $ps_id) : ($t_table->hasField('deleted') ? array($t_table->primaryKey() => (int) $ps_id, 'deleted' => 0) : array($t_table->primaryKey() => (int) $ps_id)))) { // invalid id - throw error die("Invalid id"); } // Printables // merge displays with drop-in print templates // $va_export_options = caGetAvailablePrintTemplates('summary', array('table' => $t_table->tableName())); $this->view->setVar('export_formats', $va_export_options); $va_options = array(); foreach ($va_export_options as $vn_i => $va_format_info) { $va_options[$va_format_info['name']] = $va_format_info['code']; } // Get current display list $t_display = new ca_bundle_displays(); foreach (caExtractValuesByUserLocale($t_display->getBundleDisplays(array('table' => $this->ops_tablename, 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'checkAccess' => caGetUserAccessValues($this->request)))) as $va_display) { $va_options[$va_display['name']] = "_display_" . $va_display['display_id']; } ksort($va_options); $this->view->setVar('export_format_select', caHTMLSelect('export_format', $va_options, array('class' => 'searchToolsSelect'), array('value' => $this->view->getVar('current_export_format'), 'width' => '150px'))); # # Enforce access control # if (sizeof($this->opa_access_values) && $t_table->hasField('access') && !in_array($t_table->get("access"), $this->opa_access_values)) { $this->notification->addNotification(_t("This item is not available for view"), "message"); $this->response->setRedirect(caNavUrl($this->request, "", "", "", "")); return; } MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . $t_table->getTypeName() . ": " . $t_table->get('preferred_labels') . (($vs_idno = $t_table->get($t_table->getProperty('ID_NUMBERING_ID_FIELD'))) ? " [{$vs_idno}]" : "")); $vs_type = $t_table->getTypeCode(); $this->view->setVar('detailType', $vs_table); $this->view->setVar('item', $t_table); $this->view->setVar('itemType', $vs_type); caAddPageCSSClasses(array($vs_table, $ps_function, $vs_type)); // Do we need to pull in the multisearch result set? if (ResultContext::getLastFind($this->request, $vs_table, array('noSubtype' => true)) === 'multisearch') { $o_context = new ResultContext($this->request, $vs_table, 'multisearch', $ps_function); $o_context->setAsLastFind(); $o_context->saveContext(); } else { $o_context = ResultContext::getResultContextForLastFind($this->request, $vs_table); } $this->view->setVar('previousID', $vn_previous_id = $o_context->getPreviousID($t_table->getPrimaryKey())); $this->view->setVar('nextID', $vn_next_id = $o_context->getNextID($t_table->getPrimaryKey())); $this->view->setVar('previousURL', caDetailUrl($this->request, $vs_table, $vn_previous_id)); $this->view->setVar('nextURL', caDetailUrl($this->request, $vs_table, $vn_next_id)); $this->view->setVar('resultsURL', ResultContext::getResultsUrlForLastFind($this->request, $vs_table)); $va_options = isset($this->opa_detail_types[$ps_function]['options']) && is_array($this->opa_detail_types[$ps_function]['options']) ? $this->opa_detail_types[$ps_function]['options'] : array(); $this->view->setVar('previousLink', $vn_previous_id > 0 ? caDetailLink($this->request, caGetOption('previousLink', $va_options, _t('Previous')), '', $vs_table, $vn_previous_id) : ''); $this->view->setVar('nextLink', $vn_next_id > 0 ? caDetailLink($this->request, caGetOption('nextLink', $va_options, _t('Next')), '', $vs_table, $vn_next_id) : ''); $this->view->setVar('resultsLink', ResultContext::getResultsLinkForLastFind($this->request, $vs_table, caGetOption('resultsLink', $va_options, _t('Back')))); $this->view->setVar('commentsEnabled', (bool) $va_options['enableComments']); // // // if (method_exists($t_table, 'getPrimaryRepresentationInstance')) { if ($pn_representation_id = $this->request->getParameter('representation_id', pInteger)) { $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true); $t_representation->load($pn_representation_id); } else { $t_representation = $t_table->getPrimaryRepresentationInstance(array("checkAccess" => $this->opa_access_values)); } if ($t_representation) { $this->view->setVar("t_representation", $t_representation); $this->view->setVar("representation_id", $t_representation->get("representation_id")); } else { $t_representation = $this->opo_datamodel->getInstanceByTableName("ca_object_representations", true); } $this->view->setVar("representationViewer", caObjectDetailMedia($this->request, $t_table->getPrimaryKey(), $t_representation, $t_table, array("primaryOnly" => caGetOption('representationViewerPrimaryOnly', $va_options, false), "dontShowPlaceholder" => caGetOption('representationViewerDontShowPlaceholder', $va_options, false)))); } // // map // if (!is_array($va_map_attributes = caGetOption('map_attributes', $va_options, array())) || !sizeof($va_map_attributes)) { if ($vs_map_attribute = caGetOption('map_attribute', $va_options, false)) { $va_map_attributes = array($vs_map_attribute); } } $this->view->setVar("map", ""); if (is_array($va_map_attributes) && sizeof($va_map_attributes)) { $o_map = new GeographicMap(($vn_width = caGetOption('map_width', $va_options, false)) ? $vn_width : 285, ($vn_height = caGetOption('map_height', $va_options, false)) ? $vn_height : 200, 'map'); $vn_mapped_count = 0; foreach ($va_map_attributes as $vs_map_attribute) { if ($t_table->get($vs_map_attribute)) { $o_map->mapFrom($t_table, $vs_map_attribute); $vn_mapped_count++; } } if ($vn_mapped_count > 0) { $this->view->setVar("map", $o_map->render('HTML')); } } // // comments, tags, rank // $this->view->setVar('averageRank', $t_table->getAverageRating(true)); $this->view->setVar('numRank', $t_table->getNumRatings(true)); # # User-generated comments, tags and ratings # $va_user_comments = $t_table->getComments(null, true); $va_comments = array(); if (is_array($va_user_comments)) { foreach ($va_user_comments as $va_user_comment) { if ($va_user_comment["comment"] || $va_user_comment["media1"] || $va_user_comment["media2"] || $va_user_comment["media3"] || $va_user_comment["media4"]) { # TODO: format date based on locale $va_user_comment["date"] = date("n/j/Y", $va_user_comment["created_on"]); # -- get name of commenter if ($va_user_comment["user_id"]) { $t_user = new ca_users($va_user_comment["user_id"]); $va_user_comment["author"] = $t_user->getName(); } elseif ($va_user_comment["name"]) { $va_user_comment["author"] = $va_user_comment["name"]; } $va_comments[] = $va_user_comment; } } } $this->view->setVar('comments', $va_comments); $va_user_tags = $t_table->getTags(null, true); $va_tags = array(); if (is_array($va_user_tags)) { foreach ($va_user_tags as $va_user_tag) { if (!in_array($va_user_tag["tag"], $va_tags)) { $va_tags[] = $va_user_tag["tag"]; } } } $this->view->setVar('tags_array', $va_tags); $this->view->setVar('tags', implode(", ", $va_tags)); $this->view->setVar("itemComments", caDetailItemComments($this->request, $t_table->getPrimaryKey(), $t_table, $va_comments, $va_tags)); // // share link // $this->view->setVar("shareLink", "<a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($this->request, '', 'Detail', 'ShareForm', array("tablename" => $t_table->tableName(), "item_id" => $t_table->getPrimaryKey())) . "\"); return false;'>Share</a>"); // find view // first look for type-specific view if (!$this->viewExists($vs_path = "Details/{$vs_table}_{$vs_type}_html.php")) { // If no type specific view use the default $vs_path = "Details/{$vs_table}_default_html.php"; } switch ($ps_view = $this->request->getParameter('view', pString)) { case 'pdf': $this->_genExport($t_table, $this->request->getParameter("export_format", pString), 'Detail', 'Detail'); break; default: // // Tag substitution // // Views can contain tags in the form {{{tagname}}}. Some tags, such as "itemType" and "detailType" are defined by // the detail controller. More usefully, you can pull data from the item being detailed by using a valid "get" expression // as a tag (Eg. {{{ca_objects.idno}}}. Even more usefully for some, you can also use a valid bundle display template // (see http://docs.collectiveaccess.org/wiki/Bundle_Display_Templates) as a tag. The template will be evaluated in the // context of the item being detailed. // $va_defined_vars = array_keys($this->view->getAllVars()); // get list defined vars (we don't want to copy over them) $va_tag_list = $this->getTagListForView($vs_path); // get list of tags in view foreach ($va_tag_list as $vs_tag) { if (in_array($vs_tag, $va_defined_vars)) { continue; } if (strpos($vs_tag, "^") !== false || strpos($vs_tag, "<") !== false) { $this->view->setVar($vs_tag, $t_table->getWithTemplate($vs_tag, array('checkAccess' => $this->opa_access_values))); } elseif (strpos($vs_tag, ".") !== false) { $this->view->setVar($vs_tag, $t_table->get($vs_tag, array('checkAccess' => $this->opa_access_values))); } else { $this->view->setVar($vs_tag, "?{$vs_tag}"); } } $this->render($vs_path); break; } }
public function getDisplaysAsXML() { $t_display = new ca_bundle_displays(); /** @var Datamodel $o_dm */ $o_dm = Datamodel::load(); $this->opt_locale = new ca_locales(); $va_displays = $t_display->getBundleDisplays(); $vs_buf = "<displays>\n"; foreach ($va_displays as $vn_i => $va_display_by_locale) { $va_locales = array_keys($va_display_by_locale); $va_info = $va_display_by_locale[$va_locales[0]]; if (!$t_display->load($va_info['display_id'])) { continue; } $vs_buf .= "\t<display code='" . ($va_info['display_code'] && preg_match('!^[A-Za-z0-9_]+$!', $va_info['display_code']) ? $va_info['display_code'] : 'display_' . $va_info['display_id']) . "' type='" . $o_dm->getTableName($va_info['table_num']) . "' system='" . $t_display->get('is_system') . "'>\n"; $vs_buf .= "\t\t<labels>\n"; foreach ($va_display_by_locale as $vn_locale_id => $va_display_info) { if (strlen($this->opt_locale->localeIDToCode($vn_locale_id)) > 0) { $vs_buf .= "\t\t\t<label locale='" . $this->opt_locale->localeIDToCode($vn_locale_id) . "'><name>" . caEscapeForXML($va_display_info['name']) . "</name></label>\n"; } } $vs_buf .= "\t\t</labels>\n"; $va_settings = $t_display->getSettings(); if (sizeof($va_settings) > 0) { $vs_buf .= "\t\t<settings>\n"; foreach ($va_settings as $vs_setting => $vm_val) { if (is_array($vm_val)) { foreach ($vm_val as $vn_i => $vn_val) { $vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vn_val . "]]></setting>\n"; } } else { $vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vm_val . "]]></setting>\n"; } } $vs_buf .= "\t\t</settings>\n"; } // User and group access $va_users = $t_display->getUsers(); if (sizeof($va_users) > 0) { $vs_buf .= "\t\t<userAccess>\n"; foreach ($va_users as $va_user_info) { $vs_buf .= "\t\t\t<permission user='******' access='" . $this->_convertUserGroupAccessToString(intval($va_user_info['access'])) . "'/>\n"; } $vs_buf .= "\t\t</userAccess>\n"; } $va_groups = $t_display->getUserGroups(); if (sizeof($va_groups) > 0) { $vs_buf .= "\t\t<groupAccess>\n"; foreach ($va_groups as $va_group_info) { $vs_buf .= "\t\t\t<permission group='" . $va_group_info["code"] . "' access='" . $this->_convertUserGroupAccessToString(intval($va_group_info['access'])) . "'/>\n"; } $vs_buf .= "\t\t</groupAccess>\n"; } $va_placements = $t_display->getPlacements(); $vs_buf .= "<bundlePlacements>\n"; foreach ($va_placements as $vn_placement_id => $va_placement_info) { $vs_buf .= "\t\t<placement code='" . preg_replace("![^A-Za-z0-9_]+!", "_", $va_placement_info['bundle_name']) . "'><bundle>" . $va_placement_info['bundle_name'] . "</bundle>\n"; $va_settings = caUnserializeForDatabase($va_placement_info['settings']); if (is_array($va_settings)) { $vs_buf .= "<settings>\n"; foreach ($va_settings as $vs_setting => $vm_value) { switch ($vs_setting) { case 'label': if (is_array($vm_value)) { foreach ($vm_value as $vn_locale_id => $vm_locale_specific_value) { if (preg_match("/^[a-z]{2,3}\\_[A-Z]{2,3}\$/", $vn_locale_id)) { // locale code $vs_locale_code = $vn_locale_id; } else { if (!($vs_locale_code = $this->opt_locale->localeIDToCode($vn_locale_id))) { $vs_locale_code = 'en_US'; } } $vs_buf .= "<setting name='label' locale='" . $vs_locale_code . "'>" . caEscapeForXML($vm_locale_specific_value) . "</setting>\n"; } } break; case 'restrict_to_relationship_types': if (is_array($vm_value)) { foreach ($vm_value as $vn_val) { $t_rel_type = new ca_relationship_types($vn_val); if ($t_rel_type->getPrimaryKey()) { $vs_value = $t_rel_type->get('type_code'); $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n"; } } } break; case 'restrict_to_types': if (is_array($vm_value)) { foreach ($vm_value as $vn_val) { $t_item = new ca_list_items($vn_val); if ($t_item->getPrimaryKey()) { $vs_value = $t_item->get('idno'); $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n"; } } } break; default: if (is_array($vm_value)) { foreach ($vm_value as $vn_i => $vn_val) { $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vn_val . "]]></setting>\n"; } } else { $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vm_value . "]]></setting>\n"; } break; } } $vs_buf .= "</settings>\n"; } $vs_buf .= "\t\t</placement>\n"; } $vs_buf .= "</bundlePlacements>\n"; $vs_buf .= "\t</display>\n"; } $vs_buf .= "</displays>\n"; return $vs_buf; }
public function getDisplaysAsXML($pa_options = null) { $t_display = new ca_bundle_displays(); $o_dm = Datamodel::load(); $this->opt_locale = new ca_locales(); $va_displays = $t_display->getBundleDisplays(); $vs_buf = "<displays>\n"; foreach ($va_displays as $vn_i => $va_display_by_locale) { $va_locales = array_keys($va_display_by_locale); $va_info = $va_display_by_locale[$va_locales[0]]; if (!$t_display->load($va_info['display_id'])) { continue; } $vs_buf .= "\t<display code='" . ($va_info['display_code'] && preg_match('!^[A-Za-z0-9_]+$!', $va_info['display_code']) ? $va_info['display_code'] : 'display_' . $va_info['display_id']) . "' type='" . $o_dm->getTableName($va_info['table_num']) . "' system='" . $t_display->get('is_system') . "'>\n"; $vs_buf .= "\t\t<labels>\n"; foreach ($va_display_by_locale as $vn_locale_id => $va_display_info) { if (strlen($this->opt_locale->localeIDToCode($vn_locale_id)) > 0) { $vs_buf .= "\t\t\t<label locale='" . $this->opt_locale->localeIDToCode($vn_locale_id) . "'><name>" . caEscapeForXML($va_display_info['name']) . "</name></label>\n"; } } $vs_buf .= "\t\t</labels>\n"; $va_placements = $t_display->getPlacements(); //print_R(($va_placements)); $vs_buf .= "<bundlePlacements>\n"; foreach ($va_placements as $vn_placement_id => $va_placement_info) { $vs_buf .= "\t\t<placement code='" . preg_replace("![^A-Za-z0-9_]+!", "_", $va_placement_info['bundle_name']) . "'><bundle>" . $va_placement_info['bundle_name'] . "</bundle>\n"; $va_settings = caUnserializeForDatabase($va_placement_info['settings']); if (is_array($va_settings)) { $vs_buf .= "<settings>\n"; foreach ($va_settings as $vs_setting => $vm_value) { switch ($vs_setting) { case 'label': //restrict_to_relationship_types if (is_array($vm_value)) { foreach ($vm_value as $vn_locale_id => $vm_locale_specific_value) { $vs_buf .= "<setting name='label' locale='" . $this->opt_locale->localeIDToCode($vn_locale_id) . "'>" . caEscapeForXML($vm_locale_specific_value) . "</setting>\n"; } } break; default: if (is_array($vm_value)) { foreach ($vm_value as $vn_i => $vn_val) { $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'>" . caEscapeForXML($vn_val) . "</setting>\n"; } } else { $vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'>" . caEscapeForXML($vm_value) . "</setting>\n"; } break; } } $vs_buf .= "</settings>\n"; } $vs_buf .= "\t\t</placement>\n"; } $vs_buf .= "</bundlePlacements>\n"; $vs_buf .= "\t</display>\n"; } $vs_buf .= "</displays>\n"; //print_R($va_displays); return $vs_buf; }
/** * Generates display summary of record data based upon a bundle display for print (PDF) * * @param array $pa_options Array of options passed through to _initView */ public function PrintSummary($pa_options = null) { AssetLoadManager::register('tableList'); list($vn_subject_id, $t_subject) = $this->_initView($pa_options); if (!$this->_checkAccess($t_subject)) { return false; } $t_display = new ca_bundle_displays(); $va_displays = $t_display->getBundleDisplays(array('table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'restrictToTypes' => array($t_subject->getTypeID()))); if (!($vn_display_id = $this->request->getParameter('display_id', pInteger)) || !isset($va_displays[$vn_display_id])) { if (!($vn_display_id = $this->request->user->getVar($t_subject->tableName() . '_summary_display_id')) || !isset($va_displays[$vn_display_id])) { $va_tmp = array_keys($va_displays); $vn_display_id = $va_tmp[0]; } } $this->view->setVar('t_display', $t_display); $this->view->setVar('bundle_displays', $va_displays); // Check validity and access of specified display if ($t_display->load($vn_display_id) && $t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__)) { $this->view->setVar('display_id', $vn_display_id); $va_placements = $t_display->getPlacements(array('returnAllAvailableIfEmpty' => true, 'table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'no_tooltips' => true, 'format' => 'simple', 'settingsOnly' => true)); $va_display_list = array(); foreach ($va_placements as $vn_placement_id => $va_display_item) { $va_settings = caUnserializeForDatabase($va_display_item['settings']); // get column header text $vs_header = $va_display_item['display']; if (isset($va_settings['label']) && is_array($va_settings['label'])) { if ($vs_tmp = array_shift(caExtractValuesByUserLocale(array($va_settings['label'])))) { $vs_header = $vs_tmp; } } $va_display_list[$vn_placement_id] = array('placement_id' => $vn_placement_id, 'bundle_name' => $va_display_item['bundle_name'], 'display' => $vs_header, 'settings' => $va_settings); } $this->view->setVar('placements', $va_display_list); $this->request->user->setVar($t_subject->tableName() . '_summary_display_id', $vn_display_id); $vs_format = $this->request->config->get("summary_print_format"); } else { $vn_display_id = $t_display = null; $this->view->setVar('display_id', null); $this->view->setVar('placements', array()); } // // PDF output // if (!$vn_display_id || !$t_display || !is_array($va_template_info = caGetPrintTemplateDetails('summary', "{$this->ops_table_name}_" . $t_display->get('display_code') . "_summary"))) { if (!is_array($va_template_info = caGetPrintTemplateDetails('summary', "{$this->ops_table_name}_summary"))) { if (!is_array($va_template_info = caGetPrintTemplateDetails('summary', "summary"))) { $this->postError(3110, _t("Could not find view for PDF"), "BaseEditorController->PrintSummary()"); return; } } } $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)); $vs_content = $this->render($va_template_info['path']); $o_dompdf = new DOMPDF(); $o_dompdf->load_html($vs_content); $o_dompdf->set_paper(caGetOption('pageSize', $va_template_info, 'letter'), caGetOption('pageOrientation', $va_template_info, 'portrait')); $o_dompdf->set_base_path(caGetPrintTemplateDirectoryPath('summary')); $o_dompdf->render(); $o_dompdf->stream(caGetOption('filename', $va_template_info, 'print_summary.pdf')); $vb_printed_properly = true; foreach ($va_barcode_files_to_delete as $vs_tmp) { @unlink($vs_tmp); } } catch (Exception $e) { foreach ($va_barcode_files_to_delete as $vs_tmp) { @unlink($vs_tmp); } $vb_printed_properly = false; $this->postError(3100, _t("Could not generate PDF"), "BaseEditorController->PrintSummary()"); } }
/** * Generates display summary of record data based upon a bundle display for print (PDF) * * @param array $pa_options Array of options passed through to _initView */ public function PrintSummary($pa_options = null) { require_once __CA_LIB_DIR__ . "/core/Print/html2pdf/html2pdf.class.php"; JavascriptLoadManager::register('tableList'); list($vn_subject_id, $t_subject) = $this->_initView($pa_options); // // Is record of correct type? // $va_restrict_to_types = null; if ($t_subject->getAppConfig()->get('perform_type_access_checking')) { $va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__)); } if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) { $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2560?r=' . urlencode($this->request->getFullUrlPath())); return; } // // Does user have access to row? // if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) { if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) { $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2580?r=' . urlencode($this->request->getFullUrlPath())); return; } } $t_display = new ca_bundle_displays(); $va_displays = $t_display->getBundleDisplays(array('table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'restrictToTypes' => array($t_subject->getTypeID()))); if (!($vn_display_id = $this->request->getParameter('display_id', pInteger)) || !isset($va_displays[$vn_display_id])) { if (!($vn_display_id = $this->request->user->getVar($t_subject->tableName() . '_summary_display_id')) || !isset($va_displays[$vn_display_id])) { $va_tmp = array_keys($va_displays); $vn_display_id = $va_tmp[0]; } } $this->view->setVar('t_display', $t_display); $this->view->setVar('bundle_displays', $va_displays); // Check validity and access of specified display if ($t_display->load($vn_display_id) && $t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__)) { $this->view->setVar('display_id', $vn_display_id); $va_placements = $t_display->getPlacements(array('returnAllAvailableIfEmpty' => true, 'table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'no_tooltips' => true, 'format' => 'simple', 'settingsOnly' => true)); $va_display_list = array(); foreach ($va_placements as $vn_placement_id => $va_display_item) { $va_settings = caUnserializeForDatabase($va_display_item['settings']); // get column header text $vs_header = $va_display_item['display']; if (isset($va_settings['label']) && is_array($va_settings['label'])) { if ($vs_tmp = array_shift(caExtractValuesByUserLocale(array($va_settings['label'])))) { $vs_header = $vs_tmp; } } $va_display_list[$vn_placement_id] = array('placement_id' => $vn_placement_id, 'bundle_name' => $va_display_item['bundle_name'], 'display' => $vs_header, 'settings' => $va_settings); } $this->view->setVar('placements', $va_display_list); $this->request->user->setVar($t_subject->tableName() . '_summary_display_id', $vn_display_id); $vs_format = $this->request->config->get("summary_print_format"); } else { $this->view->setVar('display_id', null); $this->view->setVar('placements', array()); } try { $vs_content = $this->render('print_summary_html.php'); $vo_html2pdf = new HTML2PDF('P', $vs_format, 'en'); $vo_html2pdf->setDefaultFont("dejavusans"); $vo_html2pdf->WriteHTML($vs_content); $vo_html2pdf->Output('summary.pdf'); $vb_printed_properly = true; } catch (Exception $e) { $vb_printed_properly = false; $o_event_log = new Eventlog(); $o_event_log->log(array('CODE' => 'DEBG', 'MESSAGE' => $vs_msg = _t("Could not generate PDF: %1", preg_replace('![^A-Za-z0-9 \\-\\?\\/\\.]+!', ' ', $e->getMessage())), 'SOURCE' => 'BaseEditorController->PrintSummary()')); $this->postError(3100, $vs_msg, "BaseEditorController->PrintSummary()"); } }