/** * getSingleEditForm * @param Zend_Db_Table_Rowset_Abstract $objFileData * @param array $arrImagesSizes * @author Thomas Schedler <*****@*****.**> */ public function getSingleEditForm(Zend_Db_Table_Rowset_Abstract $objFileData, $arrImagesSizes, $strDestinationOptions, $strGroupOptions, $objFileVersions = null, $blnAuthorizedToUpdate = true) { $this->core->logger->debug('media->views->helpers->ViewHelper->getSingleEditForm()'); $strOutput = ''; if (count($objFileData) == 1) { $objFile = $objFileData->current(); if (strpos($objFile->mimeType, 'image/') !== false) { $blnIsImage = true; $strFileIconSrc = sprintf($this->core->sysConfig->media->paths->thumb, $objFile->path) . $objFile->filename . '?v=' . $objFile->version; $strDownloadLink = '/zoolu-website/media/image/' . $objFile->id . '/' . urlencode(str_replace('.', '-', $objFile->title)); $strBasePath = ($this->core->config->domains->static->components != '' ? $this->core->config->domains->static->components : 'http://' . $_SERVER['HTTP_HOST']) . $this->core->sysConfig->media->paths->imgbase . $objFile->path; } else { if (strpos($objFile->mimeType, 'video/') !== false) { $blnIsImage = false; $strFileIconSrc = $this->getDocIcon($objFile->extension, 128); $strDownloadLink = '/zoolu-website/media/video/' . $objFile->id . '/' . urlencode(str_replace('.', '-', $objFile->title)); $strBasePath = ($this->core->config->domains->static->components != '' ? $this->core->config->domains->static->components : 'http://' . $_SERVER['HTTP_HOST']) . $this->core->sysConfig->media->paths->vidbase . $objFile->path; } else { $blnIsImage = false; $strFileIconSrc = $this->getDocIcon($objFile->extension, 128); $strDownloadLink = '/zoolu-website/media/document/' . $objFile->id . '/' . urlencode(str_replace('.', '-', $objFile->title)); $strBasePath = ($this->core->config->domains->static->components != '' ? $this->core->config->domains->static->components : 'http://' . $_SERVER['HTTP_HOST']) . $this->core->sysConfig->media->paths->docbase . $objFile->path; } } if ($objFile->description != '') { $strDescription = $objFile->description; $strTextareaCss = ' class="textarea"'; } else { $strDescription = $this->core->translate->_('Add_description_'); $strTextareaCss = ''; } // build the element $strTags = ''; if ($objFile->idLanguages != '') { require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Tags.php'; // FIXME : quick and dirty solution $objModelTags = new Model_Tags(); $objModelTags->setLanguageId($objFile->idLanguages); $objTags = $objModelTags->loadTypeTags('file', $objFile->id, 1); // TODO : version if (count($objTags) > 0) { foreach ($objTags as $objTag) { $strTags .= '<li value="' . $objTag->id . '">' . htmlentities($objTag->title, ENT_COMPAT, $this->core->sysConfig->encoding->default) . '</li>'; } } } $strLanguageSpecificChecked = $objFile->isLanguageSpecific == 1 ? ' checked="checked"' : ''; $strDestinationeSpecificChecked = $objFile->idDestination > 0 ? ' checked="checked"' : ''; $strGroupSpecificChecked = $objFile->idGroup > 0 ? ' checked="checked"' : ''; $strOutput .= '<div class="mediacontainer"> <div class="mediaicon"> <a href="' . $strDownloadLink . '" target="_blank"><img width="128" src="' . $strFileIconSrc . '"/></a><br/>'; if ($blnIsImage == false) { $strOutput .= '<div class="spacer2" style="text-align:center">' . $objFile->downloadCounter . ' Downloads</div>'; } $strOutput .= ' <div class="field"> <label for="FileIsLanguageSpecific' . $objFile->id . '"><input type="checkbox"' . $strLanguageSpecificChecked . ' class="multiCheckbox" value="1" id="FileIsLanguageSpecific' . $objFile->id . '" name="FileIsLanguageSpecific' . $objFile->id . '"> ' . $this->core->translate->_('Language_specific') . '</label> </div>'; if ($blnIsImage == false) { $strOutput .= ' <div class="field"> <label for="FileIsDestinationSpecific' . $objFile->id . '"><input type="checkbox"' . $strDestinationeSpecificChecked . ' onclick="myMedia.toggleDestinationOptions(this, \'' . $objFile->id . '\');" class="multiCheckbox" value="1" id="FileIsDestinationSpecific' . $objFile->id . '" name="FileIsDestinationSpecific' . $objFile->id . '"> ' . $this->core->translate->_('Region_specific') . '</label> <div id="shownDestinationOptions' . $objFile->id . '"' . ($objFile->idDestination == 0 ? ' style="display:none;"' : '') . '> <input type="hidden" value="' . $objFile->idDestination . '" name="FileDestinationId' . $objFile->id . '" id="FileDestinationId' . $objFile->id . '"/> <select name="selectFileDestinationId' . $objFile->id . '" id="selectFileDestinationId' . $objFile->id . '" onchange="$(\'FileDestinationId' . $objFile->id . '\').value = this.value;"> ' . $strDestinationOptions . ' </select> </div> </div>'; $strOutput .= ' <div class="field"> <label for="FileIsGroupSpecific' . $objFile->id . '"><input type="checkbox"' . $strGroupSpecificChecked . ' onclick="myMedia.toggleGroupOptions(this, \'' . $objFile->id . '\');" class="multiCheckbox" value="1" id="FileIsGroupSpecific' . $objFile->id . '" name="FileIsGroupSpecific' . $objFile->id . '"> ' . $this->core->translate->_('Group_specific') . '</label> <div id="shownGroupOptions' . $objFile->id . '"' . ($objFile->idGroup == 0 ? ' style="display:none;"' : '') . '> <input type="hidden" value="' . $objFile->idGroup . '" name="FileGroupId' . $objFile->id . '" id="FileGroupId' . $objFile->id . '"/> <select name="selectFileGroupId' . $objFile->id . '" id="selectFileGroupId' . $objFile->id . '" onchange="$(\'FileGroupId' . $objFile->id . '\').value = this.value;"> ' . $strGroupOptions . ' </select> </div> </div>'; } $strOutput .= ' </div> <div class="mediainfos"> <div class="mediainfotitle"><label for="FileTitle' . $objFile->id . '" class="gray666 bold">' . $this->core->translate->_('Title') . '</label><br/><input type="text" value="' . $objFile->title . '" id="FileTitle' . $objFile->id . '" name="FileTitle' . $objFile->id . '"/></div> <div class="mediainfodescription"><textarea onfocus="myMedia.setFocusTextarea(this.id); return false;" id="FileDescription' . $objFile->id . '" name="FileDescription' . $objFile->id . '"' . $strTextareaCss . '>' . $strDescription . '</textarea></div> <div class="mediainfotags"> <label for="FileTitle' . $objFile->id . '" class="gray666 bold">' . $this->core->translate->_('Tags') . '</label><br/> <ol> <li class="autocompletList input-text"> <input type="text" value="" id="FileTags' . $objFile->id . '" name="FileTags' . $objFile->id . '"/> <div id="FileTags' . $objFile->id . '_autocompleter" class="autocompleter"> <div class="default">' . $this->core->translate->_('Search_or_add_tags') . '</div> <ul class="feed"> ' . $strTags . ' </ul> </div> </li> </ol> <script type="text/javascript" language="javascript">//<![CDATA[ FileTags' . $objFile->id . '_list = new FacebookList(\'FileTags' . $objFile->id . '\', \'FileTags' . $objFile->id . '_autocompleter\',{ newValues: true, regexSearch: true }); ' . $this->getAllTagsForAutocompleter('FileTags' . $objFile->id) . ' //]]> </script> </div> <div class="clear"></div>'; if ($blnIsImage == false) { $strOutput .= ' <div class="mediafield"> <div class="mediatop"> ' . $this->core->translate->_('Add_medias') . ': <img src="/zoolu-statics/images/icons/icon_addmedia.png" width="16" height="16" onclick="myMedia.getAddMediaOverlay(\'divMediaContainer_documentpic\')" /> </div> <div id="divMediaContainer_documentpic" class="media"> </div> <input type="hidden" name="documentpic" id="documentpic" value="' . ($objFile->idFiles != null && $objFile->idFiles > 0 ? '[' . $objFile->idFiles . ']' : '') . '" /> </div>'; //FIXME: use syntax for applying one file } if ($blnIsImage == true) { $strOutput .= ' </div> <div class="clear"></div> <div class="spacer1"></div>'; } $strMediaUrl = ''; if ($blnIsImage == true) { $strOutput .= ' <div class="mediasizes"> <select id="mediaSizes" onchange="$(\'singleMediaUrl\').value = $F(\'singleFileBasePath\') + this.value + $F(\'singleFileName\')">'; foreach ($arrImagesSizes as $arrImageSize) { if (isset($arrImageSize['display']) && isset($arrImageSize['display']['single_edit'])) { if ($strMediaUrl == '') { $strMediaUrl = $strBasePath . $arrImageSize['folder'] . '/' . $objFile->filename . '?v=' . $objFile->version; } $strOutput .= ' <option value="' . $arrImageSize['folder'] . '/">' . $arrImageSize['folder'] . '</option>'; } } $strOutput .= ' </select> </div>'; } else { $strMediaUrl = 'http://' . $_SERVER['HTTP_HOST'] . $strDownloadLink; } $strOutput .= ' <div class="medialink"> <input type="text" id="singleMediaUrl" readonly="readonly" value="' . $strMediaUrl . '" onclick="this.select()"/><br/> <div id="d_clip_container" style="float:right; margin:0 10px 0 0; position:relative;"> <div id="d_clip_button">[copy to clipboard]</div> </div> <div class="clear"></div> <input type="hidden" id="singleFileName" value="' . $objFile->filename . '?v=' . $objFile->version . '"/> <input type="hidden" id="singleFileBasePath" value="' . $strBasePath . '"/> </div> <div class="clear"></div> <div class="spacer1"></div> <div class="mediasingleupload">'; if ($blnAuthorizedToUpdate == true) { $strOutput .= ' <label for="txtFileName" class="gray666 bold">' . $this->core->translate->_('New_version') . '</label><br/> <div> <input type="text" id="txtFileName" disabled="true" /> <span id="spanButtonPlaceholder"></span> </div> <div id="fsUploadProgress"></div>'; } if ($blnIsImage == false) { $strOutput .= ' </div>'; } if ($objFileVersions != null && $objFileVersions instanceof Zend_Db_Table_Rowset_Abstract) { $objCreated = DateTimeHelper::getDateObject(); $objArchived = DateTimeHelper::getDateObject(); $strOutput .= ' <div class="spacer1"></div> <label for="txtFileName" class="gray666 bold">' . $this->core->translate->_('Version_list') . '</label><br/> <div class="mediaversions">'; foreach ($objFileVersions as $objFileVersion) { if ($objFileVersion->created != null && $objFileVersion->archived != null) { $objCreated->set($objFileVersion->created); $objArchived->set($objFileVersion->archived); $strOutput .= ' <div class="version"><a href="/zoolu-website/media/download/' . $objFileVersion->idFiles . '/' . urlencode(str_replace('.', '-', $objFileVersion->title)) . '?v=' . $objFileVersion->version . '" target="_blank">' . $this->core->translate->_('Version') . ' ' . $objFileVersion->version . '</a> (' . $objCreated->get(Zend_Date::DATETIME_MEDIUM) . ' - ' . $objArchived->get(Zend_Date::DATETIME_MEDIUM) . ')</div>'; } } $strOutput .= ' </div>'; } $strOutput .= ' </div> </div>'; } return $strOutput; }