[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Class for exporting user_evidence data. 19 * 20 * @package core_competency 21 * @copyright 2015 Frédéric Massart - FMCorz.net 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace core_competency\external; 25 26 use moodle_url; 27 use renderer_base; 28 29 /** 30 * Class for exporting user_evidence data. 31 * 32 * @package core_competency 33 * @copyright 2015 Frédéric Massart - FMCorz.net 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class user_evidence_exporter extends persistent_exporter { 37 38 protected static function define_class() { 39 return 'core_competency\\user_evidence'; 40 } 41 42 protected static function define_other_properties() { 43 return array( 44 'canmanage' => array( 45 'type' => PARAM_BOOL 46 ), 47 'competencycount' => array( 48 'type' => PARAM_INT 49 ), 50 'competencies' => array( 51 'type' => competency_exporter::read_properties_definition(), 52 'multiple' => true 53 ), 54 'filecount' => array( 55 'type' => PARAM_INT 56 ), 57 'files' => array( 58 'type' => stored_file_exporter::read_properties_definition(), 59 'multiple' => true 60 ), 61 'hasurlorfiles' => array( 62 'type' => PARAM_BOOL 63 ), 64 'urlshort' => array( 65 'type' => PARAM_TEXT 66 ), 67 ); 68 } 69 70 protected static function define_related() { 71 return array( 72 'context' => 'context', 73 'competencies' => 'core_competency\\competency[]' 74 ); 75 } 76 77 protected function get_other_values(renderer_base $output) { 78 $contextcache = array(); 79 80 $competencies = array(); 81 foreach ($this->related['competencies'] as $competency) { 82 if (!isset($contextcache[$competency->get_competencyframeworkid()])) { 83 $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context(); 84 } 85 $context = $contextcache[$competency->get_competencyframeworkid()]; 86 87 $compexporter = new competency_exporter($competency, array('context' => $context)); 88 $competencies[] = $compexporter->export($output); 89 } 90 91 $urlshort = ''; 92 $url = $this->persistent->get_url(); 93 if (!empty($url)) { 94 $murl = new moodle_url($url); 95 $shorturl = preg_replace('@^https?://(www\.)?@', '', $murl->out(false)); 96 $urlshort = shorten_text($shorturl, 30, true); 97 } 98 99 $files = array(); 100 $storedfiles = $this->persistent->get_files(); 101 if (!empty($storedfiles)) { 102 foreach ($storedfiles as $storedfile) { 103 $fileexporter = new stored_file_exporter($storedfile, array('context' => $this->related['context'])); 104 $files[] = $fileexporter->export($output); 105 } 106 } 107 108 $values = array( 109 'canmanage' => $this->persistent->can_manage(), 110 'competencycount' => count($competencies), 111 'competencies' => $competencies, 112 'filecount' => count($files), 113 'files' => $files, 114 'hasurlorfiles' => !empty($files) || !empty($url), 115 'urlshort' => $urlshort 116 ); 117 118 return $values; 119 } 120 121 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |