Admin_PortalController::portletFeedAction PHP Метод

portletFeedAction() публичный Метод

public portletFeedAction ( )
    public function portletFeedAction()
    {
        $dashboard = $this->getCurrentConfiguration();
        $id = $this->getParam("id");
        $cache = \Pimcore\Cache::getInstance();
        if ($cache) {
            $cache->setLifetime(10);
            \Zend_Feed_Reader::setCache($cache);
        }
        $portlet = [];
        foreach ($dashboard["positions"] as $col) {
            foreach ($col as $row) {
                if ($row['id'] == $id) {
                    $portlet = $row;
                }
            }
        }
        $feedUrl = $portlet['config'];
        $feed = null;
        if (!empty($feedUrl)) {
            try {
                $feed = \Zend_Feed_Reader::import($feedUrl);
            } catch (\Exception $e) {
                Logger::error($e);
            }
        }
        $count = 0;
        $entries = [];
        if ($feed) {
            foreach ($feed as $entry) {
                // display only the latest 11 entries
                $count++;
                if ($count > 10) {
                    break;
                }
                $entry = ["title" => $entry->getTitle(), "description" => $entry->getDescription(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => $entry->getContent()];
                foreach ($entry as &$content) {
                    $content = strip_tags($content, "<h1><h2><h3><h4><h5><p><br><a><img><div><b><strong><i>");
                    $content = preg_replace('/on([a-z]+)([ ]+)?=/i', "data-on\$1=", $content);
                }
                $entries[] = $entry;
            }
        }
        $this->_helper->json(["entries" => $entries]);
    }