private static function initializeFileGalleryApi($package) { if (!empty(self::$installed[$package]->api->filegallery)) { $parent = self::$installed[$package]->api->filegallery->parent; TikiAddons_Api_FileGallery::setParents($package, $parent); $tracker = self::$installed[$package]->api->filegallery->tracker; TikiAddons_Api_FileGallery::setTrackers($package, $tracker); } }
function renderOutput($context = array()) { global $prefs; global $mimetypes; include 'lib/mime/mimetypes.php'; $galleryId = (int) $this->getOption('galleryId'); // Support Addon File Gallery API switching $api = new TikiAddons_Api_FileGallery(); $itemId = $this->getItemId(); $galleryId = $api->mapGalleryId($galleryId, $itemId); if (!isset($context['list_mode'])) { $context['list_mode'] = 'n'; } $value = $this->getValue(); if ($context['list_mode'] === 'csv') { return $value; } $ret = ''; if (!empty($value)) { if ($this->getOption('displayMode')) { // images etc $params = array('fileId' => $value); if ($context['list_mode'] === 'y') { $otherParams = $this->getOption('displayParamsForLists'); } else { $otherParams = $this->getOption('displayParams'); } if ($otherParams) { parse_str($otherParams, $otherParams); $params = array_merge($params, $otherParams); } $params['fromFieldId'] = $this->getConfiguration('fieldId'); $params['fromItemId'] = $this->getItemId(); $item = Tracker_Item::fromInfo($this->getItemData()); $params['checkItemPerms'] = $item->canModify() ? 'n' : 'y'; if ($this->getOption('displayMode') == 'img') { // img if ($context['list_mode'] === 'y') { $params['thumb'] = $context['list_mode']; $params['rel'] = 'box[' . $this->getInsertId() . ']'; } include_once 'lib/wiki-plugins/wikiplugin_img.php'; $ret = wikiplugin_img('', $params); } else { if ($this->getOption('displayMode') == 'vimeo') { // Vimeo videos stored as filegal REMOTEs include_once 'lib/wiki-plugins/wikiplugin_vimeo.php'; $ret = wikiplugin_vimeo('', $params); } else { if ($this->getOption('displayMode') == 'moodlescorm') { include_once 'lib/wiki-plugins/wikiplugin_playscorm.php'; foreach ($this->getConfiguration('files') as $fileId => $file) { $params['fileId'] = $fileId; $ret .= wikiplugin_playscorm('', $params); } } else { if ($this->getOption('displayMode') == 'googleviewer') { if ($prefs['auth_token_access'] != 'y') { $ret = tra('Token access needs to be enabled for Google viewer to be used'); } else { $files = array(); foreach ($this->getConfiguration('files') as $fileId => $file) { global $base_url, $tikiroot, $https_mode; if ($https_mode) { $scheme = 'https'; } else { $scheme = 'http'; } $googleurl = $scheme . "://docs.google.com/viewer?url="; $fileurl = urlencode($base_url . "tiki-download_file.php?fileId=" . $fileId); require_once 'lib/auth/tokens.php'; $tokenlib = AuthTokens::build($prefs); $token = $tokenlib->createToken($tikiroot . "tiki-download_file.php", array('fileId' => $fileId), array('Registered'), array('timeout' => 300, 'hits' => 3)); $fileurl .= urlencode("&TOKEN=" . $token); $url = $googleurl . $fileurl . '&embedded=true'; $title = $file['name']; $files[] = array('url' => $url, 'title' => $title, 'id' => $fileId); } $smarty = TikiLib::lib('smarty'); $smarty->assign('files', $files); $ret = $smarty->fetch('trackeroutput/files_googleviewer.tpl'); } } } } } $ret = preg_replace('/~\\/?np~/', '', $ret); } else { $smarty = TikiLib::lib('smarty'); $smarty->loadPlugin('smarty_function_object_link'); $ret = '<ol class="tracker-item-files">'; foreach ($this->getConfiguration('files') as $fileId => $file) { $ret .= '<li>'; $ret .= smarty_function_object_link(array('type' => 'file', 'id' => $fileId, 'title' => $file['name']), $smarty); $globalperms = Perms::get(array('type' => 'file gallery', 'object' => $galleryId)); if ($prefs['feature_draw'] == 'y' && $globalperms->upload_files == 'y' && ($file['filetype'] == $mimetypes["svg"] || $file['filetype'] == $mimetypes["gif"] || $file['filetype'] == $mimetypes["jpg"] || $file['filetype'] == $mimetypes["png"] || $file['filetype'] == $mimetypes["tiff"])) { $smarty->loadPlugin('smarty_function_icon'); $editicon = smarty_function_icon(['name' => 'edit'], $smarty); $ret .= " <a href='tiki-edit_draw.php?fileId=" . $file['fileId'] . "' onclick='return \$(this).ajaxEditDraw();' class='tips' title='Edit: " . $file['name'] . "' data-fileid='" . $file['fileId'] . "' data-galleryid='" . $galleryId . "'>\n\t\t\t\t\t\t\t{$editicon}\n\t\t\t\t\t\t</a>"; } $ret .= '</li>'; } $ret .= '</ol>'; } } return $ret; }