if (is_array($va_attributes) && sizeof($va_attributes) > 0) { foreach ($va_attributes as $vs_attribute_code) { if ($va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertCodesToDisplayText" => false, "returnAsArray" => true))) { $va_output_parts = array(); foreach ($va_values as $k => $va_value) { if ($va_value[$vs_attribute_code]) { # --- display hierarchy path for "lessonTopic", "learning_standard", "commonCore" if (in_array($vs_attribute_code, array("lessonTopic", "learning_standard", "commonCore"))) { $vs_tmp = ""; $va_hierarchy_ancestors = $t_list_items->getHierarchyAncestors($va_value[$vs_attribute_code], array("idsOnly" => true, "includeSelf" => true)); if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) { # --- remove the root - we don't want to display it $va_root = array_pop($va_hierarchy_ancestors); if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) { foreach ($va_hierarchy_ancestors as $vni => $vn_list_item_id) { $vs_tmp = $t_lists->getItemForDisplayByItemID($vn_list_item_id) . ($vni > 0 ? " > " . $vs_tmp : ""); } $va_output_parts[] = $vs_tmp; } } } else { $vs_value = ""; if ($vs_value = trim($va_value[$vs_attribute_code])) { $va_output_parts[] = $t_lists->getItemForDisplayByItemID($vs_value); } } } } if (sizeof($va_output_parts)) { if ($ps_mode == "print") { print "<div class='unit'><input type='checkbox' checked name='print_fields[]' value='" . $vs_attribute_code . "'> <b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . ":</b> ";
/** * Returns array of with information about usage of metadata element(s) in user interfaces * * @param $pm_element_code_or_id mixed Optional element_id or code. If set then counts are only returned for the specified element. If omitted then counts are returned for all elements. * @return array Array of counts. Keys are element_codes, values are arrays keyed on table DISPLAY name (eg. "set items", not "ca_set_items"). Values are the number of times the element is references in a user interface for the table. */ public static function getTypeRestrictionsAsList($pm_element_code_or_id = null) { // Get UI usage counts $vo_db = new Db(); $vn_element_id = null; if ($pm_element_code_or_id) { $t_element = new ca_metadata_elements($pm_element_code_or_id); if (!($vn_element_id = $t_element->getPrimaryKey())) { if ($t_element->load(array('element_code' => $pm_element_code_or_id))) { $vn_element_id = $t_element->getPrimaryKey(); } } } $vs_sql_where = ''; if ($vn_element_id) { $vs_sql_where = " WHERE cmtr.element_id = {$vn_element_id}"; } $qr_restrictions = $vo_db->query("\n\t\t\tSELECT cmtr.*, cme.element_code\n\t\t\tFROM ca_metadata_type_restrictions cmtr \n\t\t\tINNER JOIN ca_metadata_elements AS cme ON cme.element_id = cmtr.element_id\n\t\t\t{$vs_sql_where}\n\t\t"); $va_restrictions = array(); $o_dm = Datamodel::load(); $t_list = new ca_lists(); while ($qr_restrictions->nextRow()) { if (!($t_table = $o_dm->getInstanceByTableNum($qr_restrictions->get('table_num'), true))) { continue; } if ($vn_type_id = $qr_restrictions->get('type_id')) { $vs_type_name = $t_list->getItemForDisplayByItemID($vn_type_id); } else { $vs_type_name = '*'; } $va_restrictions[$qr_restrictions->get('element_code')][$t_table->getProperty('NAME_PLURAL')][$vn_type_id] = $vs_type_name; } return $va_restrictions; }
function caGetListItemByIDForDisplay($pn_item_id, $pb_return_plural = false, $pa_options = null) { global $g_list_item_label_cache; if (isset($g_list_item_label_cache[$pn_item_id . '/' . (int) $pb_return_plural])) { return $g_list_item_label_cache[$pn_item_id . '/' . (int) $pb_return_plural]; } $t_list = new ca_lists(); if ($o_trans = caGetOption('transaction', $pa_options, null)) { $t_list->setTransaction($o_trans); } return $g_list_item_label_cache[$pn_item_id . '/' . (int) $pb_return_plural] = $t_list->getItemForDisplayByItemID($pn_item_id, $pb_return_plural); }
/** * themes with most items */ private function topThemes() { $va_theme_links = array(); $vn_object_tablenum = $this->opn_objectTableNum; $o_db = new db(); # --- get the element_id for date attribute $q_theme_element_id = $o_db->query("select element_id from ca_metadata_elements where element_code = 'NovaStory_category'"); $q_theme_element_id->nextRow(); $vn_theme_element_id = $q_theme_element_id->get("element_id"); $t_list = new ca_lists(); $q_top_categories = $o_db->query("SELECT v.item_id, count(*) c\n \t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values v\n \t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes a ON v.attribute_id = a.attribute_id\n \t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_objects o ON a.row_id = o.object_id\n \t\t\t\t\t\t\t\t\t\t\t\tWHERE v.element_id = " . $vn_theme_element_id . " AND a.table_num = " . $vn_object_tablenum . " AND o.access = 1 AND o.deleted = 0\n \t\t\t\t\t\t\t\t\t\t\t\tGROUP BY v.item_id order by c DESC limit 5;"); if ($q_top_categories->numRows() > 0) { while ($q_top_categories->nextRow()) { $va_theme_links[] = caNavLink($this->request, $t_list->getItemForDisplayByItemID($q_top_categories->get("item_id")), "", "", "Browse", "clearAndAddCriteria", array("facet" => "NovaMuse_category_facet", "id" => $q_top_categories->get("item_id"))); } } return $va_theme_links; }
public function Full() { $t_lists = new ca_lists(); $t_list_items = new ca_list_items(); $o_purifier = new HTMLPurifier(); $pn_occurrence_id = $this->request->getParameter('occurrence_id', pString); $t_occurrence = new ca_occurrences($pn_occurrence_id); $va_access_values = caGetUserAccessValues($this->request); $va_occ_info[] = "<b>" . _t("Lesson type") . "</b>: " . $t_occurrence->getTypeName(); $va_occ_info2 = array(); foreach (array("gradelevel", "lessonTopic", "learning_standard", "commonCore", "skills", "EdProject", "funder") as $vs_attribute_code) { if ($va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertCodesToDisplayText" => false, "returnAsArray" => true))) { $va_output_parts = array(); foreach ($va_values as $k => $va_value) { if ($va_value[$vs_attribute_code]) { # --- display hierarchy path for "lessonTopic", "learning_standard", "commonCore" if (in_array($vs_attribute_code, array("lessonTopic", "learning_standard", "commonCore"))) { $vs_tmp = ""; $va_hierarchy_ancestors = $t_list_items->getHierarchyAncestors($va_value[$vs_attribute_code], array("idsOnly" => true, "includeSelf" => true)); if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) { # --- remove the root - we don't want to display it $va_root = array_pop($va_hierarchy_ancestors); if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) { foreach ($va_hierarchy_ancestors as $vni => $vn_list_item_id) { $vs_tmp = $t_lists->getItemForDisplayByItemID($vn_list_item_id) . ($vni > 0 ? " > " . $vs_tmp : ""); } $va_output_parts[] = $vs_tmp; } } } else { $vs_value = ""; if ($vs_value = trim($va_value[$vs_attribute_code])) { $va_output_parts[] = $t_lists->getItemForDisplayByItemID($vs_value); } } } } if (sizeof($va_output_parts)) { $va_occ_info[$vs_attribute_code] = "<b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b>: " . join(", ", $va_output_parts); } } } $va_occ_info["HR"] = "<HR>"; $va_attributes = array("theme", "guidelines", "sure", "directions", "context", "task", "glossary", "instructions", "essay", "essential", "check"); foreach ($va_attributes as $vs_attribute_code) { if ($vs_value = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>"))) { if ($vs_attribute_code == "glossary") { $va_glossary_terms = array(); $va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "returnAsArray" => true)); foreach ($va_values as $va_value) { $va_glossary_terms[] = $va_value["glossary"]; } sort($va_glossary_terms); $vs_value = implode("<br/>", $va_glossary_terms); $va_occ_info[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . $vs_value . "</div><!-- end unit -->"; } else { $va_occ_info[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . str_replace("*", "• ", $vs_value) . "</div><!-- end unit -->"; } } } $va_attributes = array("questions", "challenge", "connections", "resources", "transcription", "translation", "essay"); foreach ($va_attributes as $vs_attribute_code) { if ($vs_value = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>"))) { if (in_array($vs_attribute_code, array("questions", "resources"))) { $va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>", "returnAsArray" => true)); $vs_tmp = ""; $vs_tmp .= "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><ol>"; foreach ($va_values as $va_value_info) { $vs_tmp .= "<li>" . $va_value_info[$vs_attribute_code] . "</li>"; } $vs_tmp .= "</ol></div><!-- end unit -->"; $va_occ_info2[$vs_attribute_code] = $vs_tmp; } else { $va_occ_info2[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . str_replace("*", "• ", $vs_value) . "</div><!-- end unit -->"; } } } # --- related objects $va_related_objects_links = $t_occurrence->get("ca_objects_x_occurrences.relation_id", array("returnAsArray" => true)); $va_related_objects_info = array(); if (sizeof($va_related_objects_links)) { $t_objects_x_occurrences = new ca_objects_x_occurrences(); foreach ($va_related_objects_links as $vn_relation_id) { $va_object_info = array(); $t_objects_x_occurrences->load($vn_relation_id); $va_reps = $t_objects_x_occurrences->get("ca_objects_x_occurrences.representation_list", array("returnAsArray" => true, 'idsOnly' => true)); $va_reps_info = array(); if (is_array($va_reps)) { foreach ($va_reps as $vn_relation_id => $va_attr) { $t_rep = new ca_object_representations($va_attr['representation_list']); $va_media_info = $t_rep->getMediaInfo('media'); $vn_height = $va_media_info["large"]["HEIGHT"]; $vn_width = $va_media_info["large"]["WIDTH"]; if ($vn_height > 900) { $vn_new_width = 900 * $vn_width / $vn_height; $va_reps_info[] = "<img src='" . $t_rep->getMediaUrl('media', 'large') . "' style='height:900px; width:" . $vn_new_width . "px;'>"; } else { $va_reps_info[] = $t_rep->getMediaTag('media', 'large'); } } } $va_object_info["reps"] = $va_reps_info; # --- attributes on objects_x_occurrences record $va_attributes = array("caption", "transcription", "translation", "description", "questions"); $va_md = array(); foreach ($va_attributes as $vs_attribute_code) { if ($vs_value = $t_objects_x_occurrences->get("ca_objects_x_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>"))) { $va_md[$vs_attribute_code] = "<b>" . $t_objects_x_occurrences->getDisplayLabel("ca_objects_x_occurrences.{$vs_attribute_code}") . "</b><br/>" . $vs_value; } } # --- info from the related object record $t_lists = new ca_lists(); $vn_original_date = $t_lists->getItemIDFromList("date_types", "dateOriginal"); $vs_related_object_caption_info = "<div style=\"font-size:11px; font-style:italic;\">" . $t_objects_x_occurrences->get("ca_objects.preferred_labels.name"); if ($va_dates = $t_objects_x_occurrences->get("ca_objects.date", array("returnAsArray" => true))) { foreach ($va_dates as $va_date_info) { if ($va_date_info["dc_dates_types"] == $vn_original_date) { $vs_related_object_caption_info .= ", " . $va_date_info["dates_value"]; } } } if ($t_objects_x_occurrences->get("ca_objects.repository")) { $vs_related_object_caption_info .= ", " . $t_objects_x_occurrences->get("ca_objects.repository", array('delimiter' => ', ', 'convertCodesToDisplayText' => true)); } $vs_related_object_caption_info .= ", " . $t_objects_x_occurrences->get("ca_objects.idno") . "</div>"; $va_object_info["object_caption_info"] = $vs_related_object_caption_info; $va_object_info["md"] = $va_md; $va_related_objects_info[$vn_relation_id] = $va_object_info; } } $this->view->setVar('related_objects_info', $va_related_objects_info); $this->view->setVar('title', $t_occurrence->getLabelForDisplay()); $this->view->setVar('occ_info', $va_occ_info); $this->view->setVar('occ_info2', $va_occ_info2); require_once __CA_LIB_DIR__ . '/core/Parsers/dompdf/dompdf_config.inc.php'; $vs_output_filename = $t_occurrence->getLabelForDisplay(); $vs_output_file_name = preg_replace("/[^A-Za-z0-9\\-]+/", '_', $vs_output_filename); header("Content-Disposition: attachment; filename=export_results.pdf"); header("Content-type: application/pdf"); $vs_content = $this->render($this->ops_theme . '/ca_occ_pdf_html.php'); $o_pdf = new DOMPDF(); // Page sizes: 'letter', 'legal', 'A4' // Orientation: 'portrait' or 'landscape' $o_pdf->set_paper("letter", "portrait"); $o_pdf->load_html($vs_content, 'utf-8'); $o_pdf->render(); $o_pdf->stream($vs_output_file_name . ".pdf"); return; }