예제 #1
0
 /**
  * Generate module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once Component::path('com_tags') . DS . 'models' . DS . 'cloud.php';
     require_once Component::path('com_resources') . DS . 'tables' . DS . 'type.php';
     $database = \App::get('db');
     $this->tags = Tag::all()->whereEquals('admin', 0)->limit((int) $this->params->get('limit', 25))->order('objects', 'desc')->rows();
     // Get major types
     $t = new \Components\Resources\Tables\Type($database);
     $this->categories = $t->getMajorTypes();
     require $this->getLayoutPath();
 }
예제 #2
0
 /**
  * Generate module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once Component::path('com_tags') . DS . 'helpers' . DS . 'handler.php';
     require_once Component::path('com_resources') . DS . 'tables' . DS . 'type.php';
     $database = \App::get('db');
     $obj = new Tag($database);
     $this->tags = $obj->getTopTags(intval($this->params->get('limit', 25)));
     // Get major types
     $t = new \Components\Resources\Tables\Type($database);
     $this->categories = $t->getMajorTypes();
     require $this->getLayoutPath();
 }
예제 #3
0
 /**
  * Method to get the field options for category
  * Use the extension attribute in a form to specify the.specific extension for
  * which categories should be displayed.
  * Use the show_root attribute to specify whether to show the global category root in the list.
  *
  * @return  array    The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     $options[] = Html::select('option', '0', Lang::txt('All'));
     include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
     $db = App::get('db');
     $sr = new \Components\Resources\Tables\Type($db);
     $types = $sr->getMajorTypes();
     foreach ($types as $anode) {
         $options[] = Html::select('option', $anode->id, stripslashes($anode->type));
     }
     return $options;
 }
예제 #4
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $db = \App::get('db');
     include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
     $model = new \Components\Resources\Tables\Type($db);
     $types = $model->getMajorTypes();
     $options = array();
     foreach ($types as $type) {
         $options[] = JHtml::_('select.option', $type->id, stripslashes($type->type), 'value', 'text');
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
예제 #5
0
 /**
  * Fetch the element
  *
  * @param   string  $name          Element name
  * @param   string  $value         Element value
  * @param   object  &$node         XMLElement node object containing the settings for the element
  * @param   string  $control_name  Control name
  * @return  string
  */
 public function fetchElement($name, $value, &$node, $control_name)
 {
     $db = \App::get('db');
     include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
     $model = new \Components\Resources\Tables\Type($db);
     $types = $model->getMajorTypes();
     $html = array();
     $html[] = '<select name="' . $control_name . '[' . $name . ']" id="' . $control_name . $name . '">';
     $html[] = '<option value="0"' . ($value === 0 || $value === '0' ? ' selected="selected"' : '') . '>Select type</option>';
     foreach ($types as $type) {
         $html[] = '<option value="' . $type->id . '"' . ($value == $type->id ? ' selected="selected"' : '') . '>' . stripslashes($anode->type) . '</option>';
     }
     $html[] = '</select>';
     return implode("\n", $html);
 }
