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

  • cGuiBackendHelpbox
  • cGuiFileOverview
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiSourceEditor
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the generic file overview class.
  5:  *
  6:  * @package Core
  7:  * @subpackage GUI
  8:  * @author Mischa Holz
  9:  * @copyright four for business AG <www.4fb.de>
 10:  * @license http://www.contenido.org/license/LIZENZ.txt
 11:  * @link http://www.4fb.de
 12:  * @link http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * The class cGuiFileOverview is a cGuiPage displaying files.
 19:  * It is meant to be used but in the left bottom frame.
 20:  * As for now it is used to display HTML, CSS & JS files.
 21:  *
 22:  * <strong>Usage</strong>
 23:  * <code>
 24:  * // path to directory where files to display are located
 25:  * $path = $cfgClient[$client]['tpl']['path'];
 26:  * // basename of file to mark as selected
 27:  * $mark = stripslashes($_REQUEST['file']);
 28:  * // build page to display files
 29:  * $page = new cGuiFileOverview($path, $mark, 'html');
 30:  * // optionally set extension(s) to filter files
 31:  * $page->setFileExtension(array('html', 'tpl'));
 32:  * // render page
 33:  * $page->render();
 34:  * </code>
 35:  *
 36:  * <strong>Directory</strong>
 37:  * Only files in the directory defined by the given path are displayed.
 38:  *
 39:  * <strong>Extension</strong>
 40:  * If set via setFileExtension(array) only files of the given extensions
 41:  * are displayed. By default all extensions are considered.
 42:  *
 43:  * <strong>Order of files</strong>
 44:  * The files to be displayed are sorted alphabetically.
 45:  *
 46:  * <strong>Marking files</strong>
 47:  * When initializing the class the name of a file to mark can be given.
 48:  * This feature is totally optional.
 49:  *
 50:  * <strong>Additional file information</strong>
 51:  * When initializing the class the name of a file information type to
 52:  * display can be given.
 53:  * This feature is totally optional.
 54:  * @todo This feature does not work at the moment.
 55:  *
 56:  * <strong>Template</strong>
 57:  * This class is bound to the template generic_file_overview in a
 58:  * hardcoded manner (template,generic_file_overview.html).
 59:  * @todo This prevents this class to be used with other views.
 60:  *
 61:  * <strong>Editing a file</strong>
 62:  * When editing a file
 63:  * <ul>
 64:  * <li>the right top frame is opened with the URL:
 65:  *      main.php
 66:  *          ?area={AREA}
 67:  *          &frame=3
 68:  *          &file={FILENAME}
 69:  *          &contenido=1
 70:  * <li>whereas the right bottom frame is opened with the URL:
 71:  *      main.php
 72:  *          ?area={AREA}
 73:  *          &frame=4
 74:  *          &action={ACTION}
 75:  *          &file={FILENAME}
 76:  *          &tmp_file={FILENAME}
 77:  *          &contenido=1
 78:  * </ul>
 79:  * AREA & ACTION are filled with the current global values.
 80:  * FILENAME is the name of the current file.
 81:  * @todo Why the parameter contenido is set to 1 is to be clarified.
 82:  * IMHO it should be the current value of the global contenido variable.
 83:  * @todo Why the parameter file and tmp_file are both set is to be clarified.
 84:  *
 85:  * <strong>Deleting a file</strong>
 86:  * A delete icon is provided for each file.
 87:  * When deleting a file
 88:  * <ul>
 89:  * <li>the right bottom frame is opened with the URL:
 90:  *      main.php
 91:  *          ?area={AREA}
 92:  *          &action={ACTION}
 93:  *          &frame=4
 94:  *          &delfile={FILENAME}
 95:  * </ul>
 96:  * @todo Why the parameter contenido is not set is to be clarified.
 97:  * @todo Why the URL is generated via JS is to be clarified.
 98:  *
 99:  * If the effective setting
