当前位置: 首页>>代码示例>>PHP>>正文


PHP Webmention::addSyndicatedReplyTargets方法代码示例

本文整理汇总了PHP中Idno\Core\Webmention::addSyndicatedReplyTargets方法的典型用法代码示例。如果您正苦于以下问题:PHP Webmention::addSyndicatedReplyTargets方法的具体用法?PHP Webmention::addSyndicatedReplyTargets怎么用?PHP Webmention::addSyndicatedReplyTargets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Idno\Core\Webmention的用法示例。


在下文中一共展示了Webmention::addSyndicatedReplyTargets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAddSyndicatedReplyTargets

    function testAddSyndicatedReplyTargets()
    {
        // test u-syndication
        $doc = <<<EOD
<div class="h-entry">
  <span class="p-name e-content">This is a post</span>
  <a class="u-url" href="http://foo.bar/post">permalink</a>
  <a class="u-syndication" href="https://twitter.com/foobar/12345">on Twitter</a>
  <a class="u-syndication" href="https://www.facebook.com/foobar/posts/12345">on Facebook</a>
</div>
EOD;
        $result = Webmention::addSyndicatedReplyTargets('http://foo.bar/post', [], ['response' => 200, 'content' => $doc]);
        $this->assertEquals(['https://twitter.com/foobar/12345', 'https://www.facebook.com/foobar/posts/12345'], $result);
        // test rel-syndication
        $doc = <<<EOD
<head>
  <link rel="syndication" href="https://twitter.com/foobar/12345" />
  <link rel="syndication" href="https://www.facebook.com/foobar/posts/12345" />
</head>
<body>
  <div class="h-entry">
    <span class="p-name e-content">This is a post</span>
    <a class="u-url" href="http://foo.bar/post">permalink</a>
  </div>
</body>
EOD;
        $result = Webmention::addSyndicatedReplyTargets('http://foo.bar/post', [], ['response' => 200, 'content' => $doc]);
        $this->assertEquals(['https://twitter.com/foobar/12345', 'https://www.facebook.com/foobar/posts/12345'], $result);
    }
开发者ID:smartboyathome,项目名称:Known,代码行数:29,代码来源:WebmentionTest.php

示例2: saveDataFromInput

 function saveDataFromInput()
 {
     $page = Idno::site()->currentPage();
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->likeof = $page->getInput('like-of');
     if ($this->likeof) {
         foreach ((array) $this->likeof as $likeofurl) {
             $this->syndicatedto = Webmention::addSyndicatedReplyTargets($likeofurl, $this->syndicatedto);
         }
     }
     $this->description = $page->getInput('description');
     if (empty($this->description)) {
         $result = \IdnoPlugins\Reactions\Pages\Fetch::fetch($this->likeof);
         if (!empty($result['description'])) {
             $this->description = $result['description'];
         }
     }
     $this->setAccess($page->getInput('access'));
     Idno::site()->logging()->log("saving like. new: {$new}");
     if ($this->publish($new)) {
         Idno::site()->logging()->log("sending webmentions from {$this->getURL()} to {$this->likeof}");
         Webmention::sendWebmentionPayload($this->getURL(), $this->likeof);
     }
     return true;
 }
开发者ID:kylewm,项目名称:KnownReactions,代码行数:29,代码来源:Like.php

示例3: saveDataFromInput

 function saveDataFromInput()
 {
     $page = Idno::site()->currentPage();
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->repostof = $page->getInput('repost-of');
     if ($this->repostof) {
         foreach ((array) $this->repostof as $repostofurl) {
             $this->syndicatedto = Webmention::addSyndicatedReplyTargets($repostofurl, $this->syndicatedto);
         }
     }
     $this->description = $page->getInput('description');
     $this->body = $page->getInput('body');
     if (empty($this->description) && empty($this->body)) {
         $result = \IdnoPlugins\Reactions\Pages\Fetch::fetch($this->repostof);
         if (isset($result['description'])) {
             $this->description = $result['description'];
         }
         if (isset($result['content'])) {
             $this->body = $result['content'];
         }
     }
     $this->setAccess($page->getInput('access'));
     if ($this->publish($new)) {
         Webmention::sendWebmentionPayload($this->getURL(), $this->repostof);
     }
     return true;
 }
开发者ID:kylewm,项目名称:KnownReactions,代码行数:31,代码来源:Repost.php

示例4: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return true|false
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $body = \Idno\Core\site()->currentPage()->getInput('body');
     $inreplyto = \Idno\Core\site()->currentPage()->getInput('inreplyto');
     $tags = \Idno\Core\site()->currentPage()->getInput('tags');
     if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     if (!empty($body)) {
         $this->body = $body;
         $this->inreplyto = $inreplyto;
         $this->tags = $tags;
         if (!empty($inreplyto)) {
             if (is_array($inreplyto)) {
                 foreach ($inreplyto as $inreplytourl) {
                     $this->syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($inreplytourl, $this->syndicatedto);
                 }
             } else {
                 $this->syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($inreplyto);
             }
         }
         $this->setAccess('PUBLIC');
         if ($this->save()) {
             if ($new) {
                 $this->addToFeed();
             }
             // Add it to the Activity Streams feed
             \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
             return true;
         }
     } else {
         \Idno\Core\site()->session()->addMessage('You can\'t save an empty status update.');
     }
     return false;
 }
开发者ID:avewrigley,项目名称:idno,代码行数:46,代码来源:Status.php