예제 #6
0
 /**
  * Pull a list of records that were created within the time frame ($period)
  *
  * @param      object  $period     Time period to pull results for
  * @param      mixed   $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      array   $areas      Active area(s)
  * @param      array   $tagids     Array of tag IDs
  * @return     array
  */
 public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array())
 {
     if (is_array($areas) && $limit) {
         $ars = $this->onWhatsnewAreas();
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas) && !array_intersect($areas, array_keys($ars['resources']))) {
             return array();
         }
     }
     // Do we have a time period?
     if (!is_object($period)) {
         return array();
     }
     $database = App::get('db');
     // Instantiate some needed objects
     $rr = new \Components\Resources\Tables\Resource($database);
     // Build query
     $filters = array('startdate' => $period->cStartDate, 'enddate' => $period->cEndDate, 'sortby' => 'date');
     if (count($tagids) > 0) {
         $filters['tags'] = $tagids;
     }
     $filters['usergroups'] = \Hubzero\User\Helper::getGroups((int) User::get('id', 0), 'all');
     // Get categories
     $categories = $this->_cats;
     if (!is_array($categories)) {
         $rt = new \Components\Resources\Tables\Type($database);
         $categories = $rt->getMajorTypes();
     }
     // Normalize the category names
     // e.g., "Oneline Presentations" -> "onlinepresentations"
     $cats = array();
     for ($i = 0; $i < count($categories); $i++) {
         $cats[$categories[$i]->alias] = array();
         $cats[$categories[$i]->alias]['id'] = $categories[$i]->id;
     }
     $filters['authorized'] = false;
     if ($limit) {
         if ($this->_total != null) {
             $total = 0;
             $t = $this->_total;
             foreach ($t as $l) {
                 $total += $l;
             }
             if ($total == 0) {
                 return array();
             }
         }
         $filters['select'] = 'records';
         $filters['limit'] = $limit;
         $filters['limitstart'] = $limitstart;
         // Check the area of return. If we are returning results for a specific area/category
         // we'll need to modify the query a bit
         if (count($areas) == 1 && isset($areas[0]) && $areas[0] != 'resources') {
             $filters['type'] = $cats[$areas[0]]['id'];
         }
         // Get results
         $database->setQuery($rr->buildPluginQuery($filters));
         $rows = $database->loadObjectList();
         // Did we get any results?
         if ($rows) {
             include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'helper.php';
             // Loop through the results and set each item's HREF
             foreach ($rows as $key => $row) {
                 $resourceEx = new \Components\Resources\Helpers\Helper($row->id, $database);
                 $resourceEx->getContributors();
                 $rows[$key]->authors = $resourceEx->contributors;
                 if ($row->alias) {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&alias=' . $row->alias);
                 } else {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&id=' . $row->id);
                 }
                 if ($row->itext) {
                     $rows[$key]->text = $rows[$key]->itext;
                 } else {
                     if ($row->ftext) {
                         $rows[$key]->text = $rows[$key]->ftext;
                     }
                 }
             }
         }
         return $rows;
     } else {
         $filters['select'] = 'count';
         // Get a count
         $counts = array();
         $ares = $this->onWhatsnewAreas();
         foreach ($ares as $area => $val) {
             if (is_array($val)) {
                 foreach ($val as $a => $t) {
                     $filters['type'] = $cats[$a]['id'];
                     $database->setQuery($rr->buildPluginQuery($filters));
                     $counts[] = $database->loadResult();
                 }
             }
         }
         // Return the counts
         $this->_total = $counts;
         return $counts;
     }
 }
