Example #1
0
 /**
  * Returns content for overlay containing details for object representation
  *
  * Expects the following request parameters: 
  *		object_id = the id of the ca_objects record to display
  *		representation_id = the id of the ca_object_representations record to display; the representation must belong to the specified object
  *
  *	Optional request parameters:
  *		version = The version of the representation to display. If omitted the display version configured in media_display.conf is used
  *		order_item_id = ca_commerce_order_items.item_id value to limit representation display to
  *
  */
 public function GetRepresentationInfo()
 {
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $pn_representation_id = $this->request->getParameter('representation_id', pInteger);
     if (!($ps_display_type = trim($this->request->getParameter('display_type', pString)))) {
         $ps_display_type = 'media_overlay';
     }
     if (!($ps_containerID = trim($this->request->getParameter('containerID', pString)))) {
         $ps_containerID = 'caMediaPanelContentArea';
     }
     if (!$pn_object_id) {
         $pn_object_id = 0;
     }
     $t_rep = new ca_object_representations($pn_representation_id);
     if (!$t_rep->getPrimaryKey()) {
         $this->postError(1100, _t('Invalid object/representation'), 'DetailController->GetRepresentationInfo');
         return;
     }
     $va_opts = array('display' => $ps_display_type, 'object_id' => $pn_object_id, 'containerID' => $ps_containerID, 'access' => caGetUserAccessValues($this->request));
     if (strlen($vs_use_book_viewer = $this->request->getParameter('use_book_viewer', pInteger))) {
         $va_opts['use_book_viewer'] = (bool) $vs_use_book_viewer;
     }
     $vs_output = $t_rep->getRepresentationViewerHTMLBundle($this->request, $va_opts);
     if ($this->request->getParameter('include_tool_bar', pInteger)) {
         $vs_output = "<div class='repViewerContCont'><div id='cont{$vn_rep_id}' class='repViewerCont'>" . $vs_output . caRepToolbar($this->request, $t_rep, $pn_object_id) . "</div></div>";
     }
     $this->response->addContent($vs_output);
 }
Example #2
0
 public function getSetItemRep()
 {
     $pn_set_id = $this->request->getParameter('set_id', pInteger);
     $t_set = new ca_sets($pn_set_id);
     $t_set->load($pn_set_id);
     $va_set_items = caExtractValuesByUserLocale($t_set->getItems(array("thumbnailVersions" => array("icon"), "checkAccess" => $this->opa_access_values)));
     $this->view->setVar("set_id", $pn_set_id);
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $t_rep = new ca_object_representations($va_set_items[$pn_item_id]["representation_id"]);
     $va_rep_info = $t_rep->getMediaInfo("media", "mediumlarge");
     $this->view->setVar("rep", $t_rep->getMediaTag("media", "mediumlarge"));
     $this->view->setVar("repToolBar", caRepToolbar($this->request, $t_rep, $va_set_items[$pn_item_id]["row_id"]));
     $this->view->setVar("representation_id", $va_set_items[$pn_item_id]["representation_id"]);
     $this->view->setVar("object_id", $va_set_items[$pn_item_id]["row_id"]);
     $pn_previous_id = 0;
     $pn_next_id = 0;
     $va_set_item_ids = array_keys($va_set_items);
     $vn_current_index = array_search($pn_item_id, $va_set_item_ids);
     if ($va_set_item_ids[$vn_current_index - 1]) {
         $pn_previous_id = $va_set_item_ids[$vn_current_index - 1];
     }
     if ($va_set_item_ids[$vn_current_index + 1]) {
         $pn_next_id = $va_set_item_ids[$vn_current_index + 1];
     }
     $this->view->setVar("next_item_id", $pn_next_id);
     $this->view->setVar("previous_item_id", $pn_previous_id);
     $this->render("Gallery/set_item_rep_html.php");
 }
Example #3
0
/**
 * Returns the primary representation for display on the object detail page
 * uses settings from media_display.conf
 * options
 *		primaryOnly - true/false, show only the primary rep, default false
 *		dontShowPlaceholder - true/false, default false
 *		currentRepClass = set to class name added to thumbnail reps link tag for current rep (default = active)	
 *
 *
 * NOTE: references classes in caObjectRepresentationThumbnails to select current thumbnail
 */