100:  * client/readonly is "true" or the current user has no privileges for
101:  * the action $area . "_delete" of the current area this icon will be
102:  * inactive though.
103:  * @todo This prevents this class to be used in other areas.
104:  *
105:  * @package Core
106:  * @subpackage GUI
107:  */
108: class cGuiFileOverview extends cGuiPage {
109: 
110:     /**
111:      * Path to the directory directory where files to display are located.
112:      *
113:      * @var string
114:      */
115:     protected $_directory;
116: 
117:     /**
118:      * Basename of file that will be marked as selected.
119:      *
120:      * @var string
121:      */
122:     protected $_markedFile;
123: 
124:     /**
125:      * Type of additional file information that should be displayed as
126:      * description.
127:      *
128:      * @var string
129:      */
130:     protected $_fileInfoType;
131: 
132:     /**
133:      * Selected file extension.
134:      *
135:      * @var string
136:      */
137:     protected $_fileExtension;
138: 
139:     /**
140:      * Constructor to create an instance of this class.
141:      *
142:      * Initializes the class for the directory.
143:      *
144:      * @param string $dir
145:      *        path to the directory directory where files to display are
146:      *        located
147:      * @param string $markedFile [optional]
148:      *        basename of file that will be marked as selected.
149:      * @param string $fileInfoType [optional]
150:      *        type of additional file information that should be
151:      *        displayed as description
152:      */
153:     public function __construct($dir, $markedFile = '', $fileInfoType = '') {
154:         parent::__construct('generic_file_overview');
155: 
156:         // assign properties
157:         $this->_directory = $dir;
158:         $this->_markedFile = $markedFile;
159:         $this->_fileInfoType = $fileInfoType;
160:     }
161: 
162:     /**
163:      * Sets extension(s) to filter files that should be displayed.
164:      *
165:      * @param array|string $extension
166:      *         Name of extensions
167:      */
168:     public function setFileExtension($extension) {
169:         if (cSecurity::isString($extension)) {
170:             $extension = array($extension);
171:         }
172:         $this->_fileExtension = $extension;
173:     }
174: 
175:     /**
176:      * Renders the page
177:      *
178:      * @param cTemplate|null $template
179:      * @param bool $return
180:      */
181:     public function render($template = NULL, $return = false) {
182: 
183:         $cfg = cRegistry::getConfig();
184:         $area = cRegistry::getArea();
185:         $perm = cRegistry::getPerm();
186: 
187:         // create an array of all files in the directory
188:         $files = array();
189:         foreach (new DirectoryIterator($this->_directory) as $file) {
190:             if ($file->isDir()) {
191:                 continue;
192:             }
193:             if (!empty($this->_fileExtension) && !in_array($file->getExtension(), $this->_fileExtension)) {
194:                 continue;
195:             }
196:             $files[] = $file->getBasename();
197:         }
198: 
199:         // sort the files
200:         sort($files);
201: 
202:         // assign variables for the JavaScript
203:         $this->set('s', 'JS_AREA', $area);
204:         $this->set('s', 'JS_ACTION_DELETE', $area . '_delete');
205: 
206:         // assign variables for every file
207:         $fileInfos = new cApiFileInformationCollection();
208:         foreach($files as $file) {
209:             if($this->_fileInfoType != '') {
210:                 $fileInfo = $fileInfos->getFileInformation($file, $this->_fileInfoType);
211:                 $this->set('d', 'DESCRIPTION', $fileInfo['description']);
212:             } else {
213:                 $this->set('d', 'DESCRIPTION', '');
214:             }
215:             $this->set('d', 'AREA', $area);
216:             $this->set('d', 'ACTION', $area . '_edit');
217:             $this->set('d', 'FILENAME', $file);
218:             if($file == $this->_markedFile) {
219:                 $this->set('d', 'MARKED', 'marked');
220:             } else {
221:                 $this->set('d', 'MARKED', '');
222:             }
223:             if(getEffectiveSetting("client", "readonly", "false") == "true" || (!$perm->have_perm_area_action($area, $area . "_delete"))) {
224:                 $this->set('d', 'DELETE_IMAGE', $cfg['path']['images'] . 'delete_inact.gif');
225:             } else {
226:                 $this->set('d', 'DELETE_IMAGE', $cfg['path']['images'] . 'delete.gif');
227:             }
228: 
229:             $this->next();
230:         }
231: 
232:         // call the render method of cGuiPage to display the webpage
233:         parent::render();
234:     }
235: 
236: }
237: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0