Example #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();
 }
Example #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();
 }
 /**
  * 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;
 }
 /**
  * Down
  **/
 public function down()
 {
     if ($this->db->tableExists('#__resource_types')) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
         $query = "SELECT id FROM `#__resource_types` WHERE alias=" . $this->db->quote('windowstools');
         $this->db->setQuery($query);
         $id = $this->db->loadResult();
         if ($id) {
             $row = new \Components\Resources\Tables\Type($this->db);
             $row->delete($id);
         }
     }
 }
Example #5
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;
 }
Example #6
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);
 }
Example #7
0
 /**
  * Build a database query
  *
  * @param      array $filters Options for building the query
  * @return     string SQL
  */
 private function _buildPluginQuery($filters = array())
 {
     $database = App::get('db');
     $rt = new \Components\Resources\Tables\Type($database);
     if (isset($filters['select']) && $filters['select'] == 'count') {
         if (isset($filters['tags'])) {
             $query = "SELECT count(f.id) FROM (SELECT r.id, COUNT(DISTINCT t.tagid) AS uniques ";
         } else {
             $query = "SELECT count(DISTINCT r.id) ";
         }
     } else {
         $query = "SELECT DISTINCT r.id, r.title, r.alias, r.introtext AS itext, r.fulltxt AS ftext, r.published AS state, r.created, r.created_by, r.modified, r.publish_up, r.publish_down,\n\t\t\t\t\tCONCAT('index.php?option=com_resources&id=', r.id) AS href, 'resources' AS section ";
         if (isset($filters['tags'])) {
             $query .= ", COUNT(DISTINCT t.tagid) AS uniques ";
         }
         $query .= ", r.params, r.rating AS rcount, r.type AS data1, rt.type AS data2, r.ranking data3 ";
     }
     $query .= "FROM #__resources AS r ";
     $query .= "LEFT JOIN " . $rt->getTableName() . " AS rt ON r.type=rt.id ";
     if (isset($filters['tag'])) {
         $query .= ", #__tags_object AS t, #__tags AS tg ";
     }
     if (isset($filters['tags'])) {
         $query .= ", #__tags_object AS t ";
     }
     $query .= "WHERE r.standalone=1 ";
     if (User::isGuest() || isset($filters['authorized']) && !$filters['authorized']) {
         $query .= "AND r.published=1 AND r.access<4 ";
     }
     if (isset($filters['tag'])) {
         $query .= "AND t.objectid=r.id AND t.tbl='resources' AND t.tagid=tg.id AND (tg.tag='" . $filters['tag'] . "' OR tg.alias='" . $filters['tag'] . "') ";
     }
     if (isset($filters['tags'])) {
         $ids = implode(',', $filters['tags']);
         $query .= "AND t.objectid=r.id AND t.tbl='resources' AND t.tagid IN (" . $ids . ") ";
     }
     if (isset($filters['type']) && $filters['type'] != '') {
         $query .= "AND r.type=" . $filters['type'] . " ";
     }
     if (isset($filters['tags'])) {
         $query .= " GROUP BY r.id HAVING uniques=" . count($filters['tags']) . " ";
     }
     if (isset($filters['select']) && $filters['select'] != 'count') {
         if (isset($filters['sortby'])) {
             if (isset($filters['groupby'])) {
                 $query .= "GROUP BY r.id ";
             }
             $query .= "ORDER BY ";
             switch ($filters['sortby']) {
                 case 'title':
                     $query .= 'title ASC, publish_up DESC';
                     break;
                 case 'rating':
                     $query .= "rating DESC, times_rated DESC";
                     break;
                 case 'ranking':
                     $query .= "ranking DESC";
                     break;
                 case 'relevance':
                     $query .= "relevance DESC";
                     break;
                 case 'users':
                 case 'usage':
                     $query .= "users DESC";
                     break;
                 case 'jobs':
                     $query .= "jobs DESC";
                     break;
                 case 'date':
                 default:
                     $query .= 'publish_up DESC';
                     break;
             }
         }
         if (isset($filters['limit']) && $filters['limit'] != 'all') {
             $query .= " LIMIT " . $filters['limitstart'] . "," . $filters['limit'];
         }
     }
     if (isset($filters['select']) && $filters['select'] == 'count') {
         if (isset($filters['tags'])) {
             $query .= ") AS f";
         }
     }
     return $query;
 }
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$db = \App::get('db');
$creator = User::getInstance($this->resource->created_by);
$type = new \Components\Resources\Tables\Type($db);
$type->load($this->resource->type);
$link = rtrim(Request::base(), '/') . '/' . ltrim(Route::url('index.php?option=com_resources&id=' . $this->resource->id), '/');
?>
	<!-- Start Header -->
	<table class="tbl-header" width="100%" cellpadding="0" cellspacing="0" border="0">
		<tbody>
			<tr>
				<td width="10%" align="left" valign="bottom" nowrap="nowrap" class="sitename">
					<?php 
