/**
     * Init the uploader which is directly included in the webpage
     *
     * @return integer the uploader id
     */
    protected function initUploader()
    {
        \JS::activate('cx');
        // the uploader needs the framework
        $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
        //create an uploader
        $uploadId = $uploader->getId();
        $uploader->setCallback('fileSharingUploader');
        $uploader->setOptions(array('id' => 'fileSharing_' . $uploadId, 'style' => 'display:none;'));
        $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploadId, true);
        $folderWidgetId = $folderWidget->getId();
        $extendedFileInputCode = <<<CODE
<script type="text/javascript">
    cx.ready(function() {
            var field = jQuery('#contactForm #file_upload');
            //called if user clicks on the field
            var inputClicked = function() {
                jQuery('#fileSharing_{$uploadId}').trigger('click');
                return false;
            };

            jQuery('#fileSharing_{$uploadId}').hide();
            field.bind('click', inputClicked).removeAttr('disabled');
    });

    //uploader javascript callback function
    function fileSharingUploader(callback) {
            angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser();
    }
</script>
CODE;
        $this->objTemplate->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml(), 'FILE_INPUT_CODE' => $extendedFileInputCode, 'FOLDER_WIDGET_CODE' => $folderWidget->getXHtml()));
        return $uploadId;
        // return the upload id
    }
 /**
  * Inits the uploader when displaying a contact form.
  *
  * @param string  $callBackFun
  * @param string  $callBackJs
  * @param array   $data
  * @param string  $buttonText
  * @param array   $options
  *
  * @return null
  */
 function initUploader($callBackFun, $callBackJs, $data, $buttonText, $options = array())
 {
     global $_ARRAYLANG;
     try {
         //init the uploader
         $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
         if (!empty($callBackJs)) {
             $uploader->setCallback($callBackJs);
         }
         if (!empty($callBackFun)) {
             $uploader->setFinishedCallback(array(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Crm/Controller/CrmManager.class.php', '\\Cx\\Modules\\Crm\\Controller\\CrmManager', $callBackFun));
         }
         $uploader->setOptions($options);
         $uploader->setData($data);
         if (empty($buttonText)) {
             $buttonText = $_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES'];
         }
         return $uploader->getXHtml($buttonText);
     } catch (Exception $e) {
         return '<!-- failed initializing uploader, exception ' . get_class($e) . ' with message "' . $e->getMessage() . '" -->';
     }
 }
Beispiel #3
0
 /**
  * Overview Media Data
  *
  * @global     array     $_ARRAYLANG
  * @global     array     $_CONFIG
  * @global     array     $_CORELANG
  * @return    string    parsed content
  */
 function _overviewMedia()
 {
     global $_ARRAYLANG, $_CONFIG, $_CORELANG, $objDatabase;
     \JS::activate('shadowbox');
     $this->_objTpl->loadTemplateFile('module_media.html', true, true);
     switch ($this->archive) {
         case 'themes':
             $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_LAYOUT'];
             break;
         case 'content':
             $this->pageTitle = $_ARRAYLANG['TXT_IMAGE_ADMINISTRATION'];
             break;
         case 'Contact':
             $this->pageTitle = $_ARRAYLANG['TXT_FILE_UPLOADS'];
             break;
         case 'attach':
         case 'Access':
         case 'Blog':
         case 'Calendar':
         case 'Downloads':
         case 'Gallery':
         case 'MediaDir':
         case 'Podcast':
         case 'Shop':
             $archives = array('attach' => 'TXT_FILE_UPLOADS', 'Shop' => 'TXT_IMAGE_SHOP', 'Gallery' => 'TXT_GALLERY_TITLE', 'Access' => 'TXT_USER_ADMINISTRATION', 'MediaDir' => 'TXT_MEDIADIR_MODULE', 'Downloads' => 'TXT_DOWNLOADS', 'Calendar' => 'TXT_CALENDAR', 'Podcast' => 'TXT_PODCAST', 'Blog' => 'TXT_BLOG_MODULE');
             $moduleMatchTable = array('attach' => 'core');
             $subnavigation = '
                 <div id="subnavbar_level2">
                     <ul>';
             $license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase);
             $license->check();
             foreach ($archives as $archive => $txtKey) {
                 $moduleName = $archive;
                 if (isset($moduleMatchTable[$archive])) {
                     $moduleName = $moduleMatchTable[$archive];
                 }
                 if (!$license->isInLegalComponents($moduleName)) {
                     \DBG::msg('Module "' . $archive . '" is deactivated');
                     continue;
                 }
                 $subnavigation .= '
                         <li><a href="index.php?cmd=Media&amp;archive=' . $archive . '" class="' . ($this->archive == $archive ? 'active' : '') . '">' . $_ARRAYLANG[$txtKey] . '</a></li>';
             }
             $subnavigation .= '
                     </ul>
                 </div>';
             $this->_objTpl->setVariable('CONTENT_SUBNAVIGATION', $subnavigation);
         default:
             $this->pageTitle = $_ARRAYLANG['TXT_MEDIA_OVERVIEW'];
             if ($this->archive == "FileSharing") {
                 \Cx\Modules\FileSharing\Controller\FileSharingLib::cleanUp();
             }
             break;
     }
     // cut, copy and paste session
     if (isset($_SESSION['mediaCutFile'])) {
         $tmpArray = array();
         foreach ($_SESSION['mediaCutFile'][2] as $tmp) {
             if (file_exists($_SESSION['mediaCutFile'][0] . $tmp)) {
                 $tmpArray[] = $tmp;
             }
         }
         if (count($tmpArray) > 0) {
             $_SESSION['mediaCutFile'][0] = $_SESSION['mediaCutFile'][0];
             $_SESSION['mediaCutFile'][1] = $_SESSION['mediaCutFile'][1];
             $_SESSION['mediaCutFile'][2] = $tmpArray;
         } else {
             unset($_SESSION['mediaCutFile']);
         }
     }
     if (isset($_SESSION['mediaCopyFile'])) {
         $tmpArray = array();
         foreach ($_SESSION['mediaCopyFile'][2] as $tmp) {
             if (file_exists($_SESSION['mediaCopyFile'][0] . $tmp)) {
                 $tmpArray[] = $tmp;
             }
         }
         if (count($tmpArray) > 0) {
             $_SESSION['mediaCopyFile'][0] = $_SESSION['mediaCopyFile'][0];
             $_SESSION['mediaCopyFile'][1] = $_SESSION['mediaCopyFile'][1];
             $_SESSION['mediaCopyFile'][2] = $tmpArray;
         } else {
             unset($_SESSION['mediaCopyFile']);
         }
     }
     // tree navigation
     $tmp = $this->arrWebPaths[$this->archive];
     if (substr($this->webPath, 0, strlen($tmp)) == $tmp) {
         $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => 'http://' . $_SERVER['HTTP_HOST'] . $this->arrWebPaths[$this->archive], 'MEDIA_TREE_NAV_MAIN_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;path=' . $this->arrWebPaths[$this->archive]));
         if (strlen($this->webPath) != strlen($tmp)) {
             $tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp)));
             $tmpPath = explode('/', $tmpPath);
             $tmpLink = '';
             foreach ($tmpPath as $path) {
                 if (!empty($path)) {
                     $tmpLink .= $path . '/';
                     $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_DIR' => $path, 'MEDIA_TREE_NAV_DIR_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;path=' . $this->arrWebPaths[$this->archive] . $tmpLink));
                     $this->_objTpl->parse('mediaTreeNavigation');
                 }
             }
         }
     }
     //data we want to remember for handling the uploaded files
     $data = array('path' => $this->path, 'webPath' => $this->webPath);
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     $uploader->setCallback('mediaCallbackJs');
     $uploader->setFinishedCallback(array(ASCMS_CORE_MODULE_PATH . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished'));
     $uploader->setOptions(array('id' => 'media_browse_button', 'type' => 'button'));
     $uploader->setData($data);
     $this->_objTpl->setVariable('MEDIA_UPLOADER_BUTTON', $uploader->getXHtml($_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES']));
     //end of uploader button handling
     //check if a finished upload caused reloading of the page.
     //if yes, we know the added files and want to highlight them
     if (!empty($_GET['highlightUploadId'])) {
         $key = 'media_upload_files_' . $_GET['highlightUploadId'];
         if (isset($_SESSION[$key])) {
             $sessionHighlightCandidates = $_SESSION[$key]->toArray();
             //an array with the filenames, set in mediaLib::uploadFinished
         }
         //clean up session; we do only highlight once
         unset($_SESSION[$key]);
         if (is_array($sessionHighlightCandidates)) {
             //make sure we don't cause any unexpected behaviour if we lost the session data
             $this->highlightName = $sessionHighlightCandidates;
         }
     }
     // Check if an image has been edited.
     // If yes, we know the edited file and want to highlight them.
     if (!empty($_GET['editedImage'])) {
         \Cx\Core\Core\Controller\Cx::instanciate()->getMediaSourceManager()->getThumbnailGenerator()->createThumbnailFromPath($this->path . $_GET['editedImage'], true);
         $this->highlightName[] = $_GET['editedImage'];
     }
     // media directory tree
     $i = 0;
     $dirTree = $this->_dirTree($this->path);
     $dirTree = $this->_sortDirTree($dirTree);
     foreach (array_keys($dirTree) as $key) {
         if (isset($dirTree[$key]['icon']) && is_array($dirTree[$key]['icon'])) {
             for ($x = 0; $x < count($dirTree[$key]['icon']); $x++) {
                 $fileName = $dirTree[$key]['name'][$x];
                 if (MediaLibrary::isIllegalFileName($fileName)) {
                     continue;
                 }
                 // colors
                 $class = $i % 2 ? 'row2' : 'row1';
                 if (in_array($fileName, $this->highlightName)) {
                     $class .= '" style="background-color: ' . $this->highlightColor . ';';
                 }
                 if (isset($_SESSION['mediaCutFile']) && !empty($_SESSION['mediaCutFile'])) {
                     if ($this->webPath == $_SESSION['mediaCutFile'][1] && in_array($fileName, $_SESSION['mediaCutFile'][2])) {
                         $class .= '" style="background-color: ' . $this->highlightCCColor . ';';
                     }
                 }
                 if (isset($_SESSION['mediaCopyFile']) && !empty($_SESSION['mediaCopyFile'])) {
                     if ($this->webPath == $_SESSION['mediaCopyFile'][1] && in_array($fileName, $_SESSION['mediaCopyFile'][2])) {
                         $class .= '" style="background-color: ' . $this->highlightCCColor . ';';
                     }
                 }
                 $this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_FILE_PERM' => $this->_formatPerm($dirTree[$key]['perm'][$x], $key)));
                 // creates link
                 if ($key == 'dir') {
                     $tmpHref = 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;path=' . $this->webPath . $fileName . '/';
                 } elseif ($key == 'file') {
                     if ($this->_isImage($this->path . $fileName)) {
                         $tmpHref = 'javascript:expandcontent(\'preview_' . $fileName . '\');';
                     } else {
                         $tmpHref = 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=download&amp;path=' . $this->webPath . '&amp;file=' . $fileName;
                     }
                 }
                 $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_HREF' => $tmpHref));
                 // show thumbnail
                 if ($this->_isImage($this->path . $fileName)) {
                     // make thumbnail if it doesn't exist
                     $tmpSize = @getimagesize($this->path . $fileName);
                     $thumbnails = \Cx\Core\Core\Controller\Cx::instanciate()->getMediaSourceManager()->getThumbnailGenerator()->createThumbnailFromPath($this->path . $fileName);
                     $thumb = $this->webPath . $thumbnails[0];
                     if (in_array($fileName, $this->highlightName)) {
                         $thumb .= '?lastAccess=' . fileatime($this->path . $fileName);
                     }
                     $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_SIZE' => $tmpSize[0] . ' x ' . $tmpSize[1], 'MEDIA_FILE_NAME_PRE' => 'preview_' . $fileName, 'MEDIA_FILE_NAME_IMG_HREF' => $this->webPath . $fileName, 'MEDIA_FILE_NAME_IMG_SRC' => $thumb, 'MEDIA_FILE_NAME_IMG_SIZE' => $thumbnails[0]['size']));
                     $this->_objTpl->parse('mediaShowThumbnail');
                     $this->_objTpl->setVariable(array('MEDIA_FILE_EDIT_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=edit&amp;path=' . $this->webPath . '&amp;file=' . $fileName, 'MEDIA_EDIT' => $_ARRAYLANG['TXT_MEDIA_EDIT']));
                     $this->_objTpl->parse('mediaImageEdit');
                 }
                 $this->_objTpl->setVariable(array('MEDIA_FILE_RENAME_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=rename&amp;path=' . $this->webPath . '&amp;file=' . $fileName, 'MEDIA_RENAME' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_FILE_DELETE_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=delete&amp;path=' . $this->webPath . '&amp;file=' . $fileName, 'MEDIA_DELETE' => $_ARRAYLANG['TXT_MEDIA_DELETE'], 'MEDIA_FILE_FILESHARING_HREF' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=filesharing&amp;path=' . $this->webPath . '&amp;file=' . $fileName, 'MEDIA_FILESHARING' => $_ARRAYLANG['TXT_FILESHARING_MODULE'], 'MEDIA_FILESHARING_STATE' => \Cx\Modules\FileSharing\Controller\FileSharingLib::isShared(null, (isset($_GET['path']) ? $_GET['path'] : ASCMS_FILESHARING_WEB_PATH . '/') . $fileName) ? '_green' : '_red'));
                 if ($this->archive == "FileSharing" && !is_dir($this->path . $fileName)) {
                     $this->_objTpl->parse('mediaFilesharing');
                 } else {
                     $this->_objTpl->hideBlock('mediaFilesharing');
                 }
                 $this->_objTpl->parse('mediaDirectoryTree');
                 $i++;
             }
         }
     }
     // empty dir or php safe mode restriction
     if ($i == 0 || !@opendir($this->path)) {
         $tmpMessage = $_ARRAYLANG['TXT_MEDIA_DIR_EMPTY'];
         if (!@opendir($this->path)) {
             $tmpMessage = 'PHP Safe Mode Restriction!';
         }
         $this->_objTpl->setVariable(array('TXT_MEDIA_DIR_EMPTY' => $tmpMessage, 'MEDIA_SELECT_STATUS' => ' disabled'));
         $this->_objTpl->parse('mediaEmptyDirectory');
     } else {
         // not empty dir (select action)
         $this->_objTpl->setVariable(array('TXT_SELECT_ALL' => $_CORELANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_CORELANG['TXT_DESELECT_ALL'], 'TXT_MEDIA_SELECT_ACTION' => $_ARRAYLANG['TXT_MEDIA_SELECT_ACTION'], 'TXT_MEDIA_CUT' => $_ARRAYLANG['TXT_MEDIA_CUT'], 'TXT_MEDIA_COPY' => $_ARRAYLANG['TXT_MEDIA_COPY'], 'TXT_MEDIA_DELETE' => $_ARRAYLANG['TXT_MEDIA_DELETE']));
         $this->_objTpl->parse('mediaSelectAction');
         $this->_objTpl->setVariable('MEDIA_ARCHIVE', $this->archive);
     }
     // paste media
     if (isset($_SESSION['mediaCutFile']) or isset($_SESSION['mediaCopyFile'])) {
         $this->_objTpl->setVariable(array('MEDIDA_PASTE_ACTION' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=paste&amp;path=' . $this->webPath, 'TXT_MEDIA_PASTE' => $_ARRAYLANG['TXT_MEDIA_PASTE']));
         $this->_objTpl->parse('mediaActionPaste');
     }
     // parse variables
     $tmpHref = 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;path=' . $this->webPath;
     $tmpIcon = $this->_sortingIcons();
     $tmpClass = $this->_sortingClass();
     $this->_objTpl->setVariable(array('TXT_MEDIA_CHECK_NAME' => $_ARRAYLANG['TXT_MEDIA_CHECK_NAME'], 'TXT_MEDIA_CONFIRM_DELETE_2' => $_ARRAYLANG['TXT_MEDIA_CONFIRM_DELETE_2'], 'MEDIA_DO_ACTION_PATH' => $this->webPath, 'TXT_MEDIA_MAKE_SELECTION' => $_ARRAYLANG['TXT_MEDIA_MAKE_SELECTION'], 'TXT_MEDIA_SELECT_UPLOAD_FILE' => $_ARRAYLANG['TXT_MEDIA_SELECT_UPLOAD_FILE'], 'MEDIA_JAVA_SCRIPT_PREVIEW' => $this->_getJavaScriptCodePreview()));
     $this->_objTpl->setVariable(array('TXT_MEDIA_NEW_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_NEW_DIRECTORY'], 'MEDIA_CREATE_DIR_ACTION' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=newDir&amp;path=' . $this->webPath, 'TXT_MEDIA_NAME' => $_ARRAYLANG['TXT_MEDIA_NAME'], 'TXT_MEDIA_CREATE' => $_ARRAYLANG['TXT_MEDIA_CREATE']));
     $this->_objTpl->setVariable(array('TXT_MEDIA_UPLOAD_FILES' => $_ARRAYLANG['TXT_MEDIA_UPLOAD_FILES'], 'MEDIA_UPLOAD_FILES_ACTION' => 'index.php?cmd=Media&amp;archive=' . $this->archive . '&amp;act=upload&amp;path=' . $this->webPath, 'TXT_MEDIA_UPLOAD' => $_ARRAYLANG['TXT_MEDIA_UPLOAD'], 'TXT_MEDIA_FORCE_OVERWRITE' => $_ARRAYLANG['TXT_MEDIA_FORCE_OVERWRITE']));
     $this->_objTpl->setVariable(array('MEDIA_NAME_HREF' => $tmpHref . '&amp;sort=name&amp;sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&amp;sort=size&amp;sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&amp;sort=type&amp;sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&amp;sort=date&amp;sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&amp;sort=perm&amp;sort_desc=' . ($this->sortBy == 'perm' && !$this->sortDesc), 'TXT_MEDIA_FILE_NAME' => $_ARRAYLANG['TXT_MEDIA_FILE_NAME'], 'TXT_MEDIA_FILE_SIZE' => $_ARRAYLANG['TXT_MEDIA_FILE_SIZE'], 'TXT_MEDIA_FILE_TYPE' => $_ARRAYLANG['TXT_MEDIA_FILE_TYPE'], 'TXT_MEDIA_FILE_DATE' => $_ARRAYLANG['TXT_MEDIA_FILE_DATE'], 'TXT_MEDIA_FILE_PERM' => $_ARRAYLANG['TXT_MEDIA_FILE_PERM'], 'TXT_MEDIA_FILE_FUNCTIONS' => $_ARRAYLANG['TXT_FUNCTIONS'], 'MEDIA_NAME_ICON' => isset($tmpIcon['name']) ? $tmpIcon['name'] : '', 'MEDIA_SIZE_ICON' => isset($tmpIcon['size']) ? $tmpIcon['size'] : '', 'MEDIA_TYPE_ICON' => isset($tmpIcon['type']) ? $tmpIcon['type'] : '', 'MEDIA_DATE_ICON' => isset($tmpIcon['date']) ? $tmpIcon['date'] : '', 'MEDIA_PERM_ICON' => isset($tmpIcon['perm']) ? $tmpIcon['perm'] : '', 'MEDIA_NAME_CLASS' => isset($tmpClass['name']) ? $tmpIcon['name'] : '', 'MEDIA_SIZE_CLASS' => isset($tmpClass['size']) ? $tmpIcon['size'] : '', 'MEDIA_TYPE_CLASS' => isset($tmpClass['type']) ? $tmpIcon['type'] : '', 'MEDIA_DATE_CLASS' => isset($tmpClass['date']) ? $tmpIcon['date'] : '', 'MEDIA_PERM_CLASS' => isset($tmpClass['perm']) ? $tmpIcon['perm'] : '', 'CSRF' => \Cx\Core\Csrf\Controller\Csrf::param()));
 }
Beispiel #4
0
 /**
  * Initialize the uploader
  *
  * @return null
  */
 public function initForumUploader()
 {
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     $uploader->setCallback('forumFileUploaderCallback');
     $options = array('id' => 'forum-attachment-uploader', 'allowed-extensions' => explode(',', $this->_arrSettings['allowed_extensions']), 'style' => 'display:none', 'data-upload-limit' => 1);
     $uploader->setOptions($options);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Forum/Controller/Forum.class.php', '\\Cx\\Modules\\Forum\\Controller\\Forum', 'uploadFinished'));
     $this->_objTpl->setVariable(array('FORUM_UPLOADER' => $uploader->getXhtml(), 'FORUM_UPLOADER_ID' => $uploader->getId()));
 }
Beispiel #5
0
    /**
     * Get uploader code
     * 
     * @param string  $fieldKey       uploadFieldKey
     * @param string  $fieldName      uploadFieldName
     * @param string  $uploadCallBack upload callback function
     * @param boolean $allowImageOnly allow only images files
     * 
     * @return string uploaderCode
     * @throws \Exception
     */
    protected function getUploaderCode($fieldKey, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true)
    {
        \cmsSession::getInstance();
        $cx = \Cx\Core\Core\Controller\Cx::instanciate();
        try {
            $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
            $uploaderId = $uploader->getId();
            $uploadOptions = array('id' => 'calendarUploader_' . $uploaderId, 'style' => 'display: none');
            if ($allowImageOnly) {
                $uploadOptions['allowed-extensions'] = array('gif', 'jpg', 'png', 'jpeg');
            }
            $uploader->setCallback($fieldName . 'JsCallback');
            $uploader->setUploadLimit(1);
            $uploader->setOptions($uploadOptions);
            $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack));
            $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId);
            $this->_objTpl->setVariable(array(strtoupper($fieldName) . '_WIDGET_CODE' => $folderWidget->getXHtml(), "{$this->moduleLangVar}_" . strtoupper($fieldKey) => $uploaderId));
            $strJs = <<<JAVASCRIPT
{$uploader->getXHtml()}
<script type="text/javascript">
    cx.ready(function() {
        //called if user clicks on the field
        jQuery('#{$fieldName}').bind('click', function() {
            jQuery('#calendarUploader_{$uploaderId}').trigger('click');
            return false;
        });
    });

//uploader javascript callback function
function {$fieldName}JsCallback(callback) {
        angular.element('#mediaBrowserfolderWidget_{$folderWidget->getId()}').scope().refreshBrowser();
}
</script>
JAVASCRIPT;
            return $strJs;
        } catch (\Exception $e) {
            \DBG::msg('<!-- failed initializing uploader -->');
            throw new \Exception("failed initializing uploader");
        }
    }
 function listInputfields($objTpl, $intView, $intEntryId)
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID, $objInit;
     usort($this->arrInputfields, array(__CLASS__, "sortInputfields"));
     switch ($intView) {
         case 1:
             //Settings View
             $objTpl->addBlockfile($this->moduleLangVar . '_SETTINGS_INPUTFIELDS_CONTENT', 'settings_inputfields_content', 'module_' . $this->moduleNameLC . '_settings_inputfields.html');
             $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName);
             $arrShow = array(1 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACK_N_FRONTEND'], 2 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_FRONTEND'], 3 => $_ARRAYLANG['TXT_MEDIADIR_SHOW_BACKEND']);
             $i = 0;
             $intLastId = 0;
             foreach ($this->arrInputfields as $key => $arrInputfield) {
                 $strMustfield = $arrInputfield['required'] == 1 ? 'checked="checked"' : '';
                 $strExpSearch = $arrInputfield['search'] == 1 ? 'checked="checked"' : '';
                 if ($arrInputfield['id'] > $intLastId) {
                     $intLastId = $arrInputfield['id'];
                 }
                 $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_SETTINGS_INPUTFIELD_LASTID' => $intLastId));
                 if ($arrInputfield['id'] != 1 && $arrInputfield['id'] != 2) {
                     $objTpl->setGlobalVariable(array($this->moduleLangVar . '_SETTINGS_INPUTFIELD_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_FORM_ID' => $this->intFormId, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_TYPE' => $this->buildDropdownmenu($this->getInputfieldTypes(), $arrInputfield['type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_VERIFICATION' => $this->buildDropdownmenu($this->getInputfieldVerifications(), $arrInputfield['verification']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_SHOW' => $this->buildDropdownmenu($arrShow, $arrInputfield['show_in']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_CONTEXT' => $this->buildDropdownmenu($this->getInputContexts(), $arrInputfield['context_type']), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_MUSTFIELD' => $strMustfield, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_EXP_SEARCH' => $strExpSearch, $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME_MASTER' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE_MASTER' => contrexx_raw2xhtml($arrInputfield['default_value'][0]), $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO_MASTER' => $arrInputfield['info'][0]));
                     //fieldname
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_NAME_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_NAME_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_NAME' => $arrInputfield['name'][$arrLang['id']]));
                         $objTpl->parse($this->moduleNameLC . 'InputfieldNameList');
                     }
                     //default values
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_DEFAULTVALUE_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_DEFAULTVALUE' => contrexx_raw2xhtml($arrInputfield['default_value'][$arrLang['id']])));
                         $objTpl->parse($this->moduleNameLC . 'InputfieldDefaultvalueList');
                     }
                     //infotext
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_INFO_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_INPUTFIELD_INFO_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_SETTINGS_INPUTFIELD_INFO' => $arrInputfield['info'][$arrLang['id']]));
                         $objTpl->parse($this->moduleNameLC . 'InputfieldInfoList');
                     }
                     //language names
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         if ($key + 1 == count($this->arrFrontendLanguages)) {
                             $minimize = "<a id=\"inputfieldMinimize_" . $arrInputfield['id'] . "\" href=\"javascript:ExpandMinimizeInputfields('inputfieldName', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldDefaultvalue', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldLanguages', '" . $arrInputfield['id'] . "'); ExpandMinimizeInputfields('inputfieldInfo', '" . $arrInputfield['id'] . "');\">&laquo;&nbsp;" . $_ARRAYLANG['TXT_MEDIADIR_MINIMIZE'] . "</a>";
                         } else {
                             $minimize = "";
                         }
                         $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_MINIMIZE' => $minimize));
                         $objTpl->parse($this->moduleNameLC . 'InputfieldLanguagesList');
                     }
                     if ($arrInputfield['exp_search'] == 0) {
                         $objTpl->hideBlock($this->moduleNameLC . 'InputfieldAdvancedSearch');
                     } else {
                         $objTpl->touchBlock($this->moduleNameLC . 'InputfieldAdvancedSearch');
                     }
                     $objTpl->parse($this->moduleNameLC . 'Inputfield');
                 } else {
                     if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) {
                         $objTpl->setVariable(array($this->moduleLangVar . '_SETTINGS_SELECTOR_ID' => $arrInputfield['id'], $this->moduleLangVar . '_SETTINGS_SELECTOR_NAME' => $arrInputfield['name'][0], $this->moduleLangVar . '_SETTINGS_SELECTOR_ORDER' => $arrInputfield['order'], $this->moduleLangVar . '_SETTINGS_SELECTOR_EXP_SEARCH' => $strExpSearch));
                         $objTpl->parse($this->moduleNameLC . 'Selector');
                     }
                 }
                 $i++;
                 $objTpl->parse($this->moduleNameLC . 'InputfieldList');
             }
             $objTpl->parse('settings_inputfields_content');
             break;
         case 2:
             //modify (add/edit) View
             $objAddStep = new MediaDirectoryAddStep($this->moduleName);
             $i = 0;
             $isFileInputFound = false;
             foreach ($this->arrInputfields as $key => $arrInputfield) {
                 $strInputfield = null;
                 if ($arrInputfield['required'] == 1) {
                     $strRequiered = '<font color="#ff0000"> *</font>';
                 } else {
                     $strRequiered = null;
                 }
                 if (!empty($arrInputfield['type'])) {
                     if (!$isFileInputFound && in_array($arrInputfield['type_name'], array('image', 'file', 'downloads'))) {
                         $isFileInputFound = true;
                     }
                     $strType = $arrInputfield['type_name'];
                     $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
                     try {
                         $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                         switch ($strType) {
                             case 'add_step':
                                 $objAddStep->addNewStep(empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID]);
                                 $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId, $objAddStep);
                                 break;
                             case 'field_group':
                                 //to do
                                 break;
                             default:
                                 if ($arrInputfield['show_in'] == 1) {
                                     $bolGetInputfield = true;
                                 } else {
                                     if ($objInit->mode == 'backend' && $arrInputfield['show_in'] == 3) {
                                         $bolGetInputfield = true;
                                     } else {
                                         if ($objInit->mode == 'frontend' && $arrInputfield['show_in'] == 2) {
                                             $bolGetInputfield = true;
                                         } else {
                                             $bolGetInputfield = false;
                                         }
                                     }
                                 }
                                 if ($bolGetInputfield) {
                                     $strInputfield = $objInputfield->getInputfield(1, $arrInputfield, $intEntryId);
                                 } else {
                                     $strInputfield = null;
                                 }
                                 break;
                         }
                         if ($strInputfield != null) {
                             $this->makeJavascriptInputfieldArray($arrInputfield['id'], $this->moduleNameLC . "Inputfield[" . $arrInputfield['id'] . "]", $arrInputfield['required'], $arrInputfield['regex'], $strType);
                             $this->strJavascriptInputfieldCheck[$strType] = $objInputfield->getJavascriptCheck();
                             $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = $objInputfield->getFormOnSubmit($arrInputfield['id']);
                         }
                     } catch (Exception $error) {
                         echo "Error: " . $error->getMessage();
                     }
                 } else {
                     $objForms = new MediaDirectoryForm($this->intFormId, $this->moduleName);
                     /*if($objInit->mode == 'backend') {
                           $strStyle = 'style="overflow: auto; border: 1px solid #0A50A1; background-color: #ffffff; width: 298px; height: 200px; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"';
                       } else {
                           $strStyle = 'style="overflow: auto; float: left; list-style: none; padding: 0px; margin: 0px 5px 0px 0px;"';
                       }*/
                     if ($arrInputfield['id'] == 2 && $objForms->arrForms[$this->intFormId]['formUseLevel'] || $arrInputfield['id'] == 1 && $objForms->arrForms[$this->intFormId]['formUseCategory']) {
                         if ($arrInputfield['id'] == 2) {
                             $objLevel = new MediaDirectoryLevel(null, null, 1, $this->moduleName);
                             $arrSelectorOptions = $objLevel->listLevels($objTpl, 4, null, null, $intEntryId);
                             $strSelectedOptionsName = "selectedLevels";
                             $strNotSelectedOptionsName = "deselectedLevels";
                         } else {
                             $objCategory = new MediaDirectoryCategory(null, null, 1, $this->moduleName);
                             $arrSelectorOptions = $objCategory->listCategories($objTpl, 4, null, null, $intEntryId);
                             $strSelectedOptionsName = "selectedCategories";
                             $strNotSelectedOptionsName = "deselectedCategories";
                         }
                         $strInputfield .= '<div class="mediadirSelector container-fluid"><div class="row"><div class="col-md-offset-3">';
                         $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorLeft"><div class="row"><select id="' . $strNotSelectedOptionsName . '" name="' . $strNotSelectedOptionsName . '[]" size="12" multiple="multiple">';
                         $strInputfield .= $arrSelectorOptions['not_selected'];
                         $strInputfield .= '</select></div></div>';
                         $strInputfield .= '<div class="mediadirSelectorCenter col-md-2 col-sm-12 col-xs-12">';
                         $strInputfield .= '<input class="btn btn-default" value=" &gt;&gt; " name="addElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],addElement,removeElement);" type="button">';
                         $strInputfield .= '<br />';
                         $strInputfield .= '<input class="btn btn-default" value=" &lt;&lt; " name="removeElement" onclick="moveElement(document.entryModfyForm.elements[\'' . $strSelectedOptionsName . '\'],document.entryModfyForm.elements[\'' . $strNotSelectedOptionsName . '\'],removeElement,addElement);" type="button">';
                         $strInputfield .= '</div>';
                         $strInputfield .= '<div class="col-md-4 col-sm-12 col-xs-12 mediadirSelectorRight"><div class="row"><select id="' . $strSelectedOptionsName . '" name="' . $strSelectedOptionsName . '[]" size="12" multiple="multiple">';
                         $strInputfield .= $arrSelectorOptions['selected'];
                         $strInputfield .= '</select></div></div>';
                         $strInputfield .= '</div></div></div>';
                         $this->makeJavascriptInputfieldArray($arrInputfield['id'], $strSelectedOptionsName, 1, 1, "selector");
                         $this->arrJavascriptFormOnSubmit[$arrInputfield['id']] = "selectAll(document.entryModfyForm.elements['" . $strSelectedOptionsName . "[]']); ";
                     }
                 }
                 if ($arrInputfield['type_name'] == 'add_step' && $objInit->mode != 'backend') {
                     $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP' => $strInputfield));
                     $objTpl->parse($this->moduleNameLC . 'InputfieldAddStep');
                 } else {
                     if ($strInputfield != null) {
                         if ($arrInputfield['type_name'] == 'title') {
                             $strStartTitle = '<h2>';
                             $strEndTitle = '</h2>';
                         } else {
                             $strStartTitle = '';
                             $strEndTitle = '';
                         }
                         $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME' => $strStartTitle . (empty($arrInputfield['name'][$_LANGID]) ? $arrInputfield['name'][0] . $strRequiered : $arrInputfield['name'][$_LANGID] . $strRequiered) . $strEndTitle, $this->moduleLangVar . '_INPUTFIELD_FIELD' => $strInputfield, $this->moduleLangVar . '_INPUTFIELD_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2'));
                         if ($arrInputfield['type_name'] != 'add_step') {
                             $i++;
                             $objTpl->parse($this->moduleNameLC . 'InputfieldList');
                         }
                     }
                 }
                 if ($objInit->mode != 'backend') {
                     $objTpl->parse($this->moduleNameLC . 'InputfieldElement');
                 }
             }
             if ($isFileInputFound && $objInit->mode != 'backend') {
                 // init uploader to upload images
                 $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
                 $uploader->setCallback($this->moduleNameLC . 'UploaderCallback');
                 $uploader->setOptions(array('id' => $this->moduleNameLC . 'ImageUploader', 'style' => 'display:none', 'data-upload-limit' => 1));
                 $objTpl->setVariable(array($this->moduleLangVar . '_UPLOADER_ID' => $uploader->getId(), $this->moduleLangVar . '_UPLOADER_CODE' => $uploader->getXHtml()));
             }
             if (!empty($objAddStep->arrSteps) && $objInit->mode != 'backend') {
                 $objAddStep->getStepNavigation($objTpl);
                 $objTpl->parse($this->moduleNameLC . 'EntryAddStepNavigation');
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_ADDSTEP_TERMINATOR' => "</div>"));
             }
             break;
         case 3:
             //frontend View
             foreach ($this->arrInputfields as $key => $arrInputfield) {
                 $intInputfieldId = intval($arrInputfield['id']);
                 $intInputfieldType = intval($arrInputfield['type']);
                 if (($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId) || $objTpl->blockExists($this->moduleNameLC . '_inputfields')) && ($intInputfieldType != 16 && $intInputfieldType != 17)) {
                     if (!empty($arrInputfield['type'])) {
                         $strType = $arrInputfield['type_name'];
                         $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
                         try {
                             $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                             if (intval($arrInputfield['type_multi_lang']) == 1) {
                                 $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, $this->arrTranslationStatus);
                             } else {
                                 $arrInputfieldContent = $objInputfield->getContent($intEntryId, $arrInputfield, null);
                             }
                             if (!empty($arrInputfieldContent)) {
                                 if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) {
                                     $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[([A-Z][A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']);
                                     \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage());
                                 }
                                 foreach ($arrInputfieldContent as $strPlaceHolder => $strContent) {
                                     $objTpl->setVariable(array(strtoupper($strPlaceHolder) => $strContent));
                                 }
                                 if ($objTpl->blockExists($this->moduleNameLC . '_inputfields')) {
                                     $objTpl->parse($this->moduleNameLC . '_inputfields');
                                 } else {
                                     if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) {
                                         $objTpl->parse($this->moduleNameLC . '_inputfield_' . $intInputfieldId);
                                     }
                                 }
                             } else {
                                 if ($objTpl->blockExists($this->moduleNameLC . '_inputfield_' . $intInputfieldId)) {
                                     $objTpl->hideBlock($this->moduleNameLC . '_inputfield_' . $intInputfieldId);
                                 }
                             }
                         } catch (Exception $error) {
                             echo "Error: " . $error->getMessage();
                         }
                     }
                 }
                 $objTpl->clearVariables();
             }
             break;
         case 4:
             //Exp Search View
             $strInputfields = '';
             foreach ($this->arrInputfields as $key => $arrInputfield) {
                 if ($this->checkFieldTypeIsExpSeach($arrInputfield['type'])) {
                     if (!empty($arrInputfield['type'])) {
                         $strType = $arrInputfield['type_name'];
                         $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
                         try {
                             $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                             $strInputfield = $objInputfield->getInputfield(2, $arrInputfield);
                             if ($strInputfield != null) {
                                 $strInputfields .= '<p><label>' . $arrInputfield['name'][0] . '</label>' . $strInputfield . '</p>';
                             }
                         } catch (Exception $error) {
                             echo "Error: " . $error->getMessage();
                         }
                     }
                 }
             }
             return $strInputfields;
             break;
     }
 }
 private function parseUploadForm($objCategory)
 {
     global $_CONFIG, $_ARRAYLANG;
     if (!$this->objTemplate->blockExists('downloads_simple_file_upload') && !$this->objTemplate->blockExists('downloads_advanced_file_upload')) {
         return;
     }
     // check for upload permissiosn
     if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) {
         if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
             $this->objTemplate->hideBlock('downloads_simple_file_upload');
         }
         if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
             $this->objTemplate->hideBlock('downloads_advanced_file_upload');
         }
         return;
     }
     if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
         $objFWSystem = new \FWSystem();
         //Uploader button handling
         $cx = \Cx\Core\Core\Controller\Cx::instanciate();
         //paths we want to remember for handling the uploaded files
         $data = array('path' => $cx->getWebsiteImagesDownloadsPath(), 'webPath' => $cx->getWebsiteImagesDownloadsWebPath(), 'category_id' => $objCategory->getId());
         $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
         $uploader->setFinishedCallback(array($cx->getCodeBaseModulePath() . '/Downloads/Controller/Downloads.class.php', '\\Cx\\Modules\\Downloads\\Controller\\Downloads', 'uploadFinished'));
         $uploader->setCallback('uploadFinishedCallbackJs');
         $uploader->setData($data);
         $this->objTemplate->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE']), 'DOWNLOADS_UPLOAD_REDIRECT_URL' => \Env::get('Resolver')->getURL(), 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_UPLOAD_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_UPLOAD_FILE'], 'TXT_DOWNLOADS_MAX_FILE_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_MAX_FILE_SIZE'], 'TXT_DOWNLOADS_ADD_NEW_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_FILE'], 'DOWNLOADS_MAX_FILE_SIZE' => $this->getFormatedFileSize($objFWSystem->getMaxUploadFileSize())));
         $this->objTemplate->parse('downloads_simple_file_upload');
         if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
             $this->objTemplate->hideBlock('downloads_advanced_file_upload');
         }
     }
 }
