Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * Mustache helper shorten text.
-
 
19
 *
-
 
20
 * @package    core
-
 
21
 * @category   output
-
 
22
 * @copyright  2017 Ryan Wyllie <ryan@moodle.com>
-
 
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
24
 */
-
 
25
 
16
 
Línea 26... Línea -...
26
namespace core\output;
-
 
27
 
-
 
28
defined('MOODLE_INTERNAL') || die();
17
namespace core\output;
29
 
-
 
Línea 30... Línea 18...
30
use Mustache_LambdaHelper;
18
 
31
use renderer_base;
19
use Mustache_LambdaHelper;
32
 
20
 
-
 
21
/**
33
/**
22
 * This class will call shorten_text with the section content.
34
 * This class will call shorten_text with the section content.
23
 *
35
 *
24
 * @package core
36
 * @copyright  2017 Ryan Wyllie <ryan@moodle.com>
25
 * @copyright  2017 Ryan Wyllie <ryan@moodle.com>
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
38
 */
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
class mustache_shorten_text_helper {
27
 */
40
 
28
class mustache_shorten_text_helper {
41
    /**
29
    /**
42
     * Read a length and text component from the string.
30
     * Read a length and text component from the string.
Línea 49... Línea 37...
49
     * @param Mustache_LambdaHelper $helper Used to render nested mustache variables.
37
     * @param Mustache_LambdaHelper $helper Used to render nested mustache variables.
50
     * @return string
38
     * @return string
51
     */
39
     */
52
    public function shorten($args, Mustache_LambdaHelper $helper) {
40
    public function shorten($args, Mustache_LambdaHelper $helper) {
53
        // Split the text into an array of variables.
41
        // Split the text into an array of variables.
54
        list($length, $text) = explode(',', $args, 2);
42
        [$length, $text] = explode(',', $args, 2);
55
        $length = trim($length);
43
        $length = trim($length);
56
        $text = trim($text);
44
        $text = trim($text);
Línea 57... Línea 45...
57
 
45
 
58
        // Allow mustache tags in the length and text.
46
        // Allow mustache tags in the length and text.
59
        $text = $helper->render($text);
47
        $text = $helper->render($text);
Línea 60... Línea 48...
60
        $length = $helper->render($length);
48
        $length = $helper->render($length);
61
 
49
 
62
        return shorten_text($text, $length);
50
        return shorten_text($text, $length);
63
    }
-