/
cpg.plugin.php
107 lines (91 loc) · 2.58 KB
/
cpg.plugin.php
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
require_once 'cpgdb.php';
require_once 'cpgoptions.php';
class Cpg extends Plugin
{
const VERSION = '0.1';
function info()
{
return array(
'name' => 'Copperleaf Photo Gallery Plugin',
'version' => self::VERSION,
'url' => 'http://wiki.habariproject.org/en/CPG',
'author' => 'Bill Smith',
'authorurl' => 'http://www.copperleaf.org/',
'license' => 'Apache License 2.0',
'description' => 'A plugin for managing and displaying photos.'
);
}
// *** Uncomment when ready for release ***
//function action_update_check()
//{
// Update::add('Copperleaf Photo Gallery Plugin', '397B7ABC-7E7A-11DD-A57A-408D55D89593', self::VERSION);
//}
public function action_plugin_activation($file)
{
if ($file == str_replace( '\\','/', $this->get_file()))
{
CpgDb::registerTables();
//Options::set( 'cpg__db_version', CpgDb::DB_VERSION );
CpgOptions::setDbVersion(CpgDb::DB_VERSION);
if (CpgDb::install())
{
Session::notice(_t( 'Created the CPG database tables.', 'cpg'));
}
else
{
Session::error(_t( 'Could not install CPG database tables.', 'cpg'));
}
}
}
public function action_init()
{
//$this->add_template('event.single', dirname(__FILE__) . '/event.single.php');
Post::add_new_type('imageset', false);
Post::add_new_type('image', false);
Post::add_new_type('gallery', false);
CpgDb::registerTables();
//Utils::debug('tables registered!');
if (CpgDb::DB_VERSION > CpgOptions::getDbVersion())
{
CpgDb::install();
EventLog::log( 'Updated CPG.' );
CpgOptions::setDbVersion(CpgDb::DB_VERSION);
}
}
public function filter_adminhandler_post_loadplugins_main_menu($menus)
{
unset($menus['create_' . Post::type('imageset')]);
unset($menus['manage_' . Post::type('imageset')]);
unset($menus['create_' . Post::type('image')]);
unset($menus['manage_' . Post::type('image')]);
unset($menus['create_' . Post::type('gallery')]);
return $menus;
}
public function filter_plugin_config($actions, $plugin_id)
{
if ($plugin_id == $this->plugin_id())
{
$actions[]= _t('Configure');
}
return $actions;
}
public function action_plugin_ui($plugin_id, $action)
{
if ( $plugin_id == $this->plugin_id() )
{
switch ( $action )
{
case _t('Configure') :
$ui = new FormUI( strtolower( get_class( $this ) ) );
$customvalue= $ui->append( 'text', 'customvalue', 'cpg__customvalue', _t('Your custom value:') );
$ui->out();
break;
}
}
}
function action_plugins_loaded()
{
}
}
?>