echo Config::get('sitename');
?>
				</td>
				<td width="80%" align="left" valign="bottom" class="tagline mobilehide">
					<span class="home">
						<a href="<?php 
Example #9
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;
     }
 }
Example #10
0
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$database = App::get('db');
$this->status['fulltxt'] = stripslashes($this->status['fulltxt']);
$type = new \Components\Resources\Tables\Type($database);
$type->load(7);
$data = array();
preg_match_all("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", $this->status['fulltxt'], $matches, PREG_SET_ORDER);
if (count($matches) > 0) {
    foreach ($matches as $match) {
        $data[$match[1]] = trim($match[2]);
    }
}
$this->status['fulltxt'] = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $this->status['fulltxt']);
$this->status['fulltxt'] = trim($this->status['fulltxt']);
include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php';
$elements = new \Components\Resources\Models\Elements($data, $type->customFields);
$fields = $elements->render();
?>
	<div class="explaination">
Example #11
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;
     }
 }
Example #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;
 }
Example #13
0
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$canDo = \Components\Resources\Helpers\Permissions::getActions('resource');
$text = $this->task == 'edit' ? Lang::txt('JACTION_EDIT') . ' #' . $this->row->id : Lang::txt('JACTION_CREATE');
Toolbar::title(Lang::txt('COM_RESOURCES') . ': ' . $text, 'resources.png');
if ($canDo->get('core.edit')) {
    Toolbar::spacer();
    Toolbar::save();
}
Toolbar::cancel();
if ($this->row->standalone == 1) {
    $database = App::get('db');
    $type = new \Components\Resources\Tables\Type($database);
    $type->load($this->row->type);
    $data = array();
    preg_match_all("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", $this->row->fulltxt, $matches, PREG_SET_ORDER);
    if (count($matches) > 0) {
        foreach ($matches as $match) {
            $data[$match[1]] = stripslashes($match[2]);
        }
    }
    $this->row->fulltxt = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $this->row->fulltxt);
    $this->row->fulltxt = trim($this->row->fulltxt);
    $this->row->fulltxt = $this->row->fulltxt ? trim(stripslashes($this->row->fulltxt)) : trim(stripslashes($this->row->introtext));
    include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php';
}
// Build the path for uploading files
$path = \Components\Resources\Helpers\Html::dateToPath($this->row->created);
Example #14
0
$parent = $rh->parents[0];
//check to see if parent type is series
$rt = new \Components\Resources\Tables\Type($this->database);
$rt->load($parent->type);
//if we have a series get children
if ($rt->type == "Series" || $rt->type == "Courses") {
    $rh->getChildren($parent->id, 0, 'yes');
    $children = $rh->children;
    //remove any children without a HUBpresenter
    foreach ($children as $k => $c) {
        $rh = new \Components\Resources\Helpers\Helper($c->id, $this->database);
        $rh->getChildren();
        $sub_child = $rh->children;
        $hasHUBpresenter = false;
        foreach ($sub_child as $sc) {
            $rt = new \Components\Resources\Tables\Type($this->database);
            $rt->load($sc->type);
            if (strtolower($rt->type) == "hubpresenter") {
                $hasHUBpresenter = true;
            }
        }
        if (!$hasHUBpresenter) {
            unset($children[$k]);
        }
    }
} else {
    $children = NULL;
}
//get the contributors for the resource
$sql = "SELECT authorid, role, name FROM #__author_assoc " . "WHERE subtable='resources' " . "AND subid=" . $parent->id . " " . "ORDER BY ordering";
$this->database->setQuery($sql);
Example #15
0
 /**
  * Display module content
  *
  * @return  void
  */
 public function display()
 {
     if (User::isGuest()) {
         return false;
     }
     include_once Component::path('com_resources') . DS . 'tables' . DS . 'resource.php';
     include_once Component::path('com_resources') . DS . 'tables' . DS . 'type.php';
     $this->steps = array('Type', 'Compose', 'Attach', 'Authors', 'Tags', 'Review');
     $database = App::get('db');
     $rr = new \Components\Resources\Tables\Resource($database);
     $rt = new \Components\Resources\Tables\Type($database);
     $query = "SELECT r.*, t.type AS typetitle\n\t\t\tFROM " . $rr->getTableName() . " AS r\n\t\t\tLEFT JOIN " . $rt->getTableName() . " AS t ON r.type=t.id\n\t\t\tWHERE r.published=2 AND r.standalone=1 AND r.type!=7 AND r.created_by=" . User::get('id');
     $database->setQuery($query);
     $this->rows = $database->loadObjectList();
     if ($this->rows) {
         include_once Component::path('com_resources') . DS . 'tables' . DS . 'assoc.php';
         include_once Component::path('com_resources') . DS . 'tables' . DS . 'contributor.php';
         include_once Component::path('com_resources') . DS . 'helpers' . DS . 'tags.php';
     }
     require $this->getLayoutPath();
 }
