/** * Truncate some text * * @param string $text Text to truncate * @param integer $length Length to truncate to * @param array $options Options * @return string * @throws \InvalidArgumentException If no text is passed or length isn't a positive integer */ public function __invoke($text = null, $length = null, $options = array()) { if (null === $text) { throw new \InvalidArgumentException(__METHOD__ . '(); No text passed.'); } if (!$length || !is_numeric($length)) { throw new \InvalidArgumentException(__METHOD__ . '(); Length must be an integer'); } return String::truncate($text, $length, $options); }
/** * Validate data * * @return boolean True if data is valid */ public function check() { $this->message = trim($this->message); if ($this->message == '') { $this->setError(Lang::txt('SUPPORT_ERROR_BLANK_FIELD')); return false; } $this->title = trim($this->title); if (!$this->title) { $this->title = String::truncate($this->message, 250); } return true; }
/** * Constructor * * @param integer $scope_id Scope ID (group, course, etc.) * @return void */ public function __construct($scope_id = 0) { $this->set('scope_id', $scope_id); include_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php'; $offering = \Components\Courses\Models\Offering::getInstance($this->get('scope_id')); $course = \Components\Courses\Models\Course::getInstance($offering->get('course_id')); $this->_segments['gid'] = $course->get('alias'); $this->_segments['offering'] = $offering->alias(); $this->_segments['active'] = 'discussions'; if (Request::getVar('active') == 'outline') { $this->_segments['active'] = 'outline'; } $this->_name = String::truncate($course->get('alias'), 50) . ': ' . String::truncate($offering->get('alias'), 50); }
/** * Process data * * @return void */ protected function _process() { // New project? $new = $this->model->exists() ? false : true; // Are we in setup? $setup = $new || $this->model->inSetup() ? true : false; // Incoming $private = Request::getInt('private', 1); // Save section switch ($this->section) { case 'describe': case 'info': // Incoming $name = trim(Request::getVar('name', '', 'post')); $title = trim(Request::getVar('title', '', 'post')); $name = preg_replace('/ /', '', $name); $name = strtolower($name); // Clean up title from any scripting $title = preg_replace('/\\s+/', ' ', $title); $title = $this->_txtClean($title); // Check incoming data if ($setup && $new && !$this->model->check($name, $this->model->get('id'))) { $this->setError(Lang::txt('COM_PROJECTS_ERROR_NAME_INVALID_OR_EMPTY')); return false; } elseif (!$title) { $this->setError(Lang::txt('COM_PROJECTS_ERROR_TITLE_SHORT_OR_EMPTY')); return false; } if ($this->model->exists()) { $this->model->set('modified', Date::toSql()); $this->model->set('modified_by', User::get('id')); } else { $this->model->set('alias', $name); $this->model->set('created', Date::toSql()); $this->model->set('created_by_user', User::get('id')); $this->model->set('owned_by_group', $this->_gid); $this->model->set('owned_by_user', User::get('id')); $this->model->set('private', $this->config->get('privacy', 1)); } $this->model->set('title', \Hubzero\Utility\String::truncate($title, 250)); $this->model->set('about', trim(Request::getVar('about', '', 'post', 'none', 2))); $this->model->set('type', Request::getInt('type', 1, 'post')); // save advanced permissions if (isset($_POST['private'])) { $this->model->set('private', $private); } if ($setup && !$this->model->exists()) { // Copy params from default project type $objT = $this->model->table('Type'); $this->model->set('params', $objT->getParams($this->model->get('type'))); } // Save changes if (!$this->model->store()) { $this->setError($this->model->getError()); return false; } // Save owners for new projects if ($new) { $this->_identifier = $this->model->get('alias'); // Group owners $objO = $this->model->table('Owner'); if ($this->_gid) { if (!$objO->saveOwners($this->model->get('id'), User::get('id'), 0, $this->_gid, 0, 1, 1, '', $split_group_roles = 0)) { $this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError()); return false; } // Make sure project creator is manager $objO->reassignRole($this->model->get('id'), $users = array(User::get('id')), 0, 1); } elseif (!$objO->saveOwners($this->model->get('id'), User::get('id'), User::get('id'), $this->_gid, 1, 1, 1)) { $this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError()); return false; } } break; case 'team': if ($new) { return false; } // Save team $content = Event::trigger('projects.onProject', array($this->model, 'save', array('team'))); if (isset($content[0]) && $this->next == $this->section) { if (isset($content[0]['msg']) && !empty($content[0]['msg'])) { $this->_setNotification($content[0]['msg']['message'], $content[0]['msg']['type']); } } break; case 'settings': if ($new) { return false; } // Save privacy if (isset($_POST['private'])) { $this->model->set('private', $private); // Save changes if (!$this->model->store()) { $this->setError($this->model->getError()); return false; } } // Save params $incoming = Request::getVar('params', array()); if (!empty($incoming)) { foreach ($incoming as $key => $value) { $this->model->saveParam($key, $value); // If grant information changed if ($key == 'grant_status') { // Meta data for comment $meta = '<meta>' . Date::of('now')->toLocal('M d, Y') . ' - ' . User::get('name') . '</meta>'; $cbase = $this->model->get('admin_notes'); $cbase .= '<nb:sponsored>' . Lang::txt('COM_PROJECTS_PROJECT_MANAGER_GRANT_INFO_UPDATE') . $meta . '</nb:sponsored>'; $this->model->set('admin_notes', $cbase); // Save admin notes if (!$this->model->store()) { $this->setError($this->model->getError()); return false; } $admingroup = $this->config->get('ginfo_group', ''); if (\Hubzero\User\Group::getInstance($admingroup)) { $admins = Helpers\Html::getGroupMembers($admingroup); // Send out email to admins if (!empty($admins)) { Helpers\Html::sendHUBMessage($this->_option, $this->model, $admins, Lang::txt('COM_PROJECTS_EMAIL_ADMIN_REVIEWER_NOTIFICATION'), 'projects_new_project_admin', 'admin', Lang::txt('COM_PROJECTS_PROJECT_MANAGER_GRANT_INFO_UPDATE'), 'sponsored'); } } } } } break; } }
/** * Static method for formatting results * * @param object $row Database row * @return string HTML */ public static function out($row) { $row->href = Route::url($row->href); $month = Date::of($row->publish_up)->toLocal('M'); $day = Date::of($row->publish_up)->toLocal('d'); $year = Date::of($row->publish_up)->toLocal('Y'); // Start building the HTML $html = "\t" . '<li class="event">' . "\n"; $html .= "\t\t" . '<p class="event-date"><span class="month">' . $month . '</span> <span class="day">' . $day . '</span> <span class="year">' . $year . '</span></p>' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($row->ftext) { $row->ftext = str_replace('[[BR]]', '', $row->ftext); // Remove tags to prevent tables from being displayed within a table. $row->ftext = strip_tags($row->ftext); $html .= "\t\t" . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->ftext)), 200) . "\n"; } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
echo $this->pub->id; ?> " /> <input type="hidden" name="vid" value="<?php echo $this->pub->version_id; ?> " /> <input type="hidden" name="task" id="task" value="save" /> </fieldset> <div class="curation-wrap"> <div class="pubtitle"> <h3><span class="restype indlist"><?php echo $typetitle; ?> </span> <?php echo \Hubzero\Utility\String::truncate($this->pub->title, 65); ?> | <?php echo Lang::txt('COM_PUBLICATIONS_CURATION_VERSION') . ' ' . $this->pub->version_label; ?> </h3> </div> <p class="instruct"> <span class="pubimage"><img src="<?php echo Route::url('index.php?option=com_publications&id=' . $this->pub->id . '&v=' . $this->pub->version_id) . '/Image:thumb'; ?> " alt="" /></span> <strong class="block"><?php echo $this->pub->reviewed ? Lang::txt('COM_PUBLICATIONS_CURATION_RESUBMITTED') : Lang::txt('COM_PUBLICATIONS_CURATION_SUBMITTED'); echo ' ' . Date::of($this->pub->submitted)->toLocal('M d, Y') . ' ' . Lang::txt('COM_PUBLICATIONS_CURATION_BY') . ' ' . $this->pub->modifier('name'); ?>
/** * On after approve/kickback * * @return void */ public function onAfterStatusChange() { if ($this->getError()) { return; } $pub = $this->_pub; $status = $this->_pub->version->state; $activity = $status == 1 ? Lang::txt('COM_PUBLICATIONS_CURATION_ACTIVITY_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_CURATION_ACTIVITY_KICKBACK'); $pubtitle = \Hubzero\Utility\String::truncate($pub->title, 100); // Log activity in curation history $pub->_curationModel->saveHistory(User::get('id'), $pub->state, $status, 1); // Add activity $activity .= ' ' . strtolower(Lang::txt('version')) . ' ' . $pub->version_label . ' ' . Lang::txt('COM_PUBLICATIONS_OF') . ' ' . strtolower(Lang::txt('publication')) . ' "' . $pubtitle . '" '; // Record activity $aid = $pub->project()->recordActivity($activity, $pub->id, $pubtitle, $pub->link('version'), 'publication', 0, $admin = 1); // Start message $sef = 'publications' . DS . $pub->id . DS . $pub->version_number; $link = rtrim(Request::base(), DS) . DS . trim($pub->link('version'), DS); $manage = rtrim(Request::base(), DS) . DS . trim($pub->link('editversion'), DS); $message = $status == 1 ? Lang::txt('COM_PUBLICATIONS_CURATION_EMAIL_CURATOR_APPROVED') : Lang::txt('COM_PUBLICATIONS_CURATION_EMAIL_CURATOR_KICKED_BACK'); if ($status != 1) { $message .= "\n" . "\n"; $message .= Lang::txt('COM_PUBLICATIONS_CURATION_TAKE_ACTION') . ' ' . $manage; } else { $message .= ' ' . $link; } $pubtitle = \Hubzero\Utility\String::truncate($pub->title, 100); $subject = ucfirst(Lang::txt('COM_PUBLICATIONS_CURATION_VERSION')) . ' ' . $pub->version_label . ' ' . Lang::txt('COM_PUBLICATIONS_OF') . ' ' . strtolower(Lang::txt('COM_PUBLICATIONS_PUBLICATION')) . ' "' . $pubtitle . '" '; $subject .= $status == 1 ? Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_PUBLISHED') : Lang::txt('COM_PUBLICATIONS_MSG_ADMIN_KICKED_BACK'); // Get authors $authors = $pub->table('Author')->getAuthors($pub->version_id, 1, 1, 1); // No authors – send to publication creator if (count($authors) == 0) { $authors = array($pub->created_by); } // New version released? if ($status == 1 && $pub->get('version_number') > 1) { // Notify subsrcibers Event::trigger('publications.onWatch', array($pub)); } // Make sure there are no duplicates $authors = array_unique($authors); // Notify authors Helpers\Html::notify($pub, $authors, $subject, $message, true); return; }
/** * Get the content of the entry * * @param string $as Format to return state in [text, number] * @param integer $shorten Number of characters to shorten text to * @return string */ public function content($as = 'parsed', $shorten = 0) { $as = strtolower($as); $options = array(); switch ($as) { case 'parsed': $content = $this->get('comment.parsed', null); if ($content === null) { $config = array('option' => $this->get('option', 'com_projects'), 'scope' => $this->get('scope'), 'pagename' => $this->get('alias'), 'pageid' => 0, 'filepath' => $this->get('path'), 'domain' => ''); $content = str_replace(array('\\"', "\\'"), array('"', "'"), (string) $this->get('comment', '')); $this->importPlugin('content')->trigger('onContentPrepare', array($this->_context, &$this, &$config)); $this->set('comment.parsed', (string) $this->get('comment', '')); $this->set('comment', $content); return $this->content($as, $shorten); } $options['html'] = true; break; case 'clean': $content = strip_tags($this->content('parsed')); break; case 'raw': default: $content = str_replace(array('\\"', "\\'"), array('"', "'"), $this->get('comment')); $content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content); break; } if ($shorten) { $content = \Hubzero\Utility\String::truncate($content, $shorten, $options); } return $content; }
$when = Date::of($row->proposed)->relative(); $title = strip_tags($row->about) ? $this->escape(stripslashes($row->subject)) . ' :: ' . \Hubzero\Utility\String::truncate($this->escape(strip_tags($row->about)), 160) : NULL; ?> <li class="wishlist"> <a href="<?php echo Route::url('index.php?option=com_wishlist&task=wish&id=' . $row->wishlist . '&wishid=' . $row->id); ?> " class="tooltips" title="<?php echo $title; ?> "> #<?php echo $row->id; ?> : <?php echo \Hubzero\Utility\String::truncate(stripslashes($row->subject), 35); ?> </a> <span> <span class="<?php echo $row->status == 3 ? 'rejected' : ''; if ($row->status == 0) { echo $row->accepted == 1 ? 'accepted' : 'pending'; } ?> "> <?php echo $row->status == 3 ? Lang::txt('MOD_MYWISHES_REJECTED') : ''; if ($row->status == 0) { echo $row->accepted == 1 ? Lang::txt('MOD_MYWISHES_ACCEPTED') : Lang::txt('MOD_MYWISHES_PENDING'); }
</dd> <?php } if ($params->get('show_author') or $params->get('show_category') or $params->get('show_create_date') or $params->get('show_modify_date') or $params->get('show_publish_date') or $params->get('show_hits')) { ?> </dl> <?php } ?> <?php if ($params->get('show_intro')) { ?> <div class="intro"> <?php echo \Hubzero\Utility\String::truncate($item->introtext, $params->get('introtext_limit')); ?> </div> <?php } ?> </li> <?php } ?> </ul> <div class="pagination"> <p class="counter"> <?php echo $this->pagination->getPagesCounter();
echo $this->escape(stripslashes($this->title)); ?> " /> </a> </p> <?php } ?> <p> <a href="<?php echo Route::url('index.php?option=com_members&id=' . $this->id); ?> "> <?php echo $this->escape(stripslashes($this->title)); ?> </a>: <?php if ($this->txt) { ?> <?php echo \Hubzero\Utility\String::truncate($this->escape(strip_tags($this->txt)), $this->txt_length); ?> <?php } ?> </p> </div> <?php } }
/** * Generate an RSS feed of entries * * @return void */ public function feedTask() { if (!$this->config->get('feeds_enabled')) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // 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); // Incoming $filters = array('year' => Request::getInt('year', 0), 'month' => Request::getInt('month', 0), 'scope' => $this->config->get('show_from', 'site'), 'scope_id' => 0, 'search' => Request::getVar('search', ''), 'authorized' => false, 'state' => 1, 'access' => User::getAuthorisedViewLevels()); if ($filters['year'] > date("Y")) { $filters['year'] = 0; } if ($filters['month'] > 12) { $filters['month'] = 0; } if ($filters['scope'] == 'both') { $filters['scope'] = ''; } if (!User::isGuest()) { if ($this->config->get('access-manage-component')) { //$filters['state'] = null; $filters['authorized'] = true; array_push($filters['access'], 5); } } // Build some basic RSS document information $doc->title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option)); $doc->title .= $filters['year'] ? ': ' . $filters['year'] : ''; $doc->title .= $filters['month'] ? ': ' . sprintf("%02d", $filters['month']) : ''; $doc->description = Lang::txt('COM_BLOG_RSS_DESCRIPTION', Config::get('sitename')); $doc->copyright = Lang::txt('COM_BLOG_RSS_COPYRIGHT', date("Y"), Config::get('sitename')); $doc->category = Lang::txt('COM_BLOG_RSS_CATEGORY'); // Get the records $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 = html_entity_decode(Sanitize::stripAll($item->description)); if ($this->config->get('feed_entries') == 'partial') { $item->description = 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('email') . ' (' . $row->creator()->get('name') . ')'; // Loads item info into rss array $doc->addItem($item); } } }
/** * Generate macro output * * @return string */ public function render() { // check if we can render if (!parent::canRender()) { return \Lang::txt('[This macro is designed for Groups only]'); } // get args $args = $this->getArgs(); // get details $type = $this->_getType($args, 'all'); $limit = $this->_getLimit($args, 5); $class = $this->_getClass($args); //get resources $groupResources = $this->_getResources($type, $limit); $html = '<div class="resources ' . $class . '">'; foreach ($groupResources as $resource) { $area = strtolower(preg_replace("/[^a-zA-Z0-9]/", '', $resource->area)); $resourceLink = \Route::url('index.php?option=com_resources&id=' . $resource->id); $resourceTypeLink = \Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=resources&area=' . $area); $html .= '<a href="' . $resourceLink . '"><strong>' . $resource->title . '</strong></a>'; $html .= '<p class="category"> in: <a href="' . $resourceTypeLink . '">' . $resource->area . '</a></p>'; $html .= '<p>' . \Hubzero\Utility\String::truncate($resource->itext) . '</p>'; } $html .= '</div>'; return $html; }
// Does this category have a unique output display? $func = 'plgWhatsnew' . ucfirst($row->section) . 'Out'; // Check if a method exist (using JPlugin style) $obj = 'plgWhatsnew' . ucfirst($this->cats[$k]['category']); if (function_exists($func)) { $html .= $func($row, $this->period); } elseif (method_exists($obj, 'out')) { $html .= call_user_func(array($obj, 'out'), $row, $this->period); } else { if (strstr($row->href, 'index.php')) { $row->href = Route::url($row->href); } $html .= "\t" . '<li>' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($row->text) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->text))), 200) . '</p>' . "\n"; } $html .= "\t\t" . '<p class="href">' . rtrim(Request::getSchemeAndHttpHost(), '/') . '/' . ltrim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; } } $html .= '</ol>' . "\n"; // Initiate paging if we we're displaying an active category if ($dopaging) { $pageNav = $this->pagination($this->total, $this->start, $this->limit); $pageNav->setAdditionalUrlParam('category', urlencode(strToLower($this->active))); $pageNav->setAdditionalUrlParam('period', $this->period); $html .= $pageNav->render(); $html .= '<div class="clearfix"></div>'; } else { $html .= '<p class="moreresults">' . Lang::txt('COM_WHATSNEW_TOP_SHOWN', $amt);
/** * 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; }
$overdue = $row->isOverdue(); $oNote = $overdue ? ' <span class="block">(' . Lang::txt('PLG_PROJECTS_TODO_OVERDUE') . ')</span>' : ''; ?> <tr class="pin_grey" id="todo-<?php echo $row->get('id'); ?> "> <td><span class="ordernum"><?php echo $order; ?> </span></td> <td><a href="<?php echo Route::url($row->project()->link('todo') . '&action=view&todoid=' . $row->get('id')); ?> "><?php echo \Hubzero\Utility\String::truncate($row->get('content'), 200); ?> </a> <span class="block mini faded"><?php echo Lang::txt('PLG_PROJECTS_TODO_CREATED') . ' ' . $row->created('date') . ' ' . strtolower(Lang::txt('PLG_PROJECTS_TODO_BY')) . ' ' . $row->creator('name'); ?> | <?php echo Lang::txt('PLG_PROJECTS_TODO_COMMENTS'); ?> : <a href="<?php echo Route::url($row->project()->link('todo') . '&action=view&todoid=' . $row->get('id')); ?> "><?php echo $row->comments('count'); ?> </a></span>
echo $creator->picture($a->admin); ?> " alt="" /> <?php } ?> <div class="blog-content"> <?php if ($showProject) { ?> <span class="project-name"> <a href="<?php echo Route::url($this->model->link()); ?> "><?php echo \Hubzero\Utility\String::truncate($this->model->get('title'), 65); ?> </a> </span> <?php } ?> <span class="actor"><?php echo $a->admin == 1 ? Lang::txt('COM_PROJECTS_ADMIN') : $a->name; ?> </span> <span class="item-time">· <?php echo \Components\Projects\Helpers\Html::showTime($a->recorded, true); ?> </span> <?php
/** * Fix pathway * * @param object $page * * @return string */ public function fixupPathway() { Pathway::clear(); // Add group if ($this->model->groupOwner()) { Pathway::append(Lang::txt('COM_PROJECTS_GROUPS_COMPONENT'), Route::url('index.php?option=com_groups')); Pathway::append(\Hubzero\Utility\String::truncate($this->model->groupOwner('description'), 50), Route::url('index.php?option=com_groups&cn=' . $this->model->groupOwner('cn'))); Pathway::append(Lang::txt('COM_PROJECTS_PROJECTS'), Route::url('index.php?option=com_groups&cn=' . $this->model->groupOwner('cn') . '&active=projects')); } else { Pathway::append(Lang::txt('COMPONENT_LONG_NAME'), Route::url('index.php?option=' . $this->_option)); } if ($this->model->exists()) { Pathway::append(stripslashes($this->model->get('title')), Route::url('index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias'))); } if ($this->_tool && $this->_tool->id) { Pathway::append(ucfirst(Lang::txt('COM_PROJECTS_PANEL_TOOLS')), Route::url('index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias') . '&active=tools')); Pathway::append(\Hubzero\Utility\String::truncate($this->_tool->title, 50), Route::url('index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias') . '&active=tools&tool=' . $this->_tool->id)); Pathway::append(ucfirst(Lang::txt('COM_PROJECTS_TOOLS_TAB_WIKI')), Route::url('index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias') . '&active=tools&tool=' . $this->_tool->id . '&action=wiki')); } else { Pathway::append(ucfirst(Lang::txt('COM_PROJECTS_TAB_NOTES')), Route::url('index.php?option=' . $this->_option . '&alias=' . $this->model->get('alias') . '&active=notes')); } }
/** * Retrieves a row from the database * * @param string $refid ID of the database table row * @param string $category Element type (determines table to look in) * @param string $parent If the element has a parent element * @return array */ public function transferItem($from_type, $from_id, $to_type, $rid = 0, $deactivate = 1) { $upconfig = Component::params('com_members'); $this->banking = $upconfig->get('bankAccounts'); $database = App::get('db'); if ($from_type == NULL or $from_id == NULL or $to_type == NULL) { $this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_MISSING_INFO')); return false; } if ($from_type == $to_type) { $this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_CATEGORIES_MUST_BE_DIFFERENT')); return false; } // collectors $author = ''; $subject = ''; $body = ''; $tags = ''; $owner = ''; // name of group owning the item $anonymous = 0; // get needed scripts include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'models' . DS . 'ticket.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'models' . DS . 'question.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'models' . DS . 'wishlist.php'; $wconfig = Component::params('com_wishlist'); $admingroup = $wconfig->get('group') ? $wconfig->get('group') : 'hubadmin'; // Get needed scripts & initial data switch ($from_type) { // Transfer from a Support Ticket case 'ticket': $row = new \Components\Support\Models\Ticket($from_id); if ($row->exists()) { $author = $row->get('login'); $subject = $row->content('raw', 200); // max 200 characters $body = $row->get('summary'); $owner = $row->get('group'); // If we are de-activating original item if ($deactivate) { $row->set('status', 2); $row->set('resolved', 'transfered'); } $tags = $row->tags('string'); } else { $this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_ITEM_NOT_FOUND')); return false; } break; // Transfer from a Question // Transfer from a Question case 'question': $row = new \Components\Answers\Models\Question($from_id); if ($row->exists()) { $author = $row->get('created_by'); $subject = $row->subject('raw', 200); // max 200 characters $body = $row->get('question'); $anonymous = $row->get('anonymous'); // If we are de-activating original item if ($deactivate) { $row->set('state', 2); $row->set('reward', 0); } $tags = $row->tags('string'); } else { $this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_ITEM_NOT_FOUND')); return false; } break; // Transfer from a Wish // Transfer from a Wish case 'wish': $row = new \Components\Wishlist\Tables\Wish($database); $row->load($from_id); if ($row->id) { $author = $row->proposed_by; $subject = \Hubzero\Utility\String::truncate($row->subject, 200); // max 200 characters $body = $row->about; $anonymous = $row->anonymous; // If we are de-activating original item if ($deactivate) { $row->status = 2; $row->ranking = 0; // also delete all previous votes for this wish $objR = new \Components\Wishlist\Tables\Rank($database); $objR->remove_vote($from_id); } // get owner $objG = new \Components\Wishlist\Tables\OwnerGroup($database); $nativegroups = $objG->get_owner_groups($row->wishlist, $admingroup, '', 1); $owner = count($nativegroups) > 0 && $nativegroups[0] != $admingroup ? $nativegroups[0] : ''; // tool group $objWishlist = new \Components\Wishlist\Tables\Wishlist($database); $wishlist = $objWishlist->get_wishlist($row->wishlist); if (isset($wishlist->resource) && isset($wishlist->resource->alias)) { $tags = $wishlist->resource->type == 7 ? 'tool:' : 'resource:'; $tags .= $wishlist->resource->alias ? $wishlist->resource->alias : $wishlist->referenceid; } } else { $this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_ITEM_NOT_FOUND')); return false; } break; } // if no author can be found, use current administrator $author = User::getInstance($author); if (!is_object($author)) { $author = User::getInstance(User::get('id')); } $today = Date::toSql(); // Where do we transfer? switch ($to_type) { // Transfer to a Support Ticket case 'ticket': $newrow = new \Components\Support\Models\Ticket(); $newrow->set('open', 1); $newrow->set('status', 0); $newrow->set('created', $today); $newrow->set('login', $author->get('username')); $newrow->set('severity', 'normal'); $newrow->set('summary', $subject); $newrow->set('report', $body ? $body : $subject); $newrow->set('section', 1); $newrow->set('type', 0); $newrow->set('instances', 1); $newrow->set('email', $author->get('email')); $newrow->set('name', $author->get('name')); // do we have an owner group? $newrow->set('group', $owner ? $owner : ''); break; case 'question': $newrow = new \Components\Answers\Models\Question(); $newrow->set('subject', $subject); $newrow->set('question', $body); $newrow->set('created', $today); $newrow->set('created_by', $author->get('id')); $newrow->set('state', 0); $newrow->set('anonymous', $anonymous); break; case 'wish': $newrow = new \Components\Wishlist\Models\Wish(); $newrow->set('subject', $subject); $newrow->set('about', $body); $newrow->set('proposed', $today); $newrow->set('proposed_by', $author->get('id')); $newrow->set('status', 0); $newrow->set('anonymous', $anonymous); // which wishlist? $objWishlist = new \Components\Wishlist\Tables\Wishlist($database); $mainlist = $objWishlist->get_wishlistID(1, 'general'); $listid = 0; if (!$rid && $owner) { $rid = $this->getResourceIdFromGroup($owner); } if ($rid) { $listid = $objWishlist->get_wishlistID($rid); } $newrow->set('wishlist', $listid ? $listid : $mainlist); break; } // Save new information if (!$newrow->store()) { $this->setError($newrow->getError()); return; } else { // Checkin ticket //$newrow->checkin(); // Extras if ($newrow->exists()) { switch ($to_type) { case 'ticket': // Tag new ticket if ($tags) { $newrow->tag($tags, User::get('id'), 0); } break; case 'question': // Tag new question if ($tags) { $newrow->tag($tags, User::get('id'), 0); } break; } } } // If we are de-activating original item if ($deactivate) { // overwrite old entry if (!$row->store()) { $this->setError($row->getError()); exit; } // Clean up rewards if banking if ($this->banking) { switch ($from_type) { case 'ticket': // no banking yet break; case 'question': $reward = \Hubzero\Bank\Transaction::getAmount('answers', 'hold', $from_id, $author->get('id')); // Remove hold if ($reward) { \Hubzero\Bank\Transaction::deleteRecords('answers', 'hold', $from_id); // Make credit adjustment $BTL_Q = new \Hubzero\Bank\Teller($author->get('id')); $credit = $BTL_Q->credit_summary(); $adjusted = $credit - $reward; $BTL_Q->credit_adjustment($adjusted); } break; case 'wish': include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'helpers' . DS . 'economy.php'; $WE = new \Components\Wishlist\Helpers\Economy($database); $WE->cleanupBonus($from_id); break; } } } return $newrow->get('id'); }
/** * Static method for formatting results * * @param object $row Database row * @return string HTML */ public static function out($row) { $database = App::get('db'); $thedate = Date::of($row->published_up)->toLocal('d M Y'); // Get version authors $pa = new \Components\Publications\Tables\Author($database); $authors = $pa->getAuthors($row->version_id); $html = "\t" . '<li class="resource">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . stripslashes($row->cat_name); if ($authors) { $html .= ' <span>|</span>' . Lang::txt('PLG_MEMBERS_IMPACT_CONTRIBUTORS') . ': ' . \Components\Publications\Helpers\Html::showContributors($authors, false, true) . "\n"; } if ($row->doi) { $html .= ' <span>|</span> doi:' . $row->doi . "\n"; } if (!$row->project_provisioned && (isset($row->project_private) && $row->project_private != 1 || $row->author == true)) { $url = 'index.php?option=com_projects&alias=' . $row->project_alias; $url .= $row->author == true ? '&active=publications&pid=' . $row->id : ''; $html .= ' <span>|</span> Project: '; $html .= '<a href="'; $html .= Route::url($url) . '">'; $html .= $row->project_title; $html .= '</a>'; $html .= "\n"; } $html .= '</p>' . "\n"; if ($row->text) { $html .= "\t\t<p>" . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->text)), 300) . "</p>\n"; } $html .= "\t" . '</li>' . "\n"; return $html; }
</time></span> <span class="comment-date-on"><?php echo Lang::txt('COM_BLOG_ON'); ?> </span> <span class="date"><time datetime="<?php echo $replyto->get('created'); ?> "><?php echo $replyto->created('date'); ?> </time></span> </p> <p> <?php echo \Hubzero\Utility\String::truncate(stripslashes($replyto->get('content')), 300); ?> </p> </blockquote> <?php } } ?> <?php if (!User::isGuest()) { ?> <label for="commentcontent"> Your <?php echo $replyto->get('id') ? 'reply' : 'comments'; ?>
defined('_HZEXEC_') or die; // Get block/element properties $props = $this->pub->curation('blocks', $this->master->blockId, 'props') . '-' . $this->elementId; $complete = $this->pub->curation('blocks', $this->master->blockId, 'elementStatus', $this->elementId); $required = $this->pub->curation('blocks', $this->master->blockId, 'elements', $this->elementId)->params->required; $elName = 'content-element' . $this->elementId; $max = $this->manifest->params->max; $multiZip = isset($this->manifest->params->typeParams->multiZip) && $this->manifest->params->typeParams->multiZip == 0 ? false : true; // Customize title $defaultTitle = $this->manifest->params->title ? str_replace('{pubtitle}', $this->pub->title, $this->manifest->params->title) : NULL; $defaultTitle = $this->manifest->params->title ? str_replace('{pubversion}', $this->pub->version_label, $defaultTitle) : NULL; $error = $this->status->getError(); $aboutTxt = $this->manifest->adminTips ? $this->manifest->adminTips : $this->manifest->about; $shorten = $aboutTxt && strlen($aboutTxt) > 200 ? 1 : 0; if ($shorten) { $about = \Hubzero\Utility\String::truncate($aboutTxt, 200); $about .= ' <a href="#more-' . $elName . '" class="more-content">' . Lang::txt('COM_PUBLICATIONS_READ_MORE') . '</a>'; $about .= ' <div class="hidden">'; $about .= ' <div class="full-content" id="more-' . $elName . '">' . $aboutTxt . '</div>'; $about .= ' </div>'; } else { $about = $aboutTxt; } // Get version params and extract bundle name $bundleName = $this->pub->params->get($elName . 'bundlename', $defaultTitle); $bundleName = $bundleName ? $bundleName : 'bundle'; $bundleName .= '.zip'; // Get attachment model $modelAttach = new \Components\Publications\Models\Attachments($this->database); // Get handler model $modelHandler = new \Components\Publications\Models\Handlers($this->database);
} ?> <?php if ($this->row->isComplete()) { ?> » <span class="indlist completedtd"><a href="<?php echo Route::url($url) . '/?state=1'; ?> "><?php echo ucfirst(Lang::txt('PLG_PROJECTS_TODO_COMPLETED')); ?> </a></span> <?php } ?> » <span class="itemname"><?php echo \Hubzero\Utility\String::truncate($this->row->get('content'), 60); ?> </span> </h3> </div> <div class="pinboard"> <section class="section intropage"> <div class="grid"> <div class="col span8"> <div id="td-item" class="<?php echo $class; ?> "> <span class="pin"> </span> <div class="todo-content">
$html = '<h3>' . $this->escape(stripslashes($name)) . ' <span>(' . Lang::txt('COM_TAGS_RESULTS_THROUGH_OF', $this->filters['start'] + 1, $ttl, $total) . ')</span></h3>' . "\n"; if ($this->results) { $html .= '<ol class="results">' . "\n"; foreach ($this->results as $row) { $obj = 'plgTags' . ucfirst($row->section); if (method_exists($obj, 'out')) { $html .= call_user_func(array($obj, 'out'), $row); } else { // @todo accomodate scope (aka) group citations if (strstr($row->href, 'index.php')) { $row->href = Route::url($row->href); } $html .= "\t" . '<li>' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . \Hubzero\Utility\Sanitize::clean($row->title) . '</a></p>' . "\n"; if ($row->ftext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags($row->ftext), 200) . "</p>\n"; } $html .= "\t\t" . '<p class="href">' . $base . $row->href . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; } } $html .= '</ol>' . "\n"; } else { $html = '<p class="warning">' . Lang::txt('COM_TAGS_NO_RESULTS') . '</p>'; } echo $html; ?> </div><!-- / .container-block --> <?php $pageNav = $this->pagination($total, $this->filters['start'], $this->filters['limit']); $pageNav->setAdditionalUrlParam('task', '');
<?php echo String::highlight($record->task->name, $this->filters['search'], array('html' => true)); ?> </div> </div> <div class="td last" title="<?php echo $record->description; ?> "> <div class="small-label"><?php echo Lang::txt('COM_TIME_RECORDS_DESCRIPTION'); ?> :</div> <div class="small-content"> <?php echo String::highlight(String::truncate($record->description, 25), $this->filters['search'], array('html' => true)); ?> </div> </div> </div> <?php } ?> <?php if (!$this->records->count()) { ?> <div class="tr"> <div colspan="7" class="td no_records"><?php echo Lang::txt('COM_TIME_RECORDS_NONE_TO_DISPLAY'); ?> </div>
$html .= "\t\t\t" . '<td>' . $breeze . '</td>' . "\n"; } $html .= "\t\t\t" . '<td>' . $videoi . '</td>' . "\n"; $html .= "\t\t\t" . '<td>' . $pdf . '</td>' . "\n"; $html .= "\t\t\t" . '<td>' . $supp . '</td>' . "\n"; $html .= "\t\t\t" . '<td>' . $exercises . '</td>' . "\n"; } else { //$html .= "\t\t\t".'<td colspan="5">'.Lang::txt('Currently unavilable').'</td>'."\n"; $html .= "\t\t\t" . '<td colspan="5"> </td>' . "\n"; } $html .= "\t\t" . '</tr>' . "\n"; if ($child->standalone == 1) { if ($child->type != 31 && $child->introtext) { $html .= "\t\t" . '<tr class="' . $o . '">' . "\n"; $html .= "\t\t\t" . '<td colspan="6">'; $html .= \Hubzero\Utility\String::truncate(stripslashes($child->introtext), 200) . '<br /><br />'; $html .= "\t\t\t" . '</td>' . "\n"; $html .= "\t\t" . '</tr>' . "\n"; } } } echo $html; ?> </tbody> </table> <?php } } ?> </section><!-- / .main section --> <?php
/** * Special formatting for results * * @param object $row Database row * @param string $period Time period * @return string */ public static function out($row, $period) { $database = App::get('db'); $helper = new \Components\Resources\Helpers\Helper($row->id, $database); // Instantiate a helper object if (!isset($row->authors)) { $helper->getContributors(); $row->authors = $helper->contributors; } // Get the component params and merge with resource params $config = Component::params('com_resources'); $rparams = new \Hubzero\Config\Registry($row->params); // Set the display date switch ($rparams->get('show_date', $config->get('show_date'))) { case 0: $thedate = ''; break; case 1: $thedate = Date::of($row->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 2: $thedate = Date::of($row->modified)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 3: $thedate = Date::of($row->publish_up)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; } // Start building HTML $html = "\t" . '<li class="resource">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($rparams->get('show_ranking', $config->get('show_ranking'))) { $helper->getCitationsCount(); $helper->getLastCitationDate(); if ($row->area == 'Tools') { $stats = new \Components\Resources\Helpers\Usage\Stats($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } $statshtml = $stats->display(); $row->ranking = round($row->ranking, 1); $html .= "\t\t" . '<div class="metadata">' . "\n"; $r = 10 * $row->ranking; if (intval($r) < 10) { $r = '0' . $r; } $html .= "\t\t\t" . '<dl class="rankinfo">' . "\n"; $html .= "\t\t\t\t" . '<dt class="ranking"><span class="rank-' . $r . '">' . Lang::txt('PLG_WHATSNEW_RESOURCES_THIS_HAS') . '</span> ' . number_format($row->ranking, 1) . ' ' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING') . '</dt>' . "\n"; $html .= "\t\t\t\t" . '<dd>' . "\n"; $html .= "\t\t\t\t\t" . '<p>' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING_EXPLANATION') . '</p>' . "\n"; $html .= "\t\t\t\t\t" . '<div>' . "\n"; $html .= $statshtml; $html .= "\t\t\t\t\t" . '</div>' . "\n"; $html .= "\t\t\t\t" . '</dd>' . "\n"; $html .= "\t\t\t" . '</dl>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } elseif ($rparams->get('show_rating', $config->get('show_rating'))) { switch ($row->rating) { case 0.5: $class = ' half-stars'; break; case 1: $class = ' one-stars'; break; case 1.5: $class = ' onehalf-stars'; break; case 2: $class = ' two-stars'; break; case 2.5: $class = ' twohalf-stars'; break; case 3: $class = ' three-stars'; break; case 3.5: $class = ' threehalf-stars'; break; case 4: $class = ' four-stars'; break; case 4.5: $class = ' fourhalf-stars'; break; case 5: $class = ' five-stars'; break; case 0: default: $class = ' no-stars'; break; } $html .= "\t\t" . '<div class="metadata">' . "\n"; $html .= "\t\t\t" . '<p class="rating"><span class="avgrating' . $class . '"><span>' . Lang::txt('PLG_WHATSNEW_RESOURCES_OUT_OF_5_STARS', $row->rating) . '</span> </span></p>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . $row->area; if ($row->authors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_WHATSNEW_RESOURCES_CONTRIBUTORS') . ' ' . $row->authors; } $html .= '</p>' . "\n"; if ($row->itext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->itext)), 200) . '</p>' . "\n"; } else { if ($row->ftext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->ftext)), 200) . '</p>' . "\n"; } } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
</td> <td> <span class="<?php echo $class; ?> hasTip" title="<?php echo $status; ?> "> </span> </td> <td> <a href="<?php echo Route::url('index.php?option=com_projects&task=edit&id[]=' . $row->project_id); ?> "><?php echo \Hubzero\Utility\String::truncate($row->project_title, 50); ?> </a> </td> <td> <a href="<?php echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller . '&task=versions&id=' . $row->id . $filterstring); ?> "><?php echo $this->escape($row->versions); ?> </a> </td> <td> <?php echo $this->escape($row->base);
/** * Get the content of the entry * * @param string $as Format to return state in [text, number] * @param integer $shorten Number of characters to shorten text to * @return string */ public function content($as = 'parsed', $shorten = 0) { $as = strtolower($as); $options = array(); switch ($as) { case 'parsed': $content = $this->get('description.parsed', null); if ($content == null) { $config = array('option' => 'com_jobs', 'scope' => 'job' . DS . $this->get('code'), 'pagename' => 'jobs', 'pageid' => $this->get('code'), 'filepath' => '', 'domain' => ''); $content = stripslashes($this->get('description')); $this->importPlugin('content')->trigger('onContentPrepare', array($this->_context, &$this, &$config)); $this->set('description.parsed', $this->get('description')); $this->set('description', $content); return $this->content($as, $shorten); } $options['html'] = true; break; case 'clean': $content = strip_tags($this->content('parsed')); $content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content); break; case 'raw': default: $content = stripslashes($this->get('description')); $content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content); break; } if ($shorten) { $content = String::truncate($content, $shorten, $options); } return $content; }
/** * Static method for formatting results * * @param object $row Database row * @return string HTML */ public function out($row) { $row->href = Route::url('index.php?option=com_kb§ion=' . $row->data2 . '&category=' . $row->data1 . '&alias=' . $row->alias); // Start building the HTML $html = "\t" . '<li class="kb-entry">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($row->ftext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->ftext)), 200) . "</p>\n"; } $html .= "\t\t" . '<p class="href">' . Request::base() . ltrim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }