示例#1
0
 /**
  * Display a feed of comments
  *
  * @return    void
  */
 protected function _feed()
 {
     if (!$this->params->get('comments_feeds')) {
         $this->action = 'view';
         $this->_view();
         return;
     }
     // Set the mime encoding for the document
     Document::setType('feed');
     // Load the comments
     $comment = new \Plugins\Hubzero\Comments\Models\Comment();
     $filters = array('parent' => 0, 'item_type' => $this->obj_type, 'item_id' => $this->obj_id);
     if ($this->obj instanceof \Hubzero\Base\Model) {
         $title = $this->obj->get('title');
     } else {
         $title = $this->obj->title;
     }
     // Start a new feed object
     $doc = Document::instance();
     $doc->link = Route::url($this->url);
     $doc->title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option));
     $doc->title .= $title ? ': ' . stripslashes($title) : '';
     $doc->title .= ': ' . Lang::txt('PLG_HUBZERO_COMMENTS');
     $doc->description = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_DESCRIPTION', Config::get('sitename'), stripslashes($title));
     $doc->copyright = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_COPYRIGHT', date("Y"), Config::get('sitename'));
     // Start outputing results if any found
     if ($comment->replies('list', $filters)->total() > 0) {
         foreach ($comment->replies() as $row) {
             // URL link to article
             $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $row->id);
             $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
             if (!$row->get('anonymous')) {
                 $author = $row->creator('name');
             }
             // Prepare the title
             $title = Lang::txt('PLG_HUBZERO_COMMENTS_COMMENT_BY', $author) . ' @ ' . $row->created('time') . ' on ' . $row->created('date');
             // Strip html from feed item description text
             if ($row->isReported()) {
                 $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE');
             } else {
                 $description = $row->content('clean');
             }
             @($date = $row->created() ? date('r', strtotime($row->created())) : '');
             // Load individual item creator class
             $item = new \Hubzero\Document\Type\Feed\Item();
             $item->title = $title;
             $item->link = $link;
             $item->description = $description;
             $item->date = $date;
             $item->category = '';
             $item->author = $author;
             // Loads item info into rss array
             $doc->addItem($item);
             // Check for any replies
             if ($row->replies()->total()) {
                 foreach ($row->replies() as $reply) {
                     // URL link to article
                     $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $reply->id);
                     $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
                     if (!$reply->anonymous) {
                         $cuser = User::getInstance($reply->created_by);
                         $author = $cuser->get('name');
                     }
                     // Prepare the title
                     $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $row->id, $author) . ' @ ' . Date::of($reply->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($reply->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
                     // Strip html from feed item description text
                     if ($reply->reports) {
                         $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE');
                     } else {
                         $description = is_object($p) ? $p->parse(stripslashes($reply->content)) : nl2br(stripslashes($reply->content));
                     }
                     $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description));
                     @($date = $reply->created ? gmdate('r', strtotime($reply->created)) : '');
                     // Load individual item creator class
                     $item = new \Hubzero\Document\Type\Feed\Item();
                     $item->title = $title;
                     $item->link = $link;
                     $item->description = $description;
                     $item->date = $date;
                     $item->category = '';
                     $item->author = $author;
                     // Loads item info into rss array
                     $doc->addItem($item);
                     if ($reply->replies) {
                         foreach ($reply->replies as $response) {
                             // URL link to article
                             $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $response->id);
                             $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
                             if (!$response->anonymous) {
                                 $cuser = User::getInstance($response->created_by);
                                 $author = $cuser->get('name');
                             }
                             // Prepare the title
                             $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $reply->id, $author) . ' @ ' . Date::of($response->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($response->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
                             // Strip html from feed item description text
                             if ($response->reports) {
                                 $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE');
                             } else {
                                 $description = is_object($p) ? $p->parse(stripslashes($response->content)) : nl2br(stripslashes($response->content));
                             }
                             $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description));
                             @($date = $response->created ? gmdate('r', strtotime($response->created)) : '');
                             // Load individual item creator class
                             $item = new \Hubzero\Document\Type\Feed\Item();
                             $item->title = $title;
                             $item->link = $link;
                             $item->description = $description;
                             $item->date = $date;
                             $item->category = '';
                             $item->author = $author;
                             // Loads item info into rss array
                             $doc->addItem($item);
                         }
                     }
                 }
             }
         }
     }
     // Output the feed
     echo $doc->render();
 }