Beispiel #8
0
    /**
     * Overview Media Data
     *
     * @global     array     $_CONFIG
     * @global     array     $_ARRAYLANG
     * @return    string    parsed content
     */
    function _overviewMedia()
    {
        global $_CONFIG, $_ARRAYLANG;
        switch ($this->getAct) {
            case 'download':
                $this->_downloadMedia();
                break;
            case 'newDir':
                $this->_createDirectory($_POST['media_directory_name']);
                break;
            case 'upload':
                $this->_uploadFiles();
                break;
            case 'rename':
                $this->_renameFiles();
                break;
            case 'delete':
                $this->_deleteFiles();
                break;
            default:
        }
        // tree navigation
        $tmp = $this->arrWebPaths[$this->archive];
        if (substr($this->webPath, 0, strlen($tmp)) == $tmp) {
            $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => "Home /", 'MEDIA_TREE_NAV_MAIN_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->arrWebPaths[$this->archive])));
            if (strlen($this->webPath) != strlen($tmp)) {
                $tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp)));
                $tmpPath = explode('/', $tmpPath);
                $tmpLink = '';
                foreach ($tmpPath as $path) {
                    if (!empty($path)) {
                        $tmpLink .= $path . '/';
                        $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_DIR' => $path, 'MEDIA_TREE_NAV_DIR_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->arrWebPaths[$this->archive] . $tmpLink)));
                        $this->_objTpl->parse('mediaTreeNavigation');
                    }
                }
            }
        }
        if (isset($_GET['deletefolder']) && ($_GET['deletefolder'] = "success")) {
            $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FOLDER_DELETED_SUCESSFULLY'];
        }
        if (!empty($_GET['highlightFiles'])) {
            $this->highlightName = array_merge($this->highlightName, array_map('basename', json_decode(contrexx_stripslashes(urldecode($_GET['highlightFiles'])))));
        }
        // media directory tree
        $i = 0;
        $dirTree = $this->_dirTree($this->path);
        $dirTree = $this->_sortDirTree($dirTree);
        foreach (array_keys($dirTree) as $key) {
            if (is_array($dirTree[$key]['icon'])) {
                for ($x = 0; $x < count($dirTree[$key]['icon']); $x++) {
                    if (MediaLibrary::isIllegalFileName($dirTree[$key]['name'][$x])) {
                        continue;
                    }
                    $class = $i % 2 ? 'row2' : 'row1';
                    // highlight
                    if (in_array($dirTree[$key]['name'][$x], $this->highlightName)) {
                        $class .= '" style="background-color: ' . $this->highlightColor . ';';
                    }
                    if (!$this->manageAccessGranted()) {
                        //if the user is not allowed to delete or rename files -- hide those blocks
                        if ($this->_objTpl->blockExists('manage_access_option')) {
                            $this->_objTpl->hideBlock('manage_access_option');
                        }
                    }
                    $this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $dirTree[$key]['name'][$x], 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_RENAME_TITLE' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_DELETE_TITLE' => $_ARRAYLANG['TXT_MEDIA_DELETE']));
                    $tmpHref = $delHref = '';
                    if ($key == 'dir') {
                        $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/');
                        $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=delete&amp;path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/');
                    } elseif ($key == 'file') {
                        $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=delete&amp;path=' . rawurlencode($this->webPath) . '&amp;file=' . rawurlencode($dirTree[$key]['name'][$x]);
                        if ($this->_isImage($this->path . $dirTree[$key]['name'][$x])) {
                            $tmpSize = getimagesize($this->path . $dirTree[$key]['name'][$x]);
                            $tmpHref = 'javascript: preview(\'' . $this->webPath . $dirTree[$key]['name'][$x] . '\', ' . $tmpSize[0] . ', ' . $tmpSize[1] . ');';
                        } else {
                            $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . '&amp;act=download&amp;path=' . rawurlencode($this->webPath) . '&amp;file=' . rawurlencode($dirTree[$key]['name'][$x]);
                        }
                    }
                    $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_HREF' => $tmpHref, 'MEDIA_FILE_DELETE_HREF' => $delHref));
                    $this->_objTpl->parse('mediaDirectoryTree');
                    $i++;
                }
            }
        }
        // empty dir or php safe mode restriction
        if ($i == 0 && !@opendir($this->rootPath)) {
            $tmpMessage = !@opendir($this->path) ? 'PHP Safe Mode Restriction or wrong path' : $_ARRAYLANG['TXT_MEDIA_DIR_EMPTY'];
            $this->_objTpl->setVariable(array('TXT_MEDIA_DIR_EMPTY' => $tmpMessage, 'MEDIA_SELECT_STATUS' => ' disabled'));
            $this->_objTpl->parse('mediaEmptyDirectory');
        }
        // parse variables
        $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;path=' . rawurlencode($this->webPath);
        $tmpIcon = $this->_sortingIcons();
        if ($this->_objTpl->blockExists('manage_access_header')) {
            if ($this->manageAccessGranted()) {
                $this->_objTpl->touchBlock('manage_access_header');
            } else {
                $this->_objTpl->hideBlock('manage_access_header');
            }
        }
        $this->_objTpl->setVariable(array('MEDIA_NAME_HREF' => $tmpHref . '&amp;sort=name&amp;sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&amp;sort=size&amp;sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&amp;sort=type&amp;sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&amp;sort=date&amp;sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&amp;sort=perm&amp;sort_desc=' . ($this->sortBy == 'perm' && !$this->sortDesc), 'TXT_MEDIA_FILE_NAME' => $_ARRAYLANG['TXT_MEDIA_FILE_NAME'], 'TXT_MEDIA_FILE_SIZE' => $_ARRAYLANG['TXT_MEDIA_FILE_SIZE'], 'TXT_MEDIA_FILE_TYPE' => $_ARRAYLANG['TXT_MEDIA_FILE_TYPE'], 'TXT_MEDIA_FILE_DATE' => $_ARRAYLANG['TXT_MEDIA_FILE_DATE'], 'TXT_MEDIA_FILE_PERM' => $_ARRAYLANG['TXT_MEDIA_FILE_PERM'], 'MEDIA_NAME_ICON' => $tmpIcon['name'], 'MEDIA_SIZE_ICON' => $tmpIcon['size'], 'MEDIA_TYPE_ICON' => $tmpIcon['type'], 'MEDIA_DATE_ICON' => $tmpIcon['date'], 'MEDIA_PERM_ICON' => $tmpIcon['perm'], 'MEDIA_JAVASCRIPT' => $this->_getJavaScriptCodePreview()));
        if (!$this->uploadAccessGranted()) {
            // if user not allowed to upload files and creating folders -- hide that blocks
            if ($this->_objTpl->blockExists('media_simple_file_upload')) {
                $this->_objTpl->hideBlock('media_simple_file_upload');
            }
            if ($this->_objTpl->blockExists('media_advanced_file_upload')) {
                $this->_objTpl->hideBlock('media_advanced_file_upload');
            }
            if ($this->_objTpl->blockExists('media_create_directory')) {
                $this->_objTpl->hideBlock('media_create_directory');
            }
        } else {
            // forms for uploading files and creating folders
            if ($this->_objTpl->blockExists('media_simple_file_upload')) {
                //data we want to remember for handling the uploaded files
                $data = array('path' => $this->path, 'webPath' => $this->webPath);
                //new uploader
                $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
                $uploader->setData($data);
                $uploader->setCallback('mediaCallbackJs');
                $uploader->setFinishedCallback(array(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished'));
                $this->_objTpl->setVariable(array('TXT_MEDIA_ADD_NEW_FILE' => $_ARRAYLANG['TXT_MEDIA_ADD_NEW_FILE'], 'MEDIA_UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_MEDIA_BROWSE']), 'REDIRECT_URL' => '?section=' . $_REQUEST['section'] . '&path=' . contrexx_raw2encodedUrl($this->webPath)));
                $this->_objTpl->parse('media_simple_file_upload');
            }
            if ($this->_objTpl->blockExists('media_advanced_file_upload')) {
                $this->_objTpl->hideBlock('media_advanced_file_upload');
            }
            // create directory
            $this->_objTpl->setVariable(array('TXT_MEDIA_CREATE_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_DIRECTORY'], 'TXT_MEDIA_CREATE_NEW_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_NEW_DIRECTORY'], 'MEDIA_CREATE_DIRECTORY_URL' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&amp;act=newDir&amp;path=' . $this->webPath));
            $this->_objTpl->parse('media_create_directory');
            //custom uploader
            \JS::activate('cx');
            // the uploader needs the framework
            $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
            //create an uploader
            $uploadId = $uploader->getId();
            $uploader->setCallback('customUploader');
            $uploader->setOptions(array('id' => 'custom_' . $uploadId));
            $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploadId, true);
            $folderWidgetId = $folderWidget->getId();
            $extendedFileInputCode = <<<CODE
    <script type="text/javascript">

        //uploader javascript callback function
        function customUploader(callback) {
                angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser();
        }
    </script>
