Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the backend page for displaying files of a directory in upload section.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       Backend
  8:  * @version          SVN Revision $Rev:$
  9:  *
 10:  * @author           Timo Hummel
 11:  * @copyright        four for business AG <www.4fb.de>
 12:  * @license          http://www.contenido.org/license/LIZENZ.txt
 13:  * @link             http://www.4fb.de
 14:  * @link             http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 18: 
 19: $backendPath = cRegistry::getBackendPath();
 20: 
 21: cInclude('includes', 'api/functions.frontend.list.php');
 22: cInclude('includes', 'functions.file.php');
 23: cInclude('classes', 'class.cziparchive.php');
 24: 
 25: //cInclude('includes', 'class.ziparchive.php');
 26: 
 27: if (!(int) $client > 0) {
 28:     // if there is no client selected, display empty page
 29:     $oPage = new cGuiPage('upl_files_overview');
 30:     $oPage->render();
 31:     return;
 32: }
 33: 
 34: $page = new cGuiPage('upl_files_overview', '', 0);
 35: 
 36: $appendparameters = $_REQUEST['appendparameters'];
 37: $file = $_REQUEST['file'];
 38: 
 39: if (!is_array($browserparameters) && ($appendparameters != 'imagebrowser' || $appendparameters != 'filebrowser')) {
 40:     $browserparameters = array();
 41: }
 42: 
 43: if (!$sess->isRegistered('upl_last_path')) {
 44:     // register last path (upl_last_path) in session
 45:     $sess->register('upl_last_path');
 46: } elseif (!isset($path)) {
 47:     // if no path is given the last path is used
 48:     $path = $upl_last_path;
 49: }
 50: // if path doesn't exist use root path
 51: // this might happen when the last path is that of another client or deleted outside CONTENIDO
 52: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]['upl']['path'] . $path)) {
 53:     $path = '';
 54: }
 55: // remember current path as last path
 56: $upl_last_path = $path;
 57: 
 58: $uploads = new cApiUploadCollection();
 59: 
 60: $dbfs = new cApiDbfsCollection();
 61: 
 62: if (cApiDbfs::isDbfs($path)) {
 63:     $qpath = $path . '/';
 64: } else {
 65:     $qpath = $path;
 66: }
 67: 
 68: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
 69:     $bDirectoryIsWritable = true;
 70: } else {
 71:     $bDirectoryIsWritable = false;
 72: }
 73: 
 74: 
 75: if ($action == 'upl_modify_file') {
 76: 
 77:     $extractFolder = NULL;
 78:     $uplPath = $cfgClient[$client]['upl']['path'];
 79: 
 80:     if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
 81:         $uplPath .= $_REQUEST['path'];
 82:     }
 83: 
 84:     if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL) {
 85:         $extractFolder = $_REQUEST['efolder'];
 86:     }
 87: 
 88:     if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
 89:         $zipFile = $uplPath . $_REQUEST['file'];
 90:         cZipArchive::extract($zipFile, $uplPath, $extractFolder);
 91:     }
 92:     if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
 93:         $zipFile = $uplPath . $_REQUEST['file'];
 94:         cZipArchive::extractOverRide($zipFile, $uplPath, $extractFolder);
 95:     }
 96:     // Did the user upload a new file?
 97:     if ($bDirectoryIsWritable == true && count($_FILES) == 1 && ($_FILES['file']['size'] > 0) && ($_FILES['file']['name'] != '')) {
 98:         if ($_FILES['file']['tmp_name'] != '') {
 99:             $tmp_name = $_FILES['file']['tmp_name'];
100:             $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
101: 
102:             if ($_cecIterator->count() > 0) {
103:                 // Copy file to a temporary location
104:                 move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $file);
105:                 $tmp_name = $backendPath . $cfg['path']['temp'] . $file;
106: 
107:                 while ($chainEntry = $_cecIterator->next()) {
108:                     if (cApiDbfs::isDbfs($path)) {
109:                         $sPathPrepend = '';
110:                         $sPathApppend = '/';
111:                     } else {
112:                         $sPathPrepend = $cfgClient[$client]['upl']['path'];
113:                         $sPathApppend = '';
114:                     }
115: 
116:                     $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name']));
117: 
118:                     if ($modified !== false) {
119:                         $tmp_name = $modified;
120:                     }
121:                 }
122:             }
123: 
124:             if (cApiDbfs::isDbfs($path)) {
125:                 $dbfs->writeFromFile($tmp_name, $qpath . $file);
126:                 unlink($_FILES['file']['tmp_name']);
127:             } else {
128:                 unlink($cfgClient[$client]['upl']['path'] . $path . $file);
129: 
130:                 if (is_uploaded_file($tmp_name)) {
131:                     move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
132:                 } else {
133:                     rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
134:                 }
135:             }
136:         }
137:     }
138: 
139:     $uploads->select("idclient = '$client' AND dirname = '$qpath' AND filename='$file'");
140:     $upload = $uploads->next();
141: 
142:     // $upload->set('description', stripslashes($description));
143:     $upload->store();
144: 
145:     $properties = new cApiPropertyCollection();
146:     $properties->setValue('upload', $qpath . $file, 'file', 'protected', stripslashes($protected));
147: 
148:     $bTimeMng = (isset($_REQUEST['timemgmt']) && strlen($_REQUEST['timemgmt']) > 1);
149:     $properties->setValue('upload', $qpath . $file, 'file', 'timemgmt', ($bTimeMng) ? 1 : 0);
150:     if ($bTimeMng) {
151:         $properties->setValue('upload', $qpath . $file, 'file', 'datestart', $_REQUEST['datestart']);
152:         $properties->setValue('upload', $qpath . $file, 'file', 'dateend', $_REQUEST['dateend']);
153:     }
154: 
155:     $author = $auth->auth['uid'];
156:     $created = date('Y-m-d H:i:s');
157: 
158:     $iIdupl = $upload->get('idupl');
159:     if (!empty($iIdupl) && $iIdupl > 0) {
160:         // check for new entry:
161:         $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
162:         if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
163:             // Update existing entry
164:             $oUploadMeta->set('medianame', $medianame);
165:             $oUploadMeta->set('description', $description);
166:             $oUploadMeta->set('keywords', $keywords);
167:             $oUploadMeta->set('internal_notice', $medianotes);
168:             $oUploadMeta->set('copyright', $copyright);
169:             $oUploadMeta->set('modified', $created);
170:             $oUploadMeta->set('modifiedby', $author);
171:             $oUploadMeta->store();
172:         } else {
173:             // Create new entry
174:             $oUploadMetaColl = new cApiUploadMetaCollection();
175:             $oUploadMeta = $oUploadMetaColl->create($iIdupl, $lang, $medianame, $description, $keywords, $medianotes, $copyright, $author, $created, $created, $author);
176:         }
177:     }
178: }
179: 
180: if ($action == 'upl_multidelete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
181:     if (is_array($fdelete)) {
182:         // array of cApiUpload objects to be passed to chain function
183:         $uploadObjects = array();
184: 
185:         // Check if it is in the upload table
186:         foreach ($fdelete as $file) {
187:             $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
188:             if (false !== $item = $uploads->next()) {
189:                 if (cApiDbfs::isDbfs($qpath)) {
190:                     $dbfs->remove($qpath . $file);
191: 
192:                     // call chain once for each deleted file
193:                     $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
194:                     if ($_cecIterator->count() > 0) {
195:                         while (false !== $chainEntry = $_cecIterator->next()) {
196:                             $chainEntry->execute($item->get('idupl'), $qpath, $file);
197:                         }
198:                     }
199:                 } else {
200:                     $uploads->delete($item->get('idupl'));
201:                 }
202: 
203:                 // add current upload object to array in order to be processed
204:                 array_push($uploadObjects, $item);
205:             }
206:         }
207: 
208:         // call chain once for all deleted files
209:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
210:         if ($_cecIterator->count() > 0) {
211:             while (false !== $chainEntry = $_cecIterator->next()) {
212:                 $chainEntry->execute($uploadObjects);
213:             }
214:         }
215:     }
216: }
217: 
218: if ($action == 'upl_delete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
219:     // array of cApiUpload objects to be passed to chain function
220:     $uploadObjects = array();
221: 
222:     $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
223:     // FIXME Code is similar/redundant to cApiUploadCollection->delete(), in
224:     // previous version from UploadCollection->delete() too
225:     if (false !== $item = $uploads->next()) {
226:         if (cApiDbfs::isDbfs($qpath)) {
227:             $dbfs->remove($qpath . $file);
228:         } else {
229:             unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
230:         }
231: 
232:         // call chain for deleted file
233:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
234:         if ($_cecIterator->count() > 0) {
235:             while (false !== $chainEntry = $_cecIterator->next()) {
236:                 $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
237: 
238:                 // add current upload object to array in order to be processed
239:                 array_push($uploadObjects, $item);
240:             }
241:         }
242: 
243:         // call chain once for all deleted files
244:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
245:         if ($_cecIterator->count() > 0) {
246:             while (false !== $chainEntry = $_cecIterator->next()) {
247:                 $chainEntry->execute($uploadObjects);
248:             }
249:         }
250:     }
251: }
252: 
253: if ($action == 'upl_upload' && $bDirectoryIsWritable == true) {
254:     if ($perm->have_perm_area_action($area, 'upl_upload')) {
255:         if (count($_FILES) == 1) {
256:             foreach ($_FILES['file']['name'] as $key => $value) {
257:                 if (cString::isUtf8($_FILES['file']['name'][$key])) {
258:                     $_FILES['file']['name'][$key] = utf8_decode($_FILES['file']['name'][$key]);
259:                 }
260:                 if ($_FILES['file']['tmp_name'][$key] != '') {
261:                     $tmp_name = $_FILES['file']['tmp_name'][$key];
262:                     $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
263: 
264:                     if ($_cecIterator->count() > 0) {
265:                         // Copy file to a temporary location
266:                         move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key]);
267:                         $tmp_name = $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key];
268: 
269:                         while ($chainEntry = $_cecIterator->next()) {
270:                             if (cApiDbfs::isDbfs($path)) {
271:                                 $sPathPrepend = '';
272:                                 $sPathApppend = '/';
273:                             } else {
274:                                 $sPathPrepend = $cfgClient[$client]['upl']['path'];
275:                                 $sPathApppend = '';
276:                             }
277: 
278:                             $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
279:                             if ($modified !== false) {
280:                                 $tmp_name = $modified;
281:                             }
282:                         }
283:                     }
284: 
285:                     if (cApiDbfs::isDbfs($qpath)) {
286:                         $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
287:                         unlink($tmp_name);
288:                     } else {
289:                         if (is_uploaded_file($tmp_name)) {
290:                             $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
291: 
292:                             move_uploaded_file($tmp_name, $final_filename);
293: 
294:                             $iterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPostprocess');
295:                             while ($chainEntry = $iterator->next()) {
296:                                 $chainEntry->execute($final_filename);
297:                             }
298:                         } else {
299:                             rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
300:                         }
301:                     }
302:                 }
303:             }
304:         }
305:     } else {
306:         $page->displayError(i18n("Permission denied"));
307:         $page->render();
308:         die();
309:     }
310: }
311: 
312: if ($action == 'upl_renamefile' && $bDirectoryIsWritable == true) {
313:     $newname = str_replace('/', '', $newname);
314:     rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
315: }
316: 
317: /**
318:  *
319:  * @author marcus.gnass
320:  */
321: class UploadList extends FrontendList {
322: 
323:     /**
324:      *
325:      * @var unknown_type
326:      */
327:     var $dark;
328: 
329:     /**
330:      *
331:      * @var unknown_type
332:      */
333:     var $size;
334: 
335:     /**
336:      * Field converting facility.
337:      *
338:      * @see FrontendList::convert()
339:      * @param int $field
340:      *         Field index
341:      * @param mixed $value
342:      *         Field value
343:      * @return mixed
344:      */
345:     function convert($field, $data) {
346:         global $cfg, $path, $sess, $cfgClient, $client, $appendparameters;
347: 
348:         $backendUrl = cRegistry::getBackendUrl();
349: 
350:         if ($field == 4) {
351:             return humanReadableSize($data);
352:         }
353: 
354:         if ($field == 3) {
355:             if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
356:                 // fix for IE11 popup:
357:                 // selecting link with tiny out of popup does not work with Con.getFrame in IE11
358:                 // reverting to the old call solves this problem
359:                 if (cApiDbfs::isDbfs($path . '/' . $data)) {
360:                     $mstr = '<a href="javascript://" onclick="parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.close();"><img alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $data . '</a>';
361:                 } else {
362:                     $mstr = '<a href="javascript://" onclick="parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]['upl']['frontendpath'] . $path . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]['upl']['frontendpath'] . $path . $data . '\'; window.close();"><img alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $data . '</a>';
363:                 }
364:             } else {
365:                 $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
366:                 $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$data&appendparameters=$appendparameters&startpage=" . $_REQUEST['startpage'] . "&sortby=" . $_REQUEST['sortby'] . "&sortmode=" . $_REQUEST['sortmode'] . "&thumbnailmode=" . $_REQUEST['thumbnailmode']), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$data"), $data);
367:             }
368:             return $mstr;
369:         }
370: 
371:         if ($field == 5) {
372:             return uplGetFileTypeDescription($data);
373:         }
374: 
375:         if ($field == 2) {
376:             // If this file is an image, try to open
377:             $fileType = strtolower(cFileHandler::getExtension($data));
378:             switch ($fileType) {
379:                 case 'png':
380:                 case 'gif':
381:                 case 'tiff':
382:                 case 'bmp':
383:                 case 'jpeg':
384:                 case 'jpg':
385:                 case 'iff':
386:                 case 'xbm':
387:                 case 'wbmp':
388:                     $frontendURL = cRegistry::getFrontendUrl();
389: 
390:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
391:                     $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, '/') + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
392:                     $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
393:                     if (cFileHandler::exists($sFullPath)) {
394:                         $aDimensions = getimagesize($sFullPath);
395:                         $iWidth = $aDimensions[0];
396:                         $iHeight = $aDimensions[1];
397:                     } else {
398:                         $iWidth = 0;
399:                         $iHeight = 0;
400:                     }
401: 
402:                     if (cApiDbfs::isDbfs($data)) {
403:                         $href = $frontendURL . 'dbfs.php?file=' . $data;
404:                     } else {
405:                         $href = $frontendURL . $cfgClient[$client]['upload'] . $data;
406:                     }
407:                     $retValue = '<a class="jsZoom" href="' . $href . '">
408:                            <img class="hover" name="smallImage" alt="" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
409:                            <img class="preview" name="prevImage" alt="" src="' . $sCacheThumbnail . '">
410:                        </a>';
411:                     return $retValue;
412:                     break;
413:                 default:
414:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
415:                     return '<img class="hover_none" name="smallImage" alt="" src="' . $sCacheThumbnail . '">';
416:             }
417:         }
418: 
419:         return $data;
420:     }
421: 
422: }
423: 
424: uplSyncDirectory($path);
425: 
426: if ($sortby == '') {
427:     $sortby = 3;
428:     $sortmode = 'ASC';
429: }
430: 
431: if ($startpage == '') {
432:     $startpage = 1;
433: }
434: 
435: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
436: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
437: 
438: if ($sortby == 3 && $sortmode == 'DESC') {
439:     $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
440: } else {
441:     if ($sortby == 3) {
442:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
443:     } else {
444:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
445:     }
446: }
447: 
448: if ($sortby == 4 && $sortmode == 'DESC') {
449:     $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
450: } else {
451:     if ($sortby == 4) {
452:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
453:     } else {
454:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
455:     }
456: }
457: 
458: if ($sortby == 5 && $sortmode == 'DESC') {
459:     $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
460: } else {
461:     if ($sortby == 5) {
462:         $typesort = '<a class="gray" class="gray" href="' . $thisfile . '&sortby=5&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
463:     } else {
464:         $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
465:     }
466: }
467: 
468: // Multiple deletes at top of table
469: if ($perm->have_perm_area_action('upl', 'upl_multidelete') && $bDirectoryIsWritable == true) {
470:     $sConfirmation = "Con.showConfirmation('" . i18n('Are you sure you want to delete the selected files?') . "', function() { document.del.action.value = \'upl_multidelete\'; document.del.submit(); });return false;";
471:     $sDelete = '<a class="tableElement vAlignMiddle" href="javascript:void(0)" onclick="' . $sConfirmation . '"><img class="tableElement vAlignMiddle" src="images/delete.gif" title="' . i18n("Delete selected files") . '" alt="' . i18n("Delete selected files") . '" onmouseover="this.style.cursor=\'pointer\'"><span class="tableElement">' . i18n("Delete selected files") . '</span></a>';
472: } else {
473:     $sDelete = '';
474: }
475: 
476: if (cApiDbfs::isDbfs($path)) {
477:     $mpath = $path . '/';
478: } else {
479:     $mpath = 'upload/' . $path;
480: }
481: 
482: $sDisplayPath = generateDisplayFilePath($mpath, 85);
483: 
484: $sToolsRow = '<tr>
485:                <th colspan="6" id="cat_navbar">
486:                    <a class="tableElement vAlignMiddle" href="javascript:invertSelection();"><img class="tableElement vAlignMiddle" src="images/but_invert_selection.gif" title="' . i18n("Flip Selection") . '" alt="' . i18n("Flip Selection") . '" onmouseover="this.style.cursor=\'pointer\'"> ' . i18n("Flip Selection") . '</a>
487:                        ' . $sDelete . '
488:                    <div class="toolsRight">
489:                    ' . i18n("Path:") . " " . $sDisplayPath . '
490:                    </div>
491:                </th>
492:            </tr>';
493: $sSpacedRow = '<tr height="10">
494:                    <td colspan="6" class="emptyCell"></td>
495:               </tr>';
496: 
497: // List wraps
498: 
499: $pagerwrap = '<tr>
500:                <th colspan="6" id="cat_navbar">
501:                    <div class="toolsRight">
502:                        <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
503:                        <div class="vAlignMiddle">-C-PAGE-</div>
504:                        <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
505:                    </div>
506:                    <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
507:                </th>
508:            </tr>';
509: 
510: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
511:                ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
512:               <tr>
513:                    <th>' . i18n("Mark") . '</th>
514:                    <th>' . i18n("Preview") . '</th>
515:                    <th width="100%">' . $fnsort . '</th>
516:                    <th>' . $sizesort . '</th>
517:                    <th>' . $typesort . '</th>
518:                    <th>' . i18n("Actions") . '</th>
519:                </tr>';
520: $itemwrap = '<tr>
521:                    <td align="center">%s</td>
522:                    <td align="center">%s</td>
523:                    <td class="vAlignTop nowrap">%s</td>
524:                    <td class="vAlignTop nowrap">%s</td>
525:                    <td class="vAlignTop nowrap">%s</td>
526:                    <td class="vAlignTop nowrap">%s</td>
527:                </tr>';
528: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
529: 
530: // Object initializing
531: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
532: 
533: $uploads = new cApiUploadCollection();
534: 
535: // Fetch data
536: if (substr($path, strlen($path) - 1, 1) != "/") {
537:     if ($path != "") {
538:         $qpath = $path . "/";
539:     } else {
540:         // view the root folder
541:         $qpath = "";
542:     }
543: } else {
544:     $qpath = $path;
545: }
546: 
547: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
548: 
549: $user = new cApiUser($auth->auth['uid']);
550: 
551: if ($thumbnailmode == '') {
552:     $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
553:     if ($current_mode != '') {
554:         $thumbnailmode = $current_mode;
555:     } else {
556:         $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
557:     }
558: }
559: 
560: switch ($thumbnailmode) {
561:     case 10:
562:         $numpics = 10;
563:         break;
564:     case 25:
565:         $numpics = 25;
566:         break;
567:     case 50:
568:         $numpics = 50;
569:         break;
570:     case 100:
571:         $numpics = 100;
572:         break;
573:     case 200:
574:         $numpics = 200;
575:         break;
576:     default:
577:         $thumbnailmode = 100;
578:         $numpics = 15;
579:         break;
580: }
581: 
582: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
583: 
584: $list2->setResultsPerPage($numpics);
585: 
586: $list2->size = $thumbnailmode;
587: 
588: $rownum = 0;
589: 
590: $properties = new cApiPropertyCollection();
591: 
592: while ($item = $uploads->next()) {
593: 
594:     // Get name of directory, filename and size of file
595:     $dirname = $item->get('dirname');
596:     $filename = $item->get('filename');
597:     $filesize = $item->get('size');
598: 
599:     // Do not display directories and "filenames" begin with a dot
600:     if (true === cDirHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename) || strpos($filename, ".") === 0) {
601:         continue;
602:     }
603: 
604:     $bAddFile = true;
605: 
606:     if ($appendparameters == 'imagebrowser') {
607:         $restrictvar = 'restrict_' . $appendparameters;
608:         if (array_key_exists($restrictvar, $browserparameters)) {
609:             $fileType = strtolower(cFileHandler::getExtension($filename));
610:             if (count($browserparameters[$restrictvar]) > 0) {
611:                 $bAddFile = false;
612:                 if (in_array($fileType, $browserparameters[$restrictvar])) {
613:                     $bAddFile = true;
614:                 }
615:             }
616:         }
617:     }
618: 
619:     if ($filesize == 0) {
620:         if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename)) {
621:             $filesize = filesize($cfgClient[$client]['upl']['path'] . $dirname . $filename);
622:         }
623:     }
624: 
625:     $actions = '';
626: 
627:     $medianame = $properties->getValue('upload', $path . $filename, 'file', 'medianame');
628:     $medianotes = $properties->getValue('upload', $path . $filename, 'file', 'medianotes');
629: 
630:     $todo = new TODOLink('upload', $path . $filename, "File $path$filename", '');
631: 
632:     $proptitle = i18n("Display properties");
633: 
634:     if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
635:         $mstr = '';
636:     } else {
637:         $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
638:         $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$filename&startpage=$startpage&sortby=$sortby&sortmode=$sortmode&thumbnailmode=$thumbnailmode"), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$filename"), '<img class="vAlignMiddle tableElement" alt="' . $proptitle . '" title="' . $proptitle . '" src="images/but_art_conf2.gif" onmouseover="this.style.cursor=\'pointer\'">');
639:     }
640: 
641:     $actions = $mstr . $actions;
642: 
643:     $showfilename = $filename;
644: 
645:     $check = new cHTMLCheckbox('fdelete[]', $filename);
646: 
647:     $mark = $check->toHTML(false);
648: 
649:     if ($bAddFile == true) {
650:         // 'bgcolor' is just a placeholder...
651:         $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(cFileHandler::getExtension($filename)), $todo->render() . $actions);
652:         $rownum++;
653:     }
654: }
655: 
656: if ($rownum == 0) {
657:     header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
658: }
659: 
660: if ($sortmode == 'ASC') {
661:     $list2->sort($sortby, SORT_ASC);
662: } else {
663:     $list2->sort($sortby, SORT_DESC);
664: }
665: 
666: if ($startpage < 1) {
667:     $startpage = 1;
668: }
669: 
670: if ($startpage > $list2->getNumPages()) {
671:     $startpage = $list2->getNumPages();
672: }
673: 
674: $list2->setListStart($startpage);
675: 
676: // Create scroller
677: if ($list2->getCurrentPage() > 1) {
678:     $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
679: } else {
680:     $prevpage = '&nbsp;';
681: }
682: 
683: if ($list2->getCurrentPage() < $list2->getNumPages()) {
684:     $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
685: } else {
686:     $nextpage = '&nbsp;';
687: }
688: 
689: // curpage = $list2->getCurrentPage() . " / ". $list2->getNumPages();
690: 
691: if ($list2->getNumPages() > 1) {
692:     $num_pages = $list2->getNumPages();
693: 
694:     $paging_form .= "<script type=\"text/javascript\">
695:        function jumpToPage(select) {
696:            var pagenumber = select.selectedIndex + 1;
697:            url = '" . $sess->url('main.php') . "';
698:            document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
699:        }
700:    </script>";
701:     $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
702:     for ($i = 1; $i <= $num_pages; $i++) {
703:         if ($i == $startpage) {
704:             $selected = ' selected';
705:         } else {
706:             $selected = '';
707:         }
708:         $paging_form .= "<option value=\"$i\"$selected>$i</option>";
709:     }
710: 
711:     $paging_form .= '</select>';
712: } else {
713:     $paging_form = '1';
714: }
715: $curpage = $paging_form . ' / ' . $list2->getNumPages();
716: 
717: $scroller = $prevpage . $nextpage;
718: $output = $list2->output(true);
719: $output = str_replace('-C-SCROLLLEFT-', $prevpage, $output);
720: $output = str_replace('-C-SCROLLRIGHT-', $nextpage, $output);
721: $output = str_replace('-C-PAGE-', i18n("Page") . ' ' . $curpage, $output);
722: 
723: $select = new cHTMLSelectElement('thumbnailmode');
724: 
725: $values = array(
726:     10 => '10',
727:     25 => '25',
728:     50 => '50',
729:     100 => '100',
730:     200 => '200'
731: );
732: 
733: $select->autoFill($values);
734: 
735: $select->setDefault($thumbnailmode);
736: $select->setEvent('change', "if (document.del.thumbnailmode[0] != 'undefined') document.del.thumbnailmode[0].value = this.value; if (document.del.thumbnailmode[1] != 'undefined') document.del.thumbnailmode[1].value = this.value; if (document.del.thumbnailmode[2] != 'undefined') document.del.thumbnailmode[2].value = this.value;");
737: 
738: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
739: 
740: $output = str_replace('-C-FILESPERPAGE-', $topbar, $output);
741: 
742: $delform = new cHTMLForm('del');
743: $delform->setVar('area', $area);
744: $delform->setVar('action', '');
745: $delform->setVar('startpage', $startpage);
746: $delform->setVar('thumbnailmode', $thumbnailmode);
747: $delform->setVar('sortmode', $sortmode);
748: $delform->setVar('sortby', $sortby);
749: $delform->setVar('appendparameters', $appendparameters);
750: $delform->setVar('path', $path);
751: $delform->setVar('frame', 4);
752: // Table with (preview) images
753: $delform->appendContent($output);
754: 
755: $page->addScript($sess->url('iZoom.js.php'));
756: 
757: if ($bDirectoryIsWritable == false) {
758:     $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
759: }
760: 
761: $page->setContent(array(
762:     $delform,
763:     $jsScript
764: ));
765: 
766: $page->render();
767: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0