Exemplo n.º 1
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;
}
 /**
  * QuickLook
  */
 public function QuickLook()
 {
     $vn_object_id = (int) $this->request->getParameter('object_id', pInteger);
     $t_object = new ca_objects($vn_object_id);
     $t_rep = new ca_object_representations($t_object->getPrimaryRepresentationID());
     $this->response->addContent(caGetMediaViewerHTMLBundle($this->request, array('display' => 'media_overlay', 't_subject' => $t_object, 't_representation' => $t_rep, 'containerID' => 'caMediaPanelContentArea')));
 }
Exemplo n.º 3
0
 public function AjaxAddItem()
 {
     if (!$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm'));
         return;
     }
     global $g_ui_locale_id;
     // current locale_id for user
     $va_errors = array();
     $o_purifier = new HTMLPurifier();
     # --- set_id is passed through form, otherwise we're saving a new set, and adding the item to it
     if ($this->request->getParameter('set_id', pInteger)) {
         $t_set = $this->_getSet(__CA_EDIT_READ_ACCESS__);
         if (!$t_set && ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) {
             $va_errors["general"] = _t("You can not add items to this lightbox.  You have read only access.");
             $this->view->setVar('errors', $va_errors);
             $this->addItemForm();
             return;
         }
     } else {
         $t_set = new ca_sets();
         # --- set name - if not sent, make a decent default
         $ps_name = $o_purifier->purify($this->request->getParameter('name', pString));
         if (!$ps_name) {
             $ps_name = _t("Your lightbox");
         }
         # --- set description - optional
         $ps_description = $o_purifier->purify($this->request->getParameter('description', pString));
         $t_list = new ca_lists();
         $vn_set_type_user = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type'));
         $t_object = new ca_objects();
         $vn_object_table_num = $t_object->tableNum();
         $t_set->setMode(ACCESS_WRITE);
         $t_set->set('access', 1);
         #$t_set->set('access', $this->request->getParameter('access', pInteger));
         $t_set->set('table_num', $vn_object_table_num);
         $t_set->set('type_id', $vn_set_type_user);
         $t_set->set('user_id', $this->request->getUserID());
         $t_set->set('set_code', $this->request->getUserID() . '_' . time());
         # --- create new attribute
         if ($ps_description) {
             $t_set->addAttribute(array('description' => $ps_description, 'locale_id' => $g_ui_locale_id), 'description');
         }
         $t_set->insert();
         if ($t_set->numErrors()) {
             $va_errors["general"] = join("; ", $t_set->getErrors());
             $this->view->setVar('errors', $va_errors);
             $this->addItemForm();
             return;
         } else {
             # --- save name - add new label
             $t_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true);
             # --- select the current set
             $this->request->user->setVar('current_set_id', $t_set->get("set_id"));
         }
     }
     if ($t_set) {
         $pn_item_id = null;
         $pn_object_id = $this->request->getParameter('object_id', pInteger);
         if ($pn_object_id) {
             if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) {
                 if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) {
                     //
                     // Select primary representation
                     //
                     $t_object = new ca_objects($pn_object_id);
                     $vn_rep_id = $t_object->getPrimaryRepresentationID();
                     // get representation_id for primary
                     $t_item = new ca_set_items($pn_item_id);
                     $t_item->addSelectedRepresentation($vn_rep_id);
                     // flag as selected in item vars
                     $t_item->update();
                     $va_errors = array();
                     $this->view->setVar('message', _t("Successfully added item."));
                     $this->render("Form/reload_html.php");
                 } else {
                     $va_errors["message"] = _t('Could not add item to lightbox');
                     $this->render("Form/reload_html.php");
                 }
             } else {
                 $this->view->setVar('message', _t("Item already in lightbox."));
                 $this->render("Form/reload_html.php");
             }
         } else {
             $this->view->setVar('message', _t("Object ID is not defined"));
             $this->render("Form/reload_html.php");
         }
     }
 }
