コード例 #1
0
ファイル: entries.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * List all tags
  *
  * @return  void
  */
 public function displayTask()
 {
     // Incoming
     $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'by' => Request::getState($this->_option . '.' . $this->_controller . '.by', 'filterby', 'all'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'raw_tag'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
     // In case limit has been changed, adjust limitstart accordingly
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     $t = new Cloud();
     // Record count
     $this->view->total = $t->tags('count', $this->view->filters);
     $this->view->filters['limit'] = $this->view->filters['limit'] == 0 ? 'all' : $this->view->filters['limit'];
     // Get records
     $this->view->rows = $t->tags('list', $this->view->filters);
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->display();
 }
コード例 #2
0
ファイル: tags.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Render a tag cloud
  *
  * @param      string  $rtrn    Format to render
  * @param      array   $filters Filters to apply
  * @param      boolean $clear   Clear cached data?
  * @return     string
  */
 public function render($rtrn = 'html', $filters = array(), $clear = false)
 {
     if (strtolower($rtrn) == 'linkedlist') {
         $bits = array();
         foreach ($this->tags('list', $filters, $clear) as $tag) {
             $bits[] = '<a' . ($tag->get('admin') ? ' class="admin"' : '') . ' href="' . Route::url('index.php?option=com_support&task=tickets&find=tag:' . $tag->get('tag')) . '">' . stripslashes($tag->get('raw_tag')) . '</a>';
         }
         return implode(', ', $bits);
     }
     return parent::render($rtrn, $filters, $clear);
 }
コード例 #3
0
ファイル: tags.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Return a list of tags for an object as a comma-separated string
  *
  * @param      integer $oid       Object ID
  * @param      integer $offset    Record offset
  * @param      integer $limit     Number to return
  * @param      integer $tagger_id Tagger ID
  * @param      integer $strength  Tag strength
  * @param      integer $admin     Admin tags?
  * @return     string
  */
 public function get_tag_string($oid, $offset = 0, $limit = 0, $tagger_id = NULL, $strength = 0, $admin = 0, $label = '')
 {
     $cloud = new Cloud($oid, $this->_tbl);
     return $cloud->render('string');
 }
コード例 #4
0
ファイル: entriesv1_0.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Displays a list of tags
  *
  * @apiMethod GET
  * @apiUri    /tags/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "raw_tag",
  * 		"allowedValues": "created, id, tag, raw_tag"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @apiParameter {
  * 		"name":          "scope",
  * 		"description":   "Object scope (ex: group, resource, etc.)",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       null
  * }
  * @apiParameter {
  * 		"name":          "scope_id",
  * 		"description":   "Object scope ID. Typically a Resource ID, Group ID, etc.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "taggerid",
  * 		"description":   "ID of user that tagged items.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @return  void
  */
 public function listTask()
 {
     $cloud = new Cloud();
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'scope' => Request::getWord('scope', ''), 'scope_id' => Request::getInt('scope_id', 0), 'taggerid' => Request::getVar('tagger', ''), 'sort' => Request::getWord('sort', 'raw_tag'), 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'ASC')));
     if ($filters['scope'] == 'members' || $filters['scope'] == 'member') {
         $filters['scope'] = 'xprofiles';
     }
     $response = new stdClass();
     $response->tags = array();
     $response->total = $cloud->tags('count', $filters);
     //$response->showing = ($filters['start'] + 1) . ' - ' . ($filters['start'] + $filters['limit']);
     $response->start = $filters['start'];
     $response->limit = $filters['limit'];
     if ($response->total) {
         $base = rtrim(Request::base(), '/');
         foreach ($cloud->tags('list', $filters) as $i => $tag) {
             $obj = new stdClass();
             $obj->id = $tag->get('id');
             $obj->raw_tag = $tag->get('raw_tag');
             $obj->tag = $tag->get('tag');
             $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url($tag->link()), '/'));
             $obj->substitutes_count = $tag->get('substitutes');
             $obj->objects_count = $tag->get('total');
             $response->tags[] = $obj;
         }
     }
     $response->success = true;
     $this->send($response);
 }
