function init(&$DIALOG) { global $EDITOR; $DIALOG->title = str_replace('...', '', $DIALOG->langEngine->get('editor', 'emoticon')); $DIALOG->reloadInFrame(); $DIALOG->bodyInclude = WPRO_DIR . 'core/plugins/wproCore_emoticons/dialog.tpl.php'; $DIALOG->headContent->add('<link rel="stylesheet" href="core/plugins/wproCore_emoticons/dialog.css" type="text/css" />'); $DIALOG->headContent->add('<script type="text/javascript" src="core/plugins/wproCore_emoticons/dialog_src.js"></script>'); $DIALOG->template->assign('emoticonDir', $EDITOR->emoticonDir); $DIALOG->template->assign('emoticonURL', $EDITOR->emoticonURL); if (WPRO_EMOTICON_DIR && $EDITOR->emoticonDir != WPRO_EMOTICON_DIR) { // load from custom directory $DIALOG->template->assign('custom', true); require_once WPRO_DIR . 'core/libs/wproFilesystem.class.php'; $fs = new wproFilesystem(); $DIALOG->template->assign('files', $fs->getFilesInDir($EDITOR->emoticonDir, 'name', 'asc', array('.gif', '.png', '.jpg', '.jpeg'))); } else { // load local smilies $emoticonDir = $EDITOR->emoticonDir; $emoticonURL = $EDITOR->emoticonURL; require WPRO_DIR . 'conf/emoticons.inc.php'; $DIALOG->template->assign('emoticons', $emoticons); $DIALOG->template->assign('custom', false); } $DIALOG->options = array(array('type' => 'submit', 'name' => 'ok', 'disabled' => 'disabled', 'value' => $DIALOG->langEngine->get('core', 'insert')), array('onclick' => 'dialog.close()', 'type' => 'button', 'name' => 'close', 'value' => $DIALOG->langEngine->get('core', 'cancel'))); }
$response->addScriptCall('dialog.hideLoadMessage', ''); $response->addScriptCall('hideMessageBox', ''); return $response; } } if ($task == 'next' || $task == 'saveThenNext' || $task == 'previous' || $task == 'saveThenPrevious') { //find next file // delete temp file if (isset($WPRO_SESS->data['imageEditor'][$editorID]['temp'])) { unset($WPRO_SESS->data['imageEditor'][$editorID]['temp']); } if (is_file($directory . $temp)) { $fs->delete($directory . $temp); } if ($task == 'next' || $task == 'saveThenNext') { $files = $fs->getFilesInDir($directory, 'name', 'asc', array('.jpg', '.jpeg', '.gif', '.png'), $dir->filters); } else { $files = $fs->getFilesInDir($directory, 'name', 'desc', array('.jpg', '.jpeg', '.gif', '.png'), $dir->filters); } $newFile = ''; $found = false; if (!count($files)) { $response->addAlert($DIALOG->langEngine->get('wproCore_fileBrowser', 'JSNoFiles')); $response->addScriptCall("dialog.hideLoadMessage", ''); $response->addScriptCall('dialog.close', ''); return $response; } foreach ($files as $f) { $filename = $f['name']; if ($found) { $newFile = $filename;
function displayFolderList($folderId = 0, $folderPath = '', $page = 1, $sortBy = 'name', $sortDir = 'asc', $view = 'default', $highlight = array(), $history = true, &$response, $noError = false) { global $EDITOR, $DIALOG, $WPRO_SESS; // initial var check... if (!$response) { $response = $DIALOG->createAjaxResponse(); } if (!is_string($folderId) && !is_int($folderId) || !is_string($folderPath) || !is_array($highlight)) { $response->addAlert('Datatype error.'); $response->addScriptCall("FB.onFolderNotFound", ""); return $response; } $page = intval($page); if ($page == 0) { $page = 1; } $pageLength = 100; if ($arr = $this->getFolder($folderId, $folderPath, $response, $noError)) { $directory = $arr['directory']; $URL = $arr['URL']; $dir = $arr['dir']; if ($arr['changed']) { $highlight = array(); } $tpl = new wproTemplate(); // if images, should we display thumbnails if ($EDITOR->thumbnails && $dir->type == 'image') { if ($view == 'default') { $view = $EDITOR->defaultImageView; } $thumbnails = $view == 'thumbnails' ? true : false; if ($thumbnails) { $params['sortBy'] = 'name'; $params['sortDir'] = 'asc'; } } else { $thumbnails = false; } // get sort by and sort direction // get and validate sorting /*if (isset ($params['sortBy'])) { $sortBy = $params['sortBy']; } else { $sortBy = 'name'; }*/ if ($sortBy != 'name' && $sortBy != 'type' && $sortBy != 'modified' && $sortBy != 'size') { $sortBy = 'name'; } /*if (isset ($params['sortDir'])) { $sortDir = $params['sortDir']; } else { $sortDir = 'asc'; }*/ if ($sortDir != 'asc' && $sortDir != 'desc') { $sortDir = 'asc'; } $folderSortBy = 'name'; if ($sortBy != 'name') { $folderSortDir = 'asc'; } else { $folderSortDir = $sortDir; } $tpl->assign('sortBy', $sortBy); $tpl->assign('sortDir', $sortDir); //if (isset($params['doHistory'])) { //$DIALOG->template->assign('doHistory', false); //} else { //$DIALOG->template->assign('doHistory', true); //} // build a standard URL base to use with everything. $urlBase = $this->getURLBase($dir->id, $folderPath); // display the file list // what types of files to display? $fileTypes = array(); switch ($dir->type) { case 'image': $fileTypes = $EDITOR->allowedImageExtensions; break; case 'media': $fileTypes = $EDITOR->allowedMediaExtensions; break; case 'document': default: $fileTypes = $EDITOR->allowedDocExtensions; break; } $fs = new wproFilesystem(); if ($dir->type == 'image') { $getDimensions = true; } else { $getDimensions = false; } // get the list of folders and files $files = $fs->getFilesInDir($directory, $sortBy, $sortDir, $fileTypes, $dir->filters, $getDimensions); // if images then we need to build the thumbnails! if ($thumbnails && count($files)) { if (!$this->buildThumbnails($directory, $URL, $files, $urlBase)) { $thumbnails = false; } } // build folders afterwards so that thumbnail folder is included. $folders = $fs->getFoldersInDir($directory, $folderSortBy, $folderSortDir, $dir->filters); $total = count($files) + count($folders); $numPages = ceil($total / $pageLength); // check for selected files and adjust current page if there is only one file selected. if (count($highlight) && $numPages > 1) { // OK, flip through the pages until we find the file. $j = 0; $found = false; $num = count($folders); for ($i = 0; $i < $num; $i++) { if (in_array($folders[$i]['name'], $highlight)) { $j = $i; $found = true; break; } } if (!$found) { $num = count($files); for ($i = 0; $i < $num; $i++) { if (in_array($files[$i]['name'], $highlight)) { $j = $i; break; } } } $page = ceil($j / $pageLength); if ($page == 0) { $page = 1; } } // sanitize current page $page = intval($page); while ($page > $numPages) { $page--; } $start = $page * $pageLength - $pageLength; $end = $start + $pageLength; if ($end > $total) { $end = $total; } $tpl->assign('pageStart', $start); // no at page start $tpl->assign('pageEnd', $end); // no at page end $tpl->assign('pageCurrent', $page); // current page $tpl->assign('pageNumPages', $numPages); // number of pages $tpl->assign('pageLength', $pageLength); // length of each page $tpl->assign('pageTotal', $total); // total no of files $tpl->assign('dir', $dir); $tpl->assign('thumbnails', $thumbnails); $tpl->assign('folders', $folders); $tpl->assign('files', $files); $tpl->assign('folderID', $dir->id); $tpl->assign('folderPath', $folderPath); $tpl->assign('folderURL', $URL); $tpl->assign('sortBy', $sortBy); $tpl->assign('sortDir', $sortDir); $tpl->assign('highlight', $highlight); $tpl->assign('doHistory', false); /* generic assigns */ /*$tpl->assignByRef('EDITOR', $EDITOR); $tpl->assignByRef('langEngine', $EDITOR->langEngine); $tpl->bulkAssign(array( 'themeURL' => $EDITOR->themeFolderURL.$EDITOR->theme.'/', 'editorURL' => $EDITOR->editorURL, 'langURL' => $EDITOR->langFolderURL.$DIALOG->langEngine->actualLang.'/', ));*/ $DIALOG->assignCommonVarsToTemplate($tpl); /* end */ $html = $tpl->fetch(WPRO_DIR . 'core/plugins/wproCore_fileBrowser/tpl/files.tpl.php'); //$response->addAlert($html); // nonce $nonce = md5(uniqid(rand(), true)); $response->addScriptCall("FB.setNonce", $nonce); $WPRO_SESS->addNonce($nonce, time() + 3600); $response->addAssign("folderFrame", "innerHTML", $html); $response->addScriptCall("FB.onLoadFolder", $history); } else { $response->addScriptCall("FB.onFolderNotFound", ""); } return $response; }