| 1 |
<?php |
| 2 |
namespace MBSocial; |
| 3 |
defined('ABSPATH') or die('No direct access permitted'); |
| 4 |
|
| 5 |
|
| 6 |
$collectionBlock["email"] = array('class' => "emailBlock", |
| 7 |
'order' => 110); |
| 8 |
|
| 9 |
use \MaxButtons\maxField as maxField; |
| 10 |
use \MaxButtons\maxBlocks as maxBlocks; |
| 11 |
use \MaxButtons\maxUtils as maxUtils; |
| 12 |
|
| 13 |
class emailBlock extends block |
| 14 |
{ |
| 15 |
|
| 16 |
protected $blockname = "email"; |
| 17 |
|
| 18 |
protected $fields = array( |
| 19 |
'email_subject' => array('default' => ''), |
| 20 |
'email_content' => array('default' => ''), |
| 21 |
); |
| 22 |
|
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
$w = MBSocial()->whistle(); |
| 26 |
|
| 27 |
$w->listen('display/vars/email_subject', array($this, 'email_subject'), 'ask'); |
| 28 |
$w->listen('display/vars/email_content', array($this, 'email_content'), 'ask'); |
| 29 |
} |
| 30 |
|
| 31 |
public function email_subject() |
| 32 |
{ |
| 33 |
$blockdata = $this->data[$this->blockname]; |
| 34 |
$w = MBSocial()->whistle(); |
| 35 |
$admin = MBSocial()->admin(); |
| 36 |
|
| 37 |
if (isset($blockdata['email_subject'])) |
| 38 |
{ |
| 39 |
// applyVars to check nested vars inside the declaration. |
| 40 |
return $admin->applyVars($blockdata['email_subject']); |
| 41 |
} |
| 42 |
else { |
| 43 |
return $w->ask('display/vars/title'); ; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public function email_content() |
| 48 |
{ |
| 49 |
$blockdata = $this->data[$this->blockname]; |
| 50 |
$w = MBSocial()->whistle(); |
| 51 |
$admin = MBSocial()->admin(); |
| 52 |
|
| 53 |
if (isset($blockdata['email_content'])) |
| 54 |
{ |
| 55 |
return $admin->applyVars($blockdata['email_content']); |
| 56 |
} |
| 57 |
else { |
| 58 |
return $w->ask('display/vars/url'); // if no setting, ask the default. |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
public function admin() |
| 63 |
{ |
| 64 |
if (! Install::isPro() ) |
| 65 |
return; |
| 66 |
|
| 67 |
$admin = mbSocial()->admin(); |
| 68 |
$blockdata = $this->data[$this->blockname]; |
| 69 |
|
| 70 |
|
| 71 |
?> |
| 72 |
<div class='options option-container layout' id='twitterBlock' |
| 73 |
data-has='{"target":"network_item_active[]","values":["twitter"]}' > |
| 74 |
<div class='title'><?php _e('Email Content Options', 'mbsocial' ); ?> </div> |
| 75 |
<div class='inside'> |
| 76 |
|
| 77 |
<?php |
| 78 |
|
| 79 |
$subject = new maxField('text'); |
| 80 |
$subject->id = 'email_subject'; |
| 81 |
$subject->name = $subject->id; |
| 82 |
$subject->label = __('Subject', 'mbsocial'); |
| 83 |
$subject->help = __('Type subject for Email Sharing. Use {url} to include sharing URL, use {title} to include page/post title', 'mbsocial'); |
| 84 |
$subject->placeholder = __('Your friend wants to let your know about {title}'); |
| 85 |
$subject->value = $this->getValue('email_subject'); |
| 86 |
|
| 87 |
$admin->addField($subject, 'start','end', false); |
| 88 |
|
| 89 |
$content = new maxField('textarea'); |
| 90 |
$content->id = 'email_content'; |
| 91 |
$content->name = $content->id; |
| 92 |
$content->label = __('Content', 'mbsocial'); |
| 93 |
$content->help = __('Type subject for Email Content. Use {url} to include sharing URL, use {title} to include page/post title', 'mbsocial'); |
| 94 |
$content->placeholder = __('I found this really nice page. Read everything about {title} . Check it out : {url}'); |
| 95 |
$content->value = $this->getValue('email_content'); |
| 96 |
|
| 97 |
|
| 98 |
$admin->addField($content, 'start', 'end', false); |
| 99 |
|
| 100 |
$admin->display_fields(); |
| 101 |
?> |
| 102 |
|
| 103 |
</div> |
| 104 |
</div> |
| 105 |
|
| 106 |
<?php |
| 107 |
} |
| 108 |
|
| 109 |
} // class |
| 110 |
|