Esempio n. 1
0
 public function postDispatch()
 {
     $o_view = new View($this->getRequest(), $this->getRequest()->config->get('views_directory'));
     $o_notification = new NotificationManager($this->getRequest());
     if ($o_notification->numNotifications()) {
         $o_view->setVar('notifications', $o_notification->getNotifications($this->getResponse()->isRedirect()));
         $this->getResponse()->prependContent($o_view->render('pageFormat/notifications.php'), 'notifications');
     }
     //$nav = new AppNavigation($this->getRequest(), $this->getResponse());
     $o_view->setVar('nav', $nav);
     //$this->getResponse()->prependContent($o_view->render('pageFormat/menuBar.php'), 'menubar');
     $this->getResponse()->prependContent($o_view->render('pageFormat/pageHeader.php'), 'head');
     $this->getResponse()->appendContent($o_view->render('pageFormat/pageFooter.php'), 'footer');
 }
Esempio n. 2
0
 function caDownloadAttributeMedia($po_request, $po_response, $pn_occurrence_id, $ps_version, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $t_occurrence = new ca_occurrences($pn_occurrence_id);
     if (!$t_occurrence->getPrimaryKey()) {
         return null;
     }
     $vs_path = $t_occurrence->get('ca_occurrences.report_file', array('version' => $ps_version, 'return' => 'path'));
     $vs_path_ext = pathinfo($vs_path, PATHINFO_EXTENSION);
     if (!($vs_title = trim($t_occurrence->get('ca_occurrences.preferred_labels.name')))) {
         $vs_title = "report";
     }
     $vs_name = _t(preg_replace('![^A-Za-z0-9\\,\\/\\?\\"\']+!', '_', $vs_title) . ".{$vs_path_ext}");
     $o_view->setVar('file_path', $vs_path);
     $o_view->setVar('file_name', $vs_name);
     // send download
     return $o_view->render('ca_attributes_download_media.php');
 }
Esempio n. 3
0
 public function loadView($view_file)
 {
     if ($this->module != null) {
         $arr = explode("/", $view_file);
         if (count($arr) == 1) {
             $view_file .= "/index";
         }
         $view = new View();
         $view->setModuleName("module/" . $this->module);
         $view->setView($view_file);
         $view->setLayout($this->parent->getLayoutFile());
         $view->setLayoutClass($this->parent->getLayout());
         $view->setVar($this->parent->getVar());
         $view->setVar($this->parent->getVar());
         $view->setModuleMeta($this->parent->getModuleMeta());
         $view->setModuleTitle($this->parent->getModuleTitle());
         $view->setModuleCss($this->parent->getModuleCss());
         $view->setModuleScript($this->parent->getModuleScript());
         $view->CallView();
     } else {
         return new TException("Vui lòng cho biết module cần truy cập. {$this->module}(module cân truy cập)", 401);
     }
 }
 /**
  * Returns HTML bundle for picking representations to attach to an object-* relationship
  *
  * @param object $po_request The current request
  * @param $ps_form_name The name of the HTML form this bundle will be part of
  *
  * @return string HTML for bundle
  */
 public function getRepresentationChooserHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->getAppDatamodel()->getTableName($this->get('table_num'))));
     $o_view->setVar('t_subject', $this);
     $vn_object_id = $this->getLeftTableName() == 'ca_objects' ? $this->get($this->getLeftTableFieldName()) : $this->get($this->getRightTableFieldName());
     $o_view->setVar('t_object', $t_object = new ca_objects($vn_object_id));
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('element_code', caGetOption(array('elementCode', 'element_code'), $pa_bundle_settings, null));
     $o_view->setVar('settings', $pa_bundle_settings);
     return $o_view->render('ca_object_representation_chooser_html.php');
 }
Esempio n. 5
0
 /**
  * Renders and returns HTML form bundle for management of stops in the currently loaded tour
  * 
  * @param object $po_request The current request object
  * @param string $ps_form_name The name of the form in which the bundle will be rendered
  *
  * @return string Rendered HTML bundle for display
  */
 public function getTourStopHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('t_tour', $this);
     $o_view->setVar('t_stop', new ca_tour_stops());
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     if ($this->getPrimaryKey()) {
         $o_view->setVar('stops', $this->getStops($po_request));
     } else {
         $o_view->setVar('stops', array());
     }
     return $o_view->render('ca_tour_stops_list.php');
 }
 /**
  * Download (accessible) media for all records in this set
  */
 public function getSetMedia()
 {
     set_time_limit(600);
     // allow a lot of time for this because the sets can be potentially large
     $o_dm = Datamodel::load();
     $t_set = new ca_sets($this->request->getParameter('set_id', pInteger));
     if (!$t_set->getPrimaryKey()) {
         $this->notification->addNotification(_t('No set defined'), __NOTIFICATION_TYPE_ERROR__);
         $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey()));
         return false;
     }
     $va_record_ids = array_keys($t_set->getItemRowIDs(array('limit' => 100000)));
     if (!is_array($va_record_ids) || !sizeof($va_record_ids)) {
         $this->notification->addNotification(_t('No media is available for download'), __NOTIFICATION_TYPE_ERROR__);
         $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey()));
         return false;
     }
     $vs_subject_table = $o_dm->getTableName($t_set->get('table_num'));
     $t_instance = $o_dm->getInstanceByTableName($vs_subject_table);
     $qr_res = $vs_subject_table::createResultSet($va_record_ids);
     $qr_res->filterNonPrimaryRepresentations(false);
     $va_paths = array();
     while ($qr_res->nextHit()) {
         $va_original_paths = $qr_res->getMediaPaths('ca_object_representations.media', 'original');
         if (sizeof($va_original_paths) > 0) {
             $va_paths[$qr_res->get($t_instance->primaryKey())] = array('idno' => $qr_res->get($t_instance->getProperty('ID_NUMBERING_ID_FIELD')), 'paths' => $va_original_paths);
         }
     }
     if (sizeof($va_paths) > 0) {
         $vs_tmp_name = caGetTempFileName('DownloadSetMedia', 'zip');
         $o_phar = new PharData($vs_tmp_name, null, null, Phar::ZIP);
         foreach ($va_paths as $vn_pk => $va_path_info) {
             $vn_c = 1;
             foreach ($va_path_info['paths'] as $vs_path) {
                 if (!file_exists($vs_path)) {
                     continue;
                 }
                 $vs_filename = $va_path_info['idno'] ? $va_path_info['idno'] : $vn_pk;
                 $vs_filename .= "_{$vn_c}";
                 if ($vs_ext = pathinfo($vs_path, PATHINFO_EXTENSION)) {
                     $vs_filename .= ".{$vs_ext}";
                 }
                 $o_phar->addFile($vs_path, $vs_filename);
                 $vn_c++;
             }
         }
         $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/');
         // send download
         $vs_set_code = $t_set->get('set_code');
         $o_view->setVar('tmp_file', $vs_tmp_name);
         $o_view->setVar('download_name', 'media_for_' . mb_substr(preg_replace('![^A-Za-z0-9]+!u', '_', $vs_set_code ? $vs_set_code : $t_set->getPrimaryKey()), 0, 20) . '.zip');
         $this->response->addContent($o_view->render('ca_sets_download_media.php'));
         return;
     } else {
         $this->notification->addNotification(_t('No media is available for download'), __NOTIFICATION_TYPE_ERROR__);
         $this->opo_response->setRedirect(caEditorUrl($this->opo_request, 'ca_sets', $t_set->getPrimaryKey()));
         return;
     }
     return $this->Edit();
 }
            if ($vb_should_use_book_viewer && $this->getVar('num_multifiles') > 0) {
                // Create book viewer from single representation with multifiles
                $vb_use_book_reader = true;
                foreach ($t_rep->getFileList(null, 0, null, array('preview', 'large_preview', 'page_preview')) as $vn_id => $va_file) {
                    $va_pages[] = array('object_id' => $vn_object_id, 'representation_id' => $t_rep->getPrimaryKey(), 'thumbnail_url' => $va_file['preview_url'], 'thumbnail_path' => $va_file['preview_path'], 'thumbnail_width' => $va_file['preview_width'], 'thumbnail_height' => $va_file['preview_height'], 'thumbnail_mimetype' => $va_file['preview_mimetype'], 'normal_url' => $va_file['large_preview_url'], 'normal_path' => $va_file['large_preview_path'], 'normal_width' => $va_file['large_preview_width'], 'normal_height' => $va_file['large_preview_height'], 'normal_mimetype' => $va_file['large_preview_mimetype'], 'large_url' => $va_file['page_preview_url'], 'large_path' => $va_file['page_preview_path'], 'large_width' => $va_file['page_preview_width'], 'large_height' => $va_file['page_preview_height'], 'large_mimetype' => $va_file['page_preview_mimetype']);
                }
                $vn_object_id = $t_object->getPrimaryKey();
                $vn_representation_id = $t_rep->getPrimaryKey();
                $vs_book_viewer_content_mode = 'multifiles';
            }
        }
    }
}
if ($vb_use_book_reader) {
    $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/');
    $o_view->setVar('pages', $va_pages);
    $o_view->setVar('sections', $va_sections);
    $o_view->setVar('object_id', $vn_object_id);
    $o_view->setVar('representation_id', $vn_representation_id);
    $o_view->setVar('content_mode', $vs_book_viewer_content_mode);
    $o_view->setVar('initial_page', $vn_open_to_page);
    $o_view->setVar('display_type', $vs_display_type);
    $o_view->setVar('display_options', $va_display_options);
    $va_page_cache = $this->request->session->getVar('caDocumentViewerPageListCache');
    $va_page_cache[$vn_object_id . '/' . $vn_representation_id] = $va_pages;
    $this->request->session->setVar('caDocumentViewerPageListCache', $va_page_cache);
    $va_section_cache = $this->request->session->getVar('caDocumentViewerSectionCache');
    $va_section_cache[$vn_object_id . '/' . $vn_representation_id] = $va_sections;
    $this->request->session->setVar('caDocumentViewerSectionCache', $va_section_cache);
    print $o_view->render('bookviewer_html.php');
} else {
Esempio n. 8
0
 /** 
  * Returns HTML form bundle (for use in a ca_object_representations editor form) for media
  *
  * @param HTTPRequest $po_request The current request
  * @param string $ps_form_name
  * @param string $ps_placement_code
  * @param array $pa_bundle_settings
  * @param array $pa_options Array of options. Supported options are 
  *			noCache = If set to true then label cache is bypassed; default is true
  *
  * @return string Rendered HTML bundle
  */
 public function getCommerceOrderHistoryHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null)
 {
     global $g_ui_locale;
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $o_view->setVar('id_prefix', $ps_form_name . '_commerce_order_history');
     $o_view->setVar('placement_code', $ps_placement_code);
     // pass placement code
     $o_view->setVar('settings', $pa_bundle_settings);
     $o_view->setVar('t_subject', $this);
     return $o_view->render('ca_commerce_order_history.php');
 }
