1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Services_ContentTemplate_Controller 9{ 10 function setUp() 11 { 12 global $prefs; 13 14 if ($prefs['feature_wiki_templates'] != 'y') { 15 throw new Services_Exception_Disabled('feature_wiki_templates'); 16 } 17 } 18 19 function action_list($input) 20 { 21 // Validate access 22 $access = TikiLib::lib('access'); 23 $access->check_permission('tiki_p_use_content_templates'); 24 25 // Load the templates library 26 $templateslib = TikiLib::lib('template'); 27 28 $section = 'wiki'; 29 $offset = 0; 30 $maxRecords = -1; 31 $sort_mode = 'name_asc'; 32 $find = null; 33 34 $contentTmpl = $templateslib->list_templates($section, $offset, $maxRecords, $sort_mode, $find); 35 36 // Build the result 37 $result = []; 38 $name = ""; 39 $content = ""; 40 foreach ($contentTmpl['data'] as $val) { 41 if (count($contentTmpl) > 0) { 42 $templateId = $val['templateId']; 43 $templateData = $templateslib->get_template($templateId); 44 45 $name = $templateData['name']; 46 if (isset($templateData['content'])) { 47 $content = $templateData['content']; 48 } 49 } 50 $result[] = ['title' => $name, 'html' => $content]; 51 } 52 53 // Done 54 return [ 55 'data' => $result, 56 'cant' => count($result), 57 ]; 58 } 59} 60