コード例 #5
0
ファイル: tags.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Browse the list of tags
  *
  * @return  void
  */
 public function browseTask()
 {
     // Instantiate a new view
     if (Request::getVar('format', '') == 'xml') {
         $this->view->setLayout('browse_xml');
     }
     // Incoming
     $this->view->filters = array('admin' => 0, 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')));
     // Fallback support for deprecated sorting option
     if ($sortby = Request::getVar('sortby')) {
         Request::setVar('sort', $sortby);
     }
     $this->view->filters['sort'] = urldecode(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'sort', 'raw_tag'));
     $this->view->filters['sort_Dir'] = strtolower(Request::getState($this->_option . '.' . $this->_controller . '.sort_Dir', 'sortdir', 'asc'));
     if (!in_array($this->view->filters['sort'], array('raw_tag', 'total'))) {
         $this->view->filters['sort'] = 'raw_tag';
     }
     if (!in_array($this->view->filters['sort_Dir'], array('asc', 'desc'))) {
         $this->view->filters['sort_Dir'] = 'asc';
     }
     $this->view->total = 0;
     $t = new Cloud();
     $order = Request::getVar('order', '');
     if ($order == 'usage') {
         $limit = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int');
         $this->view->rows = $t->tags('list', array('limit' => $limit, 'admin' => 0, 'sort' => 'total', 'sort_Dir' => 'DESC', 'by' => 'user'));
     } else {
         // Record count
         $this->view->total = $t->tags('count', $this->view->filters);
         $this->view->filters['limit'] = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int');
         // Get records
         $this->view->rows = $t->tags('list', $this->view->filters);
     }
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     $this->view->config = $this->config;
     // Output HTML
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }
コード例 #6
0
 /**
  * Save an entry
  *
  * @return  void
  */
 private function saveAction()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (!$this->params->get('access-manage')) {
         throw new Exception(\Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
     }
     // set scope & scope id in save so no one can mess with hidden form inputs
     $scope = 'member';
     $scopeID = $this->member->get('uidNumber');
     // get tags
     $tags = trim(Request::getVar('tags', ''));
     // get badges
     $badges = trim(Request::getVar('badges', ''));
     // check to see if new
     $cid = Request::getInt('cid');
     $isNew = $cid < 0 ? true : false;
     // get the citation (single) or create a new one
     $citation = \Components\Citations\Models\Citation::oneOrNew($cid)->set(array('type' => Request::getInt('type'), 'cite' => Request::getVar('cite'), 'ref_type' => Request::getVar('ref_type'), 'date_submit' => Request::getVar('date_submit', '0000-00-00 00:00:00'), 'date_accept' => Request::getVar('date_accept', '0000-00-00 00:00:00'), 'date_publish' => Request::getVar('date_publish', '0000-00-00 00:00:00'), 'year' => Request::getVar('year'), 'month' => Request::getVar('month'), 'author_address' => Request::getVar('author_address'), 'editor' => Request::getVar('editor'), 'title' => Request::getVar('title'), 'booktitle' => Request::getVar('booktitle'), 'short_title' => Request::getVar('short_title'), 'journal' => Request::getVar('journal'), 'volume' => Request::getVar('volume'), 'number' => Request::getVar('number'), 'pages' => Request::getVar('pages'), 'isbn' => Request::getVar('isbn'), 'doi' => Request::getVar('doi'), 'call_number' => Request::getVar('call_number'), 'accession_number' => Request::getVar('accession_number'), 'series' => Request::getVar('series'), 'edition' => Request::getVar('edition'), 'school' => Request::getVar('school'), 'publisher' => Request::getVar('publisher'), 'institution' => Request::getVar('institution'), 'address' => Request::getVar('address'), 'location' => Request::getVar('location'), 'howpublished' => Request::getVar('howpublished'), 'url' => Request::getVar('uri'), 'eprint' => Request::getVar('eprint'), 'abstract' => Request::getVar('abstract'), 'keywords' => Request::getVar('keywords'), 'research_notes' => Request::getVar('research_notes'), 'language' => Request::getVar('language'), 'label' => Request::getVar('label'), 'uid' => User::get('id'), 'created' => Date::toSql(), 'affiliated' => Request::getInt('affiliated', 0), 'fundedby' => Request::getInt('fundedby', 0), 'scope' => $scope, 'scope_id' => $scopeID));
     // Store new content
     if (!$citation->save() && !$citation->validate()) {
         $this->setError($citation->getError());
         $this->editAction($citation);
         return;
     }
     $authorCount = $citation->relatedAuthors()->count();
     // update authors entries for new citations
     if ($isNew) {
         $authors = \Components\Citations\Models\Author::all()->where('cid', '=', $cid);
         foreach ($authors as $author) {
             $author->set('cid', $citation->id);
             $author->save();
         }
     } elseif (!$isNew && $authorCount == 0) {
         $authorField = explode(',', Request::getVar('author'));
         $totalAuths = count($authorField);
         if ($totalAuths == 0) {
             // redirect
         }
         foreach ($authorField as $key => $a) {
             // create a new row
             $authorObj = \Components\Citations\Models\Author::blank()->set(array('cid' => $citation->id, 'ordering' => $key, 'author' => $a));
             $authorObj->save();
         }
         // turn the author string into author entries
     }
     // check if we are allowing tags
     $ct1 = new \Components\Tags\Models\Cloud($citation->id, 'citations');
     $ct1->setTags($tags, User::get('id'), 0, 1, '');
     // check if we are allowing badges
     $ct2 = new \Components\Tags\Models\Cloud($citation->id, 'citations');
     $ct2->setTags($badges, User::get('id'), 0, 1, 'badge');
     // resdirect after save
     App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name), $this->getError() ? $this->getError() : Lang::txt('PLG_MEMBERS_CITATIONS_CITATION_SAVED'), $this->getError() ? 'error' : 'success');
     return;
 }
