| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class SH4_Conf_Html_Admin_View_Publish |
| 3 |
{ |
| 4 |
public function __construct( |
| 5 |
HC3_Hooks $hooks, |
| 6 |
|
| 7 |
HC3_Ui $ui, |
| 8 |
HC3_Ui_Layout1 $layout, |
| 9 |
|
| 10 |
HC3_Settings $settings |
| 11 |
) |
| 12 |
{ |
| 13 |
$this->ui = $ui; |
| 14 |
$this->layout = $layout; |
| 15 |
|
| 16 |
$this->settings = $hooks->wrap($settings); |
| 17 |
$this->self = $hooks->wrap($this); |
| 18 |
} |
| 19 |
|
| 20 |
public function render() |
| 21 |
{ |
| 22 |
$shortcode = 'shiftcontroller4'; |
| 23 |
|
| 24 |
$out = array(); |
| 25 |
|
| 26 |
$shortcodeView = '[' . $shortcode . ']'; |
| 27 |
$shortcodeView = $this->ui->makeBlockInline( $shortcodeView ) |
| 28 |
->tag('padding', 2) |
| 29 |
->tag('bgcolor', 'silver') |
| 30 |
; |
| 31 |
$shortcodeView = $this->ui->makeLabelled( '__Shortcode__', $shortcodeView ); |
| 32 |
|
| 33 |
$htmlFile = dirname(__FILE__) . '/publish.html.php'; |
| 34 |
ob_start(); |
| 35 |
require( $htmlFile ); |
| 36 |
$shortcodeView = ob_get_contents(); |
| 37 |
ob_end_clean(); |
| 38 |
|
| 39 |
$out[] = $shortcodeView; |
| 40 |
|
| 41 |
$out = $this->ui->makeList( $out ); |
| 42 |
|
| 43 |
$pageIds = HC3_Functions::wpGetIdByShortcode($shortcode); |
| 44 |
if( $pageIds ){ |
| 45 |
foreach( $pageIds as $pid => $pcontent ){ |
| 46 |
$link = get_permalink( $pid ); |
| 47 |
$label = get_the_title( $pid ); |
| 48 |
$page = $this->ui->makeAhref( $link, $label ) |
| 49 |
->addAttr('target', '_blank') |
| 50 |
; |
| 51 |
$pages[] = $page; |
| 52 |
} |
| 53 |
} |
| 54 |
else { |
| 55 |
$pages[] = '__None__'; |
| 56 |
} |
| 57 |
|
| 58 |
$addNewLink = $this->ui->makeAhref( admin_url('post-new.php'), '__Add New__' ) |
| 59 |
->tag('secondary') |
| 60 |
; |
| 61 |
|
| 62 |
$pages[] = $addNewLink; |
| 63 |
$pages = $this->ui->makeList( $pages ); |
| 64 |
$pages = $this->ui->makeLabelled( '__Pages With Shortcode__', $pages ); |
| 65 |
|
| 66 |
$out = $this->ui->makeGrid() |
| 67 |
->add( $out, 8, 12 ) |
| 68 |
->add( $pages, 4, 12 ) |
| 69 |
; |
| 70 |
|
| 71 |
$this->layout |
| 72 |
->setContent( $out ) |
| 73 |
->setBreadcrumb( $this->self->breadcrumb() ) |
| 74 |
->setHeader( $this->self->header() ) |
| 75 |
// ->setMenu( $this->self->menu() ) |
| 76 |
; |
| 77 |
|
| 78 |
$out = $this->layout->render(); |
| 79 |
return $out; |
| 80 |
} |
| 81 |
|
| 82 |
public function header() |
| 83 |
{ |
| 84 |
$out = '__Publish__'; |
| 85 |
return $out; |
| 86 |
} |
| 87 |
|
| 88 |
public function breadcrumb() |
| 89 |
{ |
| 90 |
$return = array(); |
| 91 |
$return['admin'] = array( 'admin', '__Administration__' ); |
| 92 |
return $return; |
| 93 |
} |
| 94 |
} |