Esempio n. 9
0
 /**
  * Generate GoogleMaps output in specified format
  *
  * @param $ps_format - specifies format to generate output in. Currently only 'HTML' is supported.
  * @param $pa_options - array of options to use when rendering output. Supported options are:
  *		mapType - type of map to render; valid values are 'ROADMAP', 'SATELLITE', 'HYBRID', 'TERRAIN'; if not specified 'google_maps_default_type' setting in app.conf is used; if that is not set default is 'SATELLITE'
  *		showNavigationControls - if true, navigation controls are displayed; default is to use 'google_maps_show_navigation_controls' setting in app.conf
  *		showScaleControls -  if true, scale controls are displayed; default is to use 'google_maps_show_scale_controls' setting in app.conf
  *		showMapTypeControls -  if true, map type controls are displayed; default is to use 'google_maps_show_map_type_controls' setting in app.conf
  *		cycleRandomly - if true, map cycles randomly through markers; default is false
  *		cycleRandomlyInterval - Interval between movement between markers; specify in milliseconds or seconds followed by 's' (eg. 4s); default is 2s
  *		stopAfterRandomCycles - Stop cycling after a number of movements; set to zero to cycle forever; default is zero.
  *		delimiter - Delimiter to use to separate content for different items being plotted in the same location (and therefore being put in the same marker detail balloon); default is an HTML line break tag ("<br/>")
  *		minZoomLevel - Minimum zoom level to allow; leave null if you don't want to enforce a limit
  *		maxZoomLevel - Maximum zoom level to allow; leave null if you don't want to enforce a limit
  *		zoomLevel - Zoom map to specified level rather than fitting all markers into view; leave null if you don't want to specify a zoom level. IF this option is set minZoomLevel and maxZoomLevel will be ignored.
  *		balloonView -
  *		pathColor - 
  *		pathWeight -
  *		pathOpacity - 
  */
 public function render($ps_format, $pa_options = null)
 {
     $o_config = Configuration::load();
     list($vs_width, $vs_height) = $this->getDimensions();
     list($vn_width, $vn_height) = $this->getDimensions(array('returnPixelValues' => true));
     $va_map_items = $this->getMapItems();
     $va_extents = $this->getExtents();
     $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : "<br/>";
     $vn_zoom_level = isset($pa_options['zoomLevel']) && (int) $pa_options['zoomLevel'] > 0 ? (int) $pa_options['zoomLevel'] : null;
     $vn_min_zoom_level = isset($pa_options['minZoomLevel']) && (int) $pa_options['minZoomLevel'] > 0 ? (int) $pa_options['minZoomLevel'] : null;
     $vn_max_zoom_level = isset($pa_options['maxZoomLevel']) && (int) $pa_options['maxZoomLevel'] > 0 ? (int) $pa_options['maxZoomLevel'] : null;
     $vs_path_color = isset($pa_options['pathColor']) ? $pa_options['pathColor'] : $this->opo_config->get('google_maps_path_color');
     $vn_path_weight = isset($pa_options['pathWeight']) && (int) $pa_options['pathWeight'] > 0 ? (int) $pa_options['pathWeight'] : 2;
     $vn_path_opacity = isset($pa_options['pathOpacity']) && (int) $pa_options['pathOpacity'] >= 0 && (int) $pa_options['pathOpacity'] <= 1 ? (int) $pa_options['pathOpacity'] : 0.5;
     $vs_balloon_view = isset($pa_options['balloonView']) ? $pa_options['balloonView'] : null;
     $vs_type = isset($pa_options['mapType']) ? strtoupper($pa_options['mapType']) : strtoupper($this->opo_config->get('google_maps_default_type'));
     if (!in_array($vs_type, array('ROADMAP', 'SATELLITE', 'HYBRID', 'TERRAIN'))) {
         $vs_type = 'SATELLITE';
     }
     $vs_type = strtolower($vs_type);
     if (!($vs_id = trim($this->get('id')))) {
         $vs_id = 'map';
     }
     switch (strtoupper($ps_format)) {
         # ---------------------------------
         case 'JPEG':
         case 'PNG':
         case 'GIF':
             $va_markers = array();
             $va_paths = array();
             $va_center = null;
             foreach ($va_map_items as $o_map_item) {
                 $va_coords = $o_map_item->getCoordinates();
                 if (sizeof($va_coords) > 1) {
                     // is path
                     $va_path = array();
                     foreach ($va_coords as $va_coord) {
                         $va_path[] = $va_coord['latitude'] . ',' . $va_coord['longitude'];
                     }
                     $va_paths[] = "paths=" . urlencode("color:red|weight:5|" . join("|", $va_path));
                     if (!$va_center) {
                         $va_center = $va_coord;
                     }
                 } else {
                     // is point
                     $va_coord = array_shift($va_coords);
                     $va_markers[] = "markers=" . urlencode("color:red|label:" . $o_map_item->getLabel() . "|" . $va_coord['latitude'] . ',' . $va_coord['longitude']);
                     if (!$va_center) {
                         $va_center = $va_coord;
                     }
                 }
             }
             $vs_format = strtolower($ps_format);
             if ($vs_format == 'jpeg') {
                 $vs_format = 'jpg';
             }
             return "<img src='http://maps.googleapis.com/maps/api/staticmap?format={$vs_format}&maptype=" . strtolower($vs_type) . "&zoom={$vn_zoom_level}&sensor=false&size={$vn_width}x{$vn_height}&" . join("&", array_merge($va_markers, $va_paths)) . "'/>";
             break;
             # ---------------------------------
         # ---------------------------------
         case 'HTML':
         default:
             if (isset($pa_options['showNavigationControls'])) {
                 $vb_show_navigation_control = $pa_options['showNavigationControls'] ? 'true' : 'false';
             } else {
                 $vb_show_navigation_control = $this->opo_config->get('google_maps_show_navigation_controls') ? 'true' : 'false';
             }
             if (isset($pa_options['showScaleControls'])) {
                 $vb_show_scale_control = $pa_options['showScaleControls'] ? 'true' : 'false';
             } else {
                 $vb_show_scale_control = $this->opo_config->get('google_maps_show_scale_controls') ? 'true' : 'false';
             }
             if (isset($pa_options['showMapTypeControls'])) {
                 $vb_show_map_type_control = $pa_options['showMapTypeControls'] ? 'true' : 'false';
             } else {
                 $vb_show_map_type_control = $this->opo_config->get('google_maps_show_map_type_controls') ? 'true' : 'false';
             }
             $vs_buf = "<div style='width:{$vs_width}; height:{$vs_height}' id='{$vs_id}'> </div>\n\n<script type='text/javascript'>\n\tvar caMap_{$vs_id};\n\tvar GeoMarker_{$vs_id};\njQuery(document).ready(function() {\n\tcaMap_{$vs_id} = caUI.initGoogleMap({id: '{$vs_id}', mapType: '{$vs_type}', zoomControl: true, navigationControl: {$vb_show_navigation_control} , mapTypeControl: {$vb_show_map_type_control}, scaleControl: {$vb_show_scale_control}});\n\tvar caMap_{$vs_id}_markers = [];\n\tvar caMap_{$vs_id}_current_marker = -1;\n\n\t\tvar styles = [\n\t\t  {\n\t\t\tstylers: [\n\n\t\t\t  { saturation: -100 },\n\n\t\t\t]\n\t\t  },{\n\t\t\tfeatureType: 'road',\n\t\t\telementType: 'geometry',\n\t\t\tstylers: [\n\t\t\t  { lightness: 100 },\n\t\t\t  { visibility: 'simplified' }\n\t\t\t]\n\t\t  }\n\t\t];\n\t\t\n\n\t\t\tcaMap_{$vs_id}.map.setOptions({styles: styles});\n\t\t\tvar mc_{$vs_id} = new MarkerClusterer(caMap_{$vs_id}.map, [], {maxZoom: 14});\n\t\t\tGeoMarker_{$vs_id} = new GeolocationMarker(caMap_{$vs_id}.map);\n\t\t\tGeoMarker_{$vs_id}.setCircleOptions({ fillColor: 'red', radius: '100', visible: true, map: caMap_{$vs_id}.map});\n";
             if ($vn_zoom_level > 0) {
                 $vs_buf .= "\n\t\t\t\tvar idleMinListener_{$vs_id} = google.maps.event.addListenerOnce(caMap_{$vs_id}.map, 'idle', function() {\n\t\t\t\t\tcaMap_{$vs_id}.map.setZoom({$vn_zoom_level});\n\t\t\t\t});\n\t\t\t\t";
             } else {
                 if ($vn_min_zoom_level) {
                     $vs_buf .= "\n\t\t\t\t\tvar idleMinListener_{$vs_id} = google.maps.event.addListenerOnce(caMap_{$vs_id}.map, 'idle', function() {\n\t\t\t\t\t\tif (caMap_{$vs_id}.map.getZoom() < {$vn_min_zoom_level}) {\n\t\t\t\t\t\t\tcaMap_{$vs_id}.map.setZoom({$vn_min_zoom_level});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t";
                 }
                 if ($vn_max_zoom_level) {
                     $vs_buf .= "\n\t\t\t\t\tvar idleMaxListener_{$vs_id} = google.maps.event.addListenerOnce(caMap_{$vs_id}.map, 'idle', function() {\n\t\t\t\t\t\tif (caMap_{$vs_id}.map.getZoom() > {$vn_max_zoom_level}) {\n\t\t\t\t\t\t\tcaMap_{$vs_id}.map.setZoom({$vn_max_zoom_level});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t";
                 }
             }
             $va_locs = $va_paths = array();
             foreach ($va_map_items as $o_map_item) {
                 $va_coords = $o_map_item->getCoordinates();
                 if (sizeof($va_coords) > 1) {
                     // is path
                     $va_path = array();
                     foreach ($va_coords as $va_coord) {
                         $va_path[] = "new google.maps.LatLng({$va_coord['latitude']},{$va_coord['longitude']})";
                     }
                     $va_paths[] = array('path' => $va_coords, 'pathJS' => $va_path, 'label' => $o_map_item->getLabel(), 'content' => $o_map_item->getContent(), 'ajaxContentUrl' => $o_map_item->getAjaxContentUrl(), 'ajaxContentID' => $o_map_item->getAjaxContentID());
                 } else {
                     // is point
                     $va_coord = array_shift($va_coords);
                     $va_locs[$va_coord['latitude']][$va_coord['longitude']][] = array('label' => $o_map_item->getLabel(), 'content' => $o_map_item->getContent(), 'ajaxContentUrl' => $o_map_item->getAjaxContentUrl(), 'ajaxContentID' => $o_map_item->getAjaxContentID());
                 }
             }
             foreach ($va_locs as $vn_latitude => $va_locs_by_longitude) {
                 foreach ($va_locs_by_longitude as $vn_longitude => $va_marker_content_items) {
                     $va_buf = array();
                     $va_ajax_ids = array();
                     $vs_label = $vs_ajax_content_url = '';
                     foreach ($va_marker_content_items as $va_marker_content_item) {
                         if (!$vs_label) {
                             $vs_label = $va_marker_content_item['label'];
                         }
                         if (!$vs_ajax_content_url) {
                             $vs_ajax_content_url = $va_marker_content_item['ajaxContentUrl'];
                         }
                         $va_ajax_ids[] = $va_marker_content_item['ajaxContentID'];
                         $va_buf[md5($va_marker_content_item['content'])] = $va_marker_content_item['content'];
                         // md5 is to ensure there is no duplicate content (eg. if something is mapped to the same location twice)
                     }
                     if (!($vn_latitude && $vn_longitude)) {
                         continue;
                     }
                     if ($vs_balloon_view && isset($pa_options['request']) && $pa_options['request']) {
                         $o_view = new View($pa_options['request'], isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $pa_options['request']->getViewsDirectoryPath());
                         $o_view->setVar("content", join($vs_delimiter, $va_buf));
                         $o_view->setVar("contentList", $va_buf);
                         $o_view->setVar("ids", $va_ajax_ids);
                         $vs_balloon_content = $o_view->render($vs_balloon_view);
                     } else {
                         $vs_balloon_content = join($vs_delimiter, $va_buf);
                     }
                     $vs_buf .= "\tvar m = caMap_{$vs_id}.makeMarker(" . $vn_latitude . ", " . $vn_longitude . ", '" . preg_replace("![\n\r]+!", " ", addslashes($vs_label)) . "', '" . preg_replace("![\n\r]+!", " ", addslashes($vs_balloon_content)) . "', '" . preg_replace("![\n\r]+!", " ", $vs_ajax_content_url ? addslashes($vs_ajax_content_url . "/_ajax/1/id/" . join(';', $va_ajax_ids)) : '') . "', {icon: '" . $o_config->get("themes_url") . "/" . (defined("__CA_THEME__") ? __CA_THEME__ : $o_config->get('theme')) . "/graphics/blu-pointer.png'} );\n";
                     $vs_buf .= "\tcaMap_{$vs_id}_markers.push(m);\n";
                     $vs_buf .= "\tmc_{$vs_id}.addMarker(m);\n";
                 }
             }
             foreach ($va_paths as $vn_i => $va_path) {
                 $vs_buf .= "caMap_{$vs_id}.makePath([" . join(',', $va_path['pathJS']) . "], '" . preg_replace("![\n\r]+!", " ", addslashes($va_path['label'])) . "','" . preg_replace("![\n\r]+!", " ", addslashes($va_path['content'])) . "', {strokeColor: '{$vs_path_color}', strokeWeight: {$vn_path_weight}, strokeOpacity: {$vn_path_opacity}});\n";
             }
             $vs_buf .= "\n\t\t\t\tcaMap_{$vs_id}.fitBounds(" . $va_extents['north'] . "," . $va_extents['south'] . "," . $va_extents['east'] . "," . $va_extents['west'] . ");";
             if (isset($pa_options['cycleRandomly']) && $pa_options['cycleRandomly']) {
                 if (isset($pa_options['cycleRandomlyInterval']) && $pa_options['cycleRandomlyInterval']) {
                     $vs_interval = $pa_options['cycleRandomlyInterval'];
                 } else {
                     $vs_interval = "2s";
                 }
                 if (isset($pa_options['stopAfterRandomCycles']) && $pa_options['stopAfterRandomCycles']) {
                     $vn_times = (int) $pa_options['stopAfterRandomCycles'];
                 } else {
                     $vn_times = 0;
                 }
                 $vs_buf .= "\n\t\t\t\tcaMap_{$vs_id}.openInfoWindow(caMap_{$vs_id}_markers[0]);\n\t\t\t\tjQuery(document).everyTime('{$vs_interval}', 'caMap_{$vs_id}_cycler', function() {\n\t\t\t\t\tvar i = -1;\n\t\t\t\t\tif (caMap_{$vs_id}_markers.length > 1) {\n\t\t\t\t\t\twhile((i < 0) || (i == caMap_{$vs_id}_current_marker)) {\n\t\t\t\t\t\t\t i = Math.floor(Math.random()*(caMap_{$vs_id}_markers.length));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ti = 0;\n\t\t\t\t\t}\n\t\t\t\t\tcaMap_{$vs_id}_current_marker = i;\n\t\t\t\t\tcaMap_{$vs_id}.openInfoWindow(caMap_{$vs_id}_markers[i]);\n\t\t\t\t}, {$vn_times});\n\t\t";
             }
             $vs_buf .= "\n\t});\n\tfunction clickroute() { \n\t\tvar latLng = GeoMarker_{$vs_id}.getPosition();\n\t\tif (typeof latLng === 'undefined' ) {\n\t\t\tdocument.getElementById('helpDiv').style.display = 'block';\n\t\t} else {\n\t\t\tcaMap_{$vs_id}.map.panTo(latLng);\n\t\t}\n\t}\n</script>\n";
             break;
             # ---------------------------------
     }
     return $vs_buf;
 }