CODE;
            $this->_objTpl->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml(), 'UPLOADER_ID' => $uploadId, 'FILE_INPUT_CODE' => $extendedFileInputCode, 'FOLDER_WIDGET_CODE' => $folderWidget->getXHtml()));
        }
    }
Beispiel #9
0
    /**
     * Inits the uploader when displaying a contact form.
     */
    protected function initUploader($fieldId, $restrictUpload2SingleFile = true)
    {
        try {
            $cx = \Cx\Core\Core\Controller\Cx::instanciate();
            $sessionObj = $cx->getComponent('Session')->getSession();
            $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
            //set instance name so we are able to catch the instance with js
            $uploader->setCallback('contactFormUploader_' . $fieldId);
            $cx = \Cx\Core\Core\Controller\Cx::instanciate();
            // specifies the function to call when upload is finished. must be a static function
            $uploader->setFinishedCallback(array($cx->getCodeBaseCoreModulePath() . '/Contact/Controller/Contact.class.php', '\\Cx\\Core_Modules\\Contact\\Controller\\Contact', 'uploadFinished'));
            if ($restrictUpload2SingleFile) {
                $uploader->setData(array('singleFile' => $restrictUpload2SingleFile));
                $uploader->setUploadLimit(1);
            }
            $uploaderId = $uploader->getId();
            $uploader->setOptions(array('id' => 'contactUploader_' . $uploaderId, 'style' => 'display: none'));
            //initialize the widget displaying the folder contents
            $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploaderId);
            $this->objTemplate->setVariable(array('CONTACT_UPLOADER_FOLDER_WIDGET_' . $fieldId => $folderWidget->getXhtml(), 'CONTACT_UPLOADER_ID_' . $fieldId => $uploaderId));
            $folderWidgetId = $folderWidget->getId();
            $strInputfield = $uploader->getXHtml();
            $strInputfield .= <<<CODE
            <script type="text/javascript">
            cx.ready(function() {
                    jQuery('#contactFormFieldId_{$fieldId}').bind('click', function() {
                        jQuery('#contactUploader_{$uploaderId}').trigger('click');
                        return false;
                    }).removeAttr('disabled');
            });

            //uploader javascript callback function
            function contactFormUploader_{$fieldId}(callback) {
                    angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser();
            }
            </script>
CODE;
            return $strInputfield;
        } catch (Exception $e) {
            return '<!-- failed initializing uploader, exception ' . get_class($e) . ' with message "' . $e->getMessage() . '" -->';
        }
    }
