2007-12-02 17:50:03 +00:00
< ? php
2019-05-28 16:59:38 +00:00
class ExtManagerTheme extends Themelet
{
/**
* #param ExtensionInfo[] $extensions
*/
public function display_table ( Page $page , array $extensions , bool $editable )
{
$h_en = $editable ? " <th>Enabled</th> " : " " ;
$html = "
2019-06-15 16:01:13 +00:00
" . make_form(make_link( " ext_manager / set " )) . "
2016-05-12 20:03:39 +00:00
< table id = 'extensions' class = 'zebra sortable' >
2009-01-17 03:27:18 +00:00
< thead >
2016-03-07 01:37:53 +00:00
< tr >
$h_en
< th > Name </ th >
< th > Docs </ th >
< th > Description </ th >
</ tr >
2009-01-17 03:27:18 +00:00
</ thead >
2009-01-17 04:53:11 +00:00
< tbody >
2007-12-02 17:50:03 +00:00
" ;
2019-05-28 16:59:38 +00:00
foreach ( $extensions as $extension ) {
2019-08-07 21:32:28 +00:00
if (( ! $editable && $extension -> visibility === ExtensionInfo :: VISIBLE_ADMIN )
|| $extension -> visibility === ExtensionInfo :: VISIBLE_HIDDEN ) {
2019-05-28 16:59:38 +00:00
continue ;
}
2010-01-05 13:13:11 +00:00
2019-08-07 19:53:59 +00:00
$h_name = html_escape (( $extension -> beta === true ? " [BETA] " : " " ) . ( empty ( $extension -> name ) ? $extension -> key : $extension -> name ));
2019-05-28 16:59:38 +00:00
$h_description = html_escape ( $extension -> description );
2019-08-07 19:53:59 +00:00
$h_link = make_link ( " ext_doc/ " . url_escape ( $extension -> key ));
2019-08-01 16:20:09 +00:00
2019-08-07 19:53:59 +00:00
$h_enabled = ( $extension -> is_enabled () === true ? " checked='checked' " : " " );
2019-09-29 13:30:55 +00:00
$h_disabled = ( $extension -> is_supported () === false || $extension -> core === true ? " disabled " : " " );
2019-08-01 16:20:09 +00:00
//baseline_open_in_new_black_18dp.png
2019-08-07 19:53:59 +00:00
$h_enabled_box = $editable ? " <td><input type='checkbox' name='ext_ " . html_escape ( $extension -> key ) . " ' id='ext_ " . html_escape ( $extension -> key ) . " ' $h_disabled $h_enabled ></td> " : " " ;
2019-10-10 15:32:34 +00:00
$h_docs = ( $extension -> documentation ? " <a href=' $h_link '><img src='ext/ext_manager/baseline_open_in_new_black_18dp.png'/></a> " : " " ); //TODO: A proper "docs" symbol would be preferred here.
2009-01-17 02:25:39 +00:00
2019-05-28 16:59:38 +00:00
$html .= "
2019-08-07 19:53:59 +00:00
< tr data - ext = '{$extension->name}' >
2016-03-07 01:37:53 +00:00
{ $h_enabled_box }
2019-08-07 19:53:59 +00:00
< td >< label for = 'ext_" . html_escape($extension->key) . "' > { $h_name } </ label ></ td >
2016-03-07 01:37:53 +00:00
< td > { $h_docs } </ td >
2019-08-07 19:53:59 +00:00
< td style = 'text-align: left;' > { $h_description } < b style = 'color:red' > " . $extension->get_support_info (). " </ b ></ td >
2007-12-02 17:50:03 +00:00
</ tr > " ;
2019-05-28 16:59:38 +00:00
}
$h_set = $editable ? " <tfoot><tr><td colspan='5'><input type='submit' value='Set Extensions'></td></tr></tfoot> " : " " ;
$html .= "
2009-01-17 04:53:11 +00:00
</ tbody >
2012-02-13 20:51:34 +00:00
$h_set
2007-12-02 17:50:03 +00:00
</ table >
</ form >
" ;
2019-05-28 16:59:38 +00:00
$page -> set_title ( " Extensions " );
$page -> set_heading ( " Extensions " );
$page -> add_block ( new NavBlock ());
$page -> add_block ( new Block ( " Extension Manager " , $html ));
}
2009-01-16 05:41:59 +00:00
2019-05-28 16:59:38 +00:00
/*
public function display_blocks ( Page $page , $extensions ) {
global $user ;
$col_1 = " " ;
$col_2 = " " ;
foreach ( $extensions as $extension ) {
2019-08-07 19:53:59 +00:00
$ext_name = $extension -> name ;
2019-05-28 16:59:38 +00:00
$h_name = empty ( $extension -> name ) ? $ext_name : html_escape ( $extension -> name );
$h_email = html_escape ( $extension -> email );
$h_link = isset ( $extension -> link ) ?
" <a href= \" " . html_escape ( $extension -> link ) . " \" >Original Site</a> " : " " ;
$h_doc = isset ( $extension -> documentation ) ?
2019-08-07 19:53:59 +00:00
" <a href= \" " . make_link ( " ext_doc/ " . html_escape ( $extension -> name )) . " \" >Documentation</a> " : " " ;
2019-05-28 16:59:38 +00:00
$h_author = html_escape ( $extension -> author );
$h_description = html_escape ( $extension -> description );
2019-08-07 19:53:59 +00:00
$h_enabled = $extension -> is_enabled () ? " checked='checked' " : " " ;
2019-05-28 16:59:38 +00:00
$h_author_link = empty ( $h_email ) ?
" $h_author " :
" <a href='mailto: $h_email '> $h_author </a> " ;
2009-01-17 02:49:15 +00:00
2019-05-28 16:59:38 +00:00
$html = "
< p >< table border = '1' >
< tr >
< th colspan = '2' > $h_name </ th >
</ tr >
< tr >
< td > By $h_author_link </ td >
< td width = '25%' > Enabled :& nbsp ; < input type = 'checkbox' name = 'ext_$ext_name' $h_enabled ></ td >
</ tr >
< tr >
< td style = 'text-align: left' colspan = '2' > $h_description < p > $h_link $h_doc </ td >
</ tr >
</ table >
" ;
if ( $n ++ % 2 == 0 ) {
$col_1 .= $html ;
}
else {
$col_2 .= $html ;
}
}
$html = "
" .make_form(make_link( " ext_manager / set " )). "
" . $user->get_auth_html (). "
< table border = '0' >
< tr >< td width = '50%' > $col_1 </ td >< td > $col_2 </ td ></ tr >
< tr >< td colspan = '2' >< input type = 'submit' value = 'Set Extensions' ></ td ></ tr >
</ table >
</ form >
" ;
2009-01-17 02:49:15 +00:00
2019-05-28 16:59:38 +00:00
$page -> set_title ( " Extensions " );
$page -> set_heading ( " Extensions " );
$page -> add_block ( new NavBlock ());
$page -> add_block ( new Block ( " Extension Manager " , $html ));
}
*/
2009-01-17 02:49:15 +00:00
2019-08-07 19:53:59 +00:00
public function display_doc ( Page $page , ExtensionInfo $info )
2019-05-28 16:59:38 +00:00
{
$author = " " ;
2019-06-15 16:01:13 +00:00
if ( count ( $info -> authors ) > 0 ) {
$author = " <br /><b>Author " ;
if ( count ( $info -> authors ) > 1 ) {
$author .= " s " ;
2019-05-28 16:59:38 +00:00
}
2019-06-15 16:01:13 +00:00
$author .= " :</b> " ;
2019-08-07 19:53:59 +00:00
foreach ( $info -> authors as $auth => $email ) {
if ( ! empty ( $email )) {
$author .= " <a href= \" mailto: " . html_escape ( $email ) . " \" > " . html_escape ( $auth ) . " </a> " ;
2019-06-15 16:01:13 +00:00
} else {
2019-08-07 19:53:59 +00:00
$author .= html_escape ( $auth );
2019-06-15 16:01:13 +00:00
}
2019-08-07 19:53:59 +00:00
$author .= " <br/> " ;
2019-06-15 16:01:13 +00:00
}
2019-05-28 16:59:38 +00:00
}
2019-06-15 16:01:13 +00:00
$version = ( $info -> version ) ? " <br><b>Version:</b> " . html_escape ( $info -> version ) : " " ;
$link = ( $info -> link ) ? " <br><b>Home Page:</b> <a href= \" " . html_escape ( $info -> link ) . " \" >Link</a> " : " " ;
2019-05-28 16:59:38 +00:00
$doc = $info -> documentation ;
$html = "
2009-01-17 04:00:52 +00:00
< div style = 'margin: auto; text-align: left; width: 512px;' >
$author
$version
2010-01-05 10:11:53 +00:00
$link
2009-01-17 04:00:52 +00:00
< p > $doc
2010-01-05 10:11:53 +00:00
< hr >
2019-06-15 16:01:13 +00:00
< p >< a href = '" . make_link("ext_manager") . "' > Back to the list </ a >
2009-01-17 04:00:52 +00:00
</ div > " ;
2019-06-15 16:01:13 +00:00
$page -> set_title ( " Documentation for " . html_escape ( $info -> name ));
2019-05-28 16:59:38 +00:00
$page -> set_heading ( html_escape ( $info -> name ));
$page -> add_block ( new NavBlock ());
$page -> add_block ( new Block ( " Documentation " , $html ));
}
2007-12-02 17:50:03 +00:00
}