/** * Returns display string for relationship bundles. Used by themes/default/bundles/ca_entities.php and the like. * * @param RequestHTTP $po_request * @param string $ps_table * @param array $pa_attributes * @param array $pa_options * * @return string */ function caGetRelationDisplayString($po_request, $ps_table, $pa_attributes = null, $pa_options = null) { $o_config = Configuration::load(); $o_dm = Datamodel::load(); if (!($vs_relationship_type_display_position = caGetOption('relationshipTypeDisplayPosition', $pa_options, null))) { $vs_relationship_type_display_position = strtolower($o_config->get($ps_table . '_lookup_relationship_type_position')); } $vs_attr_str = _caHTMLMakeAttributeString(is_array($pa_attributes) ? $pa_attributes : array()); $vs_display = "{" . (isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : "_display") . "}"; if (isset($pa_options['makeLink']) && $pa_options['makeLink']) { $vs_display = "<a href='" . urldecode(caEditorUrl($po_request, $ps_table, '{' . $o_dm->getTablePrimaryKeyName($ps_table) . '}', false, array('rel' => true))) . "' {$vs_attr_str}>{$vs_display}</a>"; } switch ($vs_relationship_type_display_position) { case 'left': return "({{relationship_typename}}) {$vs_display}"; break; case 'none': return "{$vs_display}"; break; default: case 'right': return "{$vs_display} ({{relationship_typename}})"; break; } }
/** * */ function caSearchLink($po_request, $ps_content, $ps_classname, $ps_table, $ps_search, $pa_other_params = null, $pa_attributes = null, $pa_options = null) { if (!($vs_url = caSearchUrl($po_request, $ps_table, $ps_search, false, $pa_other_params, $pa_options))) { return "<strong>Error: no url for search</strong>"; } $vs_tag = "<a href='" . $vs_url . "'"; if ($ps_classname) { $vs_tag .= " class='{$ps_classname}'"; } if (is_array($pa_attributes)) { $vs_tag .= _caHTMLMakeAttributeString($pa_attributes); } $vs_tag .= '>' . $ps_content . '</a>'; return $vs_tag; }
/** * */ function caNavLink($po_request, $ps_content, $ps_classname, $ps_module_path, $ps_controller, $ps_action, $pa_other_params = null, $pa_attributes = null, $pa_options = null) { if (!($vs_url = caNavUrl($po_request, $ps_module_path, $ps_controller, $ps_action, $pa_other_params, $pa_options))) { return "<strong>Error: no url for navigation</strong>"; } $vs_tag = "<a href='" . $vs_url . "'"; if ($ps_classname) { $vs_tag .= " class='{$ps_classname}'"; } if (is_array($pa_attributes)) { $vs_tag .= _caHTMLMakeAttributeString($pa_attributes); } $vs_tag .= '>' . $ps_content . '</a>'; return $vs_tag; }
/** * @param array $pa_options Options are: * graphicsPath = */ function caNavIcon($po_request, $pn_type, $pn_size = null, $pa_attributes = null, $pa_options = null) { if (!is_array($pa_attributes)) { $pa_attributes = array(); } $vs_graphics_path = isset($pa_options['graphicsPath']) && $pa_options['graphicsPath'] ? $pa_options['graphicsPath'] : $po_request->getThemeUrlPath() . "/graphics"; $vs_button = ''; if ($vs_img_name = _caNavTypeToImgName($pn_type, $pn_size)) { if (!isset($pa_attributes['alt'])) { $pa_attributes['alt'] = $vs_img_name; } $vs_attr = _caHTMLMakeAttributeString($pa_attributes); $vs_button = "<img src='{$vs_graphics_path}/buttons/{$vs_img_name}.png' border='0' {$vs_attr}/>"; } return $vs_button; }
/** * */ function caHTMLImage($ps_url, $pa_options = null) { if (!is_array($pa_options)) { $pa_options = array(); } $va_attributes = array('src' => $ps_url); foreach (array('name', 'id', 'width', 'height', 'vspace', 'hspace', 'alt', 'title', 'usemap', 'align', 'border', 'class', 'style') as $vs_attr) { if (isset($pa_options[$vs_attr])) { $va_attributes[$vs_attr] = $pa_options[$vs_attr]; } } $vs_attr_string = _caHTMLMakeAttributeString($va_attributes, $pa_options); foreach (array('tilepic_init_magnification', 'tilepic_use_labels', 'tilepic_edit_labels', 'tilepic_parameter_list', 'tilepic_app_parameters', 'directly_embed_flash', 'tilepic_label_processor_url', 'tilepic_label_typecode', 'tilepic_label_default_title', 'tilepic_label_title_readonly') as $vs_k) { if (!isset($pa_options[$vs_k])) { $pa_options[$vs_k] = null; } } if (preg_match("/\\.tpc\$/", $ps_url)) { # # Tilepic # $vn_width = (int) $pa_options["width"]; $vn_height = (int) $pa_options["height"]; $vn_tile_width = (int) $pa_options["tile_width"]; $vn_tile_height = (int) $pa_options["tile_height"]; $vn_layers = (int) $pa_options["layers"]; $vn_ratio = (double) $pa_options["layer_ratio"]; if (!($vs_id_name = (string) $pa_options["idname"])) { $vs_id_name = (string) $pa_options["id"]; } if (!$vs_id_name) { $vs_id_name = "bischen"; } $vn_sx = intval($vn_width / 2.0); $vn_sy = intval(0 - $vn_height / 2.0); $vn_init_magnification = (double) $pa_options["tilepic_init_magnification"]; $vb_use_labels = (bool) $pa_options["tilepic_use_labels"]; $vb_edit_labels = (bool) $pa_options["tilepic_edit_labels"]; $vs_parameter_list = (string) $pa_options["tilepic_parameter_list"]; $vs_app_parameters = (string) $pa_options["tilepic_app_parameters"]; $vn_viewer_width = $pa_options["viewer_width"]; $vn_viewer_height = $pa_options["viewer_height"]; $vs_annotation_load_url = caGetOption("annotation_load_url", $pa_options, null); $vs_annotation_save_url = caGetOption("annotation_save_url", $pa_options, null); $vs_help_load_url = caGetOption("help_load_url", $pa_options, null); $vs_viewer_base_url = caGetOption("viewer_base_url", $pa_options, __CA_URL_ROOT__); $vb_directly_embed_flash = (bool) $pa_options['directly_embed_flash']; $vn_label_typecode = intval($pa_options["tilepic_label_typecode"]); $vs_label_title = (string) $pa_options["tilepic_label_default_title"]; $vn_label_title_readonly = (string) $pa_options["tilepic_label_title_readonly"] ? 1 : 0; if (!$vn_viewer_width || !$vn_viewer_height) { $o_config = Configuration::load(); $vn_viewer_width = (int) $o_config->get("tilepic_viewer_width"); if (!$vn_viewer_width) { $vn_viewer_width = 500; } $vn_viewer_height = (int) $o_config->get("tilepic_viewer_height"); if (!$vn_viewer_height) { $vn_viewer_height = 500; } } $vs_flash_vars = "tpViewerUrl={$vs_viewer_base_url}/viewers/apps/tilepic.php&tpImageUrl={$ps_url}&tpWidth={$vn_width}&tpHeight={$vn_height}&tpInitMagnification={$vn_init_magnification}&tpScales={$vn_layers}&tpRatio={$vn_ratio}&tpTileWidth={$vn_tile_width}&tpTileHeight={$vn_tile_height}&tpUseLabels={$vb_use_labels}&tpEditLabels={$vb_edit_labels}&tpParameterList={$vs_parameter_list}{$vs_app_parameters}&labelTypecode={$vn_label_typecode}&labelDefaultTitle=" . urlencode($vs_label_title) . "&labelTitleReadOnly={$vn_label_title_readonly}"; $vs_error_tag = caGetOption("alt_image_tag", $pa_options, ''); $vn_viewer_width_with_units = $vn_viewer_width; $vn_viewer_height_with_units = $vn_viewer_height; if (preg_match('!^[\\d]+$!', $vn_viewer_width)) { $vn_viewer_width_with_units .= 'px'; } if (preg_match('!^[\\d]+$!', $vn_viewer_height)) { $vn_viewer_height_with_units .= 'px'; } JavascriptLoadManager::register("swf/swfobject"); $vs_tag = "\n\t\t\t\t<div id='{$vs_id_name}' style='width:{$vn_viewer_width_with_units}; height: {$vn_viewer_height_with_units}; position: relative; z-index: 0;'>\n\t\t\t\t\t{$vs_error_tag}\n\t\t\t\t</div>\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\tvar elem = document.createElement('canvas');\n\t\t\t\t\tif (elem.getContext && elem.getContext('2d')) {\n\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\tjQuery('#{$vs_id_name}').tileviewer({\n\t\t\t\t\t\t\t\tid: '{$vs_id_name}_viewer',\n\t\t\t\t\t\t\t\tsrc: '{$vs_viewer_base_url}/viewers/apps/tilepic.php?p={$ps_url}&t=',\n\t\t\t\t\t\t\t\twidth: '{$vn_viewer_width}',\n\t\t\t\t\t\t\t\theight: '{$vn_viewer_height}',\n\t\t\t\t\t\t\t\tmagnifier: false,\n\t\t\t\t\t\t\t\tbuttonUrlPath: '{$vs_viewer_base_url}/themes/default/graphics/buttons',\n\t\t\t\t\t\t\t\tannotationLoadUrl: '{$vs_annotation_load_url}',\n\t\t\t\t\t\t\t\tannotationSaveUrl: '{$vs_annotation_save_url}',\n\t\t\t\t\t\t\t\thelpLoadUrl: '{$vs_help_load_url}',\n\t\t\t\t\t\t\t\tinfo: {\n\t\t\t\t\t\t\t\t\twidth: '{$vn_width}',\n\t\t\t\t\t\t\t\t\theight: '{$vn_height}',\n\t\t\t\t\t\t\t\t\ttilesize: 256,\n\t\t\t\t\t\t\t\t\tlevels: '{$vn_layers}'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}); \n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fall-back to Flash-based viewer if browse doesn't support <canvas>\n\t\t\t\t\t\tswfobject.embedSWF(\"{$vs_viewer_base_url}/viewers/apps/bischen.swf\", \"{$vs_id_name}\", \"{$vn_viewer_width}\", \"{$vn_viewer_height}\", \"9.0.0\",\"{$vs_viewer_base_url}/viewers/apps/expressInstall.swf\", false, {AllowScriptAccess: \"always\", allowFullScreen: \"true\", flashvars:\"{$vs_flash_vars}\", bgcolor: \"#000000\", wmode: \"transparent\"});\n\t\t\t\t\t}\n\t\t\t\t</script>\n"; return $vs_tag; } else { # # Standard image # if (!isset($pa_options["width"])) { $pa_options["width"] = 100; } if (!isset($pa_options["height"])) { $pa_options["height"] = 100; } if ($ps_url && $pa_options["width"] > 0 && $pa_options["height"] > 0) { $vs_element = "<img {$vs_attr_string} />"; } else { $vs_element = ""; } } return $vs_element; }
/** * Generates an HTML <img> or Tilepic embed tag with supplied URL and attributes * * @param $ps_url string The image URL * @param $pa_options array Options include: * scaleCSSWidthTo = width in pixels to *style* via CSS the returned image to. Does not actually alter the image. Aspect ratio of the image is preserved, with the combination of scaleCSSWidthTo and scaleCSSHeightTo being taken as a bounding box for the image. Only applicable to standard <img> tags. Tilepic display size cannot be styled using CSS; use the "width" and "height" options instead. * scaleCSSHeightTo = height in pixels to *style* via CSS the returned image to. * * @return string */ function caHTMLImage($ps_url, $pa_options = null) { if (!is_array($pa_options)) { $pa_options = array(); } $va_attributes = array('src' => $ps_url); foreach (array('name', 'id', 'width', 'height', 'vspace', 'hspace', 'alt', 'title', 'usemap', 'align', 'border', 'class', 'style') as $vs_attr) { if (isset($pa_options[$vs_attr])) { $va_attributes[$vs_attr] = $pa_options[$vs_attr]; } } $vn_scale_css_width_to = caGetOption('scaleCSSWidthTo', $pa_options, null); $vn_scale_css_height_to = caGetOption('scaleCSSHeightTo', $pa_options, null); if ($vn_scale_css_width_to || $vn_scale_css_height_to) { if (!$vn_scale_css_width_to) { $vn_scale_css_width_to = $vn_scale_css_height_to; } if (!$vn_scale_css_height_to) { $vn_scale_css_height_to = $vn_scale_css_width_to; } $va_scaled_dimensions = caFitImageDimensions($va_attributes['width'], $va_attributes['height'], $vn_scale_css_width_to, $vn_scale_css_height_to); $va_attributes['width'] = $va_scaled_dimensions['width'] . 'px'; $va_attributes['height'] = $va_scaled_dimensions['height'] . 'px'; } $vs_attr_string = _caHTMLMakeAttributeString($va_attributes, $pa_options); foreach (array('tilepic_init_magnification', 'tilepic_use_labels', 'tilepic_edit_labels', 'tilepic_parameter_list', 'tilepic_app_parameters', 'directly_embed_flash', 'tilepic_label_processor_url', 'tilepic_label_typecode', 'tilepic_label_default_title', 'tilepic_label_title_readonly') as $vs_k) { if (!isset($pa_options[$vs_k])) { $pa_options[$vs_k] = null; } } if (preg_match("/\\.tpc\$/", $ps_url)) { # # Tilepic # $vn_width = (int) $pa_options["width"]; $vn_height = (int) $pa_options["height"]; $vn_tile_width = (int) $pa_options["tile_width"]; $vn_tile_height = (int) $pa_options["tile_height"]; $vn_layers = (int) $pa_options["layers"]; $vn_ratio = (double) $pa_options["layer_ratio"]; if (!($vs_id_name = (string) $pa_options["idname"])) { $vs_id_name = (string) $pa_options["id"]; } $vn_sx = intval($vn_width / 2.0); $vn_sy = intval(0 - $vn_height / 2.0); $vn_init_magnification = (double) $pa_options["tilepic_init_magnification"]; $vb_use_labels = (bool) $pa_options["tilepic_use_labels"]; $vb_edit_labels = (bool) $pa_options["tilepic_edit_labels"]; $vs_parameter_list = (string) $pa_options["tilepic_parameter_list"]; $vs_app_parameters = (string) $pa_options["tilepic_app_parameters"]; $vn_viewer_width = $pa_options["viewer_width"]; $vn_viewer_height = $pa_options["viewer_height"]; $vs_annotation_load_url = caGetOption("annotation_load_url", $pa_options, null); $vs_annotation_save_url = caGetOption("annotation_save_url", $pa_options, null); $vs_help_load_url = caGetOption("help_load_url", $pa_options, null); $vs_download_url = caGetOption("download_url", $pa_options, null); $vs_annotation_editor_panel = caGetOption("annotationEditorPanel", $pa_options, null); $vs_annotation_editor_url = caGetOption("annotationEditorUrl", $pa_options, null); $vs_viewer_base_url = caGetOption("viewer_base_url", $pa_options, __CA_URL_ROOT__); $vb_directly_embed_flash = (bool) $pa_options['directly_embed_flash']; $vn_label_typecode = intval($pa_options["tilepic_label_typecode"]); $vs_label_title = (string) $pa_options["tilepic_label_default_title"]; $vn_label_title_readonly = (string) $pa_options["tilepic_label_title_readonly"] ? 1 : 0; if (!$vn_viewer_width || !$vn_viewer_height) { $o_config = Configuration::load(); $vn_viewer_width = (int) $o_config->get("tilepic_viewer_width"); if (!$vn_viewer_width) { $vn_viewer_width = 500; } $vn_viewer_height = (int) $o_config->get("tilepic_viewer_height"); if (!$vn_viewer_height) { $vn_viewer_height = 500; } } $vs_error_tag = caGetOption("alt_image_tag", $pa_options, ''); $vn_viewer_width_with_units = $vn_viewer_width; $vn_viewer_height_with_units = $vn_viewer_height; if (preg_match('!^[\\d]+$!', $vn_viewer_width)) { $vn_viewer_width_with_units .= 'px'; } if (preg_match('!^[\\d]+$!', $vn_viewer_height)) { $vn_viewer_height_with_units .= 'px'; } $o_config = Configuration::load(); $vb_use_key = $o_config->get('annotation_class_element') ? "true" : "false"; $vs_tag = "\n\t\t\t\t<div id='{$vs_id_name}' style='width:{$vn_viewer_width_with_units}; height: {$vn_viewer_height_with_units}; position: relative; z-index: 0;'>\n\t\t\t\t\t{$vs_error_tag}\n\t\t\t\t</div>\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\tvar elem = document.createElement('canvas');\n\t\t\t\t\tif (elem.getContext && elem.getContext('2d')) {\n\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\tjQuery('#{$vs_id_name}').tileviewer({\n\t\t\t\t\t\t\t\tid: '{$vs_id_name}_viewer',\n\t\t\t\t\t\t\t\tsrc: '{$vs_viewer_base_url}/viewers/apps/tilepic.php?p={$ps_url}&t=',\n\t\t\t\t\t\t\t\twidth: '{$vn_viewer_width}',\n\t\t\t\t\t\t\t\theight: '{$vn_viewer_height}',\n\t\t\t\t\t\t\t\tmagnifier: false,\n\t\t\t\t\t\t\t\tbuttonUrlPath: '{$vs_viewer_base_url}/themes/default/graphics/buttons',\n\t\t\t\t\t\t\t\tannotationLoadUrl: '{$vs_annotation_load_url}',\n\t\t\t\t\t\t\t\tannotationSaveUrl: '{$vs_annotation_save_url}',\n\t\t\t\t\t\t\t\tannotationEditorPanel: '{$vs_annotation_editor_panel}',\n\t\t\t\t\t\t\t\tannotationEditorUrl: '{$vs_annotation_editor_url}',\n\t\t\t\t\t\t\t\tannotationEditorLink: '" . addslashes(_t('More...')) . "',\n\t\t\t\t\t\t\t\thelpLoadUrl: '{$vs_help_load_url}',\n\t\t\t\t\t\t\t\tmediaDownloadUrl: '{$vs_download_url}',\n\t\t\t\t\t\t\t\tuseKey: {$vb_use_key},\n\t\t\t\t\t\t\t\tinfo: {\n\t\t\t\t\t\t\t\t\twidth: '{$vn_width}',\n\t\t\t\t\t\t\t\t\theight: '{$vn_height}',\n\t\t\t\t\t\t\t\t\ttilesize: 256,\n\t\t\t\t\t\t\t\t\tlevels: '{$vn_layers}'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}); \n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t</script>\n"; return $vs_tag; } else { # # Standard image # if (!isset($pa_options["width"])) { $pa_options["width"] = 100; } if (!isset($pa_options["height"])) { $pa_options["height"] = 100; } if ($ps_url && $pa_options["width"] > 0 && $pa_options["height"] > 0) { $vs_element = "<img {$vs_attr_string} />"; } else { $vs_element = ""; } } return $vs_element; }