Beispiel #10
0
 /**
  * Get the uploader object
  *
  * @return \Cx\Core_Modules\Uploader\Model\Entity\Uploader
  */
 public function getUploader()
 {
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     //set instance name so we are able to catch the instance with js
     $uploader->setCallback('marketUploaderCallback');
     $uploader->setOptions(array('id' => 'marketUploader', 'allowed-extensions' => array('jpg', 'jpeg', 'png', 'gif'), 'data-upload-limit' => 1, 'style' => 'display:none'));
     return $uploader;
 }
Beispiel #11
0
 /**
  * Sets the template for the file selection
  *
  * Sets the template and all neede variables
  * for the file selection.
  * @param object $tpl The template object (by reference)
  */
 function initFileSelectTemplate(&$tpl)
 {
     global $_ARRAYLANG;
     $template = file_get_contents(ASCMS_LIBRARY_PATH . "/importexport/template/import.fileselect.html");
     $tpl->setTemplate($template, true, true);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     // init uploader to upload csv
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     $uploader->setCallback('importUploaderCallback');
     $uploader->setOptions(array('id' => 'importCsvUploader', 'allowed-extensions' => array('csv'), 'data-upload-limit' => 1));
     $uploader->setFinishedCallback(array($cx->getCodeBaseLibraryPath() . '/importexport/import.class.php', '\\Import', 'uploadFinished'));
     $tpl->setVariable(array("TXT_IMPORT" => $_ARRAYLANG['TXT_IMPORT'], "IMPORT_TYPELIST" => $this->getTypeSelectList(), "TXT_FILETYPE" => $_ARRAYLANG['TXT_FILETYPE'], "TXT_CHOOSE_FILE" => $_ARRAYLANG['TXT_CHOOSE_FILE'], "TXT_SEPARATOR" => $_ARRAYLANG['TXT_SEPARATOR'], "TXT_ENCLOSURE" => $_ARRAYLANG['TXT_ENCLOSURE'], "TXT_DESC_DELIMITER" => $_ARRAYLANG['TXT_DESC_DELIMITER'], "TXT_DESC_ENCLOSURE" => $_ARRAYLANG['TXT_DESC_ENCLOSURE'], "TXT_HELP" => $_ARRAYLANG['TXT_HELP'], 'IMPORT_UPLOADER_BUTTON' => $uploader->getXHtml($_ARRAYLANG['TXT_BROWSE']), 'IMPORT_UPLOADER_ID' => $uploader->getId()));
 }