Example #16
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;
 }
Example #17
0
     }
 }
 $html .= '</td>' . "\n";
 if ($this->helper->children && count($this->helper->children) > 0) {
     $videoi = '';
     $breeze = '';
     $hubpresenter = '';
     $pdf = '';
     $video = '';
     $exercises = '';
     $supp = '';
     $grandchildren = $this->helper->children;
     foreach ($grandchildren as $grandchild) {
         $grandchild->title = $this->escape($grandchild->title);
         $grandchild->path = \Components\Resources\Helpers\Html::processPath($this->option, $grandchild, $child->id);
         $grandchild_rt = new \Components\Resources\Tables\Type($this->database);
         $grandchild_rt->load($grandchild->type);
         $alias = $grandchild_rt->alias;
         switch ($alias) {
             case "player":
             case "quicktime":
                 $videoi .= !$videoi ? '<a href="' . $grandchild->path . '">' . Lang::txt('View') . '</a>' : '';
                 break;
             case "breeze":
                 $breeze .= !$breeze ? '<a title="View Presentation - Flash Version" class="breeze flash" href="' . $grandchild->path . '&amp;no_html=1" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View Flash') . '</a>' : '';
                 break;
             case "hubpresenter":
                 $hubpresenter .= !$hubpresenter ? '<a title="View Presentation - HTML5 Version" class="hubpresenter html5" href="' . $grandchild->path . '" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View HTML') . '</a>' : '';
                 break;
             case "pdf":
             default:
Example #18
0
		<div class="col span9 omega">
			<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;
Example #19
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;
     }
 }