Esempio n. 10
0
 /**
  * Returns HTML bundle for adding/editing/deleting placements from a form
  *
  * @param object $po_request The current request
  * @param $ps_form_name The name of the HTML form this bundle will be part of
  * @return string HTML for bundle
  */
 public function getSearchFormHTMLFormBundle($po_request, $ps_form_name, $pa_options = null)
 {
     if (!$this->haveAccessToForm($po_request->getUserID(), __CA_SEARCH_FORM_EDIT_ACCESS__)) {
         return null;
     }
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     $o_view->setVar('lookup_urls', caJSONLookupServiceUrl($po_request, $this->_DATAMODEL->getTableName($this->get('table_num'))));
     $o_view->setVar('t_form', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     return $o_view->render('ca_search_form_placements.php');
 }
 public function getPropertyHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $ps_property, $pa_attributes = null, $pa_options = null)
 {
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     $o_view->setVar('property', $ps_property);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $pa_attributes['name'] = $pa_attributes['id'] = "{$ps_placement_code}{$ps_form_name}{$ps_property}";
     $o_view->setVar('form_element', $this->getPropertyHTMLFormElement($ps_property, $pa_attributes));
     return $o_view->render('ca_representation_annotation_properties.php');
 }
 /**
  * Return HTML form element for editing.
  *
  * @param array $pa_element_info An array of information about the metadata element being edited
  * @param array $pa_options array Options include:
  *			class = the CSS class to apply to all visible form elements [Default=lookupBg]
  *			width = the width of the form element [Default=field width defined in metadata element definition]
  *			height = the height of the form element [Default=field height defined in metadata element definition]
  *			request = the RequestHTTP object for the current request; required for lookups to work [Default is null]
  *
  * @return string
  */
 public function htmlFormElement($pa_element_info, $pa_options = null)
 {
     $t_instance = self::elementTypeToInstance($this->getType());
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('fieldWidth'));
     $vs_class = trim(isset($pa_options['class']) && $pa_options['class'] ? $pa_options['class'] : 'lookupBg');
     if ($pa_options['request']) {
         if ($vs_restrict_to_type = caGetOption('restrictTo' . $this->ops_name_singular . 'TypeIdno', $pa_element_info['settings'], null)) {
             $va_params = array('max' => 50, 'type' => $vs_restrict_to_type);
         } else {
             $va_params = array('max' => 50);
         }
         $vs_url = caNavUrl($pa_options['request'], 'lookup', $this->ops_name_singular, 'Get', $va_params);
     } else {
         // no lookup is possible
         return $this->getDisplayValue();
     }
     $va_pieces = caEditorUrl($pa_options['request'], $t_instance->tableName(), 0, true);
     $va_pieces['controller'] = str_replace('Editor', 'QuickAdd', $va_pieces['controller']);
     $va_pieces['action'] = 'Form';
     $vs_quickadd_url = caNavUrl($pa_options['request'], $va_pieces['module'], $va_pieces['controller'], $va_pieces['action'], array($t_instance->primaryKey() => 0));
     $o_view = new View($pa_options['request'], $pa_options['request']->getViewsDirectoryPath() . "/bundles/");
     $o_view->setVar('field_name_prefix', "{fieldNamePrefix}{$pa_element_info['element_id']}");
     $o_view->setVar('quickadd_url', $vs_quickadd_url);
     $o_view->setVar('lookup_url', $vs_url);
     $o_view->setVar('options', $pa_options);
     $o_view->setVar('settings', $va_settings);
     $o_view->setVar('element_info', $pa_element_info);
     $o_view->setVar('class', $vs_class);
     return $o_view->render('authority_attribute.php');
 }