Beispiel #12
0
 /**
  * Set up the HTML elements for all the Product Attributes of any Product.
  *
  * The following types of Attributes are supported:
  * 0    Dropdown menu, customers may select no (the default) or one option.
  * 1    Radio buttons, customers need to select one option.
  * 2    Checkboxes, customers may select no, one or several options.
  * 3    Dropdown menu, customers need to select one option.
  * 4    Optional text field
  * 5    Mandatory text field
  * 6    Optional file upload field
  * 7    Mandatory file upload field
  * Types 1 and 3 are functionally identical, they only differ by
  * the kind of widget being used.
  * The individual Product Attributes carry a unique ID enabling the
  * JavaScript code contained within the Shop page to verify that
  * all mandatory choices have been made before any Product can
  * be added to the cart.
  * @param   integer     $product_id     The Product ID
  * @param   string      $formName       The name of the HTML form containing
  *                                      the Product and options
  * @param   integer     $cart_id        The optional cart Product ID,
  *                                      null if not applicable.
  * @param   boolean     $flagUpload     If a product has an upload
  *                                      Attribute associated with it,
  *                                      this parameter will be set to true
  * @return  string                      The string with the HTML code
  */
 static function productOptions($product_id, $formName, $cart_id = null, &$flagUpload = false)
 {
     global $_ARRAYLANG;
     //\DBG::log("productOptions($product_id, $formName, $cart_id, $flagUpload): Entered");
     // Semicolon separated list of Attribute name IDs to verify
     // before the Product is added to the cart
     $checkOptionIds = '';
     // check if the product option block exists in the template
     if (self::$objTemplate->blockExists('shopProductOptionsRow') && self::$objTemplate->blockExists('shopProductOptionsValuesRow')) {
         $domId = 0;
         $count = 0;
         $arrAttributes = Attributes::getArray($count, null, null, '`ord` ASC', array('product_id' => $product_id));
         //\DBG::log("Attributes: ".var_export($arrAttributes, true));
         // When there are no Attributes for this Product, hide the
         // options blocks
         if (empty($arrAttributes)) {
             self::$objTemplate->hideBlock('shopProductOptionsRow');
             self::$objTemplate->hideBlock('shopProductOptionsValuesRow');
         } else {
             $isUpload = false;
             // Loop through the Attribute Names for the Product
             foreach ($arrAttributes as $attribute_id => $objAttribute) {
                 $mandatory = false;
                 $arrOptions = Attributes::getOptionArrayByAttributeId($attribute_id);
                 $arrRelation = Attributes::getRelationArray($product_id);
                 // This attribute does not apply for this product
                 if (empty($arrRelation)) {
                     continue;
                 }
                 $selectValues = '';
                 // create head of option menu/checkbox/radiobutton
                 switch ($objAttribute->getType()) {
                     case Attribute::TYPE_CHECKBOX:
                     case Attribute::TYPE_TEXT_OPTIONAL:
                     case Attribute::TYPE_UPLOAD_OPTIONAL:
                     case Attribute::TYPE_TEXTAREA_OPTIONAL:
                     case Attribute::TYPE_EMAIL_OPTIONAL:
                     case Attribute::TYPE_EMAIL_OPTIONAL:
                     case Attribute::TYPE_URL_OPTIONAL:
                     case Attribute::TYPE_DATE_OPTIONAL:
                     case Attribute::TYPE_NUMBER_INT_OPTIONAL:
                     case Attribute::TYPE_NUMBER_FLOAT_OPTIONAL:
                         // No container nor hidden field for optional types
                         break;
                     case Attribute::TYPE_MENU_OPTIONAL:
                         // There is no hidden input field here either,
                         // but the dropdown menu container
                         $selectValues = '<select name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" class="product-option-field" style="width:180px;">' . "\n" . '<option value="0">' . $objAttribute->getName() . '&nbsp;' . $_ARRAYLANG['TXT_CHOOSE'] . "</option>\n";
                         break;
                     case Attribute::TYPE_RADIOBUTTON:
                     case Attribute::TYPE_TEXT_MANDATORY:
                     case Attribute::TYPE_UPLOAD_MANDATORY:
                     case Attribute::TYPE_TEXTAREA_MANDATORY:
                     case Attribute::TYPE_EMAIL_MANDATORY:
                     case Attribute::TYPE_URL_MANDATORY:
                     case Attribute::TYPE_DATE_MANDATORY:
                     case Attribute::TYPE_NUMBER_INT_MANDATORY:
                     case Attribute::TYPE_NUMBER_FLOAT_MANDATORY:
                         $mandatory = true;
                         // The Attribute name, indicating a mandatory option.
                         $selectValues = '<input type="hidden" id="productOption-' . $product_id . '-' . $attribute_id . '" value="' . $objAttribute->getName() . '" />' . "\n";
                         // The Attribute verification regex, if applicable
                         $regex = Attribute::getVerificationRegex($objAttribute->getType());
                         if ($regex != '') {
                             $selectValues .= '<input type="hidden" id="attributeVerification-' . $product_id . '-' . $attribute_id . '" value="' . $regex . '" />' . "\n";
                         }
                         $checkOptionIds .= "{$attribute_id};";
                         break;
                     case Attribute::TYPE_MENU_MANDATORY:
                         $selectValues = '<input type="hidden" id="productOption-' . $product_id . '-' . $attribute_id . '" value="' . $objAttribute->getName() . '" />' . "\n" . '<select name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" class="product-option-field" style="width:180px;">' . "\n" . (count($arrOptions) > 1 ? '<option value="0">' . $objAttribute->getName() . '&nbsp;' . $_ARRAYLANG['TXT_CHOOSE'] . "</option>\n" : '');
                         $checkOptionIds .= "{$attribute_id};";
                         break;
                 }
                 $i = 0;
                 foreach ($arrOptions as $option_id => $arrOption) {
                     // This option does not apply to this product
                     if (!isset($arrRelation[$option_id])) {
                         continue;
                     }
                     $option_price = '';
                     $selected = false;
                     // Show the price only if non-zero
                     if ($arrOption['price'] != 0) {
                         $pricePrefix = $arrOption['price'] > 0 ? '+' : '';
                         $option_price = '&nbsp;(' . $pricePrefix . Currency::getCurrencyPrice($arrOption['price']) . '&nbsp;' . Currency::getActiveCurrencySymbol() . ')';
                     }
                     // mark the option value as selected if it was before
                     // and this page was requested from the cart
                     if (isset($cart_id)) {
                         $options = Cart::get_options_array($cart_id, $attribute_id);
                         if (is_array($options) && in_array($option_id, $options)) {
                             $selected = true;
                         }
                     }
                     // create option menu/checkbox/radiobutton
                     switch ($objAttribute->getType()) {
                         case Attribute::TYPE_MENU_OPTIONAL:
                             $selectValues .= '<option value="' . $option_id . '" ' . ($arrOption['price'] != 0 ? 'data-price="' . $arrOption['price'] . '" ' : '') . ($selected ? 'selected="selected"' : '') . ' >' . $arrOption['value'] . $option_price . "</option>\n";
                             break;
                         case Attribute::TYPE_RADIOBUTTON:
                             $selectValues .= '<input class="product-option-field" type="radio" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $option_id . '"' . ($arrOption['price'] != 0 ? ' data-price="' . $arrOption['price'] . '"' : '') . ($selected ? ' checked="checked"' : '') . ' /><label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">&nbsp;' . $arrOption['value'] . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_CHECKBOX:
                             $selectValues .= '<input class="product-option-field" type="checkbox" name="productOption[' . $attribute_id . '][' . $i . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $option_id . '"' . ($arrOption['price'] != 0 ? ' data-price="' . $arrOption['price'] . '" ' : '') . ($selected ? ' checked="checked"' : '') . ' /><label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">&nbsp;' . $arrOption['value'] . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_MENU_MANDATORY:
                             $selectValues .= '<option value="' . $option_id . '"' . ($selected ? ' selected="selected"' : '') . ($arrOption['price'] != 0 ? ' data-price="' . $arrOption['price'] . '" ' : '') . ' >' . $arrOption['value'] . $option_price . "</option>\n";
                             break;
                         case Attribute::TYPE_TEXT_OPTIONAL:
                         case Attribute::TYPE_TEXT_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $selectValues .= '<input type="text" maxlength="65535" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $arrOption['value'] . '" style="width:180px;" />' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_EMAIL_OPTIONAL:
                         case Attribute::TYPE_EMAIL_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $selectValues .= '<input type="text" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $arrOption['value'] . '" style="width:180px;" />' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_URL_OPTIONAL:
                         case Attribute::TYPE_URL_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $selectValues .= '<input type="text" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $arrOption['value'] . '" style="width:180px;" />' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_DATE_OPTIONAL:
                         case Attribute::TYPE_DATE_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             // Passed by reference
                             $element_id = 'productOption-' . $product_id . '-' . $attribute_id . '-' . $domId;
                             $selectValues .= \Html::getDatepicker('productOption[' . $attribute_id . ']', array('defaultDate' => $arrOption['value']), 'style="width:180px;"', $element_id) . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_NUMBER_INT_OPTIONAL:
                         case Attribute::TYPE_NUMBER_INT_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $selectValues .= '<input type="text" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $arrOption['value'] . '" style="width:180px;" />' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_NUMBER_FLOAT_OPTIONAL:
                         case Attribute::TYPE_NUMBER_FLOAT_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $selectValues .= '<input type="text" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $arrOption['value'] . '" style="width:180px;" />' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_UPLOAD_OPTIONAL:
                         case Attribute::TYPE_UPLOAD_MANDATORY:
                             //                            $option_price = '&nbsp;';
                             $isUpload = true;
                             $selectValues .= '<input type="input" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" style="width:180px; float:left" />' . '<input type="button" name="productOption[' . $attribute_id . ']" onClick="getUploader(cx.jQuery(this));" data-input-id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" value="' . $_ARRAYLANG['TXT_SHOP_CHOOSE_FILE'] . '"/>' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                         case Attribute::TYPE_TEXTAREA_OPTIONAL:
                         case Attribute::TYPE_TEXTAREA_MANDATORY:
                             //                            $valuePrice = '&nbsp;';
                             $selectValues .= '<textarea maxlength="65535" name="productOption[' . $attribute_id . ']" id="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '" style="width:300px;">' . contrexx_input2xhtml($arrOption['value']) . '</textarea>' . '<label for="productOption-' . $product_id . '-' . $attribute_id . '-' . $domId . '">' . $option_price . "</label><br />\n";
                             break;
                     }
                     ++$i;
                     ++$domId;
                 }
                 // create foot of option menu/checkbox/radiobutton
                 switch ($objAttribute->getType()) {
                     case Attribute::TYPE_MENU_OPTIONAL:
                         $selectValues .= "</select><br />";
                         break;
                     case Attribute::TYPE_RADIOBUTTON:
                         $selectValues .= "<br />";
                         break;
                     case Attribute::TYPE_CHECKBOX:
                         $selectValues .= "";
                         break;
                     case Attribute::TYPE_MENU_MANDATORY:
                         $selectValues .= "</select><br />";
                         break;
                         // Set enctype in form if one of these is present
                     // Set enctype in form if one of these is present
                     case Attribute::TYPE_UPLOAD_OPTIONAL:
                     case Attribute::TYPE_UPLOAD_MANDATORY:
                         // Avoid code analyzer warning
                         $flagUpload = true || $flagUpload;
                         break;
                         /* Nothing to to
                                                 case Attribute::TYPE_TEXT_OPTIONAL:
                                                 case Attribute::TYPE_TEXT_MANDATORY:
                                                 case Attribute::TYPE_TEXTAREA_OPTIONAL:
                                                 case Attribute::TYPE_TEXTAREA_MANDATORY:
                                                 case Attribute::TYPE_EMAIL_OPTIONAL:
                                                 case Attribute::TYPE_EMAIL_MANDATORY:
                                                 case Attribute::TYPE_URL_OPTIONAL:
                                                 case Attribute::TYPE_URL_MANDATORY:
                                                 case Attribute::TYPE_DATE_OPTIONAL:
                                                 case Attribute::TYPE_DATE_MANDATORY:
                                                 case Attribute::TYPE_NUMBER_INT_OPTIONAL:
                                                 case Attribute::TYPE_NUMBER_INT_MANDATORY:
                                                 case Attribute::TYPE_NUMBER_FLOAT_OPTIONAL:
                                                 case Attribute::TYPE_NUMBER_FLOAT_MANDATORY:
                         */
                 }
                 $selectValues .= "\n";
                 self::$objTemplate->setVariable(array('SHOP_PRODCUT_OPTION' => $selectValues, 'SHOP_PRODUCT_OPTION' => $selectValues, 'SHOP_PRODUCT_OPTIONS_NAME' => $objAttribute->getName(), 'SHOP_PRODUCT_OPTIONS_TITLE' => '<a href="javascript:{}" onclick="toggleOptions(' . $product_id . ', this)" title="' . $_ARRAYLANG['TXT_OPTIONS'] . '">' . $_ARRAYLANG['TXT_OPTIONS'] . "</a>\n"));
                 if ($mandatory && self::$objTemplate->blockExists('product_attribute_mandatory')) {
                     self::$objTemplate->touchBlock('product_attribute_mandatory');
                 }
                 self::$objTemplate->parse('shopProductOptionsValuesRow');
             }
             self::$objTemplate->parse('shopProductOptionsRow');
             if ($isUpload) {
                 //initialize the uploader
                 $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
                 //create an uploader
                 $uploader->setCallback('productOptionsUploaderCallback');
                 $uploader->setOptions(array('id' => 'productOptionsUploader', 'allowed-extensions' => array('jpg', 'png', 'gif'), 'data-upload-limit' => 1, 'style' => 'display:none'));
                 self::$objTemplate->setVariable(array('SHOP_PRODUCT_OPTIONS_UPLOADER_CODE' => $uploader->getXHtml(), 'SHOP_PRODUCT_OPTIONS_UPLOADER_ID' => $uploader->getId()));
             }
         }
     }
     return "return checkProductOption('shopProductForm{$formName}', " . "{$product_id}, '" . substr($checkOptionIds, 0, strlen($checkOptionIds) - 1) . "');";
 }