예제 #7
0
 /**
  * Retrieve records for items associated with this group
  *
  * @param      object  $group      Group that owns the records
  * @param      unknown $authorized Authorization level
  * @param      mixed   $limit      SQL record limit
  * @param      integer $limitstart SQL record limit start
  * @param      string  $sort       The field to sort records by
  * @param      string  $access     Access level
  * @param      mixed   $areas      An array or string of areas that should retrieve records
  * @return     mixed Returns integer when counting records, array when retrieving records
  */
 public function getResources($group, $authorized, $limit = 0, $limitstart = 0, $sort = 'date', $access = 'all', $areas = null)
 {
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas) && $limit) {
         $ars = $this->getResourcesAreas();
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas) && !array_intersect($areas, array_keys($ars['resources']))) {
             return array();
         }
     }
     // Do we have a member ID?
     if (!$group->get('cn')) {
         return array();
     }
     $database = App::get('db');
     // Instantiate some needed objects
     $rr = new \Components\Resources\Tables\Resource($database);
     // Build query
     $filters = array();
     $filters['now'] = \Date::toSql();
     $filters['sortby'] = $sort;
     $filters['group'] = $group->get('cn');
     $filters['access'] = $access;
     $filters['authorized'] = $authorized;
     $filters['state'] = array(1);
     // Get categories
     $categories = $this->_cats;
     if (!is_array($categories)) {
         $rt = new \Components\Resources\Tables\Type($database);
         $categories = $rt->getMajorTypes();
     }
     // Normalize the category names
     // e.g., "Oneline Presentations" -> "onlinepresentations"
     $cats = array();
     for ($i = 0; $i < count($categories); $i++) {
         $normalized = preg_replace("/[^a-zA-Z0-9]/", '', $categories[$i]->type);
         $normalized = strtolower($normalized);
         $cats[$normalized] = array();
         $cats[$normalized]['id'] = $categories[$i]->id;
     }
     if ($limit) {
         if ($this->_total != null) {
             $total = 0;
             $t = $this->_total;
             foreach ($t as $l) {
                 $total += $l;
             }
         }
         if ($total == 0) {
             return array();
         }
         $filters['select'] = 'records';
         $filters['limit'] = $limit;
         $filters['limitstart'] = $limitstart;
         // Check the area of return. If we are returning results for a specific area/category
         // we'll need to modify the query a bit
         if (count($areas) == 1 && !isset($areas['resources']) && $areas[0] != 'resources') {
             $filters['type'] = $cats[$areas[0]]['id'];
         }
         // Get results
         $database->setQuery($rr->buildPluginQuery($filters));
         $rows = $database->loadObjectList();
         // Did we get any results?
         if ($rows) {
             // Loop through the results and set each item's HREF
             foreach ($rows as $key => $row) {
                 if ($row->alias) {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&alias=' . $row->alias);
                 } else {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&id=' . $row->id);
                 }
             }
         }
         // Return the results
         return $rows;
     } else {
         $filters['select'] = 'count';
         // Get a count
         $counts = array();
         $ares = $this->getResourcesAreas();
         foreach ($ares as $area => $val) {
             if (is_array($val)) {
                 $i = 0;
                 foreach ($val as $a => $t) {
                     if ($limitstart == -1) {
                         if ($i == 0) {
                             $database->setQuery($rr->buildPluginQuery($filters));
                             $counts[] = $database->loadResult();
                         } else {
                             $counts[] = 0;
                         }
                     } else {
                         $filters['type'] = $cats[$a]['id'];
                         // Execute a count query for each area/category
                         $database->setQuery($rr->buildPluginQuery($filters));
                         $counts[] = $database->loadResult();
                     }
                     $i++;
                 }
             }
         }
         // Return the counts
         $this->_total = $counts;
         return $counts;
     }
 }
예제 #8
0
 /**
  * [_getResources description]
  * @param  string  $type  [description]
  * @param  integer $limit [description]
  * @return [type]         [description]
  */
 private function _getResources($type = 'all', $limit = 5)
 {
     // database object
     $database = \App::get('db');
     // Instantiate some needed objects
     $rr = new \Components\Resources\Tables\Resource($database);
     // Build query
     $filters = array();
     $filters['now'] = date('Y-m-d H:i:s', time() + 0 * 60 * 60);
     $filters['sortby'] = 'date';
     $filters['group'] = $this->group->get('cn');
     $filters['access'] = 'all';
     $filters['authorized'] = '';
     $filters['select'] = 'records';
     $filters['limit'] = $limit;
     $filters['limitstart'] = 0;
     // Get categories
     $rt = new \Components\Resources\Tables\Type($database);
     $categories = $rt->getMajorTypes();
     // Normalize the category names
     // e.g., "Oneline Presentations" -> "onlinepresentations"
     $cats = array();
     for ($i = 0; $i < count($categories); $i++) {
         $normalized = preg_replace("/[^a-zA-Z0-9]/", '', $categories[$i]->type);
         $normalized = strtolower($normalized);
         $cats[$normalized] = array();
         $cats[$normalized]['id'] = $categories[$i]->id;
     }
     // do we have a type?
     if (in_array($type, array_keys($cats))) {
         $filters['type'] = $cats[$type]['id'];
     }
     // Get results
     $database->setQuery($rr->buildPluginQuery($filters));
     $rows = $database->loadObjectList();
     return $rows;
 }