Exemplo n.º 4
0
 /**
  *
  */
 public function SelectRepresentations()
 {
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $t_item = new ca_set_items($pn_item_id);
     $t_set = new ca_sets($t_item->get('set_id'));
     if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
         // TODO: proper error reporting or redirect?
         return;
     }
     $t_object = new ca_objects($pn_object_id);
     if (!$vn_object_id) {
         $vn_object_id = 0;
     }
     $t_rep = new ca_object_representations($t_object->getPrimaryRepresentationID());
     $va_opts = array('use_book_viewer' => true, 'display' => 'media_overlay', 'object_id' => $pn_object_id, 'item_id' => $pn_item_id, 'containerID' => 'caMediaPanelContentArea', 'access' => caGetUserAccessValues($this->request));
     $this->response->addContent($t_rep->getRepresentationViewerHTMLBundle($this->request, $va_opts, array('sectionsAreSelectable' => true, 'use_book_viewer_when_number_of_representations_exceeds' => 0)));
 }
Exemplo n.º 5
0
 /**
  * 
  */
 public function addItem($pn_object_id, $pa_values, $pa_options = null)
 {
     if (isset($pa_options['order_id']) && (int) $pa_options['order_id']) {
         $vn_order_id = (int) $pa_options['order_id'];
     } else {
         $vn_order_id = $this->getPrimaryKey();
     }
     if (!$vn_order_id) {
         return null;
     }
     $t_item = new ca_commerce_order_items();
     $t_item->setMode(ACCESS_WRITE);
     $t_item->set('order_id', $vn_order_id);
     $t_item->set('object_id', $pn_object_id);
     foreach ($pa_values as $vs_f => $vs_v) {
         $t_item->set($vs_f, $vs_v);
     }
     if (isset($pa_options['additional_fees']) && is_array($pa_options['additional_fees'])) {
         $va_fees = array();
         foreach ($pa_options['additional_fees'] as $vs_code => $vn_fee) {
             $va_fees[$vs_code] = sprintf("%4.2f", $vn_fee);
         }
         $t_item->set('additional_fees', $va_fees);
     }
     // set fulfillment method
     if (!isset($pa_values['fullfillment_method'])) {
         if (isset($this->opo_services_list[$t_item->get('service')]['fulfillment_method'])) {
             $t_item->set('fullfillment_method', $this->opo_services_list[$t_item->get('service')]['fulfillment_method']);
         }
     }
     $t_item->insert();
     if ($t_item->numErrors()) {
         $this->errors = $t_item->errors;
         return null;
     }
     // Add first representation by default
     $t_object = new ca_objects($pn_object_id);
     $vn_rep_id = $t_object->getPrimaryRepresentationID();
     if ($this->get('order_type') == 'O') {
         $t_item->addRepresentations(isset($pa_options['representation_ids']) && is_array($pa_options['representation_ids']) ? $pa_options['representation_ids'] : array($vn_rep_id));
     }
     return $t_item;
 }
 /**
  *
  */
 public function SelectRepresentations()
 {
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $pn_object_id = (int) $this->request->getParameter('object_id', pInteger);
     $t_item = new ca_commerce_order_items($pn_item_id);
     $t_object = new ca_objects($pn_object_id);
     $t_rep = new ca_object_representations($t_object->getPrimaryRepresentationID());
     $va_opts = array('use_book_viewer' => true, 'display' => 'media_overlay', 't_subject' => $t_object, 't_representation' => $t_rep, 'order_item_id' => $pn_item_id, 'containerID' => 'caMediaPanelContentArea', 'access' => caGetUserAccessValues($this->request));
     $this->response->addContent(caGetMediaViewerHTMLBundle($this->request, $va_opts, array('sectionsAreSelectable' => true, 'use_book_viewer_when_number_of_representations_exceeds' => 0)));
 }