本文整理汇总了PHP中Publisher::publish方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::publish方法的具体用法?PHP Publisher::publish怎么用?PHP Publisher::publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::publish方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manageMessages
public function manageMessages($entity)
{
$requester = new Requester();
$publisher = new Publisher();
$entityObject = new Entity();
$downloader = new FileDownloader();
$published = new Published();
$summary = '';
$title = '';
$readmoreLabel = '';
// get author id
$author = $entity->author_id;
// The entity is not active
if (!$entity->activate) {
return 0;
}
// Retrieve the entity categories
$entityListCategory = [];
$readmoreLabel = '';
foreach ($entity->options as $key => $value) {
if ($value->options_id == 1) {
$entityListCategory[] = $value->value;
}
if ($value->options_id == 2) {
$entityDisplayType = $value->value;
}
if ($value->options_id == 3) {
$entityPublishType = $value->value;
}
if ($value->options_id == 5) {
$entityImage = $value->value;
}
if ($value->options_id == 6) {
$readmoreLabel = $value->value;
}
}
// Try request to sociallymap on response
try {
if ($_ENV['ENVIRONNEMENT'] === 'dev') {
$requester = new MockRequester();
$jsonData = $requester->getMessages();
} else {
$_POST['entityId'] = esc_html($_POST['entityId']);
$_POST['token'] = esc_html($_POST['token']);
$_POST['environment'] = esc_html($_POST['environment']);
$jsonData = $requester->launch($_POST['entityId'], $_POST['token'], $_POST['environment']);
}
if (empty($jsonData)) {
throw new Exception('No data returned from request', 1);
exit;
}
Logger::messageReceive('See return data', $jsonData);
foreach ($jsonData as $key => $value) {
$summary = '';
$contentArticle = '';
$readmore = '';
// Check Link object existing
if (isset($value->link)) {
// Check if Title existing
if (!empty($value->link->title)) {
$title = $value->link->title;
}
if (!empty($value->link->summary)) {
$summary = $value->link->summary;
}
// Check if Link URL existing
if (!empty($value->link->url)) {
$readmoreLabel = stripslashes($readmoreLabel);
$readmore = $this->templater->loadReadMore($value->link->url, $entityDisplayType, $entity->id, $readmoreLabel);
} else {
Logger::alert('This article not contain url');
}
}
$contentArticle = $summary;
// add readmore to content if $readmore is not empty
if ($readmore != '') {
$contentArticle .= $readmore;
}
$imageTag = '';
$imageSrc = '';
// Check if article posted
$canBePublish = true;
$messageId = $value->guid;
if ($published->isPublished($messageId)) {
$contextMessageId = '(id message=' . $messageId . ')';
Logger::alert('Message of sociallymap existing, so he is not publish', $contextMessageId);
$canBePublish = false;
continue;
}
$pathTempory = plugin_dir_path(__FILE__) . 'tmp/';
// Check if Media object exist
if (isset($value->media) && $value->media->type == 'photo') {
try {
$returnDownload = $downloader->download($value->media->url, $pathTempory);
$filename = $returnDownload['filename'];
$fileExtension = $returnDownload['extension'];
$mediaManager = new MediaWordpressManager();
$imageSrc = $mediaManager->integrateMediaToWordpress($filename, $fileExtension);
} catch (fileDownloadException $e) {
Logger::error('error download' . $e);
//.........这里部分代码省略.........
示例2: array
<?php
include "publisher.php";
//define hub and feeds
$hub = 'http://pubsubhubbub.appspot.com/';
$feeds = array('http://www.example.com/feed1.xml', 'http://www.example.com/feed2.xml', 'http://www.example.com/feed3.xml');
//create new subscriber
$publisher = new Publisher($hub);
//publish feeds
$response = $publisher->publish($feed);
//print response
var_dump($response);
示例3: publishpage
public function publishpage()
{
global $varChecker;
/**
*TODO: check user access
* canPublish does not actually check, dummy method
**/
$page = $this->getPage();
if ($varChecker->getValue('action') == 'publish') {
if ($page->published() == 1 || $page->published() == 2) {
echo json_encode(array('error' => 'alredy_published'));
return false;
}
} else {
if ($varChecker->getValue('action') == 'expire') {
if ($page->published() > 2) {
echo json_encode(array('error' => 'alredy_expired'));
return false;
}
} else {
throw new DataException('invalid_pubaction');
}
}
if ($this->INK_User->canPublish($page)) {
switch ($page->published()) {
case 0:
//draft
//draft
case 2:
//waiting publish approval
//waiting publish approval
case 4:
//withdrawn, set to publish
//withdrawn, set to publish
case 5:
$status = 1;
$msg = 'pub';
break;
//Expired -- Set all these to published
//Expired -- Set all these to published
case 3:
//waiting withdraw approval
//waiting withdraw approval
case 1:
$status = 4;
$msg = 'withdrawn';
break;
//published, set to withdrawn
}
} else {
switch ($page->published()) {
case 4:
//withdrawn
//withdrawn
case 5:
//expired
//expired
case 3:
//waiting withdrawn approval
//waiting withdrawn approval
case 0:
$status = 2;
$msg = 'pub_wait';
break;
//draft --- set all these to waiting publish approval
//draft --- set all these to waiting publish approval
case 2:
//waiting publish approval
//waiting publish approval
case 1:
$status = 3;
$msg = 'withdrawn_wait';
break;
//published -- set all these to waithing withdraw approval
}
}
$page->setPublished($status);
$this->dRep->updatePage($page, 'published', $page->published());
$page = $this->dRep->getPage($page->getId());
$publisher = new Publisher($page);
switch ($status) {
case 1:
case 4:
$publisher->publish();
break;
}
echo json_encode(array('success' => $msg, 'status' => $status, 'oldStatus' => $page->published(true), 'date' => $page->getPublishDate('l j F @ g:ia')));
}
示例4: EventChannel
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* $Id$
*
******************************************************************************/
include "../interface/EventChannel.php";
include "../interface/Publisher.php";
$subject = "testsubj";
print "generating Famouso EventChannel\n";
$EventChannel = new EventChannel($subject);
print "generating PHP Publisher\n";
$Publisher = new Publisher($EventChannel);
print "sending announcement\n";
if (!$Publisher->announce()) {
print "announcement failed - exit\n";
exit;
}
print "start publishing data\n";
for ($i = 0; $i < 10; $i++) {
sleep(2);
$Publisher->publish("testdata");
print $i . " published\n";
}
print "sending unannouncement\n";
$Publisher->unannounce();