コード例 #7
0
ファイル: tags.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Browse the list of tags
  *
  * @return  void
  */
 public function browseTask()
 {
     // Instantiate a new view
     if (Request::getVar('format', '') == 'xml') {
         $this->view->setLayout('browse_xml');
     }
     // Fallback support for deprecated sorting option
     if ($sortby = Request::getVar('sortby')) {
         Request::setVar('sort', $sortby);
     }
     // Incoming
     $filters = array('admin' => 0, 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'sort' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'sort', 'raw_tag')), 'sort_Dir' => strtolower(Request::getState($this->_option . '.' . $this->_controller . '.sort_Dir', 'sortdir', 'asc')));
     if (!in_array($filters['sort'], array('raw_tag', 'total'))) {
         $filters['sort'] = 'raw_tag';
     }
     if (!in_array($filters['sort_Dir'], array('asc', 'desc'))) {
         $filters['sort_Dir'] = 'asc';
     }
     $t = new Cloud();
     // Record count
     $total = $t->tags('count', $filters);
     // Get records
     $rows = $t->tags('list', $filters);
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     $this->view->set('rows', $rows)->set('total', $total)->set('filters', $filters)->set('config', $this->config)->display();
 }
コード例 #8
0
 /**
  * Save an entry
  *
  * @return		 void
  */
 private function _save()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->_loginTask();
     }
     // set scope & scope id in save so no one can mess with hidden form inputs
     //$scope = 'group';
     $scope_id = $this->group->get('gidNumber');
     // get tags
     $tags = trim(Request::getVar('tags', ''));
     // get badges
     $badges = trim(Request::getVar('badges', ''));
     // check to see if new
     $cid = Request::getInt('id');
     $isNew = $cid < 0 ? true : false;
     // get the citation (single) or create a new one
     $citation = \Components\Citations\Models\Citation::oneOrNew($cid)->set(array('type' => Request::getInt('type'), 'cite' => Request::getVar('cite'), 'ref_type' => Request::getVar('ref_type'), 'date_submit' => Request::getVar('date_submit'), 'date_accept' => Request::getVar('date_accept'), 'date_publish' => Request::getVar('date_publish'), 'year' => Request::getVar('year'), 'month' => Request::getVar('month'), 'author_address' => Request::getVar('author_address'), 'editor' => Request::getVar('editor'), 'title' => Request::getVar('title'), 'booktitle' => Request::getVar('booktitle'), 'short_title' => Request::getVar('short_title'), 'journal' => Request::getVar('journal'), 'volume' => Request::getVar('volume'), 'number' => Request::getVar('number'), 'pages' => Request::getVar('pages'), 'isbn' => Request::getVar('isbn'), 'doi' => Request::getVar('doi'), 'call_number' => Request::getVar('call_number'), 'accession_number' => Request::getVar('accession_number'), 'series' => Request::getVar('series'), 'edition' => Request::getVar('edition'), 'school' => Request::getVar('school'), 'publisher' => Request::getVar('publisher'), 'institution' => Request::getVar('institution'), 'address' => Request::getVar('address'), 'location' => Request::getVar('location'), 'howpublished' => Request::getVar('howpublished'), 'url' => Request::getVar('uri'), 'eprint' => Request::getVar('eprint'), 'abstract' => Request::getVar('abstract'), 'keywords' => Request::getVar('keywords'), 'research_notes' => Request::getVar('research_notes'), 'language' => Request::getVar('language'), 'label' => Request::getVar('label'), 'uid' => User::get('id'), 'created' => Date::toSql(), 'scope' => self::PLUGIN_SCOPE, 'scope_id' => $scope_id));
     // Store new content
     if (!$citation->save()) {
         $this->setError($citation->getError());
         $this->_edit();
         return;
     }
     $authorCount = $citation->relatedAuthors()->count();
     // update authors entries for new citations
     if ($isNew) {
         $authors = \Components\Citations\Models\Author::all()->where('cid', '=', $cid);
         foreach ($authors as $author) {
             $author->set('cid', $citation->id);
             $author->save();
         }
     } elseif (!$isNew && $authorCount == 0) {
         $authorField = explode(',', Request::getVar('author'));
         $totalAuths = count($authorField);
         if ($totalAuths == 0) {
             // redirect with Error
         } else {
             foreach ($authorField as $key => $a) {
                 // create a new author entry
                 $authorObj = \Components\Citations\Models\Author::blank()->set(array('cid' => $citation->id, 'ordering' => $key, 'author' => $a));
                 $authorObj->save();
             }
         }
     }
     // check if we are allowing tags
     $ct1 = new \Components\Tags\Models\Cloud($citation->id, 'citations');
     $ct1->setTags($tags, User::get('id'), 0, 1, '');
     // check if we are allowing badges
     $ct2 = new \Components\Tags\Models\Cloud($citation->id, 'citations');
     $ct2->setTags($badges, User::get('id'), 0, 1, 'badge');
     // redirect after save
     App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_CITATION_SAVED'), 'success');
     return;
 }