예제 #9
0
 /**
  * Retrieve records for items tagged with specific tags
  *
  * @param      array   $tags       Tags to match records against
  * @param      mixed   $limit      SQL record limit
  * @param      integer $limitstart SQL record limit start
  * @param      string  $sort       The field to sort records by
  * @param      mixed   $areas      An array or string of areas that should retrieve records
  * @return     mixed Returns integer when counting records, array when retrieving records
  */
 public function onTagView($tags, $limit = 0, $limitstart = 0, $sort = '', $areas = null)
 {
     $response = array('name' => $this->_name, 'title' => Lang::txt('PLG_TAGS_RESOURCES'), 'total' => 0, 'results' => null, 'sql' => '', 'children' => array());
     $database = App::get('db');
     $rt = new \Components\Resources\Tables\Type($database);
     foreach ($rt->getMajorTypes() as $category) {
         $response['children'][$category->alias] = array('name' => $category->alias, 'title' => $category->type, 'total' => 0, 'results' => null, 'sql' => '', 'id' => $category->id);
     }
     if (empty($tags)) {
         return $response;
     }
     $ids = array();
     foreach ($tags as $tag) {
         $ids[] = $tag->get('id');
     }
     // Instantiate some needed objects
     $rr = new \Components\Resources\Tables\Resource($database);
     // Build query
     $filters = array();
     $filters['tags'] = $ids;
     $filters['now'] = Date::toSql();
     $filters['sortby'] = $sort ? $sort : 'ranking';
     $filters['authorized'] = false;
     $filters['usergroups'] = \Hubzero\User\Helper::getGroups(User::get('id'), 'all');
     $filters['select'] = 'count';
     foreach ($response['children'] as $k => $t) {
         $filters['type'] = $t['id'];
         // Execute a count query for each area/category
         $database->setQuery($this->_buildPluginQuery($filters));
         $response['children'][$k]['total'] = $database->loadResult();
         $response['total'] += $response['children'][$k]['total'];
     }
     if ($areas && ($areas == $response['name'] || isset($response['children'][$areas]))) {
         // Push some CSS and JS to the tmeplate that may be needed
         \Hubzero\Document\Assets::addComponentStylesheet('com_resources');
         $filters['select'] = 'records';
         $filters['limit'] = $limit;
         $filters['limitstart'] = $limitstart;
         $filters['sortby'] = $sort ? $sort : 'date';
         // Check the area of return. If we are returning results for a specific area/category
         // we'll need to modify the query a bit
         if (isset($response['children'][$areas])) {
             $filters['type'] = $response['children'][$areas]['id'];
             $database->setQuery($this->_buildPluginQuery($filters));
             $response['children'][$areas]['results'] = $database->loadObjectList();
         } else {
             unset($filters['type']);
             $database->setQuery($this->_buildPluginQuery($filters));
             $response['results'] = $database->loadObjectList();
         }
     } else {
         $filters['select'] = 'records';
         $filters['limit'] = 'all';
         $filters['limitstart'] = $limitstart;
         $filters['sortby'] = $sort ? $sort : 'date';
         // Check the area of return. If we are returning results for a specific area/category
         // we'll need to modify the query a bit
         if (isset($response['children'][$areas])) {
             $filters['type'] = $response['children'][$areas]['id'];
             $response['children'][$key]['sql'] = $this->_buildPluginQuery($filters);
         } else {
             unset($filters['type']);
             $response['sql'] = $this->_buildPluginQuery($filters);
         }
     }
     return $response;
 }
