/** * Short description for 'display' * * Long description (if any) ... * * @param unknown $tpl Parameter description (if any) ... * @return void */ function display($tpl = null) { // Initialize variables $image = ''; $menu = \App::get('menu'); $item = $menu->getActive(); if ($item) { $params = $menu->getParams($item->id); } else { $params = new \Hubzero\Config\Registry(''); $template = App::get('template')->template; $inifile = App::get('template')->path . DS . 'html' . DS . 'com_user' . DS . 'logout' . DS . 'config.ini'; if (file_exists($inifile)) { $params->parse(file_get_contents($inifile)); } $params->def('page_title', Lang::txt('Logout')); } $type = 'logout'; // Set some default page parameters if not set $params->def('show_page_title', 1); if (!$params->get('page_title')) { $params->set('page_title', Lang::txt('Logout')); } if (!$item) { $params->def('header_logout', ''); } $params->def('pageclass_sfx', ''); $params->def('logout', '/'); $params->def('description_logout', 1); $params->def('description_logout_text', Lang::txt('LOGOUT_DESCRIPTION')); $params->def('image_logout', 'key.jpg'); $params->def('image_logout_align', 'right'); $usersConfig = Component::params('com_users'); $params->def('registration', $usersConfig->get('allowUserRegistration')); $title = Lang::txt('Logout'); // Set page title Document::setTitle($title); // Build logout image if enabled if ($params->get('image_' . $type) != -1) { $image = '/images/stories/' . $params->get('image_' . $type); $image = '<img src="' . $image . '" align="' . $params->get('image_' . $type . '_align') . '" hspace="10" alt="" />'; } // Get the return URL if (!($url = Request::getVar('return', '', 'method', 'base64'))) { $url = base64_encode($params->get($type)); } $this->assign('image', $image); $this->assign('type', $type); $this->assign('return', $url); $this->assignRef('params', $params); parent::display($tpl); }
/** * redefine the function an add some properties to make the styling more easy * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if (!count($this->_items)) { $app = JFactory::getApplication(); $menu = \App::get('menu'); $active = $menu->getActive(); $params = new \Hubzero\Config\Registry(); if ($active) { $params->parse($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * return void * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initiliase variables. $app = JFactory::getApplication('site'); $pk = Request::getInt('id'); $this->setState('category.id', $pk); // Load the parameters. Merge Global and Menu Item params into new object $params = $app->getParams(); $menuParams = new \Hubzero\Config\Registry(); if ($menu = \App::get('menu')->getActive()) { $menuParams->parse($menu->params); } $mergedParams = clone $menuParams; $mergedParams->merge($params); $this->setState('params', $mergedParams); $user = User::getInstance(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $groups = implode(',', $user->getAuthorisedViewLevels()); if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { // limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $nowDate = $db->Quote(Date::toSQL()); $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')'); $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } else { $this->setState('filter.published', array(0, 1, 2)); } // process show_noauth parameter if (!$params->get('show_noauth')) { $this->setState('filter.access', true); } else { $this->setState('filter.access', false); } // Optional filter text $this->setState('list.filter', Request::getString('filter-search')); // filter.order $itemid = Request::getInt('id', 0) . ':' . Request::getInt('Itemid', 0); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'a.ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $this->setState('list.start', Request::getUInt('limitstart', 0)); // set limit for query. If list, use parameter. If blog, add blog parameters for limit. if (Request::getCmd('layout') == 'blog' || $params->get('layout_type') == 'blog') { $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links'); $this->setState('list.links', $params->get('num_links')); } else { $limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint'); } $this->setState('list.limit', $limit); // set the depth of the category query based on parameter $showSubcategories = $params->get('show_subcategory_content', '0'); if ($showSubcategories) { $this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1')); $this->setState('filter.subcategories', true); } $this->setState('filter.language', App::get('language.filter')); $this->setState('layout', Request::getCmd('layout')); }
/** * Save an Import * * @return void */ public function saveTask($redirect = true) { // check token Session::checkToken(); // Get request vars $import = Request::getVar('import', array()); $hooks = Request::getVar('hooks', array()); $params = Request::getVar('params', array()); $fields = Request::getVar('mapping', array()); $file = Request::getVar('file', array(), 'FILES'); // Create import model object $this->import = new \Components\Members\Models\Import(isset($import['id']) ? $import['id'] : null); // Set our hooks $this->import->set('hooks', json_encode($hooks)); // Set our fields $this->import->set('fields', json_encode($fields)); // Load current params $iparams = new \Hubzero\Config\Registry($this->import->get('params')); // Bind incoming params $iparams->parse($params); // Set params on import object $this->import->set('params', $iparams->toString()); // Bind input to model if (!$this->import->bind($import)) { $this->setError($this->import->getError()); return $this->editTask($this->import); } // Is this a new import? $isNew = false; if (!$this->import->exists()) { $isNew = true; // Set the created by/at $this->import->set('created_by', User::get('id')); $this->import->set('created_at', Date::toSql()); } // Do we have a data file /*if ($this->import->get('file')) { // Get record count $importImporter = new \Hubzero\Content\Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); }*/ // Attempt to save if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } // create folder for files if (!$this->_createImportFilespace($this->import)) { return $this->editTask(); } // If we have a file if (is_array($file) && $file['size'] > 0 && $file['error'] == 0) { move_uploaded_file($file['tmp_name'], $this->import->fileSpacePath() . DS . $file['name']); $this->import->set('file', $file['name']); $this->import->set('fields', ''); // Force into the field map view $isNew = true; } // Do we have a data file? if ($this->import->get('file')) { // get record count $importImporter = new \Hubzero\Content\Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // Save again with import count if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask($this->import); } // Inform user & redirect if ($redirect) { if ($isNew) { $this->view->set('import', $this->import)->setLayout('fields')->display(); return; } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_IMPORT_CREATED'), 'passed'); return; } $this->editTask($this->import); }
/** * Save an Import * * @return void */ public function saveTask() { // check token Session::checkToken(); // get request vars $import = Request::getVar('import', array()); $hooks = Request::getVar('hooks', array()); $params = Request::getVar('params', array()); $file = Request::getVar('file', array(), 'FILES'); // create import model object $this->import = new Models\Import(); // set our hooks $this->import->set('hooks', json_encode($hooks)); // load current params $iparams = new \Hubzero\Config\Registry($this->import->get('params')); // bind incoming params $iparams->parse($params); // set params on import object $this->import->set('params', $iparams->toString()); // bind input to model if (!$this->import->bind($import)) { $this->setError($this->import->getError()); return $this->editTask(); } // is this a new import $isNew = false; if (!$this->import->get('id')) { $isNew = true; // set the created by/at $this->import->set('created_by', User::get('id')); $this->import->set('created_at', Date::toSql()); } // do we have a data file if ($this->import->get('file')) { // get record count $importImporter = new Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // attempt to save if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } // is this a new import if ($isNew) { // create folder for files $this->_createImportFilespace($this->import); } // if we have a file if (is_array($file) && $file['size'] > 0 && $file['error'] == 0) { $ext = strtolower(Filesystem::extension($file['name'])); if (!in_array($ext, array('csv', 'xml'))) { $this->setError(Lang::txt('COM_RESOURCES_IMPORT_UNSUPPORTED_FILE_TYPE')); return $this->editTask(); } if (!is_dir($this->import->fileSpacePath())) { Filesystem::makeDirectory($this->import->fileSpacePath()); } move_uploaded_file($file['tmp_name'], $this->import->fileSpacePath() . DS . $file['name']); $this->import->set('file', $file['name']); } // do we have a data file if ($this->import->get('file')) { // get record count $importImporter = new Importer(); $count = $importImporter->count($this->import); $this->import->set('count', $count); } // save again with import count if (!$this->import->store(true)) { $this->setError($this->import->getError()); return $this->editTask(); } //inform user & redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=display', false), Lang::txt('COM_RESOURCES_IMPORT_CREATED'), 'passed'); }
/** * Method to get category data for the current category * * @param int An optional ID * * @return object * @since 1.5 */ public function getCategory() { if (!is_object($this->_item)) { $app = JFactory::getApplication(); $menu = \App::get('menu'); $active = $menu->getActive(); $params = new \Hubzero\Config\Registry(); if ($active) { $params->parse($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); if (is_object($this->_item)) { $this->_children = $this->_item->getChildren(); $this->_parent = false; if ($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; }
/** * Saves changes to a course or saves a new entry if creating * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); // Incoming $fields = Request::getVar('fields', array(), 'post'); // Instantiate a Course object $model = \Components\Courses\Models\Offering::getInstance($fields['id']); if (!$model->bind($fields)) { $this->setError($model->getError()); $this->editTask($model); return; } $p = new \Hubzero\Config\Registry(''); $p->parse(Request::getVar('params', '', 'post')); // Make sure the logo gets carried over $op = new \Hubzero\Config\Registry($model->get('params')); $p->set('logo', $op->get('logo')); $model->set('params', $p->toString()); if (!$model->store(true)) { $this->setError($model->getError()); $this->editTask($model); return; } if ($this->_task == 'apply') { return $this->editTask($model); } // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&course=' . $model->get('course_id'), false), Lang::txt('COM_COURSES_ITEM_SAVED')); }