Esempio n. 13
0
 /** 
  * Returns HTML form bundle for component listing
  *
  * @param HTTPRequest $po_request The current request
  * @param string $ps_form_name
  * @param string $ps_placement_code
  * @param array $pa_bundle_settings
  * @param array $pa_options Array of options. Options include:
  *			noCache = If set to true then label cache is bypassed. [Default = true]
  *
  * @return string Rendered HTML bundle
  */
 public function getComponentListHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null)
 {
     global $g_ui_locale;
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     // pass placement code
     $o_view->setVar('settings', $pa_bundle_settings);
     $o_view->setVar('add_label', isset($pa_bundle_settings['add_label'][$g_ui_locale]) ? $pa_bundle_settings['add_label'][$g_ui_locale] : null);
     $o_view->setVar('t_subject', $this);
     return $o_view->render('ca_objects_components_list.php');
 }
} elseif ($vn_value_id > 0) {
    // displaying media attribute
    if ($vb_should_use_book_viewer && $this->getVar('num_multifiles') > 0) {
        // Create book viewer from single representation with multifiles
        $vb_use_book_reader = true;
        $vn_subject_id = $t_subject->getPrimaryKey();
        foreach ($t_value->getFileList(null, 0, null, array('preview', 'large_preview', 'page_preview')) as $vn_id => $va_file) {
            $va_pages[] = array('subject_id' => $vn_subject_id, 'value_id' => $vn_value_id, 'thumbnail_url' => $va_file['preview_url'], 'thumbnail_path' => $va_file['preview_path'], 'thumbnail_width' => $va_file['preview_width'], 'thumbnail_height' => $va_file['preview_height'], 'thumbnail_mimetype' => $va_file['preview_mimetype'], 'normal_url' => $va_file['large_preview_url'], 'normal_path' => $va_file['large_preview_path'], 'normal_width' => $va_file['large_preview_width'], 'normal_height' => $va_file['large_preview_height'], 'normal_mimetype' => $va_file['large_preview_mimetype'], 'large_url' => $va_file['page_preview_url'], 'large_path' => $va_file['page_preview_path'], 'large_width' => $va_file['page_preview_width'], 'large_height' => $va_file['page_preview_height'], 'large_mimetype' => $va_file['page_preview_mimetype']);
        }
        $vs_book_viewer_content_mode = 'multifiles';
    }
}
if ($vb_use_book_reader) {
    // Return Javascript for document viewer interface
    $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/');
    $o_view->setVar('t_subject', $t_subject);
    $o_view->setVar('t_representation', $t_rep);
    $o_view->setVar('t_attribute_value', $t_value);
    $o_view->setVar('item_id', $t_set_item ? $t_set_item->getPrimaryKey() : null);
    $o_view->setVar('pages', $va_pages);
    $o_view->setVar('sections', $va_sections);
    $o_view->setVar('content_mode', $vs_book_viewer_content_mode);
    $o_view->setVar('initial_page', $vn_open_to_page);
    $o_view->setVar('display_type', $vs_display_type);
    $o_view->setVar('display_options', $va_display_options);
    // Save pages in cache so BaseEditorController::GetPageListAsJSON() can get them for return to the document viewer
    $va_page_cache = $this->request->session->getVar('caDocumentViewerPageListCache');
    $vs_page_cache_key = $vs_book_viewer_content_mode == 'hierarchy_of_representations' ? md5($vn_subject_id) : md5($vn_subject_id . '/' . $vn_representation_id . '/' . $vn_value_id);
    $va_page_cache[$vs_page_cache_key] = $va_pages;
    $this->request->session->setVar('caDocumentViewerPageListCache', $va_page_cache);
    $va_section_cache = $this->request->session->getVar('caDocumentViewerSectionCache');
 /**
  * 
  *
  * 
  */
 public function Run()
 {
     AssetLoadManager::register('fileupload');
     $t_importer = $this->getImporterInstance();
     $this->view->setVar('t_importer', $t_importer);
     $this->view->setVar('last_settings', $va_last_settings = $this->request->user->getVar('batch_metadata_last_settings'));
     $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('id', 'fileImportPath');
     $o_view->setVar('defaultPath', caGetOption('fileImportPath', $va_last_settings, null));
     $this->view->setVar('file_browser', $o_view->render('settings_directory_browser_html.php'));
     $this->render('metadataimport/importer_run_html.php');
 }
Esempio n. 16
0
 /**
  * Renders and returns HTML form bundle for management of type restriction in the currently loaded ui
  * 
  * @param object $po_request The current request object
  * @param string $ps_form_name The name of the form in which the bundle will be rendered
  *
  * @return string Rendered HTML bundle for display
  */
 public function getTypeRestrictionsHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('t_ui', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     $va_type_restrictions = $this->getTypeRestrictions();
     $va_restriction_type_ids = array();
     if (is_array($va_type_restrictions)) {
         foreach ($va_type_restrictions as $vn_i => $va_restriction) {
             $va_restriction_type_ids[] = $va_restriction['type_id'];
         }
     }
     if (!($t_instance = $this->_DATAMODEL->getInstanceByTableNum($vn_table_num = $this->get('editor_type')))) {
         return null;
     }
     if ($t_instance instanceof BaseRelationshipModel) {
         // interstitial
         $o_view->setVar('type_restrictions', $t_instance->getRelationshipTypesAsHTMLSelect($t_instance->getLeftTableName(), null, null, array('name' => 'type_restrictions[]', 'multiple' => 1, 'size' => 5), array('values' => $va_restriction_type_ids)));
     } else {
         // list-based
         $o_view->setVar('type_restrictions', $t_instance->getTypeListAsHTMLFormElement('type_restrictions[]', array('multiple' => 1, 'height' => 5), array('value' => 0, 'values' => $va_restriction_type_ids)));
     }
     return $o_view->render('ca_editor_ui_type_restrictions.php');
 }
 /**
  * Outputting data
  */
 public function output()
 {
     if ($this->outputData === false) {
         header('Content-Type: text/html; charset=utf-8', true, 404);
         $view = new View();
         $view->setVar('title', '404');
         echo $view->render('404', 'error');
     } elseif (is_array($this->outputData)) {
         header('Content-Type: application/json');
         echo json_encode($this->outputData);
     } else {
         header('Content-Type: text/html; charset=utf-8');
         echo $this->outputData;
     }
 }
Esempio n. 18
0
 /**
  * Renders and returns HTML form bundle for set membership control. This a bundle that can appear in the editor of any item type (objects, entities, places, collections, etc.)
  * that can be the content type of a set, and enables users to toggle membership in any set for the open record.
  *
  * @param object $po_request The current request object
  * @param string $ps_form_name The name of the containing HTML form
  * @param int $pn_table_num The table_num of the currently open item record
  * @param int $pn_item_id The row_id of the currently open item record
  * @param int $pn_user_id The user_id of the current user; used to determine which sets are displayed as choices
  * @param array $pa_bundle_settings Bundle settings
  * @param array $pa_options Array of options (none supported yet)
  *
  * @return string Rendered HTML bundle for display
  */
 public function getItemSetMembershipHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pn_table_num, $pn_row_id, $pn_user_id = null, $pa_bundle_settings = null, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $va_cur_sets = caExtractValuesByUserLocale($this->getSetsForItem($pn_table_num, $pn_row_id, array('user_id' => $pn_user_id)));
     $o_view->setVar('t_set', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     $o_view->setVar('set_ids', array_keys($va_cur_sets));
     $o_view->setVar('available_set_ids', $va_available_sets = $this->getAvailableSetsForItem($pn_table_num, $pn_row_id, array('user_id' => $pn_user_id, 'access' => __CA_SET_EDIT_ACCESS__)));
     $o_view->setVar('sets', $va_sets = $this->getSets(array('table' => $pn_table_num, 'user_id' => $pn_user_id, 'access' => __CA_SET_EDIT_ACCESS__)));
     $o_view->setVar('settings', $pa_bundle_settings);
     $va_set_options = array();
     foreach ($va_sets as $vn_set_id => $va_sets_by_locale) {
         foreach ($va_sets_by_locale as $vn_locale_id => $va_set) {
             $va_set_options[$va_set['name']] = $vn_set_id;
         }
     }
     $o_view->setVar('set_options', $va_set_options);
     $vn_i = 0;
     $va_initial_values = array();
     foreach ($va_cur_sets as $va_set_info) {
         $va_initial_values[$va_set_info['item_id'] . ''] = array('set_id' => $va_set_info['set_id'], 'set_name' => $va_set_info['name']);
         $vn_i++;
     }
     $o_view->setVar('initial_values', $va_initial_values);
     $o_view->setVar('batch', (bool) (isset($pa_options['batch']) && $pa_options['batch']));
     return $o_view->render('ca_sets.php');
 }
 /**
  * Renders and returns HTML form bundle for management of type restriction in the currently loaded display
  * 
  * @param object $po_request The current request object
  * @param string $ps_form_name The name of the form in which the bundle will be rendered
  *
  * @return string Rendered HTML bundle for display
  */
 public function getTypeRestrictionsHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('t_display', $this);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     $va_type_restrictions = $this->getTypeRestrictions();
     $va_restriction_type_ids = array();
     if (is_array($va_type_restrictions)) {
         foreach ($va_type_restrictions as $vn_i => $va_restriction) {
             $va_restriction_type_ids[] = $va_restriction['type_id'];
         }
     }
     if (!($t_instance = $this->_DATAMODEL->getInstanceByTableNum($vn_table_num = $this->get('table_num')))) {
         return null;
     }
     $o_view->setVar('type_restrictions', $t_instance->getTypeListAsHTMLFormElement('type_restrictions[]', array('multiple' => 1, 'height' => 5), array('value' => 0, 'values' => $va_restriction_type_ids)));
     return $o_view->render('ca_bundle_display_type_restrictions.php');
 }
Esempio n. 20
0
 function resetSend()
 {
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Reset Password"));
     $t_user = new ca_users();
     $vs_message = "";
     $va_errors = array();
     $ps_email = $this->request->getParameter('reset_email', pString);
     if (!caCheckEmailAddress($ps_email)) {
         $this->view->setVar("message", _t("E-mail address is not valid"));
         $this->resetForm();
     } else {
         $t_user->setErrorOutput(0);
         if (!$t_user->load(array("user_name" => $ps_email))) {
             $t_user->load(array("email" => $ps_email));
         }
         # verify user exists with this e-mail address
         if ($t_user->getPrimaryKey()) {
             # user with e-mail does exists...
             if (sizeof($va_errors) == 0) {
                 $o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
                 $vs_reset_key = md5($t_user->get("user_id") . '/' . $t_user->get("password"));
                 # --- get the subject of the email from template
                 $vs_subject_line = $o_view->render('mailTemplates/instructions_subject.tpl');
                 # -- generate mail text from template - get both the text and html versions
                 $vs_password_reset_url = $this->request->config->get("site_host") . caNavUrl($this->request, '', 'LoginReg', 'resetSave', array('key' => $vs_reset_key));
                 $o_view->setVar("password_reset_url", $vs_password_reset_url);
                 $vs_mail_message_text = $o_view->render('mailTemplates/instructions.tpl');
                 $vs_mail_message_html = $o_view->render('mailTemplates/instructions_html.tpl');
                 caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
                 $this->view->setVar("email", $this->request->config->get("ca_admin_email"));
                 $this->view->setVar("action", "send");
                 $this->render('LoginReg/form_reset_html.php');
             }
         } else {
             $this->view->setVar("message", _t("There is no registered user with the email address you provided"));
             $this->resetForm();
         }
     }
 }
 /** 
  * Returns HTML form bundle (for use in a ca_object_representations editor form) for captions
  *
  * @param HTTPRequest $po_request The current request
  * @param string $ps_form_name
  * @param string $ps_placement_code
  * @param array $pa_bundle_settings
  * @param array $pa_options Array of options. Supported options are 
  *			noCache = If set to true then label cache is bypassed; default is true
  *
  * @return string Rendered HTML bundle
  */
 public function getCaptionHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null)
 {
     global $g_ui_locale;
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     // pass placement code
     $o_view->setVar('settings', $pa_bundle_settings);
     $o_view->setVar('t_subject', $this);
     $o_view->setVar('t_caption', new ca_object_representation_captions());
     //$va_media_info = $this->getMediaInfo('media');
     //if (!is_array($va_media_info)) { $va_media_info = array('original' => array('PROPERTIES' => array('typename' => null))); }
     //$o_view->setVar('representation_typename', $va_media_info['original']['PROPERTIES']['typename']);
     $o_view->setVar('representation_num_caption_files', $this->numCaptionFiles());
     $o_view->setVar('initialValues', $this->getCaptionFileList());
     return $o_view->render('ca_object_representation_captions.php');
 }
