function view() { $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/filemanager/assets/styles.css', 'screen', 70); $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $path = DOCROOT . $FileManager->getStartLocation() . (is_array($this->_context) && !empty($this->_context) ? '/' . implode('/', $this->_context) . '/' : NULL); if (is_writable($path)) { // Build file/dir creation menu $create_menu = new XMLElement('ul'); $create_menu->setAttribute('class', 'create-menu'); $li = new XMLElement('li'); $li->appendChild(Widget::Anchor(__('New Directory'), extension_filemanager::baseURL() . 'new/directory/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL), __('New Directory'), 'button create')); $create_menu->appendChild($li); $li = new XMLElement('li'); $li->appendChild(Widget::Anchor(__('New File'), extension_filemanager::baseURL() . 'new/file/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL), __('New File'), 'button create')); $create_menu->appendChild($li); $li = new XMLElement('li'); $li->appendChild(Widget::Anchor(__('Upload File'), extension_filemanager::baseURL() . 'new/upload/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL), __('Upload File'), 'button create')); $create_menu->appendChild($li); } else { $create_menu = new XMLElement('p', __('This directory is not writable')); $create_menu->setAttribute('class', 'create-menu'); } $this->setPageType('table'); $this->appendSubheading(trim($FileManager->getStartLocationLink(), '/') . (is_array($this->_context) ? $FileManager->buildBreadCrumbs($this->_context) : NULL)); $this->Form->appendChild($create_menu); $Iterator = new DirectoryIterator($path); $aTableHead = array(array(__('Name'), 'col'), array(__('Size'), 'col'), array(__('Permissions'), 'col'), array(__('Modified'), 'col'), array(__('Available Actions'), 'col')); $aTableBody = array(); if (iterator_count($Iterator) <= 0) { $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead))))); } else { foreach ($Iterator as $file) { if ($row = $FileManager->buildTableRow($file, $path != DOCROOT . $FileManager->getStartLocation())) { $aTableBody[] = $row; } } } sort($aTableBody); $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody)); $this->Form->appendChild($table); $tableActions = new XMLElement('div'); $tableActions->setAttribute('class', 'actions'); $options = array(array(NULL, false, __('With Selected...')), array('archive', false, __('Archive')), array('delete', false, __('Delete'))); $tableActions->appendChild(Widget::Select('with-selected', $options)); $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit')); $this->Form->appendChild($tableActions); }
function action() { switch ($_POST['type']) { case 'upload': $this->__actionUpload(); array_shift($this->_context); redirect(extension_filemanager::baseURL() . 'browse/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL)); break; case 'file': $this->__actionFile(); array_shift($this->_context); redirect(extension_filemanager::baseURL() . 'browse/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL)); break; case 'directory': $this->__actionDirectory(); array_shift($this->_context); redirect(extension_filemanager::baseURL() . 'browse/' . (is_array($this->_context) && !empty($this->_context) ? implode('/', $this->_context) . '/' : NULL) . '/' . $_POST['fields']['directory']['name']); break; } /* if(isset($_POST['action']['save'])){ $fields = $_POST['fields']; $file->setName($fields['name']); if(isset($fields['contents'])) $file->setContents($fields['contents']); $file->setPermissions($fields['permissions']); $relpath = str_replace(DOCROOT . $FileManager->getStartLocation(), NULL, dirname($_GET['file'])); if($file->isWritable()) redirect($FileManager->baseURL() . 'properties/?file=' . rtrim(dirname($_GET['file']), '/') . '/' . $file->name()); else redirect($FileManager->baseURL() . 'browse/' . $relpath); }*/ }
function view() { $this->Form->setAttribute('action', extension_filemanager::baseURL() . 'properties/?file=' . $_GET['file']); $file = new File(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file']); $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR); } if (isset($_GET['result'])) { switch ($_GET['result']) { case 'saved': $this->pageAlert(__('%s updated successfully', array($file->isDir() ? 'Folder' : 'File')), Alert::SUCCESS); break; } } $this->setPageType('form'); $path = extension_filemanager::baseURL() . 'browse/'; $breadcrumb = ''; $pathelements = explode('/', $_GET['file']); foreach ($pathelements as $element) { if ($element != '') { $path .= $element . '/'; $breadcrumb .= ' / ' . ($element == end($pathelements) ? $element : Widget::Anchor($element, $path)->generate()); } } $this->appendSubheading(trim($FileManager->getStartLocationLink(), '/') . $breadcrumb); $fields = array(); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Essentials')); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('fields[name]', General::sanitize($file->name()))); if (isset($this->_errors['name'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $div->appendChild($label); } $label = Widget::Label('Permissions'); $label->appendChild(Widget::Input('fields[permissions]', General::sanitize($file->permissions()))); if (isset($this->_errors['permissions'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['permissions'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $this->Form->appendChild($fieldset); if (!$file->isDir() && in_array(File::fileType($file->name()), array(File::CODE, File::DOC))) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Editor')); $label = Widget::Label('Contents'); $label->appendChild(Widget::Textarea('fields[contents]', '25', '50', General::sanitize($file->contents()), array('class' => 'code'))); if (isset($this->_errors['contents'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['contents'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); } if (!$file->isDir() && File::fileType($file->name()) == File::IMAGE) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Preview')); $img = new XMLElement('img'); $img->setAttribute('src', URL . $FileManager->getStartLocation() . $_GET['file']); $img->setAttribute('alt', $file->name()); $fieldset->appendChild($img); $this->Form->appendChild($fieldset); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); if (is_writeable(DOCROOT . $this->_FileManager->getStartLocation() . $_GET['file'])) { $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's'))); $button = new XMLElement('button', 'Delete'); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => 'Delete this ' . ($file->isDir() ? 'Folder' : 'File'))); $div->appendChild($button); } else { $notice = new XMLElement('p', 'The server does not have permission to edit this file.'); $notice->setAttribute('class', 'inactive'); $div->appendChild($notice); } $this->Form->appendChild($div); }