Beispiel #13
0
 /**
  * Initialize the access image uploader and get the uploader instance
  * 
  * @return \Cx\Core_Modules\Uploader\Model\Entity\Uploader
  */
 public function getImageUploader()
 {
     // init uploader to upload images
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     $uploader->setCallback('accessImageUploaderCallback');
     $uploader->setOptions(array('id' => 'accessImageUploader', 'allowed-extensions' => array('jpg', 'jpeg', 'png', 'gif'), 'style' => 'display:none', 'data-upload-limit' => 1));
     $this->attachJavaScriptFunction('imageUploaderCode');
     return $uploader;
 }
 /**
  * Get the uploader
  *
  * @param string $callbackJs callback javascript function name
  * @param array  $options    uploader options
  *
  * @return \Cx\Core_Modules\Uploader\Model\Entity\Uploader
  */
 public function getUploader($callbackJs, $options = array())
 {
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     //set instance name so we are able to catch the instance with js
     if (!empty($callbackJs)) {
         $uploader->setCallback($callbackJs);
     }
     if (!empty($options)) {
         $uploader->setOptions($options);
     }
     return $uploader;
 }
Beispiel #15
0
 /**
  * set up Import page
  * call specific function depending on $_GET
  * @access private
  */
 private function import()
 {
     global $_ARRAYLANG, $objTemplate;
     \Permission::checkAccess(102, 'static');
     $objTemplate->addBlockfile('ADMIN_CONTENT', 'skins_import', 'skins_import.html');
     $this->pageTitle = $_ARRAYLANG['TXT_THEME_IMPORT'];
     if (!empty($_GET['import'])) {
         $this->importFile();
     }
     // init uploader to import of themes
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     $uploader->setCallback('themesZipFileUploaderCallback');
     $uploader->setOptions(array('id' => 'local-archive-uploader', 'allowed-extensions' => array('zip'), 'style' => 'display:none', 'data-upload-limit' => 1));
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $uploader->setFinishedCallback(array($cx->getCodeBaseCorePath() . '/ViewManager/Controller/ViewManager.class.php', '\\Cx\\Core\\ViewManager\\Controller\\ViewManager', 'uploadFinished'));
     $objTemplate->setVariable(array('TXT_THEMES_EDIT' => $_ARRAYLANG['TXT_SETTINGS_MODFIY'], 'TXT_THEMES_CREATE' => $_ARRAYLANG['TXT_CREATE'], 'TXT_THEME_IMPORT' => $_ARRAYLANG['TXT_THEME_IMPORT'], 'TXT_THEME_LOCAL_FILE' => $_ARRAYLANG['TXT_THEME_LOCAL_FILE'], 'TXT_THEME_SPECIFY_URL' => $_ARRAYLANG['TXT_THEME_SPECIFY_URL'], 'TXT_THEME_IMPORT_INFO' => $_ARRAYLANG['TXT_THEME_IMPORT_INFO'], 'TXT_THEME_NO_URL_SPECIFIED' => $_ARRAYLANG['TXT_THEME_NO_URL_SPECIFIED'], 'TXT_THEME_NO_FILE_SPECIFIED' => $_ARRAYLANG['TXT_THEME_NO_FILE_SPECIFIED'], 'TXT_THEME_FILESYSTEM' => sprintf($_ARRAYLANG['TXT_THEME_FILESYSTEM'], \Cx\Core\Core\Controller\Cx::instanciate()->getThemesFolderName()), 'THEMES_MENU' => $this->getDropdownNotInDb(), 'TXT_THEME_DO_IMPORT' => $_ARRAYLANG['TXT_THEME_DO_IMPORT'], 'TXT_THEME_IMPORT_THEME' => $_ARRAYLANG['TXT_THEME_IMPORT_THEME'], 'TXT_VIEWMANAGER_THEME_SELECTION_TXT' => $_ARRAYLANG['TXT_VIEWMANAGER_THEME_SELECTION_TXT'], 'TXT_VIEWMANAGER_THEME' => $_ARRAYLANG['TXT_VIEWMANAGER_THEME'], 'TXT_VIEWMANAGER_SOURCE' => $_ARRAYLANG['TXT_VIEWMANAGER_SOURCE'], 'TXT_SELECT_FILE' => $_ARRAYLANG['TXT_SELECT_FILE'], 'THEMES_UPLOADER_CODE' => $uploader->getXHtml(), 'THEMES_UPLOADER_ID' => $uploader->getId()));
 }