Esempio n. 22
0
 /**
  * Extract geographic data from a data object (model instance or search result) and load it for rendering
  *
  * @param $po_data_object BaseModel|SearchResult A model instance or search result object from which to extract data for the map
  * @param $ps_georeference_field_name string The name of the georeference or geonames attribute to plot map items with; should be in <table>.<element_code> format (eg. "ca_objects.map_coords")
  * @param $pa_options array Optional array of options; supported options include:
  *			label - attribute (or field) to use for a short label for the map point, in <table>.<element_code> format (eg. "ca_objects.idno" or "ca_objects.preferred_labels.name")
  *			content - attribute (or field) to use for info balloon content shown when map item is clicked, in <table>.<element_code> format (eg. "ca_objects.description"). The content of the field is used as-is, so you must apply any styling to the data before it is stored in the database. If you want to style content "on-the-fly" use contentView or contentTemplate
  *			contentTemplate - text template to use for info balloon content shown when map item is clicked; attributes in <table>.<element_code> format will be substituted when prefixed with a caret ("^"). Eg. "The title of this is ^ca_objects.preferred_labels.name and the date is ^ca_objects.creation_date"
  *			contentView - view to use to render info balloon content shown when map item is clicked; specify the view filename with path relative to the main view directory (eg. "Splash/splash_html.php"); the view will be passed a single variable, "data", containing the data object
  *			ajaxContentUrl - URL to use to load via AJAX in info balloon. The primary key of the item will be added to the URL as the "id" parameter. The AJAX handler referenced by the URL must return ready-to-display HTML suitable for display in an info balloon. Unlike all other balloon content options, ajaxContentUrl defers rendering of balloon content until viewed, and does not embed content in the initial HTML load. For these reasons it is usually the best performing and most scaleable option.
  *			checkAccess - array of access field values to filter data (item and representation level); omit or pass empty array to do no filtering
  *			viewPath - path to views; will use standard system view path if not defined
  *			request = current request; required for generation of editor links
  *			color = hex color to use for item marker; can include bundle display template tags for inclusion of colors stored in metadata elements
  * @return array Returns an array with two keys: 'points' = number of unique markers added to map; 'items' = number of result hits than were plotted at least once on the map
  */
 public function mapFrom($po_data_object, $ps_georeference_field_name, $pa_options = null)
 {
     $po_request = caGetOption('request', $pa_options, null);
     $pa_options['label'] = caGetOption('label', $pa_options, null);
     $pa_options['content'] = caGetOption('content', $pa_options, null);
     $vs_color = caGetOption('color', $pa_options, null);
     $vb_render_label_as_link = caGetOption('renderLabelAsLink', $pa_options, false);
     $vn_point_count = 0;
     $vn_item_count = 0;
     $va_tmp = explode('.', $ps_georeference_field_name);
     $vs_field_name = array_pop($va_tmp);
     $va_point_buf = array();
     //
     // Data object is a model instance?
     //
     if (is_subclass_of($po_data_object, 'BaseModel')) {
         if ($po_data_object->hasField('access') && isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess'])) {
             if (!in_array($po_data_object->get('access'), $pa_options['checkAccess'])) {
                 return array('items' => 0, 'points' => 0);
             }
         }
         $vn_id = $po_data_object->getPrimaryKey();
         if (is_array($va_coordinates = $po_data_object->get($ps_georeference_field_name, array('coordinates' => true, 'returnAsArray' => true)))) {
             foreach ($va_coordinates as $vn_i => $va_geoname) {
                 $va_coordinate = isset($va_geoname[$vs_field_name]) ? $va_geoname[$vs_field_name] : $va_geoname;
                 $vs_label = $vs_content = $vs_ajax_content = null;
                 if (!is_null($pa_options['labelTemplate'])) {
                     $vs_label = caProcessTemplateForIDs($pa_options['labelTemplate'], $po_data_object->tableName(), array($vn_id), array('returnAsLink' => $vb_render_label_as_link || strpos($pa_options['contentTemplate'], "<l>") !== false));
                 } else {
                     if (!is_null($pa_options['label'])) {
                         $vs_label = $po_data_object->get($pa_options['label'], array('returnAsLink' => $vb_render_label_as_link || strpos($pa_options['contentTemplate'], "<l>") !== false));
                     } else {
                         $vs_label = $va_coordinate['label'];
                     }
                 }
                 if (!is_null($vs_color)) {
                     $vs_color = caProcessTemplateForIDs($vs_color, $po_data_object->tableName(), array($vn_id), array('returnAsLink' => false));
                 } else {
                     $vs_color = null;
                 }
                 if (isset($pa_options['ajaxContentUrl']) && $pa_options['ajaxContentUrl']) {
                     $vs_ajax_content = $pa_options['ajaxContentUrl'];
                 } else {
                     if (!is_null($pa_options['contentView']) && $pa_options['request']) {
                         $o_view = new View($pa_options['request'], isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $pa_options['request']->getViewsDirectoryPath());
                         $o_view->setVar('data', $po_data_object);
                         $o_view->setVar('access_values', $pa_options['checkAccess']);
                         $vs_content = $o_view->render($pa_options['contentView']);
                     } else {
                         if (!is_null($pa_options['contentTemplate'])) {
                             $vs_content = caProcessTemplateForIDs($pa_options['contentTemplate'], $po_data_object->tableName(), $po_data_object->get($po_data_object->tableName() . "." . $po_data_object->primaryKey(), array('returnAsArray' => true)), array('returnAsLink' => strpos($pa_options['contentTemplate'], "<l>") !== false));
                         } else {
                             if (!is_null($pa_options['content'])) {
                                 if ($pa_options['content']) {
                                     $vs_content = $po_data_object->get($pa_options['content']);
                                 }
                             } else {
                                 $vs_content = $va_coordinate['label'];
                             }
                         }
                     }
                 }
                 $va_path = explode(";", $va_coordinate['path']);
                 if (sizeof($va_path) > 1) {
                     $va_coordinate_pairs = array();
                     foreach ($va_path as $vs_pair) {
                         $va_pair = explode(',', $vs_pair);
                         $va_coordinate_pairs[] = array('latitude' => $va_pair[0], 'longitude' => $va_pair[1]);
                     }
                     $this->addMapItem(new GeographicMapItem(array('coordinates' => $va_coordinate_pairs, 'label' => $vs_label, 'content' => $vs_content, 'ajaxContentUrl' => $vs_ajax_content, 'ajaxContentID' => $vn_id, 'color' => $vs_color)));
                 } else {
                     $this->addMapItem(new GeographicMapItem(array('latitude' => $va_coordinate['latitude'], 'longitude' => $va_coordinate['longitude'], 'label' => $vs_label, 'content' => $vs_content, 'ajaxContentUrl' => $vs_ajax_content, 'ajaxContentID' => $vn_id, 'color' => $vs_color)));
                 }
                 if (!$va_point_buf[$va_coordinate['latitude'] . '/' . $va_coordinate['longitude']]) {
                     $vn_point_count++;
                 }
                 $va_point_buf[$va_coordinate['latitude'] . '/' . $va_coordinate['longitude']]++;
             }
             $vn_item_count++;
         }
         return array('items' => $vn_item_count, 'points' => $vn_point_count);
     }
     //
     // Data object is a search result?
     //
     if (is_subclass_of($po_data_object, 'SearchResult')) {
         $po_data_object->setOption('prefetch', 1000);
         $va_access_values = null;
         if (isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess'])) {
             $va_access_values = $pa_options['checkAccess'];
         }
         $t_instance = $po_data_object->getResultTableInstance();
         $vs_table = $t_instance->tableName();
         $vs_pk = $t_instance->primaryKey();
         while ($po_data_object->nextHit()) {
             if ($va_access_values) {
                 if (!in_array($po_data_object->get('access'), $va_access_values)) {
                     continue;
                 }
             }
             if ($va_coordinates = $po_data_object->get($ps_georeference_field_name, array('coordinates' => true, 'returnAsArray' => true, 'returnAllLocales' => true))) {
                 $vn_id = $po_data_object->get("{$vs_table}.{$vs_pk}");
                 $vs_table = $po_data_object->tableName();
                 foreach ($va_coordinates as $vn_element_id => $va_geonames_by_locale) {
                     foreach ($va_geonames_by_locale as $vn_locale_id => $va_coord_list) {
                         foreach ($va_coord_list as $vn_attribute_id => $va_geoname) {
                             $va_coordinate = isset($va_geoname[$vs_field_name]) ? $va_geoname[$vs_field_name] : $va_geoname;
                             $vs_label = $vs_content = $vs_ajax_content = null;
                             if (!is_null($pa_options['labelTemplate'])) {
                                 $vs_label = caProcessTemplateForIDs($pa_options['labelTemplate'], $vs_table, array($vn_id), array('returnAsLink' => $vb_render_label_as_link || strpos($pa_options['contentTemplate'], "<l>") !== false));
                             } else {
                                 if (!is_null($pa_options['label'])) {
                                     $vs_label = $po_data_object->get($pa_options['label'], array('returnAsLink' => $vb_render_label_as_link || strpos($pa_options['contentTemplate'], "<l>") !== false));
                                 } else {
                                     $vs_label = $va_coordinate['label'];
                                 }
                             }
                             if (!is_null($pa_options['color'])) {
                                 $vs_color = caProcessTemplateForIDs($pa_options['color'], $vs_table, array($vn_id), array('returnAsLink' => false));
                             } else {
                                 $vs_color = null;
                             }
                             if (isset($pa_options['ajaxContentUrl']) && $pa_options['ajaxContentUrl']) {
                                 $vs_ajax_content = $pa_options['ajaxContentUrl'];
                             } else {
                                 if (!is_null($pa_options['contentView']) && $pa_options['request']) {
                                     $o_view = new View($pa_options['request'], isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $pa_options['request']->getViewsDirectoryPath());
                                     $o_view->setVar('data', $po_data_object);
                                     $o_view->setVar('access_values', $pa_options['checkAccess']);
                                     $vs_content = $o_view->render($pa_options['contentView']);
                                 } else {
                                     if (!is_null($pa_options['contentTemplate'])) {
                                         $vs_content = caProcessTemplateForIDs($pa_options['contentTemplate'], $po_data_object->tableName(), $po_data_object->get($po_data_object->tableName() . "." . $po_data_object->primaryKey(), array('returnAsArray' => true)), array('returnAsLink' => strpos($pa_options['contentTemplate'], "<l>") !== false));
                                     } else {
                                         if (!is_null($pa_options['content'])) {
                                             if ($pa_options['content']) {
                                                 $vs_content = $po_data_object->get($pa_options['content']);
                                             }
                                         } else {
                                             $vs_content = $va_coordinate['label'];
                                         }
                                     }
                                 }
                             }
                             $va_path = explode(";", $va_coordinate['path']);
                             if (sizeof($va_path) > 1) {
                                 $va_coordinate_pairs = array();
                                 foreach ($va_path as $vs_pair) {
                                     $va_pair = explode(',', $vs_pair);
                                     $va_coordinate_pairs[] = array('latitude' => $va_pair[0], 'longitude' => $va_pair[1]);
                                 }
                                 $this->addMapItem(new GeographicMapItem(array('coordinates' => $va_coordinate_pairs, 'label' => $vs_label, 'content' => $vs_content, 'ajaxContentUrl' => $vs_ajax_content, 'ajaxContentID' => $vn_id, 'color' => $vs_color)));
                             } else {
                                 $this->addMapItem(new GeographicMapItem(array('latitude' => $va_coordinate['latitude'], 'longitude' => $va_coordinate['longitude'], 'label' => $vs_label, 'content' => $vs_content, 'ajaxContentUrl' => $vs_ajax_content, 'ajaxContentID' => $vn_id, 'color' => $vs_color)));
                             }
                             if (!$va_point_buf[$va_coordinate['latitude'] . '/' . $va_coordinate['longitude']]) {
                                 $vn_point_count++;
                             }
                             $va_point_buf[$va_coordinate['latitude'] . '/' . $va_coordinate['longitude']]++;
                         }
                         $vn_item_count++;
                     }
                 }
             }
         }
     }
     return array('items' => $vn_item_count, 'points' => $vn_point_count);
 }
 /**
  * 
  */
 public function getACLWorldHTMLFormBundle($po_request, $ps_form_name, $pa_options = null)
 {
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     require_once __CA_MODELS_DIR__ . '/ca_acl.php';
     $t_acl = new ca_acl();
     $vn_access = 0;
     if ($t_acl->load(array('group_id' => null, 'user_id' => null, 'table_num' => $this->tableNum(), 'row_id' => $this->getPrimaryKey()))) {
         // try to load existing record
         $vn_access = $t_acl->get('access');
     } else {
         $vn_access = $this->getAppConfig()->get('default_item_access_level');
     }
     $o_view->setVar('t_instance', $this);
     $o_view->setVar('table_num', $pn_table_num);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('request', $po_request);
     $o_view->setVar('t_group', $t_group);
     $o_view->setVar('initialValue', $vn_access);
     return $o_view->render('ca_acl_world.php');
 }