예제 #10
0
 /**
  * Return either a count or an array of the member's contributions
  *
  * @param      object  $member     Current member
  * @param      string  $option     Component name
  * @param      string  $authorized Authorization level
  * @param      integer $limit      Number of record to return
  * @param      integer $limitstart Record return start
  * @param      string  $sort       Field to sort records on
  * @param      array   $areas      Areas to return data for
  * @return     array
  */
 public function onMembersContributions($member, $option, $limit = 0, $limitstart = 0, $sort, $areas = null)
 {
     $database = App::get('db');
     if (is_array($areas) && $limit) {
         $ars = $this->onMembersContributionsAreas();
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas) && !array_intersect($areas, array_keys($ars['resources']))) {
             return array();
         }
     }
     // Do we have a member ID?
     if ($member instanceof \Hubzero\User\Profile) {
         if (!$member->get('uidNumber')) {
             return array();
         } else {
             $uidNumber = $member->get('uidNumber');
         }
     } else {
         if (!$member->uidNumber) {
             return array();
         } else {
             $uidNumber = $member->uidNumber;
         }
     }
     // Instantiate some needed objects
     $rr = new \Components\Resources\Tables\Resource($database);
     // Build query
     $filters = array();
     $filters['author'] = $uidNumber;
     $filters['sortby'] = $sort;
     //$filters['authorized'] = $authorized;
     //$filters['usergroups'] = \Hubzero\User\Helper::getGroups($uidNumber, 'all');
     $filters['usergroups'] = $member->getGroups('all');
     // Get categories
     $categories = $this->_cats;
     if (!is_array($categories)) {
         $rt = new \Components\Resources\Tables\Type($database);
         $categories = $rt->getMajorTypes();
     }
     // Normalize the category names
     // e.g., "Oneline Presentations" -> "onlinepresentations"
     $cats = array();
     $normalized_valid_chars = 'a-zA-Z0-9';
     for ($i = 0; $i < count($categories); $i++) {
         $normalized = preg_replace("/[^{$normalized_valid_chars}]/", "", $categories[$i]->type);
         $normalized = strtolower($normalized);
         $cats[$normalized] = array();
         $cats[$normalized]['id'] = $categories[$i]->id;
     }
     if ($limit) {
         if ($this->_total != null) {
             $total = 0;
             $t = $this->_total;
             foreach ($t as $l) {
                 $total += $l;
             }
         }
         if ($total == 0) {
             return array();
         }
         $filters['select'] = 'records';
         $filters['limit'] = $limit;
         $filters['limitstart'] = $limitstart;
         // Check the area of return. If we are returning results for a specific area/category
         // we'll need to modify the query a bit
         //if (count($areas) == 1 && key($areas[0]) != 'resources') {
         if (count($areas) == 1 && !isset($areas['resources'])) {
             $filters['type'] = isset($cats[$areas[0]]) ? $cats[$areas[0]]['id'] : 0;
         }
         // Get results
         $database->setQuery($rr->buildPluginQuery($filters));
         $rows = $database->loadObjectList();
         // Did we get any results?
         if ($rows) {
             // Loop through the results and set each item's HREF
             foreach ($rows as $key => $row) {
                 if ($row->alias) {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&alias=' . $row->alias);
                 } else {
                     $rows[$key]->href = Route::url('index.php?option=com_resources&id=' . $row->id);
                 }
             }
         }
         // Return the results
         return $rows;
     } else {
         $filters['select'] = 'count';
         // Get a count
         $counts = array();
         $ares = $this->onMembersContributionsAreas();
         foreach ($ares as $area => $val) {
             if (is_array($val)) {
                 $i = 0;
                 foreach ($val as $a => $t) {
                     if ($limitstart == -1) {
                         if ($i == 0) {
                             $database->setQuery($rr->buildPluginQuery($filters));
                             $counts[] = $database->loadResult();
                         } else {
                             $counts[] = 0;
                         }
                     } else {
                         $filters['type'] = $cats[$a]['id'];
                         // Execute a count query for each area/category
                         $database->setQuery($rr->buildPluginQuery($filters));
                         $counts[] = $database->loadResult();
                     }
                     $i++;
                 }
             }
         }
         // Return the counts
         $this->_total = $counts;
         return $counts;
     }
 }
