* all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 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. * */ // No direct access defined('_HZEXEC_') or die; $database = \App::get('db'); // Get version authors $pa = new \Components\Publications\Tables\Author($database); ?> <ul class="mypubs"> <?php foreach ($this->results as $row) { // Get version authors $authors = $pa->getAuthors($row->version_id); $info = array(); $info[] = Date::of($row->published_up)->toLocal('d M Y'); $info[] = $row->cat_name; $info[] = Lang::txt('COM_PUBLICATIONS_CONTRIBUTORS') . ': ' . \Components\Publications\Helpers\Html::showContributors($authors, false, true); // Display List of items $this->view('_item')->set('option', 'com_publications')->set('row', $row)->set('info', $info)->display(); } ?>
/** * Check completion status * * @return object */ public function getStatus($pub = NULL, $manifest = NULL, $elementId = NULL) { // Set block manifest if ($this->_manifest === NULL) { $this->_manifest = $manifest ? $manifest : self::getManifest(); } // Start status $status = new \Components\Publications\Models\Status(); // Get authors if (!isset($pub->_authors)) { $pAuthors = new \Components\Publications\Tables\Author($this->_parent->_db); $pub->_authors = $pAuthors->getAuthors($pub->version_id); $pub->_submitter = $pAuthors->getSubmitter($pub->version_id, $pub->created_by); } // Are authors required? $required = $this->_manifest->params->required; $status->status = $required && (!$pub->_authors || count($pub->_authors) == 0) ? 0 : 1; if ($status->status == 0) { $status->setError('Missing authors'); } return $status; }
defined('_HZEXEC_') or die; $database = \App::get('db'); switch ($this->filters['sortby']) { case 'date_created': $show_date = 1; break; case 'date_modified': $show_date = 2; break; case 'date': default: $show_date = 3; break; } // Get version authors $pa = new \Components\Publications\Tables\Author($database); ?> <ol class="results" id="publications"> <?php foreach ($this->results as $line) { $authors = $pa->getAuthors($line->version_id); // Get parameters $params = clone $this->config; $rparams = new \Hubzero\Config\Registry($line->params); $params->merge($rparams); // Set the display date switch ($show_date) { case 0: $thedate = ''; break;
/** * 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; }
/** * Unpublish version/delete draft * * @return string */ public function cancelDraft() { // Incoming $pid = $this->_pid ? $this->_pid : Request::getInt('pid', 0); $confirm = Request::getInt('confirm', 0); $version = Request::getVar('version', 'default'); $ajax = Request::getInt('ajax', 0); // Check permission if (!$this->model->access('content')) { throw new Exception(Lang::txt('ALERTNOTAUTH'), 403); return; } // Load publication model $pub = new \Components\Publications\Models\Publication($pid, $version); if (!$pub->exists() || !$pub->belongsToProject($this->model->get('id'))) { throw new Exception(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_VERSION_NOT_FOUND'), 404); return; } // Save version ID $vid = $pub->version->get('id'); // Append breadcrumbs if (!$ajax) { Pathway::append(stripslashes($pub->version->get('title')), $pub->link('edit')); } $baseUrl = Route::url($pub->link('editbase')); $baseEdit = Route::url($pub->link('edit')); // Can only unpublish published version or delete a draft if ($pub->version->get('state') != 1 && $pub->version->get('state') != 3 && $pub->version->get('state') != 4) { $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_CANT_DELETE')); } // Unpublish/delete version if ($confirm) { if (!$this->getError()) { $pubtitle = \Hubzero\Utility\String::truncate($pub->version->get('title'), 100); if ($pub->version->get('state') == 1) { // Unpublish published version $pub->version->set('published_down', Date::toSql()); $pub->version->set('modified', Date::toSql()); $pub->version->set('modified_by', $this->_uid); $pub->version->set('state', 0); if (!$pub->version->store()) { throw new Exception(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_UNPUBLISH_FAILED'), 403); return; } else { $this->_msg = Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_VERSION_UNPUBLISHED'); // Add activity $action = Lang::txt('PLG_PROJECTS_PUBLICATIONS_ACTIVITY_UNPUBLISHED'); $action .= ' ' . strtolower(Lang::txt('version')) . ' ' . $pub->version->get('version_label') . ' ' . Lang::txt('PLG_PROJECTS_PUBLICATIONS_OF') . ' ' . strtolower(Lang::txt('publication')) . ' "' . $pubtitle . '" '; $aid = $this->model->recordActivity($action, $pid, $pubtitle, Route::url($pub->link('editversion')), 'publication', 0); } } elseif ($pub->version->get('state') == 3 || $pub->version->get('state') == 4) { $vlabel = $pub->version->get('version_label'); // Delete draft version if (!$pub->version->delete()) { throw new Exception(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_DELETE_DRAFT_FAILED'), 403); return; } // Delete authors $pa = new \Components\Publications\Tables\Author($this->_database); $authors = $pa->deleteAssociations($vid); // Delete attachments $pContent = new \Components\Publications\Tables\Attachment($this->_database); $pContent->deleteAttachments($vid); // Delete screenshots $pScreenshot = new \Components\Publications\Tables\Screenshot($this->_database); $pScreenshot->deleteScreenshots($vid); // Build publication path $path = PATH_APP . DS . trim($this->_pubconfig->get('webpath'), DS) . DS . \Hubzero\Utility\String::pad($pid); // Build version path $vPath = $path . DS . \Hubzero\Utility\String::pad($vid); // Delete all version files if (is_dir($vPath)) { Filesystem::deleteDirectory($vPath); } // Delete access accosiations $pAccess = new \Components\Publications\Tables\Access($this->_database); $pAccess->deleteGroups($vid); // Delete audience $pAudience = new \Components\Publications\Tables\Audience($this->_database); $pAudience->deleteAudience($vid); // Delete publication existence if ($pub->versionCount() == 0) { // Delete all files if (is_dir($path)) { Filesystem::delete($path); } $pub->publication->delete($pid); $pub->publication->deleteExistence($pid); // Delete related publishing activity from feed $objAA = $this->model->table('Activity'); $objAA->deleteActivityByReference($this->model->get('id'), $pid, 'publication'); } // Add activity $action = Lang::txt('PLG_PROJECTS_PUBLICATIONS_ACTIVITY_DRAFT_DELETED'); $action .= ' ' . $vlabel . ' '; $action .= Lang::txt('PLG_PROJECTS_PUBLICATIONS_OF_PUBLICATION') . ' "' . $pubtitle . '"'; $aid = $this->model->recordActivity($action, $pid, '', '', 'publication', 0); $this->_msg = Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_DRAFT_DELETED'); } } } else { $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'cancel')); // Output HTML $view->option = $this->_option; $view->database = $this->_database; $view->project = $this->model; $view->uid = $this->_uid; $view->pid = $pid; $view->pub = $pub; $view->publishedCount = $pub->version->getPublishedCount($pid); $view->task = $this->_task; $view->config = $this->model->config(); $view->pubconfig = $this->_pubconfig; $view->ajax = $ajax; $view->title = $this->_area['title']; // Get messages and errors $view->msg = $this->_msg; if ($this->getError()) { $view->setError($this->getError()); } return $view->loadTemplate(); } // Pass error or success message if ($this->getError()) { \Notify::message($this->getError(), 'error', 'projects'); } elseif (!empty($this->_msg)) { \Notify::message($this->_msg, 'success', 'projects'); } App::redirect($baseUrl); return; }
/** * Static method for formatting results * * @param object $row Database row * @return string HTML */ public static function out($row) { include_once Component::path('com_publications') . DS . 'tables' . DS . 'author.php'; require_once Component::path('com_publications') . DS . 'helpers' . DS . 'html.php'; $row->href = Route::url('index.php?option=com_publications&id=' . $row->id); $database = App::get('db'); // Get version authors $pa = new \Components\Publications\Tables\Author($database); $authors = $pa->getAuthors($row->ftext); // Get the component params $config = Component::params('com_publications'); $row->rating = $row->rcount; $row->category = $row->data1; $row->area = $row->data2; $row->ranking = $row->data3; // Set the display date switch ($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; } if (strstr($row->href, 'index.php')) { $row->href = Route::url($row->href); } // Start building the HTML $html = "\t" . '<li class="'; $html .= 'publication">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '/?v=' . $row->alias . '">' . stripslashes($row->title) . '</a></p>' . "\n"; $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . $row->area; if ($authors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_TAGS_PUBLICATIONS_CONTRIBUTORS') . ' ' . stripslashes(\Components\Publications\Helpers\Html::showContributors($authors, true, false)); } $html .= '</p>' . "\n"; if ($row->itext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->itext)), 200) . '</p>' . "\n"; } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href . '/?v=' . $row->alias, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
/** * 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'); $config = Component::params('com_publications'); // Get version authors $pa = new \Components\Publications\Tables\Author($database); $authors = $pa->getAuthors($row->version_id); // Start building HTML $html = "\t" . '<li class="publication">' . "\n"; $html .= "\t\t" . '<p><span class="pub-thumb"><img src="' . Route::url('index.php?option=com_publications&id=' . $row->id . '&v=' . $row->version_id) . '/Image:thumb' . '" alt="" /></span>'; $html .= '<span class="pub-details"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a>' . "\n"; $html .= "\t\t" . '<span class="block details">' . Date::of($row->published_up)->toLocal('d M Y') . ' <span>|</span> ' . $row->cat_name; if ($authors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_WHATSNEW_PUBLICATIONS_CONTRIBUTORS') . ' ' . \Components\Publications\Helpers\Html::showContributors($authors, false, true); } $html .= '</span></span></p>' . "\n"; if ($row->text) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->text)), 200) . '</p>' . "\n"; } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
* 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. * */ // No direct access defined('_HZEXEC_') or die; // Sorting and paging $sortbyDir = $this->filters['sortdir'] == 'ASC' ? 'DESC' : 'ASC'; $whatsleft = $this->total - $this->filters['start'] - $this->filters['limit']; $prev_start = $this->filters['start'] - $this->filters['limit']; $prev_start = $prev_start < 0 ? 0 : $prev_start; $next_start = $this->filters['start'] + $this->filters['limit']; // URL $route = 'index.php?option=' . $this->option . '&controller=curation'; $pa = new \Components\Publications\Tables\Author($this->database); $this->css()->js()->css('jquery.fancybox.css', 'system')->css('curation.css')->js('curation.js'); ?> <div id="content-header" class="full"> <h2><?php echo $this->title; ?> </h2> </div><!-- / #content-header --> <div class="main section curation"> <p><?php echo Lang::txt('COM_PUBLICATIONS_CURATION_LIST_INSTRUCT'); ?> </p> <div class="container"> <ul class="entries-menu filter-options">
/** * Display publications user authors * * @apiMethod GET * @apiUri /publications/list * @apiParameter { * "name": "limit", * "description": "Number of result to return.", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "start", * "description": "Number of where to start returning results.", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "sort", * "description": "Field to sort results by.", * "type": "string", * "required": false, * "default": "title", * "allowedValues": "title, created, alias" * } * @apiParameter { * "name": "sort_Dir", * "description": "Direction to sort results by.", * "type": "string", * "required": false, * "default": "desc", * "allowedValues": "asc, desc" * } * @return void */ public function listTask() { $model = new Publication(); Lang::load('plg_projects_publications', PATH_CORE . DS . 'plugins' . DS . 'projects' . DS . 'publications'); // Set filters $filters = array('limit' => Request::getInt('limit', Config::get('list_limit')), 'start' => Request::getInt('start', 0), 'sortby' => Request::getWord('sort', 'title'), 'sortdir' => strtoupper(Request::getWord('sort_Dir', 'ASC')), 'author' => User::get('id')); $response = new stdClass(); $response->publications = array(); $response->total = $model->entries('count', $filters); $database = \App::get('db'); $pa = new \Components\Publications\Tables\Author($database); if ($response->total) { $base = rtrim(Request::base(), '/'); foreach ($model->entries('list', $filters) as $i => $entry) { $obj = new stdClass(); $obj->id = $entry->get('id'); $obj->alias = $entry->get('alias'); $obj->title = $entry->get('title'); $obj->abstract = $entry->get('abstract'); $obj->creator = $entry->creator('name'); $obj->created = $entry->get('created'); $obj->published = $entry->published('date'); $obj->masterType = $entry->masterType()->type; $obj->category = $entry->category()->name; $obj->version = $entry->get('version_number'); $obj->versionLabel = $entry->get('version_label'); $obj->status = $entry->get('state'); $obj->statusName = $entry->getStatusName(); $obj->authors = $pa->getAuthors($entry->get('version_id')); $obj->thumbUrl = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link('thumb')), '/')); $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link('version')), '/')); $obj->manageUri = str_replace('/api', '', $base . '/' . ltrim(Route::url($entry->link('editversion')), '/')); $obj->project = $entry->project()->get('alias'); $response->publications[] = $obj; } } $this->send($response); }
* The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 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. * */ // No direct access defined('_HZEXEC_') or die; // Load full record $pAuthor = new \Components\Publications\Tables\Author($this->database); $author = $pAuthor->getAuthorByOwnerId($this->row->publication_version_id, $this->row->project_owner_id); // Get profile thumb image $profile = \Hubzero\User\Profile::getInstance($this->row->user_id); $actor = \Hubzero\User\Profile::getInstance(User::get('id')); $thumb = $profile ? $profile->getPicture() : $actor->getPicture(true); $name = $author->name ? $author->name : $author->p_name; $name = trim($name) ? $name : $author->invited_name; if (trim($name)) { $nameParts = explode(" ", $name); $lastname = end($nameParts); $firstname = count($nameParts) > 1 ? $nameParts[0] : ''; } else { $firstname = htmlspecialchars($author->givenName); $lastname = htmlspecialchars($author->surname); if (!$author->user_id) {
* */ // No direct access defined('_HZEXEC_') or die; $pubParams = $this->publication->params; $filters = array('category' => Request::getVar('category', ''), 'sortby' => Request::getCmd('sortby', 'date'), 'limit' => Request::getInt('limit', 10000), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'tag' => trim(Request::getVar('tag', '', 'request', 'none', 2)), 'tag_ignored' => array()); // Instantiate a publication object $model = new \Components\Publications\Models\Publication(); // Execute count query $total = $model->entries('count', $filters); // Run query with limit $results = $model->entries('list', $filters); // Initiate paging $pageNav = new \Hubzero\Pagination\Paginator($total, $filters['start'], $filters['limit']); $database = \App::get('db'); $pa = new \Components\Publications\Tables\Author($database); ?> <label for="pub-search"><?php echo Lang::txt('Search'); ?> </label> <input id="pub-search" name="search" placeholder="Start typing here" type="text" data-list=".pub-selector" autocomplete="off" /> <ul class="pub-selector" id="pub-selector"> <?php foreach ($results as $item) { $selected = false; $liId = 'choice-' . $item->get('id'); /*$info = $item->info; if ($item->url) { $info .= ' <a href="' . $item->url . '" target="_blank">' . Lang::txt('Read license terms ›') . '</a>';