Esempio n. 24
0
/**
 * Generates standard-format inspector panels for editors
 *
 * @param View $po_view Inspector view object
 * @param array $pa_options Optional array of options. Supported options are:
 *		backText = a string to use as the "back" button text; default is "Results"
 *
 * @return string HTML implementing the inspector
 */
function caBatchEditorInspector($po_view, $pa_options = null)
{
    require_once __CA_MODELS_DIR__ . '/ca_sets.php';
    $t_set = $po_view->getVar('t_set');
    $t_item = $po_view->getVar('t_item');
    $vs_table_name = $t_item->tableName();
    if (($vs_priv_table_name = $vs_table_name) == 'ca_list_items') {
        $vs_priv_table_name = 'ca_lists';
    }
    $o_result_context = $po_view->getVar('result_context');
    $t_ui = $po_view->getVar('t_ui');
    $o_dm = Datamodel::load();
    // action extra to preserve currently open screen across next/previous links
    //$vs_screen_extra 	= ($po_view->getVar('screen')) ? '/'.$po_view->getVar('screen') : '';
    $vs_buf = '<h3 class="nextPrevious">' . caNavLink($po_view->request, 'Back', '', 'manage', 'Set', 'ListSets') . "</h3>\n";
    $vs_color = null;
    if ($t_type) {
        $vs_color = trim($t_type->get('color'));
    }
    if (!$vs_color && $t_ui) {
        $vs_color = trim($t_ui->get('color'));
    }
    if (!$vs_color) {
        $vs_color = "444444";
    }
    $vs_buf .= "<h4><div id='caColorbox' style='border: 6px solid #{$vs_color}; padding-bottom:15px;'>\n";
    if ($po_view->request->user->canDoAction("can_edit_" . $vs_priv_table_name) && sizeof($t_item->getTypeList()) > 1) {
        if ($po_view->request->user->canDoAction("can_change_type_{$vs_table_name}")) {
            $vs_buf .= "<div id='inspectorChangeType'><div id='inspectorChangeTypeButton'><a href='#' onclick='caTypeChangePanel.showPanel(); return false;'>" . caNavIcon($po_view->request, __CA_NAV_BUTTON_CHANGE__, null, array('title' => _t('Change type'))) . "</a></div></div>\n";
            $vo_change_type_view = new View($po_view->request, $po_view->request->getViewsDirectoryPath() . "/bundles/");
            $vo_change_type_view->setVar('t_item', $t_item);
            $vo_change_type_view->setVar('t_set', $t_set);
            $vo_change_type_view->setVar('set_id', $t_set->getPrimaryKey());
            FooterManager::add($vo_change_type_view->render("batch_change_type_html.php"));
        }
        $vs_buf .= "<strong>" . _t("Editing %1", $vs_type_name) . ": </strong>\n";
    } else {
        $vs_buf .= "<strong>" . _t("Viewing %1", $vs_type_name) . ": </strong>\n";
    }
    $vn_item_count = $t_set->getItemCount(array('user_id' => $po_view->request->getUserID()));
    $vs_item_name = $vn_item_count == 1 ? $t_item->getProperty("NAME_SINGULAR") : $t_item->getProperty("NAME_PLURAL");
    $vs_buf .= "<strong>" . _t("Batch editing %1 %2 in set", $vn_item_count, $vs_item_name) . ": </strong>\n";
    if (!($vs_label = $t_set->getLabelForDisplay())) {
        if (!($vs_label = $t_set->get('set_code'))) {
            $vs_label = '[' . _t('BLANK') . ']';
        }
    }
    if ($t_set->haveAccessToSet($po_view->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
        $vs_label = caEditorLink($po_view->request, $vs_label, '', 'ca_sets', $t_set->getPrimaryKey());
    }
    $vs_buf .= "<div style='width:190px; overflow:hidden;'>{$vs_watch}{$vs_label}" . "<a title='{$vs_idno}'>" . ($vs_idno ? " ({$vs_idno})" : '') . "</a></div>\n";
    // -------------------------------------------------------------------------------------
    $vs_buf .= "<div>" . _t('Set contains <em>%1</em>', join(", ", $t_set->getTypesForItems())) . "</div>\n";
    // -------------------------------------------------------------------------------------
    // Nav link for batch delete
    // -------------------------------------------------------------------------------------
    if ($vn_item_count > 0 && $po_view->request->user->canDoAction('can_batch_delete_' . $o_dm->getTableName($t_set->get('table_num')))) {
        $vs_buf .= "<div class='button' style='text-align:right;'><a href='#' id='inspectorMoreInfo'>" . _t("More options") . "</a> &rsaquo;</div>\n\t\t\t\t<div id='inspectorInfo' style='background-color:#f9f9f9; border: 1px solid #eee;'>";
        $vs_buf .= caNavLink($po_view->request, caNavIcon($po_view->request, __CA_NAV_BUTTON_DEL_BUNDLE__, null, array('style' => 'margin-top:7px; vertical-align: text-bottom;')) . " " . _t("Delete <strong><em>all</em></strong> records in set"), null, 'batch', 'Editor', 'Delete', array('set_id' => $t_set->getPrimaryKey()));
        $vs_buf .= "</div>\n";
        $vs_buf .= "<script type='text/javascript'>\n\t\t\t\tjQuery('#inspectorMoreInfo').click(function() {\n\t\t\t\t\tjQuery('#inspectorInfo').slideToggle(350, function() { \n\t\t\t\t\t\tjQuery('#inspectorMoreInfo').html((this.style.display == 'block') ? '" . addslashes(_t('Close options')) . "' : '" . addslashes(_t('More options')) . "');\n\t\t\t\t\t}); \n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t</script>";
    }
    // -------------------------------------------------------------------------------------
    $vs_buf .= "</div></h4>\n";
    return $vs_buf;
}
 /**
  * 
  */
 public function getUserHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pn_table_num, $pn_item_id, $pn_user_id = null, $pa_options = null)
 {
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     require_once __CA_MODELS_DIR__ . '/ca_users.php';
     $t_user = new ca_users();
     $o_dm = Datamodel::load();
     $t_rel = $o_dm->getInstanceByTableName($this->getProperty('USERS_RELATIONSHIP_TABLE'));
     $o_view->setVar('t_rel', $t_rel);
     $o_view->setVar('t_instance', $this);
     $o_view->setVar('table_num', $pn_table_num);
     $o_view->setVar('id_prefix', $ps_form_name);
     $o_view->setVar('placement_code', $ps_placement_code);
     $o_view->setVar('request', $po_request);
     $o_view->setVar('t_user', $t_user);
     $o_view->setVar('initialValues', $this->getUsers(array('returnAsInitialValuesForBundle' => true)));
     return $o_view->render('ca_users.php');
 }