示例5: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return true|false
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
     $inreplyto = \Idno\Core\Idno::site()->currentPage()->getInput('inreplyto');
     $tags = \Idno\Core\Idno::site()->currentPage()->getInput('tags');
     $access = \Idno\Core\Idno::site()->currentPage()->getInput('access');
     if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     if (!empty($body)) {
         $this->body = $body;
         $this->inreplyto = $inreplyto;
         $this->tags = $tags;
         // TODO fetch syndicated reply targets asynchronously (or maybe on-demand, when syndicating?)
         if (!empty($inreplyto)) {
             if (is_array($inreplyto)) {
                 foreach ($inreplyto as $inreplytourl) {
                     $this->syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($inreplytourl, $this->syndicatedto);
                 }
             } else {
                 $this->syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($inreplyto);
             }
         }
         $this->setAccess($access);
         if ($this->publish($new)) {
             if ($this->getAccess() == 'PUBLIC') {
                 \Idno\Core\Idno::site()->queue()->enqueue('default', 'webmention/sendall', ['source' => $this->getURL(), 'text' => \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription())]);
             }
             return true;
         }
     } else {
         \Idno\Core\Idno::site()->session()->addErrorMessage('You can\'t save an empty status update.');
     }
     return false;
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:46,代码来源:Status.php

示例6: getContent

 function getContent()
 {
     $this->gatekeeper();
     $url = $this->getInput('share_url', $this->getInput('url'));
     $title = $this->getInput('share_title', $this->getInput('title'));
     $type = $this->getInput('share_type');
     $syndicatedto = [];
     // remove cruft added by mobile apps
     if (preg_match('~\\b(?:f|ht)tps?://[^\\s]+\\b~i', $url, $matches)) {
         $url = $matches[0];
     }
     $event = new \Idno\Core\Event();
     $event->setResponse($url);
     \Idno\Core\Idno::site()->events()->dispatch('url/shorten', $event);
     $short_url = $event->response();
     if (!$type || !\Idno\Common\ContentType::getRegisteredForIndieWebPostType($type)) {
         $share_type = 'note';
         // Probe to see if this is something we can MF2 parse, before we do
         $headers = [];
         if ($head = \Idno\Core\Webservice::head($url)) {
             $headers = http_parse_headers($head['header']);
         }
         // Only MF2 Parse supported types
         if (isset($headers['Content-Type']) && preg_match('/text\\/(html|plain)+/', $headers['Content-Type'])) {
             if ($response = \Idno\Core\Webservice::get($url)) {
                 if ($mf2 = \Idno\Core\Webmention::parseContent($response['content'])) {
                     if (!empty($mf2['items'])) {
                         foreach ($mf2['items'] as $item) {
                             if (!empty($item['type'])) {
                                 if (in_array('h-entry', $item['type'])) {
                                     $share_type = 'reply';
                                 }
                                 if (in_array('h-event', $item['type'])) {
                                     $share_type = 'rsvp';
                                 }
                             }
                         }
                     }
                 }
                 $syndicatedto = \Idno\Core\Webmention::addSyndicatedReplyTargets($url, $syndicatedto, $response);
             }
         }
     } else {
         $share_type = $type;
     }
     $content_type = \Idno\Common\ContentType::getRegisteredForIndieWebPostType($share_type);
     $hide_nav = false;
     if ($this->getInput('via') == 'ff_social') {
         $hide_nav = true;
     }
     if (!empty($content_type)) {
         if ($page = \Idno\Core\Idno::site()->getPageHandler($content_type->getEditURL())) {
             if ($share_type == 'note') {
                 $page->setInput('body', $title . ' ' . $short_url);
             } else {
                 $page->setInput('short-url', $short_url);
                 $page->setInput('url', $url);
                 $page->setInput('syndicatedto', $syndicatedto);
                 // prefill the @-name of the person we're replying to
                 $atusers = [];
                 foreach (array_merge((array) $url, (array) $syndicatedto) as $tweeturl) {
                     if (strstr($tweeturl, 'twitter.com') !== false) {
                         if (preg_match("|https?://([a-z]+\\.)?twitter\\.com/(#!/)?@?([^/]*)|", $tweeturl, $matches) && !empty($matches[3])) {
                             $atusers[] = '@' . $matches[3];
                         }
                         if (preg_match_all("|@([^\\s^\\)]+)|", $title, $matches)) {
                             $atusers = array_merge($atusers, $matches[0]);
                         }
                     }
                 }
                 if ($atusers) {
                     // See if one of your registered twitter handles is present, if so remove it.
                     $user = \Idno\Core\Idno::site()->session()->currentUser();
                     if (!empty($user->twitter) && is_array($user->twitter)) {
                         $me = [];
                         foreach ($user->twitter as $k => $v) {
                             $me[] = '@' . $k;
                         }
                         $atusers = array_diff($atusers, $me);
                     }
                 }
                 if ($atusers) {
                     $atusers = array_unique($atusers);
                     $page->setInput('body', implode(' ', $atusers) . ' ');
                 }
             }
             $page->setInput('hidenav', $hide_nav);
             $page->setInput('sharing', true);
             $page->setInput('share_type', $share_type);
             $page->get();
         }
     } else {
         $t = \Idno\Core\Idno::site()->template();
         $body = $t->__(array('share_type' => $share_type, 'content_type' => $content_type, 'sharing' => true))->draw('entity/share');
         $t->__(array('title' => 'Share', 'body' => $body, 'hidenav' => $hide_nav))->drawPage();
     }
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:97,代码来源:Share.php


注:本文中的Idno\Core\Webmention::addSyndicatedReplyTargets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。