예제 #11
0
			<div class="grid">
				<div class="col span6">
					<h3>Intellectual Property Considerations</h3>
					<p>All materials contributed must have <strong>clearly defined rights and privileges</strong>. Online presentations and instructional material are normally licensed under <a class="legal creative-commons" href="/legal/cc" title="Learn more about Creative Commons">Creative Commons 3</a>. Read <a class="legal licensing" href="/legal/licensing">more details</a> about our licensing policies.</p>
				</div><!-- / .col span6 -->
				<div class="col span6 omega">
					<h3>Questions or concerns?</h3>
					<p>We hope that our self-service upload process is intuitive and easy to use. If you encounter any problems during the upload process or need assistance of any kind, please <a class="new-ticket" href="/support/ticket/new">file a trouble report</a>.</p>
				</div><!-- / .col span6 -->
			</div><!-- / .grid -->
		</div><!-- / .col span9 omega -->
	</div><!-- / .grid -->

<?php 
$t = new \Components\Resources\Tables\Type($database);
$categories = $t->getMajorTypes();
if ($categories) {
    ?>
	<div class="grid">
		<div class="col span3">
			<h2>What can I contribute?</h2>
		</div><!-- / .col span3 -->
		<div class="col span9 omega">
			<div class="grid">
		<?php 
    $i = 0;
    $clm = '';
    foreach ($categories as $category) {
        if ($category->contributable != 1) {
            continue;
        }
예제 #12
0
 /**
  * Parse the segments of a URL.
  *
  * @param   array  &$segments  The segments of the URL to parse.
  * @return  array  The URL attributes to be used by the application.
  */
 public function parse(&$segments)
 {
     $vars = array();
     if (empty($segments[0])) {
         return $vars;
     }
     if (is_numeric($segments[0])) {
         $vars['id'] = $segments[0];
     } elseif (in_array($segments[0], array('browse', 'license', 'sourcecode'))) {
         $vars['task'] = $segments[0];
     } elseif (in_array($segments[0], array('new', 'draft', 'start', 'retract', 'delete', 'discard', 'remove', 'reorder', 'access'))) {
         $vars['task'] = $segments[0];
         $vars['controller'] = 'create';
         if (isset($segments[1])) {
             $vars['id'] = $segments[1];
         }
     } else {
         include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
         $database = \App::get('db');
         $t = new \Components\Resources\Tables\Type($database);
         $types = $t->getMajorTypes();
         // Normalize the title
         // This is so we can determine the type of resource to display from the URL
         // For example, /resources/learningmodules => Learning Modules
         for ($i = 0; $i < count($types); $i++) {
             //$normalized = preg_replace("/[^a-zA-Z0-9]/", '', $types[$i]->type);
             //$normalized = strtolower($normalized);
             if (trim($segments[0]) == $types[$i]->alias) {
                 $vars['type'] = $segments[0];
                 $vars['task'] = 'browsetags';
             }
         }
         if ($segments[0] == 'license') {
             $vars['task'] = $segments[0];
         } else {
             if (!isset($vars['type'])) {
                 $vars['alias'] = $segments[0];
             }
         }
     }
     if (!empty($segments[1])) {
         switch ($segments[1]) {
             case 'download':
                 $vars['task'] = 'download';
                 if (isset($segments[2])) {
                     $vars['file'] = $segments[2];
                 }
                 break;
             case 'play':
                 $vars['task'] = 'play';
                 break;
             case 'watch':
                 $vars['task'] = 'watch';
                 break;
             case 'video':
                 $vars['task'] = 'video';
                 break;
                 //case 'license':  $vars['task'] = 'license';  break;
             //case 'license':  $vars['task'] = 'license';  break;
             case 'citation':
                 $vars['task'] = 'citation';
                 break;
             case 'feed.rss':
                 $vars['task'] = 'feed';
                 break;
             case 'feed':
                 $vars['task'] = 'feed';
                 break;
             case 'license':
             case 'sourcecode':
                 $vars['tool'] = $segments[1];
                 break;
             default:
                 if ($segments[0] == 'browse') {
                     $vars['type'] = $segments[1];
                 } else {
                     $vars['active'] = $segments[1];
                 }
                 break;
         }
     }
     return $vars;
 }