aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Pdledit.php
blob: 5cb00f1653ea738e9de65d183033aaf72c8e0a70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace Zotlabs\Module;


class Pdledit extends \Zotlabs\Web\Controller {

	function post() {
		if(! local_channel())
			return;
		if(! $_REQUEST['module'])
			return;
		if(! trim($_REQUEST['content'])) {
			del_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl');
			goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
		}
		set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content']));
		build_sync_packet();
		info( t('Layout updated.') . EOL);
		goaway(z_root() . '/pdledit/' . $_REQUEST['module']);
	}
	
	
	function get() {
	
		if(! local_channel()) {
			notice( t('Permission denied.') . EOL);
			return;
		}
	
		if(argc() > 1)
			$module = 'mod_' . argv(1) . '.pdl';
		else {
			$o .= '<div class="generic-content-wrapper-styled">';
			$o .= '<h1>' . t('Edit System Page Description') . '</h1>';
			$files = glob('Zotlabs/Module/*.php');
			if($files) {
				foreach($files as $f) {
					$name = lcfirst(basename($f,'.php'));
					$x = theme_include('mod_' . $name . '.pdl');
					if($x) {
						$o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />';
					}
				}
			}

			$o .= '</div>';
			
			// list module pdl files
			return $o;
		}
	
		$t = get_pconfig(local_channel(),'system',$module);
		if(! $t)
			$t = file_get_contents(theme_include($module));
		if(! $t) {
			notice( t('Layout not found.') . EOL);
			return '';
		}
	
		$o = replace_macros(get_markup_template('pdledit.tpl'),array(
			'$header' => t('Edit System Page Description'),
			'$mname' => t('Module Name:'),
			'$help' => t('Layout Help'),
			'$module' => argv(1),
			'$content' => htmlspecialchars($t,ENT_COMPAT,'UTF-8'),
			'$submit' => t('Submit')
		));
	    
		return $o;
	}
	
}