Esempio n. 26
0
/**
 * Sends mail message using specified view and variable to merge
 *
 * Parameters are:
 *
 * 	$pa_to: 	Email address(es) of message recipients. Can be a string containing a single email address or
 *				an associative array with keys set to multiple addresses and corresponding values optionally set to
 *				a human-readable recipient name.
 *	$pa_from:	The email address of the message sender. Can be a string containing a single email address or
 *				an associative array with keys set to multiple addresses and corresponding values optionally set to
 *				a human-readable sender name.
 *	$ps_subject:	The subject line of the message
 *	$ps_view:	The name of a view in the 'mailTemplates' view directory
 * 	$pa_values:	An array of values
 * 	$pa_cc: 	Email address(es) of cc'ed message recipients. Can be a string containing a single email address or
 *				an associative array with keys set to multiple addresses and corresponding values optionally set to
 *				a human-readable recipient name. (optional)
 * 	$pa_bcc: 	Email address(es) of bcc'ed message recipients. Can be a string containing a single email address or
 *				an associative array with keys set to multiple addresses and corresponding values optionally set to
 *				a human-readable recipient name. (optional)
 *
 * @return string True if send, false if error
 */
function caSendMessageUsingView($po_request, $pa_to, $pa_from, $ps_subject, $ps_view, $pa_values, $pa_cc = null, $pa_bcc = null)
{
    $vs_view_path = is_object($po_request) ? $po_request->getViewsDirectoryPath() : __CA_BASE_DIR__ . '/themes/default/views';
    $o_view = new View(null, $vs_view_path . "/mailTemplates");
    foreach ($pa_values as $vs_key => $vm_val) {
        $o_view->setVar($vs_key, $vm_val);
    }
    return caSendmail($pa_to, $pa_from, $ps_subject, null, $o_view->render($ps_view), $pa_cc, $pa_bcc);
}
Esempio n. 27
0
/**
 * 
 *
 * @param RequestHTTP $po_request
 * @param array $pa_options
 * @param array $pa_additional_display_options
 * @return string HTML output
 */
