当前位置: 首页>>代码示例>>PHP>>正文


PHP MoodleQuickForm::getElementType方法代码示例

本文整理汇总了PHP中MoodleQuickForm::getElementType方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::getElementType方法的具体用法?PHP MoodleQuickForm::getElementType怎么用?PHP MoodleQuickForm::getElementType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoodleQuickForm的用法示例。


在下文中一共展示了MoodleQuickForm::getElementType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * Internal method. Validates all old-style uploaded files.
  */
 function _validate_files(&$files)
 {
     global $CFG, $COURSE;
     $files = array();
     if (empty($_FILES)) {
         // we do not need to do any checks because no files were submitted
         // note: server side rules do not work for files - use custom verification in validate() instead
         return true;
     }
     $errors = array();
     $filenames = array();
     // now check that we really want each file
     foreach ($_FILES as $elname => $file) {
         $required = $this->_form->isElementRequired($elname);
         if ($file['error'] == 4 and $file['size'] == 0) {
             if ($required) {
                 $errors[$elname] = get_string('required');
             }
             unset($_FILES[$elname]);
             continue;
         }
         if (!empty($file['error'])) {
             $errors[$elname] = file_get_upload_error($file['error']);
             unset($_FILES[$elname]);
             continue;
         }
         if (!is_uploaded_file($file['tmp_name'])) {
             // TODO: improve error message
             $errors[$elname] = get_string('error');
             unset($_FILES[$elname]);
             continue;
         }
         if (!$this->_form->elementExists($elname) or !$this->_form->getElementType($elname) == 'file') {
             // hmm, this file was not requested
             unset($_FILES[$elname]);
             continue;
         }
         /*
           // TODO: rethink the file scanning
                     if ($CFG->runclamonupload) {
                         if (!clam_scan_moodle_file($_FILES[$elname], $COURSE)) {
                             $errors[$elname] = $_FILES[$elname]['uploadlog'];
                             unset($_FILES[$elname]);
                             continue;
                         }
                     }
         */
         $filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
         if ($filename === '') {
             // TODO: improve error message - wrong chars
             $errors[$elname] = get_string('error');
             unset($_FILES[$elname]);
             continue;
         }
         if (in_array($filename, $filenames)) {
             // TODO: improve error message - duplicate name
             $errors[$elname] = get_string('error');
             unset($_FILES[$elname]);
             continue;
         }
         $filenames[] = $filename;
         $_FILES[$elname]['name'] = $filename;
         $files[$elname] = $_FILES[$elname]['tmp_name'];
     }
     // return errors if found
     if (count($errors) == 0) {
         return true;
     } else {
         $files = array();
         return $errors;
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:75,代码来源:formslib.php


注:本文中的MoodleQuickForm::getElementType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。