示例#2
0
 /**
  * Display an RSS feed of latest entries
  *
  * @return  string
  */
 private function _feed()
 {
     if (!$this->params->get('feeds_enabled', 1)) {
         return $this->_browse();
     }
     include_once PATH_CORE . DS . 'libraries' . DS . 'joomla' . DS . 'document' . DS . 'feed' . DS . 'feed.php';
     // Filters for returning results
     $filters = array('limit' => Request::getInt('limit', Config::get('list_limit')), 'start' => Request::getInt('limitstart', 0), 'year' => Request::getInt('year', 0), 'month' => Request::getInt('month', 0), 'scope' => 'group', 'scope_id' => $this->group->get('gidNumber'), 'search' => Request::getVar('search', ''), 'created_by' => Request::getInt('author', 0), 'state' => 'public');
     $path = Request::path();
     if (strstr($path, '/')) {
         $bits = $this->_parseUrl();
         $filters['year'] = isset($bits[0]) && is_numeric($bits[0]) ? $bits[0] : $filters['year'];
         $filters['month'] = isset($bits[1]) && is_numeric($bits[1]) ? $bits[1] : $filters['month'];
     }
     if ($filters['year'] > date("Y")) {
         $filters['year'] = 0;
     }
     if ($filters['month'] > 12) {
         $filters['month'] = 0;
     }
     // Set the mime encoding for the document
     Document::setType('feed');
     // Start a new feed object
     $doc = Document::instance();
     $doc->link = Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name);
     // Build some basic RSS document information
     $doc->title = Config::get('sitename') . ': ' . Lang::txt('Groups') . ': ' . stripslashes($this->group->get('description')) . ': ' . Lang::txt('Blog');
     $doc->description = Lang::txt('PLG_GROUPS_BLOG_RSS_DESCRIPTION', $this->group->get('cn'), Config::get('sitename'));
     $doc->copyright = Lang::txt('PLG_GROUPS_BLOG_RSS_COPYRIGHT', date("Y"), Config::get('sitename'));
     $doc->category = Lang::txt('PLG_GROUPS_BLOG_RSS_CATEGORY');
     $rows = $this->model->entries($filters)->ordered()->paginated()->rows();
     // Start outputing results if any found
     if ($rows->count() > 0) {
         foreach ($rows as $row) {
             $item = new \Hubzero\Document\Type\Feed\Item();
             // Strip html from feed item description text
             $item->description = $row->content;
             $item->description = \Hubzero\Utility\Sanitize::stripAll(strip_tags(html_entity_decode($item->description)));
             if ($this->params->get('feed_entries') == 'partial') {
                 $item->description = \Hubzero\Utility\String::truncate($item->description, 300);
             }
             $item->description = '<![CDATA[' . $item->description . ']]>';
             // Load individual item creator class
             $item->title = html_entity_decode(strip_tags($row->get('title')));
             $item->link = Route::url($row->link());
             $item->date = date('r', strtotime($row->published()));
             $item->category = '';
             $item->author = $row->creator()->get('name');
             // Loads item info into rss array
             $doc->addItem($item);
         }
     }
     // Output the feed
     echo $doc->render();
     exit;
 }
示例#3
0
 /**
  * Создает новый Документ. При создании нового Документа добавляется запись в БД.
  * @param string $file Путь к файлу
  * @param boolean $copy Если значение параметра Истина, то файл будет скопирован в папку модуля trustednetsiger
  * @param string $name Пользовательское имя файла
  * @param string $type Тип файла. По умолчанию DOCUMENT_TYPE_DOCUMENT
  * @return \Document
  */
 public static function createDocument($file, $copy, $name = null, $type = DOCUMENT_TYPE_FILE)
 {
     $sysName = CDirectory::getFileName($file);
     echo $sysName . PHP_EOL;
     if ($copy && CDirectory::exists($file) && !is_dir($file)) {
         print_r("Copy file" . PHP_EOL);
         print_r(TRUSDET_SIGN_DOCS_ROOT . PHP_EOL);
         if (!CDirectory::exists(TRUSDET_SIGN_DOCS_ROOT)) {
             print_r("Create folder" . PHP_EOL);
             CDirectory::create(TRUSDET_SIGN_DOCS_ROOT);
         }
         $new_path = TRUSDET_SIGN_DOCS_ROOT . '/' . $sysName;
         copy($file, $new_path);
         //unlink($file);
         $file = $new_path;
     }
     $name = $name ? $name : $sysName;
     $doc = new Document();
     $doc->setPath(str_replace($sysName, urlencode($sysName), $file));
     $doc->setName($name);
     $doc->setSysName($sysName);
     $doc->setType($type);
     // $doc->getProperties()->add(new Property($doc->getId(), "STATUS", "NONE"));
     // $props = $doc->getProperties();
     // $props->add(new Property(null, "ORDER", $orderId));
     print_r($doc);
     $doc->save();
     return $doc;
 }
示例#4
0
 /**
  * Output an XSL template
  *
  * @return  void
  */
 public function stylesheetTask()
 {
     Document::setType('xml');
     $this->view->setLayout(Request::getVar('stylesheet', 'stylesheet'))->display();
 }
示例#5
0
 /**
  * 
  * @return \Document
  */
 public function copy()
 {
     $new = new Document();
     $new->setName($this->getName());
     $new->setPath($this->getPath());
     $new->setSigners($this->getSigners());
     $new->setSysName($this->getSysName());
     $new->setType($this->getType());
     $list = $this->getProperties()->getList();
     foreach ($list as &$prop) {
         $newProp = new Property(null, $prop->getType(), $prop->getValue());
         $new->getProperties()->add($newProp);
     }
     return $new;
 }
示例#6
0
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
Document::setType('xml');
// Output XML header.
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
// Output root element.
echo '<root>' . "\n";
// Output the data.
echo "\t" . '<tags>' . "\n";
if ($this->rows) {
    foreach ($this->rows as $datum) {
        echo "\t\t" . '<tag>' . "\n";
        echo "\t\t\t" . '<raw>' . $this->escape(stripslashes($datum->get('raw_tag'))) . '</raw>' . "\n";
        echo "\t\t\t" . '<normalized>' . $this->escape($datum->get('tag')) . '</normalized>' . "\n";
        echo "\t\t\t" . '<total>' . $this->escape($datum->get('total')) . '</total>' . "\n";
        echo "\t\t" . '</tag>' . "\n";
    }
}