function caRepresentationViewerHTMLBundleForSearchResult($po_data, $po_request, $pa_options = null, $pa_additional_display_options = null)
{
    $ps_version = $po_request->getParameter('version', pString);
    $va_access_values = isset($pa_options['access']) && is_array($pa_options['access']) ? $pa_options['access'] : array();
    $vs_display_type = isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : 'media_overlay';
    $vs_container_dom_id = isset($pa_options['containerID']) && $pa_options['containerID'] ? $pa_options['containerID'] : null;
    $vn_object_id = isset($pa_options['object_id']) && $pa_options['object_id'] ? $pa_options['object_id'] : null;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $vn_order_item_id = isset($pa_options['order_item_id']) && $pa_options['order_item_id'] ? $pa_options['order_item_id'] : null;
    $vb_media_editor = isset($pa_options['mediaEditor']) && $pa_options['mediaEditor'] ? true : false;
    $vb_no_controls = isset($pa_options['noControls']) && $pa_options['noControls'] ? true : false;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $t_object = new ca_objects($vn_object_id);
    //if (!$t_object->getPrimaryKey()) { return false; }
    if (!$po_data->getPrimaryKey() && $t_object->getPrimaryKey() && method_exists($po_data, 'load')) {
        $po_data->load($t_object->getPrimaryRepresentationID(array('checkAccess' => $va_access_values)));
    }
    $t_set_item = new ca_set_items();
    if ($vn_item_id) {
        $t_set_item->load($vn_item_id);
    }
    $t_order_item = new ca_commerce_order_items();
    if ($vn_order_item_id) {
        $t_order_item->load($vn_order_item_id);
    }
    $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
    $o_view->setVar('t_object', $t_object);
    $o_view->setVar('t_set_item', $t_set_item);
    $o_view->setVar('t_order_item', $t_order_item);
    $o_view->setVar('use_media_editor', $vb_media_editor);
    $o_view->setVar('noControls', $vb_no_controls);
    $va_rep_display_info = array();
    if (isset($pa_options['use_book_viewer'])) {
        $va_rep_display_info['use_book_viewer'] = (bool) $pa_options['use_book_viewer'];
    }
    if ($t_object->getPrimaryKey()) {
        $o_view->setVar('reps', $va_reps = $t_object->getRepresentations(array('icon'), null, array("return_with_access" => $va_access_values)));
    }
    $t_media = new Media();
    $va_buf = array();
    while ($po_data->nextHit()) {
        if (method_exists($po_data, 'numFiles')) {
            $o_view->setVar('num_multifiles', $po_data->numFiles());
        }
        $o_view->setVar('t_object_representation', $po_data);
        if (($vn_representation_id = $po_data->getPrimaryKey()) && (!sizeof($va_access_values) || in_array($po_data->get('access'), $va_access_values))) {
            // check rep access
            $va_rep_display_info = caGetMediaDisplayInfo($vs_display_type, $vs_mimetype = $po_data->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
            $va_rep_display_info['poster_frame_url'] = $po_data->getMediaUrl('media', $va_rep_display_info['poster_frame_version']);
            $va_additional_display_options = array();
            if (is_array($pa_additional_display_options) && isset($pa_additional_display_options[$vs_mimetype]) && is_array($pa_additional_display_options[$vs_mimetype])) {
                $va_additional_display_options = $pa_additional_display_options[$vs_mimetype];
            }
            $o_view->setVar('display_options', caGetMediaDisplayInfo('detail', $vs_mimetype));
            $o_view->setVar('display_type', $vs_display_type);
            $o_view->setVar('representation_id', $vn_representation_id);
            $o_view->setVar('t_object_representation', $po_data);
            $o_view->setVar('versions', $va_versions = $po_data->getMediaVersions('media'));
            $o_view->setVar('containerID', $vs_container_dom_id . $vn_representation_id);
            $o_view->setVar('version_type', $t_media->getMimetypeTypename($po_data->getMediaInfo('media', 'original', 'MIMETYPE')));
            if ($t_object->getPrimaryKey()) {
                $vn_next_rep = $vn_prev_rep = null;
                $va_rep_list = array_values($va_reps);
                foreach ($va_rep_list as $vn_i => $va_rep) {
                    if ($va_rep['representation_id'] == $vn_representation_id) {
                        if (isset($va_rep_list[$vn_i - 1])) {
                            $vn_prev_rep = $va_rep_list[$vn_i - 1]['representation_id'];
                        }
                        if (isset($va_rep_list[$vn_i + 1])) {
                            $vn_next_rep = $va_rep_list[$vn_i + 1]['representation_id'];
                        }
                        $o_view->setVar('representation_index', $vn_i + 1);
                    }
                }
                $o_view->setVar('previous_representation_id', $vn_prev_rep);
                $o_view->setVar('next_representation_id', $vn_next_rep);
            }
            if (!in_array($ps_version, $va_versions)) {
                if (!($ps_version = $va_rep_display_info['display_version'])) {
                    $ps_version = null;
                }
            }
            $o_view->setVar('version_info', $po_data->getMediaInfo('media', $ps_version));
            $o_view->setVar('version', $ps_version);
        }
        $va_buf[$vn_representation_id] = $o_view->render('representation_viewer_html.php');
    }
    return $va_buf;
}
Esempio n. 28
0
 /**
  *
  */
 public function SendShare()
 {
     $va_errors = array();
     $ps_tablename = $this->request->getParameter('tablename', pString);
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     if (!($t_item = $this->opo_datamodel->getInstanceByTableName($ps_tablename, true))) {
         die("Invalid table name " . $ps_tablename . " for detail");
         // shouldn't happen
     }
     if (!$t_item->load($pn_item_id)) {
         $this->view->setVar("message", _t("ID does not exist"));
         $this->render("Form/reload_html.php");
         return;
     }
     $o_purifier = new HTMLPurifier();
     $ps_to_email = $o_purifier->purify($this->request->getParameter('to_email', pString));
     $ps_from_email = $o_purifier->purify($this->request->getParameter('from_email', pString));
     $ps_from_name = $o_purifier->purify($this->request->getParameter('from_name', pString));
     $ps_subject = $o_purifier->purify($this->request->getParameter('subject', pString));
     $ps_message = $o_purifier->purify($this->request->getParameter('message', pString));
     $pn_security = $this->request->getParameter('security', pInteger);
     $pn_sum = $this->request->getParameter('sum', pInteger);
     # --- check vars are set and email addresses are valid
     $va_to_email = array();
     $va_to_email_process = array();
     if (!$ps_to_email) {
         $va_errors["to_email"] = _t("Please enter a valid email address or multiple addresses separated by commas");
     } else {
         # --- explode on commas to support multiple addresses - then check each one
         $va_to_email_process = explode(",", $ps_to_email);
         foreach ($va_to_email_process as $vs_email_to_verify) {
             $vs_email_to_verify = trim($vs_email_to_verify);
             if (caCheckEmailAddress($vs_email_to_verify)) {
                 $va_to_email[$vs_email_to_verify] = "";
             } else {
                 $ps_to_email = "";
                 $va_errors["to_email"] = _t("Please enter a valid email address or multiple addresses separated by commas");
             }
         }
     }
     if (!$ps_from_email || !caCheckEmailAddress($ps_from_email)) {
         $ps_from_email = "";
         $va_errors["from_email"] = _t("Please enter a valid email address");
     }
     if (!$ps_from_name) {
         $va_errors["from_name"] = _t("Please enter your name");
     }
     if (!$ps_subject) {
         $va_errors["subject"] = _t("Please enter a subject");
     }
     if (!$ps_message) {
         $va_errors["message"] = _t("Please enter a message");
     }
     if (!$this->request->isLoggedIn()) {
         # --- check for security answer if not logged in
         if (!$pn_security) {
             $va_errors["security"] = _t("Please answer the security question.");
         } else {
             if ($pn_security != $pn_sum) {
                 $va_errors["security"] = _t("Your answer was incorrect, please try again");
             }
         }
     }
     $this->view->setVar('t_item', $t_item);
     $this->view->setVar('item_id', $pn_item_id);
     $this->view->setVar('tablename', $ps_tablename);
     if (sizeof($va_errors) == 0) {
         $o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
         $o_view->setVar("item", $t_item);
         $o_view->setVar("item_id", $pn_item_id);
         $o_view->setVar("from_name", $ps_from_name);
         $o_view->setVar("message", $ps_message);
         $o_view->setVar("detailConfig", $this->config);
         # -- generate mail text from template - get both html and text versions
         if ($ps_tablename == "ca_objects") {
             $vs_mail_message_text = $o_view->render("mailTemplates/share_object_email_text.tpl");
         } else {
             $vs_mail_message_text = $o_view->render("mailTemplates/share_email_text.tpl");
         }
         if ($ps_tablename == "ca_objects") {
             $vs_mail_message_html = $o_view->render("/mailTemplates/share_object_email_html.tpl");
         } else {
             $vs_mail_message_html = $o_view->render("/mailTemplates/share_email_html.tpl");
         }
         $va_media = null;
         if ($ps_tablename == "ca_objects") {
             # --- get media for attachment
             $vs_media_version = "";
             # Media representation to email
             # --- version is set in media_display.conf.
             if (method_exists($t_item, 'getPrimaryRepresentationInstance')) {
                 if ($t_primary_rep = $t_item->getPrimaryRepresentationInstance()) {
                     if (!sizeof($this->opa_access_values) || in_array($t_primary_rep->get('access'), $this->opa_access_values)) {
                         // check rep access
                         $va_media = array();
                         $va_rep_display_info = caGetMediaDisplayInfo('email', $t_primary_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
                         $vs_media_version = $va_rep_display_info['display_version'];
                         $va_media['path'] = $t_primary_rep->getMediaPath('media', $vs_media_version);
                         $va_media_info = $t_primary_rep->getFileInfo('media', $vs_media_version);
                         if (!($va_media['name'] = $va_media_info['ORIGINAL_FILENAME'])) {
                             $va_media['name'] = $va_media_info[$vs_media_version]['FILENAME'];
                         }
                         # --- this is the mimetype of the version being downloaded
                         $va_media["mimetype"] = $va_media_info[$vs_media_version]['MIMETYPE'];
                     }
                 }
             }
         }
         if (caSendmail($va_to_email, array($ps_from_email => $ps_from_name), $ps_subject, $vs_mail_message_text, $vs_mail_message_html, null, null, $va_media)) {
             $this->view->setVar("message", _t("Your email was sent"));
             $this->render("Form/reload_html.php");
             return;
         } else {
             $va_errors["general"] = _t("Your email could not be sent");
         }
     }
     if (sizeof($va_errors)) {
         # --- there were errors in the form data, so reload form with errors displayed - pass params to preload form
         $this->view->setVar('to_email', $ps_to_email);
         $this->view->setVar('from_email', $ps_from_email);
         $this->view->setVar('from_name', $ps_from_name);
         $this->view->setVar('subject', $ps_subject);
         $this->view->setVar('message', $ps_message);
         $this->view->setVar('errors', $va_errors);
         $va_errors["general"] = _t("There were errors in your form");
         $this->ShareForm();
     } else {
         $this->view->setVar("message", _t("Your message was sent"));
         $this->render("Form/reload_html.php");
         return;
     }
 }
Esempio n. 29
0
/**
 * Return rendered HTML for media viewer for both re
 *
 * @param RequestHTTP $po_request
 * @param array $pa_options
 * @param array $pa_additional_display_options
 * @return string HTML output
 */
function caGetMediaViewerHTMLBundle($po_request, $pa_options = null, $pa_additional_display_options = null)
{
    $va_access_values = isset($pa_options['access']) && is_array($pa_options['access']) ? $pa_options['access'] : array();
    $vs_display_type = isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : 'media_overlay';
    $vs_container_dom_id = isset($pa_options['containerID']) && $pa_options['containerID'] ? $pa_options['containerID'] : null;
    $t_subject = isset($pa_options['t_subject']) && $pa_options['t_subject'] ? $pa_options['t_subject'] : null;
    $t_rep = isset($pa_options['t_representation']) && $pa_options['t_representation'] ? $pa_options['t_representation'] : null;
    $vn_representation_id = $t_rep ? $t_rep->getPrimaryKey() : null;
    $t_attr_val = isset($pa_options['t_attribute_value']) && $pa_options['t_attribute_value'] ? $pa_options['t_attribute_value'] : null;
    $vn_value_id = $t_attr_val ? $t_attr_val->getPrimaryKey() : null;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $vn_order_item_id = isset($pa_options['order_item_id']) && $pa_options['order_item_id'] ? $pa_options['order_item_id'] : null;
    $vb_media_editor = isset($pa_options['mediaEditor']) && $pa_options['mediaEditor'] ? true : false;
    $vb_no_controls = isset($pa_options['noControls']) && $pa_options['noControls'] ? true : false;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $vn_subject_id = $t_subject ? $t_subject->getPrimaryKey() : null;
    if (!$vn_value_id && !$vn_representation_id) {
        $t_rep->load($t_subject->getPrimaryRepresentationID(array('checkAccess' => $va_access_values)));
    }
    $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
    $t_set_item = new ca_set_items();
    if ($vn_item_id) {
        $t_set_item->load($vn_item_id);
    }
    $t_order_item = new ca_commerce_order_items();
    if ($vn_order_item_id) {
        $t_order_item->load($vn_order_item_id);
    }
    $o_view->setVar('containerID', $vs_container_dom_id);
    $o_view->setVar('t_subject', $t_subject);
    $o_view->setVar('t_representation', $t_rep);
    if ($vn_representation_id && (!sizeof($va_access_values) || in_array($t_rep->get('access'), $va_access_values))) {
        // check rep access
        $va_rep_display_info = caGetMediaDisplayInfo($vs_display_type, $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
        $va_rep_display_info['poster_frame_url'] = $t_rep->getMediaUrl('media', $va_rep_display_info['poster_frame_version']);
        $o_view->setVar('num_multifiles', $t_rep->numFiles());
        if (isset($pa_options['use_book_viewer'])) {
            $va_rep_display_info['use_book_viewer'] = (bool) $pa_options['use_book_viewer'];
        }
        $o_view->setVar('display_type', $vs_display_type);
        if (is_array($pa_additional_display_options)) {
            $va_rep_display_info = array_merge($va_rep_display_info, $pa_additional_display_options);
        }
        $o_view->setVar('display_options', $va_rep_display_info);
        $o_view->setVar('representation_id', $vn_representation_id);
        $o_view->setVar('versions', $va_versions = $t_rep->getMediaVersions('media'));
        $t_media = new Media();
        $o_view->setVar('version_type', $t_media->getMimetypeTypename($t_rep->getMediaInfo('media', 'original', 'MIMETYPE')));
        if ($vn_subject_id) {
            $o_view->setVar('reps', $va_reps = $t_subject->getRepresentations(array('icon'), null, array("return_with_access" => $va_access_values)));
            $vn_next_rep = $vn_prev_rep = null;
            $va_rep_list = array_values($va_reps);
            foreach ($va_rep_list as $vn_i => $va_rep) {
                if ($va_rep['representation_id'] == $vn_representation_id) {
                    if (isset($va_rep_list[$vn_i - 1])) {
                        $vn_prev_rep = $va_rep_list[$vn_i - 1]['representation_id'];
                    }
                    if (isset($va_rep_list[$vn_i + 1])) {
                        $vn_next_rep = $va_rep_list[$vn_i + 1]['representation_id'];
                    }
                    $o_view->setVar('representation_index', $vn_i + 1);
                }
            }
            $o_view->setVar('previous_representation_id', $vn_prev_rep);
            $o_view->setVar('next_representation_id', $vn_next_rep);
        }
        $ps_version = $po_request->getParameter('version', pString);
        if (!in_array($ps_version, $va_versions)) {
            if (!($ps_version = $va_rep_display_info['display_version'])) {
                $ps_version = null;
            }
        }
        $o_view->setVar('version', $ps_version);
        $o_view->setVar('version_info', $t_rep->getMediaInfo('media', $ps_version));
        $o_view->setVar('t_set_item', $t_set_item);
        $o_view->setVar('t_order_item', $t_order_item);
        $o_view->setVar('use_media_editor', $vb_media_editor);
        $o_view->setVar('noControls', $vb_no_controls);
    } else {
        //$t_attr = new ca_attributes($t_attr_val->get('attribute_id'));
        $t_attr_val->useBlobAsMediaField(true);
        $va_rep_display_info = caGetMediaDisplayInfo($vs_display_type, $t_attr_val->getMediaInfo('value_blob', 'INPUT', 'MIMETYPE'));
        $va_rep_display_info['poster_frame_url'] = $t_attr_val->getMediaUrl('value_blob', $va_rep_display_info['poster_frame_version']);
        $o_view->setVar('num_multifiles', $t_attr_val->numFiles());
        if (isset($pa_options['use_book_viewer'])) {
            $va_rep_display_info['use_book_viewer'] = (bool) $pa_options['use_book_viewer'];
        }
        $o_view->setVar('display_type', $vs_display_type);
        if (is_array($pa_additional_display_options)) {
            $va_rep_display_info = array_merge($va_rep_display_info, $pa_additional_display_options);
        }
        $o_view->setVar('display_options', $va_rep_display_info);
        $o_view->setVar('representation_id', $vn_representation_id);
        $o_view->setVar('t_attribute_value', $t_attr_val);
        $o_view->setVar('versions', $va_versions = $t_attr_val->getMediaVersions('value_blob'));
        $t_media = new Media();
        $o_view->setVar('version_type', $t_media->getMimetypeTypename($t_attr_val->getMediaInfo('value_blob', 'original', 'MIMETYPE')));
        $o_view->setVar('reps', array());
        $ps_version = $po_request->getParameter('version', pString);
        if (!in_array($ps_version, $va_versions)) {
            if (!($ps_version = $va_rep_display_info['display_version'])) {
                $ps_version = null;
            }
        }
        $o_view->setVar('version', $ps_version);
        $o_view->setVar('version_info', $t_attr_val->getMediaInfo('value_blob', $ps_version));
        $o_view->setVar('t_subject', $t_subject);
        $o_view->setVar('t_set_item', $t_set_item);
        $o_view->setVar('t_order_item', $t_order_item);
        $o_view->setVar('use_media_editor', $vb_media_editor);
        $o_view->setVar('noControls', $vb_no_controls);
    }
    return $o_view->render('representation_viewer_html.php');
}
Esempio n. 30
0
 /**
  * Returns bundle HTML (using bundle view) for specifying settings for the currently loaded row
  *
  * @param HTTPRequest Request object
  * @param array $pa_options Optional array of options. Support options are:
  *		id = 
  *		name = 
  *		settings = 
  * @return string HTML code for bundle
  */
 public function getHTMLSettingFormBundle($po_request, $pa_options = null)
 {
     $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
     $o_view->setVar('t_subject', $this);
     return $o_view->render('settings.php');
 }