Example #20
0
 /**
  * Display forms for editing/creating a reosurce
  *
  * @return     void
  */
 public function displayTask()
 {
     // Incoming
     $alias = Request::getVar('app', '');
     $version = Request::getVar('editversion', 'dev');
     $step = Request::getInt('step', 1);
     // Load the tool
     $obj = new \Components\Tools\Tables\Tool($this->database);
     $this->_toolid = $obj->getToolId($alias);
     if (!$this->_toolid) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=pipeline'));
         return;
     }
     // make sure user is authorized to go further
     if (!$this->_checkAccess($this->_toolid)) {
         App::abort(403, Lang::txt('COM_TOOLS_ALERTNOTAUTH'));
         return;
     }
     $nextstep = $step + 1;
     // get tool version (dev or current) information
     $obj->getToolStatus($this->_toolid, $this->_option, $status, $version);
     // get resource information
     $row = new \Components\Resources\Tables\Resource($this->database);
     $row->loadAlias($alias);
     $row->alias = $row->alias ? $row->alias : $alias;
     if (!$status['fulltxt']) {
         $status['fulltxt'] = $row->fulltxt;
     }
     // process first step
     if ($nextstep == 3 && (isset($_POST['nbtag']) || isset($_POST['fulltxt']))) {
         if (!isset($_POST['fulltxt']) || !trim($_POST['fulltxt'])) {
             $this->setError(Lang::txt('COM_TOOLS_REQUIRED_FIELD_CHECK', 'Abstract'));
             $step = 1;
             $nextstep--;
         }
         $hztv = \Components\Tools\Helpers\Version::getToolRevision($this->_toolid, $version);
         $objV = new \Components\Tools\Tables\Version($this->database);
         if (!$objV->bind($_POST)) {
             $this->setError($objV->getError());
             return;
         }
         $body = $this->txtClean($_POST['fulltxt']);
         if (preg_match("/([\\<])([^\\>]{1,})*([\\>])/i", $body)) {
             // Do nothing
             $status['fulltxt'] = trim(stripslashes($body));
         } else {
             // Wiki format will be used
             $status['fulltxt'] = Request::getVar('fulltxt', $status['fulltxt'], 'post');
         }
         // Get custom areas, add wrapper tags, and compile into fulltxt
         $type = new \Components\Resources\Tables\Type($this->database);
         $type->load($row->type);
         include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'models' . DS . 'elements.php';
         $elements = new \Components\Resources\Models\Elements(array(), $type->customFields);
         $schema = $elements->getSchema();
         $fields = array();
         foreach ($schema->fields as $field) {
             $fields[$field->name] = $field;
         }
         $nbtag = Request::getVar('nbtag', array());
         $found = array();
         foreach ($nbtag as $tagname => $tagcontent) {
             $f = '';
             $status['fulltxt'] .= "\n" . '<nb:' . $tagname . '>';
             if (is_array($tagcontent)) {
                 $c = count($tagcontent);
                 $num = 0;
                 foreach ($tagcontent as $key => $val) {
                     if (trim($val)) {
                         $num++;
                     }
                     $status['fulltxt'] .= '<' . $key . '>' . trim($val) . '</' . $key . '>';
                 }
                 if ($c == $num) {
                     $f = 'found';
                 }
             } else {
                 $f = trim($tagcontent);
                 if ($f) {
                     $status['fulltxt'] .= trim($tagcontent);
                 }
             }
             $status['fulltxt'] .= '</nb:' . $tagname . '>' . "\n";
             if (!$f && isset($fields[$tagname]) && $fields[$tagname]->required) {
                 $this->setError(Lang::txt('COM_TOOLS_REQUIRED_FIELD_CHECK', $fields[$tagname]->label));
             }
             $found[] = $tagname;
         }
         foreach ($fields as $field) {
             if (!in_array($field->name, $found) && $field->required) {
                 $found[] = $field->name;
                 $this->setError(Lang::txt('COM_TOOLS_REQUIRED_FIELD_CHECK', $field->label));
             }
         }
         $hztv->fulltxt = $objV->fulltxt = $status['fulltxt'];
         $hztv->description = $objV->description = \Hubzero\Utility\String::truncate(Request::getVar('description', $status['description'], 'post'), 500);
         $hztv->title = $objV->title = \Hubzero\Utility\String::truncate(preg_replace('/\\s+/', ' ', Request::getVar('title', $status['title'], 'post')), 500);
         if (!$hztv->update()) {
             throw new Exception(Lang::txt('COM_TOOLS_ERROR_UPDATING_TOOL'), 500);
         } else {
             // get updated tool status
             $obj->getToolStatus($this->_toolid, $this->_option, $status, $version);
         }
         if ($version == 'dev') {
             // update resource page
             $this->updatePage($row->id, $status);
         }
     }
     // Group access
     //$accesses = array('Public', 'Registered', 'Special', 'Protected', 'Private');
     //$lists = array();
     //$lists['access'] = \Components\Tools\Helpers\Html::selectAccess($accesses, $row->access);
     //$groups = \Hubzero\User\Helper::getGroups(User::get('id'), 'members');
     // get authors
     $objA = new \Components\Tools\Tables\Author($this->database);
     $authors = $version == 'current' ? $objA->getToolAuthors($version, $row->id, $status['toolname']) : array();
     // Tags
     $tags = Request::getVar('tags', '', 'post');
     $tagfa = Request::getVar('tagfa', '', 'post');
     // Get any HUB focus areas
     // These are used where any resource is required to have one of these tags
     $tconfig = Component::params('com_tags');
     $fa1 = $tconfig->get('focus_area_01');
     $fa2 = $tconfig->get('focus_area_02');
     $fa3 = $tconfig->get('focus_area_03');
     $fa4 = $tconfig->get('focus_area_04');
     $fa5 = $tconfig->get('focus_area_05');
     $fa6 = $tconfig->get('focus_area_06');
     $fa7 = $tconfig->get('focus_area_07');
     $fa8 = $tconfig->get('focus_area_08');
     $fa9 = $tconfig->get('focus_area_09');
     $fa10 = $tconfig->get('focus_area_10');
     // Instantiate our tag object
     $tagcloud = new \Components\Resources\Helpers\Tags($row->id);
     // Normalize the focus areas
     $tagfa1 = $tagcloud->normalize($fa1);
     $tagfa2 = $tagcloud->normalize($fa2);
     $tagfa3 = $tagcloud->normalize($fa3);
     $tagfa4 = $tagcloud->normalize($fa4);
     $tagfa5 = $tagcloud->normalize($fa5);
     $tagfa6 = $tagcloud->normalize($fa6);
     $tagfa7 = $tagcloud->normalize($fa7);
     $tagfa8 = $tagcloud->normalize($fa8);
     $tagfa9 = $tagcloud->normalize($fa9);
     $tagfa10 = $tagcloud->normalize($fa10);
     // process new tags
     if ($tags or $tagfa) {
         $newtags = '';
         if ($tagfa) {
             $newtags = $tagfa . ', ';
         }
         if ($tags) {
             $newtags .= $tags;
         }
         $tagcloud->setTags($newtags, User::get('id'));
     }
     // Get all the tags on this resource
     $tags_men = $tagcloud->tags();
     $mytagarray = array();
     $fas = array($tagfa1, $tagfa2, $tagfa3, $tagfa4, $tagfa5, $tagfa6, $tagfa7, $tagfa8, $tagfa9, $tagfa10);
     $fats = array();
     if ($fa1) {
         $fats[$fa1] = $tagfa1;
     }
     if ($fa2) {
         $fats[$fa2] = $tagfa2;
     }
     if ($fa3) {
         $fats[$fa3] = $tagfa3;
     }
     if ($fa4) {
         $fats[$fa4] = $tagfa4;
     }
     if ($fa5) {
         $fats[$fa5] = $tagfa5;
     }
     if ($fa6) {
         $fats[$fa6] = $tagfa6;
     }
     if ($fa7) {
         $fats[$fa7] = $tagfa7;
     }
     if ($fa8) {
         $fats[$fa8] = $tagfa8;
     }
     if ($fa9) {
         $fats[$fa9] = $tagfa9;
     }
     if ($fa10) {
         $fats[$fa10] = $tagfa10;
     }
     // Loop through all the tags and pull out the focus areas - those will be displayed differently
     foreach ($tags_men as $tag_men) {
         if (in_array($tag_men->get('tag'), $fas)) {
             $tagfa = $tag_men->get('tag');
         } else {
             $mytagarray[] = $tag_men->get('raw_tag');
         }
     }
     $tags = implode(', ', $mytagarray);
     // Set the document title
     $this->view->title = Lang::txt(strtoupper($this->_option)) . ': ' . Lang::txt('COM_TOOLS_EDIT_TOOL_PAGE') . ' (' . $status['toolname'] . ')';
     Document::setTitle($this->view->title);
     // Set the document pathway (breadcrumbs)
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option);
     }
     if (Pathway::count() <= 1) {
         Pathway::append(Lang::txt('COM_TOOLS_STATUS_FOR', $status['toolname']), 'index.php?option=' . $this->_option . '&controller=pipeline&task=status&app=' . $alias);
         Pathway::append(Lang::txt('COM_TOOLS_EDIT_TOOL_PAGE'), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&app=' . $alias . '&task=start&step=1');
     }
     $this->view->row = $row;
     $this->view->step = $step;
     $this->view->version = $version;
     $this->view->status = $status;
     $this->view->tags = $tags;
     $this->view->tagfa = $tagfa;
     $this->view->fats = $fats;
     $this->view->authors = $authors;
     // Pass error messages to the view
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output HTML
     $this->view->display();
 }