Beispiel #16
0
 /**
  * Import and Export data from/to csv
  * @author  Reto Kohli <*****@*****.**> (parts)
  */
 function _import()
 {
     global $_ARRAYLANG, $objDatabase;
     self::$pageTitle = $_ARRAYLANG['TXT_SHOP_IMPORT_TITLE'];
     self::$objTemplate->loadTemplateFile('module_shop_import.html');
     self::$objTemplate->setGlobalVariable(array('TXT_SHOP_IMPORT_CATEGORIES_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CATEGORIES_TIPS']), 'TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS' => contrexx_raw2xhtml($_ARRAYLANG['TXT_SHOP_IMPORT_CHOOSE_TEMPLATE_TIPS'])));
     $objCSVimport = new CsvImport();
     // Delete template
     if (isset($_REQUEST['deleteImg'])) {
         $query = "\n                DELETE FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg\n                 WHERE img_id=" . $_REQUEST['img'];
         if ($objDatabase->Execute($query)) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_DELETED']);
         } else {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_DELETE']);
         }
     }
     // Save template
     if (isset($_REQUEST['SaveImg'])) {
         $query = "\n                INSERT INTO " . DBPREFIX . "module_shop" . MODULE_INDEX . "_importimg (\n                    img_name, img_cats, img_fields_file, img_fields_db\n                ) VALUES (\n                    '" . $_REQUEST['ImgName'] . "',\n                    '" . $_REQUEST['category'] . "',\n                    '" . $_REQUEST['pairs_left_keys'] . "',\n                    '" . $_REQUEST['pairs_right_keys'] . "'\n                )";
         if ($objDatabase->Execute($query)) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_SAVED']);
         } else {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_ERROR_SAVE']);
         }
     }
     $objCSVimport->initTemplateArray();
     $fileExists = false;
     $fileName = isset($_POST['csvFile']) ? contrexx_input2raw($_POST['csvFile']) : '';
     $uploaderId = isset($_POST['importCsvUploaderId']) ? contrexx_input2raw($_POST['importCsvUploaderId']) : '';
     if (!empty($fileName) && !empty($uploaderId)) {
         $objSession = \cmsSession::getInstance();
         $tmpFile = $objSession->getTempPath() . '/' . $uploaderId . '/' . $fileName;
         $fileExists = \Cx\Lib\FileSystem\FileSystem::exists($tmpFile);
     }
     // Import Categories
     // This is not subject to change, so it's hardcoded
     if (isset($_REQUEST['ImportCategories']) && $fileExists) {
         // delete existing categories on request only!
         // mind that this necessarily also clears all products and
         // their associated attributes!
         if (!empty($_POST['clearCategories'])) {
             Products::deleteByShopCategory(0, false, true);
             ShopCategories::deleteAll();
             // NOTE: Removing Attributes is now disabled.  Optionally enable this.
             //                Attributes::deleteAll();
         }
         $objCsv = new CsvBv($tmpFile);
         $importedLines = 0;
         $arrCategoryLevel = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
         $line = $objCsv->NextLine();
         while ($line) {
             $level = 0;
             foreach ($line as $catName) {
                 ++$level;
                 if (!empty($catName)) {
                     $parentCatId = $objCSVimport->getCategoryId($catName, $arrCategoryLevel[$level - 1]);
                     $arrCategoryLevel[$level] = $parentCatId;
                 }
             }
             ++$importedLines;
             $line = $objCsv->NextLine();
         }
         \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_IMPORTED_CATEGORIES'] . ': ' . $importedLines);
     }
     // Import
     if (isset($_REQUEST['importFileProducts']) && $fileExists) {
         if (isset($_POST['clearProducts']) && $_POST['clearProducts']) {
             Products::deleteByShopCategory(0, false, true);
             // The categories need not be removed, but it is done by design!
             ShopCategories::deleteAll();
             // NOTE: Removing Attributes is now disabled.  Optionally enable this.
             //                Attributes::deleteAll();
         }
         $arrFileContent = $objCSVimport->GetFileContent($tmpFile);
         $query = '
             SELECT img_id, img_name, img_cats, img_fields_file, img_fields_db
               FROM ' . DBPREFIX . 'module_shop' . MODULE_INDEX . '_importimg
              WHERE img_id=' . $_REQUEST['ImportImage'];
         $objResult = $objDatabase->Execute($query);
         $arrCategoryName = preg_split('/;/', $objResult->fields['img_cats'], null, PREG_SPLIT_NO_EMPTY);
         $arrFirstLine = $arrFileContent[0];
         $arrCategoryColumnIndex = array();
         for ($x = 0; $x < count($arrCategoryName); ++$x) {
             foreach ($arrFirstLine as $index => $strColumnName) {
                 if ($strColumnName == $arrCategoryName[$x]) {
                     $arrCategoryColumnIndex[] = $index;
                 }
             }
         }
         $arrTemplateFieldName = preg_split('/;/', $objResult->fields['img_fields_file'], null, PREG_SPLIT_NO_EMPTY);
         $arrDatabaseFieldIndex = array();
         for ($x = 0; $x < count($arrTemplateFieldName); ++$x) {
             foreach ($arrFirstLine as $index => $strColumnName) {
                 if ($strColumnName == $arrTemplateFieldName[$x]) {
                     $arrDatabaseFieldIndex[] = $index;
                 }
             }
         }
         $arrProductFieldName = preg_split('/;/', $objResult->fields['img_fields_db'], null, PREG_SPLIT_NO_EMPTY);
         $arrProductDatabaseFieldName = array();
         for ($x = 0; $x < count($arrProductFieldName); ++$x) {
             $dbname = $objCSVimport->DBfieldsName($arrProductFieldName[$x]);
             $arrProductDatabaseFieldName[$dbname] = (isset($arrProductDatabaseFieldName[$dbname]) ? $arrProductDatabaseFieldName[$dbname] . ';' : '') . $x;
         }
         $importedLines = 0;
         $errorLines = 0;
         // Array of IDs of newly inserted records
         $arrId = array();
         for ($x = 1; $x < count($arrFileContent); ++$x) {
             $category_id = false;
             for ($cat = 0; $cat < count($arrCategoryColumnIndex); ++$cat) {
                 $catName = $arrFileContent[$x][$arrCategoryColumnIndex[$cat]];
                 if (empty($catName) && !empty($category_id)) {
                     break;
                 }
                 if (empty($catName)) {
                     $category_id = $objCSVimport->GetFirstCat();
                 } else {
                     $category_id = $objCSVimport->getCategoryId($catName, $category_id);
                 }
             }
             if ($category_id == 0) {
                 $category_id = $objCSVimport->GetFirstCat();
             }
             $objProduct = new Product('', $category_id, '', Distribution::TYPE_DELIVERY, 0, 1, 0, 0, 0);
             foreach ($arrProductDatabaseFieldName as $index => $strFieldIndex) {
                 $value = '';
                 if (strpos($strFieldIndex, ';')) {
                     $prod2line = explode(';', $strFieldIndex);
                     for ($z = 0; $z < count($prod2line); ++$z) {
                         $value .= $arrFileContent[$x][$arrDatabaseFieldIndex[$prod2line[$z]]] . '<br />';
                     }
                 } else {
                     $value = $arrFileContent[$x][$arrDatabaseFieldIndex[$strFieldIndex]];
                 }
                 $objProduct->{$index}($value);
             }
             if ($objProduct->store()) {
                 $arrId[] = $objProduct->id();
                 ++$importedLines;
             } else {
                 ++$errorLines;
             }
         }
         // Fix picture field and create thumbnails
         Products::makeThumbnailsById($arrId);
         if ($importedLines) {
             \Message::ok($_ARRAYLANG['TXT_SHOP_IMPORT_SUCCESSFULLY_IMPORTED_PRODUCTS'] . ': ' . $importedLines);
         }
         if ($errorLines) {
             \Message::error($_ARRAYLANG['TXT_SHOP_IMPORT_NOT_SUCCESSFULLY_IMPORTED_PRODUCTS'] . ': ' . $errorLines);
         }
     }
     // end import
     $jsnofiles = '';
     $fileFields = $dblist = null;
     $arrTemplateArray = $objCSVimport->getTemplateArray();
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] != 'ImportImg') {
         if (count($arrTemplateArray) == 0) {
             self::$objTemplate->hideBlock('import_products');
             self::$objTemplate->touchBlock('import_products_no_template');
         } else {
             $imageChoice = $objCSVimport->GetImageChoice();
             self::$objTemplate->setVariable(array('IMAGE_CHOICE' => $imageChoice));
         }
     } else {
         if (!isset($_REQUEST['SelectFields'])) {
             $jsnofiles = "selectTab('import1');";
         } else {
             if (isset($_POST['mode']) && $_POST['csvFile'] == '') {
                 $jsnofiles = "selectTab('import4');";
             } else {
                 $jsnofiles = "selectTab('import2');";
                 if ($fileExists) {
                     $fileFields = '
                         <select name="FileFields" id="file_field" style="width: 200px;" size="10">
                             ' . $objCSVimport->getFilefieldMenuOptions($tmpFile) . '
                         </select>' . "\n";
                 }
                 $dblist = '
                     <select name="DbFields" id="given_field" style="width: 200px;" size="10">
                         ' . $objCSVimport->getAvailableNamesMenuOptions() . '
                     </select>' . "\n";
             }
         }
     }
     $jsSelectLayer = 'selectTab("import1");';
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'ImportImg') {
         $jsSelectLayer = 'selectTab("import2");';
     }
     $arrTemplateArray = $objCSVimport->getTemplateArray();
     if ($arrTemplateArray) {
         $arrName = $objCSVimport->getNameArray();
         self::$objTemplate->setVariable('SHOP_IMPORT_TEMPLATE_MENU', \Html::getSelect('ImportImage', $arrName));
     } else {
         self::$objTemplate->touchBlock('import_products_no_template');
     }
     for ($x = 0; $x < count($arrTemplateArray); ++$x) {
         self::$objTemplate->setVariable(array('IMG_NAME' => $arrTemplateArray[$x]['name'], 'IMG_ID' => $arrTemplateArray[$x]['id'], 'CLASS_NAME' => 'row' . ($x % 2 + 1), 'SHOP_CMS_OFFSET' => \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()));
         self::$objTemplate->parse('imgRow');
     }
     //initialize the uploader
     $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader();
     //create an uploader
     $uploader->setCallback('importUploaderCallback');
     $uploader->setOptions(array('id' => 'importCsvUploader', 'allowed-extensions' => array('csv', 'xls'), 'data-upload-limit' => 1, 'style' => 'display:none'));
     self::$objTemplate->setVariable(array('SELECT_LAYER_ONLOAD' => $jsSelectLayer, 'NO_FILES' => isset($jsnofiles) ? $jsnofiles : '', 'FILE_FIELDS_LIST' => isset($fileFields) ? $fileFields : '', 'DB_FIELDS_LIST' => isset($dblist) ? $dblist : '', 'SHOP_IMPORT_CSV_UPLOADER_CODE' => $uploader->getXHtml(), 'SHOP_IMPORT_CSV_UPLOADER_ID' => $uploader->getId()));
     // TODO: !!! CSV EXPORT IS OBSOLETE AND DYSFUNCT !!!
     /*
             // Export groups -- hardcoded
             $content_location = '';
             if (isset($_REQUEST['group'])) {
                 $query = $fieldNames = $content_location = '';
                 $arrPictures = null;
                 switch ($_REQUEST['group']) {
                     // products - plain fields:
                     case 'tproduct':
                         $content_location = "ProdukteTabelle.csv";
                         $fieldNames = array(
                             'id', 'product_id', 'picture', 'title', 'catid', 'distribution',
                             'normalprice', 'resellerprice', 'short', 'long',
                             'stock', 'stock_visible', 'discountprice', 'discount_active',
                             'active', 'b2b', 'b2c', 'date_start', 'date_end',
                             'manufacturer', 'manufacturer_url', 'external_link',
                             'ord', 'vat_id', 'weight',
                             'flags', 'group_id', 'article_id', 'keywords', );
                         $query = "
                             SELECT id, product_id, picture, title, catid, distribution,
                                    normalprice, resellerprice, short, long,
                                    stock, stock_visible, discountprice, discount_active,
                                    active, b2b, b2c, date_start, date_end,
                                    manufacturer, manufacturer_url, external_link,
                                    sort_order, vat_id, weight,
                                    flags, group_id, article_id, keywords
                               FROM ".DBPREFIX."module_shop_products
                              ORDER BY id ASC";
                         break;
                     // products - custom:
                     case 'rproduct':
                         $content_location = "ProdukteRelationen.csv";
                         $fieldNames = array(
                             'id', 'product_id', 'picture', 'title',
                             'catid', 'category', 'parentcategory', 'distribution',
                             'normalprice', 'resellerprice', 'discountprice', 'discount_active',
                             'short', 'long',
                             'stock', 'stock_visible',
                             'active', 'b2b', 'b2c',
                             'date_start', 'date_end',
                             'manufacturer_name', 'manufacturer_website',
                             'manufacturer_url', 'external_link',
                             'ord',
                             'vat_percent', 'weight',
                             'discount_group', 'article_group', 'keywords', );
                         // c1.catid *MUST NOT* be NULL
                         // c2.catid *MAY* be NULL (if c1.catid is root)
                         // vat_id *MAY* be NULL
                         $query = "
                             SELECT p.id, p.product_id, p.picture, p.title,
                                    p.catid, c1.catname as category, c2.catname as parentcategory, p.distribution,
                                    p.normalprice, p.resellerprice, p.discountprice, p.discount_active,
                                    p.short, p.long, p.stock, p.stock_visible,
                                    p.active, p.b2b, p.b2c, p.date_start, p.date_end,
                                    m.name as manufacturer_name,
                                    m.url as manufacturer_website,
                                    p.manufacturer_url, p.external_link,
                                    p.ord,
                                    v.percent as vat_percent, p.weight,
                                    d.name AS discount_group,
                                    a.name AS article_group,
                                    p.keywords
                               FROM ".DBPREFIX."module_shop_products p
                              INNER JOIN ".DBPREFIX."module_shop_categories c1 ON p.catid=c1.catid
                               LEFT JOIN ".DBPREFIX."module_shop_categories c2 ON c1.parentid=c2.catid
                               LEFT JOIN ".DBPREFIX."module_shop_vat v ON vat_id=v.id
                               LEFT JOIN ".DBPREFIX."module_shop_manufacturer as m ON m.id = p.manufacturer
                               LEFT JOIN ".DBPREFIX."module_shop_discountgroup_count_name as d ON d.id = p.group_id
                               LEFT JOIN ".DBPREFIX."module_shop_article_group as a ON a.id = p.article_id
                              ORDER BY catid ASC, product_id ASC";
                         break;
                     // customer - plain fields:
     // TODO: Use Customer class!
                     case 'tcustomer':
                         $content_location = "KundenTabelle.csv";
                         $fieldNames = array(
                             'customerid', 'username', 'password', 'prefix', 'company', 'firstname', 'lastname',
                             'address', 'city', 'zip', 'country_id', 'phone', 'fax', 'email',
                             'ccnumber', 'ccdate', 'ccname', 'cvc_code', 'company_note',
                             'is_reseller', 'register_date', 'customer_status', 'group_id', );
                         $query = "
                             SELECT customerid, username, password, prefix, company, firstname, lastname,
                                    address, city, zip, country_id, phone, fax, email,
                                    ccnumber, ccdate, ccname, cvc_code, company_note,
                                    is_reseller, register_date, customer_status,
                                    group_id
                               FROM ".DBPREFIX."module_shop_customers
                              ORDER BY lastname ASC, firstname ASC";
                         break;
                     // customer - custom:
     // TODO: Use Customer class!
                     case 'rcustomer':
                         $content_location = "KundenRelationen.csv";
                         $fieldNames = array(
                             'customerid', 'username', 'firstname', 'lastname', 'prefix', 'company',
                             'address', 'zip', 'city', 'countries_name',
                             'phone', 'fax', 'email', 'is_reseller', 'register_date', 'group_name', );
                         $query = "
                             SELECT c.customerid, c.username, c.firstname, c.lastname, c.prefix, c.company,
                                    c.address, c.zip, c.city, n.countries_name,
                                    c.phone, c.fax, c.email, c.is_reseller, c.register_date,
                                    d.name AS group_name
                               FROM ".DBPREFIX."module_shop_customers c
                              INNER JOIN ".DBPREFIX."module_shop_countries n ON c.country_id=n.countries_id
                               LEFT JOIN ".DBPREFIX."module_shop_customer_group d ON c.group_id=d.id
                              ORDER BY c.lastname ASC, c.firstname ASC";
                         break;
                     // orders - plain fields:
                     case 'torder':
                         $content_location = "BestellungenTabelle.csv";
                         $fieldNames = array(
                             'id', 'customer_id', 'currency_id', 'order_sum', 'sum',
                             'date_time', 'status', 'ship_prefix', 'ship_company', 'ship_firstname', 'ship_lastname',
                             'ship_address', 'ship_city', 'ship_zip', 'ship_country_id', 'ship_phone',
                             'vat_amount', 'currency_ship_price', 'shipment_id', 'payment_id', 'currency_payment_price',
                             'ip', 'host', 'lang_id', 'browser', 'note',
                             'last_modified', 'modified_by');
                         $query = "
                             SELECT id, customer_id, currency_id, order_sum, sum,
                                    date_time, status, ship_prefix, ship_company, ship_firstname, ship_lastname,
                                    ship_address, ship_city, ship_zip, ship_country_id, ship_phone,
                                    vat_amount, currency_ship_price, shipment_id, payment_id, currency_payment_price,
                                    ip, host, lang_id, browser, note,
                                    last_modified, modified_by
                               FROM ".DBPREFIX."module_shop".MODULE_INDEX."_orders
                              ORDER BY id ASC";
                         break;
                     // orders - custom:
                     case 'rorder':
     // TODO: Use Customer class!
                         $content_location = "BestellungenRelationen.csv";
                         $fieldNames = array(
                             'id', 'order_sum', 'vat_amount', 'currency_ship_price', 'currency_payment_price',
                             'sum', 'date_time', 'status', 'ship_prefix', 'ship_company',
                             'ship_firstname', 'ship_lastname', 'ship_address', 'ship_city', 'ship_zip',
                             'ship_phone', 'note',
                             'customer_id', 'username', 'firstname', 'lastname', 'prefix', 'company',
                             'address', 'zip', 'city', 'countries_name',
                             'phone', 'fax', 'email', 'is_reseller', 'register_date',
                             'currency_code', 'shipper_name', 'payment_name',
                             'account_number', 'bank_name', 'bank_code');
                         $query = "
                             SELECT o.id, o.order_sum, o.vat_amount, o.currency_ship_price, o.currency_payment_price,
                                    o.sum, o.date_time, o.status, o.ship_prefix, o.ship_company,
                                    o.ship_firstname, o.ship_lastname, o.ship_address, o.ship_city, o.ship_zip,
                                    o.ship_phone, o.note,
                                    o.customer_id,
                                    c.username, c.firstname, c.lastname, c.prefix, c.company,
                                    c.address, c.zip, c.city, n.countries_name,
                                    c.phone, c.fax, c.email, c.is_reseller, c.register_date,
                                    u.code AS currency_code, s.name AS shipper_name, p.name AS payment_name,
                                    l.holder, l.bank, l.blz
                               FROM ".DBPREFIX."module_shop_orders o
                              INNER JOIN ".DBPREFIX."module_shop_customers c ON o.customer_id=c.customerid
                              INNER JOIN ".DBPREFIX."module_shop_countries n ON c.country_id=n.countries_id
                              INNER JOIN ".DBPREFIX."module_shop_currencies u ON o.currency_id=u.id
                               LEFT JOIN ".DBPREFIX."module_shop_shipper s ON o.shipment_id=s.id
                               LEFT JOIN ".DBPREFIX."module_shop_payment p ON o.payment_id=p.id
                               LEFT JOIN ".DBPREFIX."module_shop_lsv l ON o.id=l.order_id
                              ORDER BY o.id ASC";
                         break;
                 } // switch
     
                 if ($query && $objResult = $objDatabase->Execute($query)) {
                     // field names
                     $fileContent = '"'.join('";"', $fieldNames)."\"\n";
                     while (!$objResult->EOF) {
                         $arrRow = $objResult->FetchRow();
                         $arrReplaced = array();
                         // Decode the pictures
                         foreach ($arrRow as $index => $field) {
                             if ($index == 'picture') {
                                 $arrPictures = Products::get_image_array_from_base64($field);
                                 $field =
                                     'http://'.
                                     $_SERVER['HTTP_HOST'].'/'.
                                     ASCMS_SHOP_IMAGES_WEB_PATH.'/'.
                                     $arrPictures[1]['img'];
                             }
                             $arrReplaced[] = str_replace('"', '""', $field);
                         }
                         $fileContent .= '"'.join('";"', $arrReplaced)."\"\n";
                     }
                     // Test the output for UTF8!
                     if (strtoupper(CONTREXX_CHARSET) == 'UTF-8') {
                         $fileContent = utf8_decode($fileContent);
                     }
     // TODO: Add success message?
                     // set content to filename and -type for download
                     header("Content-Disposition: inline; filename=$content_location");
                     header("Content-Type: text/comma-separated-values");
                     echo($fileContent);
                     exit();
                 }
                 \Message::error($_ARRAYLANG['TXT_SHOP_EXPORT_ERROR']);
             } else {
                 // can't submit without a group selection
             } // if/else group
             // end export
     
             // make sure that language entries exist for all of
             // TXT_SHOP_EXPORT_GROUP_*, TXT_SHOP_EXPORT_GROUP_*_TIP !!
             $arrGroups = array('tproduct', 'rproduct', 'tcustomer', 'rcustomer', 'torder', 'rorder');
             $tipText = '';
             for ($i = 0; $i < count($arrGroups); ++$i) {
                 self::$objTemplate->setCurrentBlock('groupRow');
                 self::$objTemplate->setVariable(array(
                     'SHOP_EXPORT_GROUP' => $_ARRAYLANG['TXT_SHOP_EXPORT_GROUP_'.strtoupper($arrGroups[$i])],
                     'SHOP_EXPORT_GROUP_CODE' => $arrGroups[$i],
                     'SHOP_EXPORT_INDEX' => $i,
                     'CLASS_NAME' => 'row'.($i % 2 + 1),
                 ));
                 self::$objTemplate->parse('groupRow');
                 $tipText .= 'Text['.$i.']=["","'.$_ARRAYLANG['TXT_SHOP_EXPORT_GROUP_'.strtoupper($arrGroups[$i]).'_TIP'].'"];';
             }
     */
 }