function caObjectDetailMedia($po_request, $pn_object_id, $t_representation, $t_object, $pa_options = null)
{
    if (!is_array($pa_options)) {
        $pa_options = array();
    }
    if (!$pa_options["currentRepClass"]) {
        $pa_options["currentRepClass"] = "active";
    }
    $va_access_values = caGetUserAccessValues($po_request);
    if ($t_representation) {
        $vn_current_rep_id = $t_representation->get("representation_id");
    }
    if ($pa_options["primaryOnly"]) {
        if ($vn_current_rep_id) {
            $va_rep_ids = array($vn_current_rep_id);
        } else {
            if ($vn_primary_rep_id = $t_object->getPrimaryRepresentationID(array("checkAccess" => $va_access_values))) {
                $va_rep_ids = array($vn_primary_rep_id);
            }
        }
    } else {
        # --- are there multiple reps?
        $va_rep_ids = $t_object->getRepresentationIDs(array("checkAccess" => $va_access_values));
        if (sizeof($va_rep_ids)) {
            $vn_primary_id = array_search("1", $va_rep_ids);
            if ($vn_primary) {
                unset($va_rep_ids[$vn_primary_id]);
                $va_rep_ids = array_merge(array($vn_primary_id), array_keys($va_rep_ids));
            } else {
                $va_rep_ids = array_keys($va_rep_ids);
            }
        }
    }
    $va_rep_tags = array();
    if (sizeof($va_rep_ids)) {
        $vs_output = "";
        $qr_reps = caMakeSearchResult('ca_object_representations', $va_rep_ids);
        $va_rep_tags = $qr_reps->getRepresentationViewerHTMLBundles($po_request, array('display' => 'detail', 'object_id' => $pn_object_id, 'containerID' => 'cont'));
        $qr_reps->seek(0);
        while ($qr_reps->nextHit()) {
            $vn_rep_id = $qr_reps->get('representation_id');
            $vs_tool_bar = caRepToolbar($po_request, $qr_reps, $pn_object_id);
            $va_rep_tags[$vn_rep_id] = "<div class='repViewerContCont'><div id='cont{$vn_rep_id}' class='repViewerCont'>" . $va_rep_tags[$vn_rep_id] . $vs_tool_bar . "</div></div>";
        }
        if (sizeof($va_rep_ids) > 1) {
            $vs_output .= '<div class="jcarousel-wrapper"><div class="jcarousel" id="repViewerCarousel"><ul>';
        }
        $vn_count = 0;
        $va_slide_rep_ids = array();
        foreach ($va_rep_tags as $vn_rep_id => $vs_rep_tag) {
            if (sizeof($va_rep_ids) > 1) {
                $vs_output .= "<li id='slide" . $vn_rep_id . "' class='" . $vn_rep_id . "'>";
            }
            if ($vn_count == 0) {
                $vs_output .= $vs_rep_tag;
            }
            // only load first one initially
            if (sizeof($va_rep_ids) > 1) {
                $vs_output .= "</li>";
            }
            $va_slide_rep_ids[] = $vn_rep_id;
            $vn_count++;
        }
        if (sizeof($va_rep_ids) > 1) {
            $vs_output .= "</ul></div><!-- end jcarousel -->\n\t\t\t\t\t\t\t\t<!-- Prev/next controls -->\n\t\t\t\t\t\t\t\t<div id='detailRepNav'><a href='#' id='detailRepNavPrev' title='" . _t("Previous") . "'><span class='glyphicon glyphicon-arrow-left'></span></a> <a href='#' id='detailRepNavNext' title='" . _t("Next") . "'><span class='glyphicon glyphicon-arrow-right'></span></a><div style='clear:both;'></div></div><!-- end detailRepNav -->\n\t\t\t\t\t\t\t</div><!-- end jcarousel-wrapper -->\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\tvar caSlideRepresentationIDs = " . json_encode($va_slide_rep_ids) . ";\n\t\t\t\t\t\t\t/* width of li */\n\t\t\t\t\t\t\t\$('.jcarousel li').width(\$('.jcarousel').width());\n\t\t\t\t\t\t\t\$( window ).resize(function() { \$('.jcarousel li').width(\$('.jcarousel').width()); });\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t/* Carousel initialization */\n\t\t\t\t\t\t\t\$('.jcarousel').jcarousel({\n\t\t\t\t\t\t\t\tanimation: {\n\t\t\t\t\t\t\t\t\tduration: 0 // make changing image immediately\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\twrap: 'circular'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t\t\t// make fadeIn effect\n\t\t\t\t\t\t\t\$('.jcarousel').on('jcarousel:animate', function (event, carousel) {\n\t\t\t\t\t\t\t\t\$(carousel._element.context).find('li').hide().fadeIn(500);\n\t\t\t\t\t\t\t}).on('jcarousel:animateend', function(event, carousel) {\n\t\t\t\t\t\t\t\tvar current_rep_id = parseInt(\$('.jcarousel').jcarousel('first').attr('id').replace('slide', ''));\n\t\t\t\t\t\t\t\tvar i = caSlideRepresentationIDs.indexOf(current_rep_id);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (!jQuery('#slide' + caSlideRepresentationIDs[i]).html()) {\n\t\t\t\t\t\t\t\t\t// load media via ajax\n\t\t\t\t\t\t\t\t\tjQuery('#slide' + caSlideRepresentationIDs[i]).html('<div style=\\'margin-top: 120px; text-align: center; width: 100%;\\'>Loading...</div>');\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tjQuery('#slide' + caSlideRepresentationIDs[i]).load('" . caNavUrl($po_request, '*', '*', 'GetRepresentationInfo', array('object_id' => $pn_object_id, 'representation_id' => '')) . "' + caSlideRepresentationIDs[i] + '/include_tool_bar/1/display_type/detail/containerID/slide' + caSlideRepresentationIDs[i]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t/* Prev control initialization */\n\t\t\t\t\t\t\t\$('#detailRepNavPrev')\n\t\t\t\t\t\t\t\t.on('jcarouselcontrol:active', function() { \$(this).removeClass('inactive'); })\n\t\t\t\t\t\t\t\t.on('jcarouselcontrol:inactive', function() { \$(this).addClass('inactive'); })\n\t\t\t\t\t\t\t\t.jcarouselControl({ \n\t\t\t\t\t\t\t\t\ttarget: '-=1',\n\t\t\t\t\t\t\t\t\tmethod: function() {\n\t\t\t\t\t\t\t\t\t\t\t\$('.jcarousel').jcarousel('scroll', '-=1', true, function() {\n\t\t\t\t\t\t\t\t\t\t\t\tvar id = \$('.jcarousel').jcarousel('target').attr('class');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails ." . $pa_options["currentRepClass"] . "').removeClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails #detailRepresentationThumbnail' + id).addClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails #detailRepresentationThumbnail' + id + ' a').addClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t\t\t/* Next control initialization */\n\t\t\t\t\t\t\t\$('#detailRepNavNext')\n\t\t\t\t\t\t\t\t.on('jcarouselcontrol:active', function() { \$(this).removeClass('inactive'); })\n\t\t\t\t\t\t\t\t.on('jcarouselcontrol:inactive', function() { \$(this).addClass('inactive'); })\n\t\t\t\t\t\t\t\t.jcarouselControl({\n\t\t\t\t\t\t\t\t\ttarget: '+=1',\n\t\t\t\t\t\t\t\t\tmethod: function() {\n\t\t\t\t\t\t\t\t\t\t\t\$('.jcarousel').jcarousel('scroll', '+=1', true, function() {\n\t\t\t\t\t\t\t\t\t\t\t\tvar id = \$('.jcarousel').jcarousel('target').attr('class');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails ." . $pa_options["currentRepClass"] . "').removeClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails #detailRepresentationThumbnail' + id).addClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t\t\$('#detailRepresentationThumbnails #detailRepresentationThumbnail' + id + ' a').addClass('" . $pa_options["currentRepClass"] . "');\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});";
            if ($vn_current_rep_id) {
                $vs_output .= "\$('.jcarousel').jcarousel('scroll', \$('#slide" . $vn_current_rep_id . "'));";
            }
            $vs_output .= "\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>";
        }
        return $vs_output;
    } else {
        if (!$pa_options["dontShowPlaceholder"]) {
            if (!$po_request->config->get("disable_my_collections")) {
                $o_set_config = caGetSetsConfig();
                $vs_lightbox_icon = $o_set_config->get("add_to_lightbox_icon");
                if (!$vs_lightbox_icon) {
                    $vs_lightbox_icon = "<i class='fa fa-suitcase'></i>";
                }
                $va_lightbox_display_name = caGetSetDisplayName($o_set_config);
                $vs_lightbox_display_name = $va_lightbox_display_name["singular"];
                $vs_lightbox_display_name_plural = $va_lightbox_display_name["plural"];
                $vs_tool_bar = "<div id='detailMediaToolbar'>";
                if ($po_request->isLoggedIn()) {
                    $vs_tool_bar .= " <a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($po_request, '', 'Sets', 'addItemForm', array("object_id" => $pn_object_id)) . "\"); return false;' title='" . _t("Add item to %1", $vs_lightbox_display_name) . "'>" . $vs_lightbox_icon . "</a>\n";
                } else {
                    $vs_tool_bar .= " <a href='#' onclick='caMediaPanel.showPanel(\"" . caNavUrl($po_request, '', 'LoginReg', 'LoginForm') . "\"); return false;' title='" . _t("Login to add item to %1", $vs_lightbox_display_name) . "'>" . $vs_lightbox_icon . "</a>\n";
                }
                $vs_tool_bar .= "</div><!-- end detailMediaToolbar -->\n";
            }
            $vs_placeholder = getPlaceholder($t_object->getTypeCode(), "placeholder_large_media_icon");
            return "<div class='detailMediaPlaceholder'>" . $vs_placeholder . "</div>" . $vs_tool_bar;
        }
    }
}