/** * Display a list of all categories * * @return void */ public function displayTask() { // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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')); //print_r($this->view->filters); // Get option group ID $ogId = Request::getVar('ogId', array(0)); $this->view->ogId = $ogId; // Get option group $optionGroup = new OptionGroup($ogId); $this->view->optionGroup = $optionGroup; $obj = new Archive(); // Get record count $this->view->total = $obj->options('count', $ogId, $this->view->filters); // Get records $this->view->rows = $obj->options('list', $ogId, $this->view->filters); //print_r($this->view->rows); die; // Set any errors if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } // Output the HTML //print_r($this->view); die; $this->view->display(); }
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { if (!$offering->access('manage', 'section')) { return; } $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'managers'))->set('display_menu_tab', true)->set('icon', 'f083'); if ($describe) { return $response; } $nonadmin = Request::getState('com_courses.offering' . $offering->get('id') . '.nonadmin', 0); if (!($active = Request::getVar('active')) && !$nonadmin) { Request::setVar('active', $active = $this->_name); } if ($response->get('name') == $active) { // Set the page title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_' . strtoupper($this->_name))); Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $offering->link() . '&active=' . $this->_name); $view = with($this->view('default', 'overview'))->set('option', Request::getVar('option', 'com_courses'))->set('course', $course)->set('offering', $offering)->set('params', $this->params); foreach ($this->getErrors() as $error) { $view->setError($error); } $response->set('html', $view->loadTemplate()); } // Return the output return $response; }
/** * Display a list of all categories * * @return void */ public function displayTask() { // Get product ID $pId = Request::getVar('id'); if (empty($pId)) { $pId = Request::getVar('pId', array(0)); } $this->view->pId = $pId; // Get product $product = new Product($pId); $this->view->product = $product; // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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')); $obj = new Archive(); // Get record count $this->view->total = $obj->skus('count', $pId, $this->view->filters); // Get records $this->view->rows = $obj->skus('list', $pId, $this->view->filters); // Set any errors if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } // Output the HTML $this->view->display(); }
/** * Displays a list of courses * * @return void */ public function displayTask() { // Incoming $this->view->filters = array('unit' => Request::getState($this->_option . '.' . $this->_controller . '.unit', 'unit', 0), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1'), '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')); $this->view->unit = \Components\Courses\Models\Unit::getInstance($this->view->filters['unit']); if (!$this->view->unit->exists()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=courses', false)); return; } $this->view->offering = \Components\Courses\Models\Offering::getInstance($this->view->unit->get('offering_id')); $this->view->course = \Components\Courses\Models\Course::getInstance($this->view->offering->get('course_id')); $rows = $this->view->unit->assetgroups(null, $this->view->filters); // establish the hierarchy of the menu $children = array(0 => array()); $levellimit = $this->view->filters['limit'] == 0 ? 500 : $this->view->filters['limit']; // first pass - collect children foreach ($rows as $v) { $children[0][] = $v; $children[$v->get('id')] = $v->children(); } // second pass - get an indent list of the items $list = $this->treeRecurse(0, '', array(), $children, max(0, $levellimit - 1)); $this->view->total = count($list); $this->view->rows = array_slice($list, $this->view->filters['start'], $this->view->filters['limit']); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->display(); }
/** * Lists publications * * @return void */ public function displayTask() { // Incoming $this->view->filters = array(); $this->view->filters['limit'] = Request::getState($this->_option . '.publications.limit', 'limit', Config::get('list_limit'), 'int'); $this->view->filters['start'] = Request::getState($this->_option . '.publications.limitstart', 'limitstart', 0, 'int'); $this->view->filters['search'] = urldecode(trim(Request::getState($this->_option . '.publications.search', 'search', ''))); $this->view->filters['sortby'] = trim(Request::getState($this->_option . '.publications.sortby', 'filter_order', 'created')); $this->view->filters['sortdir'] = trim(Request::getState($this->_option . '.publications.sortdir', 'filter_order_Dir', 'DESC')); $this->view->filters['status'] = trim(Request::getState($this->_option . '.publications.status', 'status', 'all')); $this->view->filters['dev'] = 1; $this->view->filters['category'] = trim(Request::getState($this->_option . '.publications.category', 'category', '')); // Instantiate a publication object $this->view->model = new Models\Publication($this->database); // Get record count $this->view->total = $this->view->model->entries('count', $this->view->filters, true); // Get publications $this->view->rows = $this->view->model->entries('list', $this->view->filters, true); $this->view->config = $this->config; // Get <select> of types // Get types $rt = new Tables\Category($this->database); $this->view->categories = $rt->getContribCategories(); // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Output the HTML $this->view->display(); }
/** * Lists projects * * @return void */ public function displayTask() { $this->view->config = $this->config; // Get quotas $this->view->defaultQuota = Helpers\Html::convertSize(floatval($this->config->get('defaultQuota', 1)), 'GB', 'b'); $this->view->premiumQuota = Helpers\Html::convertSize(floatval($this->config->get('premiumQuota', 30)), 'GB', 'b'); // Get filters $this->view->filters = array('limit' => Request::getState($this->_option . '.projects.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.projects.limitstart', 'limitstart', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.projects.search', 'search', '')), 'sortby' => Request::getState($this->_option . '.projects.sort', 'filter_order', 'id'), 'sortdir' => Request::getState($this->_option . '.projects.sortdir', 'filter_order_Dir', 'DESC'), 'authorized' => true, 'getowner' => 1, 'activity' => 1, 'quota' => Request::getVar('quota', 'all', 'post')); $this->view->limit = $this->view->filters['limit']; $this->view->start = $this->view->filters['start']; // Retrieve all records when filtering by quota (no paging) if ($this->view->filters['quota'] != 'all') { $this->view->filters['limit'] = 'all'; $this->view->filters['start'] = 0; } $obj = new Tables\Project($this->database); // Get records $this->view->rows = $obj->getRecords($this->view->filters, true, 0, 1); // Get a record count $this->view->total = $obj->getCount($this->view->filters, true, 0, 1); // Filtering by quota if ($this->view->filters['quota'] != 'all' && $this->view->rows) { $counter = $this->view->total; $rows = $this->view->rows; for ($i = 0, $n = count($rows); $i < $n; $i++) { $params = new \Hubzero\Config\Registry($rows[$i]->params); $quota = $params->get('quota', 0); if ($this->view->filters['quota'] == 'premium' && $quota < $this->view->premiumQuota || $this->view->filters['quota'] == 'regular' && $quota > $this->view->defaultQuota) { $counter--; unset($rows[$i]); } } $rows = array_values($rows); $this->view->total = $counter > 0 ? $counter : 0; // Fix up paging after filter if (count($rows) > $this->view->limit) { $k = 0; for ($i = 0, $n = count($rows); $i < $n; $i++) { if ($k < $this->view->start || $k >= $this->view->limit + $this->view->start) { unset($rows[$i]); } $k++; } } $this->view->rows = array_values($rows); } // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Check that master path is there if ($this->config->get('offroot') && !is_dir($this->config->get('webpath'))) { $this->view->setError(Lang::txt('Master directory does not exist. Administrator must fix this! ') . $this->config->get('webpath')); } // Output the HTML $this->view->display(); }
/** * Display a list of all categories * * @return void */ public function displayTask() { // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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')); $obj = new Archive(); // Get record count $this->view->total = $obj->products('count', $this->view->filters); // Get records $this->view->rows = $obj->products('list', $this->view->filters); // For all records here get SKUs $skus = new \stdClass(); $warehouse = new Warehouse(); foreach ($this->view->rows as $r) { $key = $r->pId; $allSkus = $warehouse->getProductSkus($r->pId, 'all', false); // Count how many active and how many inactive SKUs there are $skuCounter = new \stdClass(); $skuCounter->active = 0; $skuCounter->inactive = 0; foreach ($allSkus as $skuInfo) { if ($skuInfo->sActive) { $skuCounter->active++; } else { $skuCounter->inactive++; } } $skus->{$key} = $skuCounter; } $this->view->skus = $skus; // access groups $accessGroups = array(); if ($this->config->get('productAccess')) { $ag = \Hubzero\Access\Group::all()->rows(); $accessGroups[0] = 'None'; foreach ($ag as $obj) { $accessGroups[$obj->get('id')] = $obj->get('title'); } } else { $ag = Access::assetgroups(); $accessGroups[0] = 'All'; foreach ($ag as $obj) { $accessGroups[$obj->value] = $obj->text; } } $this->view->ag = $accessGroups; // Output the HTML $this->view->set('config', $this->config)->display(); }
/** * List roles * * @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' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); // Instantiate an object $model = new Tables\Role($this->database); // Get a record count $this->view->total = $model->count($this->view->filters); // Get records $this->view->rows = $model->find($this->view->filters); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->display(); }
/** * Display a list of all users * * @return void */ public function displayTask() { // Get SKU ID $sId = Request::getVar('sId'); $this->view->sId = $sId; // Get SKU $sku = Sku::getInstance($sId); $this->view->sku = $sku; // Get filters $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'srId'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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')); //print_r($this->view->filters); die; // Get record count $this->view->filters['return'] = 'count'; $this->view->total = SerialsHelper::getSkuSerials($this->view->filters, $sId); // Get records $this->view->filters['return'] = 'list'; $this->view->rows = SerialsHelper::getSkuSerials($this->view->filters, $sId); // Output the HTML $this->view->display(); }
/** * Display a list of all option groups * * @return void */ public function displayTask() { $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), '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')); $obj = new Archive(); // Get record count $this->view->total = $obj->optionGroups('count', $this->view->filters); // Get records $this->view->rows = $obj->optionGroups('list', $this->view->filters); //print_r($this->view->rows); die; // For all records here get options $options = new \stdClass(); $warehouse = new Warehouse(); foreach ($this->view->rows as $r) { $key = $r->ogId; $allOptions = $warehouse->getOptionGroupOptions($key, 'rows', false); //print_r($allOptions); die; // Count how many active and how many inactive options there are $optionCounter = new \stdClass(); $optionCounter->active = 0; $optionCounter->inactive = 0; foreach ($allOptions as $optionInfo) { if ($optionInfo->oActive) { $optionCounter->active++; } else { $optionCounter->inactive++; } } $options->{$key} = $optionCounter; } //print_r($options); die; $this->view->options = $options; // Set any errors if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } // Output the HTML //print_r($this->view); die; $this->view->display(); }
/** * List resource types * * @return void */ public function displayTask() { // Incoming $this->view->filters = array(); $this->view->filters['limit'] = Request::getState($this->_option . '.licenses.limit', 'limit', Config::get('list_limit'), 'int'); $this->view->filters['start'] = Request::getState($this->_option . '.licenses.limitstart', 'limitstart', 0, 'int'); $this->view->filters['search'] = trim(Request::getState($this->_option . '.licenses.search', 'search', '')); $this->view->filters['sort'] = trim(Request::getState($this->_option . '.licenses.sort', 'filter_order', 'title')); $this->view->filters['sort_Dir'] = trim(Request::getState($this->_option . '.licenses.sortdir', 'filter_order_Dir', 'ASC')); // Instantiate an object $rt = new \Components\Publications\Tables\License($this->database); // Get a record count $this->view->total = $rt->getCount($this->view->filters); // Get records $this->view->rows = $rt->getRecords($this->view->filters); // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Output the HTML $this->view->display(); }
/** * Displays a list of courses * * @return void */ public function displayTask() { // Incoming $this->view->filters = array('course' => Request::getState($this->_option . '.' . $this->_controller . '.course', 'course', 0), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'state' => Request::getState($this->_option . '.' . $this->_controller . '.state', 'state', '-1'), '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'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); $this->view->course = \Components\Courses\Models\Course::getInstance($this->view->filters['course']); if (!$this->view->course->exists()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=courses', false)); return; } // 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; $this->view->filters['count'] = true; $this->view->total = $this->view->course->offerings($this->view->filters); $this->view->filters['count'] = false; $this->view->rows = $this->view->course->offerings($this->view->filters); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->display(); }
function display($tpl = null) { $config = Component::params('com_media'); $style = Request::getState('media.list.layout', 'layout', 'thumbs', 'word'); Document::setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu'); Html::behavior('framework', true); \Hubzero\Document\Assets::addComponentScript('com_media', 'mediamanager.js'); \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'mediamanager.css'); Html::behavior('modal'); Document::addScriptDeclaration("\n\t\tjQuery(document).ready(function(\$){\n\t\t\tdocument.preview = \$.fancybox;\n\t\t});"); Html::asset('script', 'system/jquery.treeview.js', true, true, false, false); Html::asset('stylesheet', 'system/jquery.treeview.css', array(), true); if (Lang::isRTL()) { Html::asset('stylesheet', 'media/jquery.treeview_rtl.css', array(), true); } if (DIRECTORY_SEPARATOR == '\\') { $base = str_replace(DIRECTORY_SEPARATOR, "\\\\", COM_MEDIA_BASE); } else { $base = COM_MEDIA_BASE; } $js = "\n\t\t\tvar basepath = '" . $base . "';\n\t\t\tvar viewstyle = '" . $style . "';\n\t\t"; Document::addScriptDeclaration($js); // Display form for FTP credentials? // Don't set them here, as there are other functions called before this one if there is any file write operation $ftp = !JClientHelper::hasCredentials('ftp'); $session = App::get('session'); $state = $this->get('state'); $this->assignRef('session', $session); $this->assignRef('config', $config); $this->assignRef('state', $state); $this->require_ftp = $ftp; $this->folders_id = ' id="media-tree"'; $this->folders = $this->get('folderTree'); // Set the toolbar $this->addToolbar(); parent::display($tpl); echo Html::behavior('keepalive'); }
/** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { Plugin::import('content'); $vName = Request::getCmd('view', 'media'); switch ($vName) { case 'images': $vLayout = Request::getCmd('layout', 'default'); $mName = 'manager'; break; case 'imagesList': $mName = 'list'; $vLayout = Request::getCmd('layout', 'default'); break; case 'mediaList': $mName = 'list'; $vLayout = Request::getState('media.list.layout', 'layout', 'thumbs', 'word'); break; case 'media': default: $vName = 'media'; $vLayout = Request::getCmd('layout', 'default'); $mName = 'manager'; break; } $vType = Document::getType(); // Get/Create the view $view = $this->getView($vName, $vType); // Get/Create the model if ($model = $this->getModel($mName)) { // Push the model into the view (as default) $view->setModel($model, true); } // Set the layout $view->setLayout($vLayout); // Display the view $view->display(); return $this; }
function display($tpl = null) { // Do not allow cache App::get('response')->headers->set('Cache-Control', 'no-cache', false); App::get('response')->headers->set('Pragma', 'no-cache'); $style = Request::getState('media.list.layout', 'layout', 'thumbs', 'word'); Html::behavior('framework', true); //Document::addStyleSheet('../media/media/css/medialist-'.$style.'.css'); \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'medialist-' . $style . '.css'); if (Lang::isRTL()) { //Document::addStyleSheet('../media/media/css/medialist-'.$style.'_rtl.css'); \Hubzero\Document\Assets::addComponentStylesheet('com_media', 'medialist-' . $style . '_rtl.css'); } Document::addScriptDeclaration("\n\t\tjQuery(document).ready(function(\$){\n\t\t\twindow.parent.document.updateUploader();\n\t\t\t\$('a.img-preview').on('click', function(e) {\n\t\t\t\te.preventDefault();\n\t\t\t\twindow.top.document.preview.open(\$(this).attr('href'));\n\t\t\t});\n\t\t});"); $images = $this->get('images'); $documents = $this->get('documents'); $folders = $this->get('folders'); $state = $this->get('state'); // Check for invalid folder name if (empty($state->folder)) { $dirname = Request::getVar('folder', '', '', 'string'); if (!empty($dirname)) { $dirname = htmlspecialchars($dirname, ENT_COMPAT, 'UTF-8'); if (Lang::hasKey('COM_MEDIA_ERROR_UNABLE_TO_BROWSE_FOLDER_WARNDIRNAME')) { throw new Exception(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_BROWSE_FOLDER_WARNDIRNAME', $dirname), 100); } else { throw new Exception(sprintf('Unable to browse: %s. Directory name must only contain alphanumeric characters and no spaces.', $dirname), 100); } } } $this->baseURL = Request::root(); $this->assignRef('images', $images); $this->assignRef('documents', $documents); $this->assignRef('folders', $folders); $this->assignRef('state', $state); parent::display($tpl); }
/** * Display a list of entries for an event * * @return void */ public function displayTask() { $ids = Request::getVar('id', array(0)); $ids = !is_array($ids) ? array($ids) : $ids; if (count($ids) < 1) { App::redirect(Route::url('index.php?option=' . $this->_option, false)); return; } // Get filters $this->view->filters = array(); $this->view->filters['event_id'] = $ids[0]; $this->view->filters['search'] = urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')); $this->view->filters['limit'] = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'); $this->view->filters['start'] = Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'); $obj = new Page($this->database); // Get a record count $this->view->total = $obj->getCount($this->view->filters); // Get records $this->view->rows = $obj->getRecords($this->view->filters); $this->view->event = new Event($this->database); $this->view->event->load($ids[0]); // Output the HTML $this->view->display(); }
/** * Retrieve and parse incoming filters * * @return array */ public static function getFilters() { // Query filters defaults $filters = array(); $filters['search'] = ''; $filters['status'] = 'open'; $filters['type'] = 0; $filters['owner'] = ''; $filters['reportedby'] = ''; $filters['severity'] = 'normal'; $filters['severity'] = ''; $filters['sort'] = trim(Request::getState('com_support.tickets.sort', 'filter_order', 'created')); $filters['sortdir'] = trim(Request::getState('com_support.tickets.sortdir', 'filter_order_Dir', 'DESC')); // Paging vars $filters['limit'] = Request::getState('com_support.tickets.limit', 'limit', Config::get('list_limit'), 'int'); $filters['start'] = Request::getState('com_support.tickets.limitstart', 'limitstart', 0, 'int'); // Incoming $filters['_find'] = urldecode(trim(Request::getState('com_support.tickets.find', 'find', ''))); $filters['_show'] = urldecode(trim(Request::getState('com_support.tickets.show', 'show', ''))); // Break it apart so we can get our filters // Starting string hsould look like "filter:option filter:option" if ($filters['_find'] != '') { $chunks = explode(' ', $filters['_find']); $filters['_show'] = ''; } else { $chunks = explode(' ', $filters['_show']); } // Loop through each chunk (filter:option) foreach ($chunks as $chunk) { if (!strstr($chunk, ':')) { $chunk = trim($chunk, '"'); $chunk = trim($chunk, "'"); $filters['search'] = $chunk; continue; } // Break each chunk into its pieces (filter, option) $pieces = explode(':', $chunk); // Find matching filters and ensure the vaule provided is valid switch ($pieces[0]) { case 'q': $pieces[0] = 'search'; if (isset($pieces[1])) { $pieces[1] = trim($pieces[1], '"'); // Remove any surrounding quotes $pieces[1] = trim($pieces[1], "'"); // Remove any surrounding quotes } else { $pieces[1] = $filters[$pieces[0]]; } break; case 'status': $allowed = array('open', 'closed', 'all', 'waiting', 'new'); if (!in_array($pieces[1], $allowed)) { $pieces[1] = $filters[$pieces[0]]; } break; case 'type': $allowed = array('submitted' => 0, 'automatic' => 1, 'none' => 2, 'tool' => 3); if (in_array($pieces[1], $allowed)) { $pieces[1] = $allowed[$pieces[1]]; } else { $pieces[1] = 0; } break; case 'owner': case 'reportedby': if (isset($pieces[1])) { if ($pieces[1] == 'me') { $pieces[1] = User::get('username'); } else { if ($pieces[1] == 'none') { $pieces[1] = 'none'; } } } break; case 'severity': $allowed = array('critical', 'major', 'normal', 'minor', 'trivial'); if (!in_array($pieces[1], $allowed)) { $pieces[1] = $filters[$pieces[0]]; } break; } $filters[$pieces[0]] = isset($pieces[1]) ? $pieces[1] : ''; } // Return the array return $filters; }
/** * Save students info as CSV file * * @return void */ public function csvTask() { $this->view->filters = array('offering' => Request::getState($this->_option . '.' . $this->_controller . '.offering', 'offering', 0), 'section_id' => Request::getState($this->_option . '.' . $this->_controller . '.section', 'section', 0)); $this->view->offering = \Components\Courses\Models\Offering::getInstance($this->view->filters['offering']); $this->view->filters['offering_id'] = $this->view->filters['offering']; $this->view->course = \Components\Courses\Models\Course::getInstance($this->view->offering->get('course_id')); if (!$this->view->filters['offering_id']) { $this->view->filters['offering_id'] = null; } if (!$this->view->filters['section_id']) { $this->view->filters['section_id'] = null; } $this->view->filters['student'] = 1; $tbl = new Tables\Member($this->database); $this->view->rows = $tbl->find($this->view->filters); //$this->view->offering->students($this->view->filters); if ($this->view->rows) { foreach ($this->view->rows as $key => $row) { $this->view->rows[$key] = new \Components\Courses\Models\Student($row); } } // Output the CSV $this->view->display(); }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $params = Component::params('com_newsfeeds'); // List state information $limit = Request::getState('global.list.limit', 'limit', Config::get('list_limit'), 'uint'); $this->setState('list.limit', $limit); $limitstart = Request::getUInt('limitstart', 0); $this->setState('list.start', $limitstart); $orderCol = Request::getCmd('filter_order', 'ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = Request::getCmd('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $id = Request::getVar('id', 0, '', 'int'); $this->setState('category.id', $id); if (!User::authorise('core.edit.state', 'com_newsfeeds') && !User::authorise('core.edit', 'com_newsfeeds')) { // limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', \App::get('language.filter')); // Load the parameters. $this->setState('params', $params); }
/** * Download CSV report (SKU) * * @return void */ public function downloadSkuTask() { // Get filters $filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'dDownloaded'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); $rowsRaw = CartDownload::getDownloadsSku('array', $filters); $rows = array(); foreach ($rowsRaw as $row) { $rows[] = array($row['pName'], $row['sSku'], $row['downloaded']); } $date = date('d-m-Y'); header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=cart-downloads-sku-" . $date . ".csv"); // Disable caching header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1 header("Pragma: no-cache"); // HTTP 1.0 header("Expires: 0"); // Proxies $output = fopen("php://output", "w"); $row = array('Product', 'SKU', 'Downloaded (times)'); fputcsv($output, $row); foreach ($rows as $row) { // replace($row) empty vals with n/a foreach ($row as $k => $val) { if (empty($val)) { $row[$k] = 'n/a'; } } fputcsv($output, $row); } fclose($output); die; }
/** * Download CSV report (default) * * @return void */ public function downloadOrdersTask() { // Get filters $filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'dDownloaded'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC')); //print_r($filters); die; // Get orders, request array to be returned $orders = CartOrders::getItemsOrdered('list', $filters); foreach ($orders as $order) { $orderItems = unserialize(Cart::getTransactionInfo($order->tId)->tiItems); $order->itemInfo = $orderItems[$order->sId]; } $rowsRaw = $orders; $date = date('d-m-Y'); $rows = array(); foreach ($rowsRaw as $row) { $itemInfo = $row->itemInfo['info']; $rows[] = array($row->sId, $itemInfo->pName . ', ' . $itemInfo->sSku, $row->tiQty, $row->tiPrice, $row->tId, $row->tLastUpdated, $row->Name, $row->uidNumber); } header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=cart-items-ordered" . $date . ".csv"); // Disable caching header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1 header("Pragma: no-cache"); // HTTP 1.0 header("Expires: 0"); // Proxies $output = fopen("php://output", "w"); $row = array('SKU ID', 'Product', 'QTY', 'Price', 'Order ID', 'Order Placed', 'Purchased By', 'Purchased By (userId)'); fputcsv($output, $row); foreach ($rows as $row) { fputcsv($output, $row); } fclose($output); die; }
/** * Show sent messages * * @param object $database JDatabase * @param string $option Name of the component * @param object $member Current member * @return string */ public function sent($database, $option, $member) { $view = $this->view('sent', 'default'); $view->option = $option; $view->member = $member; // Filters for returning results $filters = array(); $filters['limit'] = Request::getState($option . '.plugin.messages.limit', 'limit', Config::get('list_limit'), 'int'); $filters['start'] = Request::getState($option . '.plugin.messages.limitstart', 'limitstart', 0, 'int'); $filters['created_by'] = $member->get('uidNumber'); $recipient = new \Hubzero\Message\Message($database); $view->total = $recipient->getSentMessagesCount($filters); $view->rows = $recipient->getSentMessages($filters); $pageNav = new \Hubzero\Pagination\Paginator($view->total, $filters['start'], $filters['limit']); $pageNav->setAdditionalUrlParam('id', $member->get('uidNumber')); $pageNav->setAdditionalUrlParam('active', 'messages'); $pageNav->setAdditionalUrlParam('task', 'sent'); $pageNav->setAdditionalUrlParam('action', ''); $view->pagenavhtml = $pageNav->render(); foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }
/** * Display a list of entries * * @return void */ public function displayTask() { // Incoming $this->view->filters = array(); $this->view->filters['limit'] = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'); $this->view->filters['start'] = Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'); $this->view->filters['search'] = urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')); $this->view->filters['catid'] = Request::getVar('catid', 0, '', 'int'); $this->view->filters['scope_id'] = Request::getVar('group_id', 0, '', 'int'); $ee = new Event($this->database); // Get a record count $this->view->total = $ee->getCount($this->view->filters); // Get records $this->view->rows = $ee->getRecords($this->view->filters); // Get list of categories $categories[] = \Html::select('option', '0', '- ' . Lang::txt('COM_EVENTS_CAL_LANG_EVENT_ALLCAT'), 'value', 'text'); $this->database->setQuery("SELECT id AS value, title AS text FROM `#__categories` WHERE extension='{$this->_option}'"); $categories = array_merge($categories, $this->database->loadObjectList()); $this->view->clist = \Html::select('genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $this->view->filters['catid'], false, false); //get list of groups $groups[] = \Html::select('option', '0', '- ' . Lang::txt('COM_EVENTS_ALL_GROUPS'), 'value', 'text'); $sql = "SELECT DISTINCT(g.gidNumber) AS value, g.description AS text\n\t\t\t\tFROM `#__events` AS e, `#__xgroups` AS g\n\t\t\t\tWHERE e.scope='group'\n\t\t\t\tAND e.scope_id=g.gidNumber"; $this->database->setQuery($sql); $groups = array_merge($groups, $this->database->loadObjectList()); $this->view->glist = \Html::select('genericlist', $groups, 'group_id', 'class="inputbox"', 'value', 'text', $this->view->filters['scope_id'], false, false); // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->display(); }
<?php /** * @package Joomla.Administrator * @subpackage com_media * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_HZEXEC_') or die; $style = Request::getState('media.list.layout', 'layout', 'thumbs', 'word'); ?> <div id="submenu-box"> <div class="submenu-box"> <div class="submenu-pad"> <ul id="submenu" class="media"> <li><a href="#" id="thumbs" onclick="MediaManager.setViewType('thumbs')" class="<?php echo $style == "thumbs" ? 'active' : ''; ?> "> <?php echo Lang::txt('COM_MEDIA_THUMBNAIL_VIEW'); ?> </a></li> <li><a href="#" id="details" onclick="MediaManager.setViewType('details')" class="<?php echo $style == "details" ? 'active' : ''; ?> "> <?php echo Lang::txt('COM_MEDIA_DETAIL_VIEW'); ?>
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 2.5 */ protected function populateState() { $client = Request::getstate('com_languages.overrides.filter.client', 'filter_client', 0, 'int') ? 'administrator' : 'site'; $this->setState('filter.client', $client); $language = Request::getState('com_languages.overrides.filter.language', 'filter_language', 'en-GB', 'cmd'); $this->setState('filter.language', $language); }
/** * Display a list of sponsors * * @return void */ public function defaultTask() { // Instantiate a view $this->view = $this->view('default', 'admin'); $this->view->option = $this->_option; $this->view->controller = $this->_controller; $this->view->task = $this->_task; // Incoming $this->view->filters = array('limit' => Request::getState($this->_option . '.plugins.sponsors.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.plugins.sponsors.limitstart', 'limitstart', 0, 'int'), 'sort' => Request::getState($this->_option . '.plugins.sponsors.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.plugins.sponsors.sortdir', 'filter_order_Dir', 'ASC')); $model = new \Plugins\Resources\Sponsors\Tables\Sponsor($this->database); // Get a record count $this->view->total = $model->getCount($this->view->filters); // Get records $this->view->rows = $model->getRecords($this->view->filters); if ($this->getError()) { $this->view->setError($this->getError()); } return $this->view->loadTemplate(); }
/** * Return data on a group view (this will be some form of HTML) * * @param object $group Current group * @param string $option Name of the component * @param string $authorized User's authorization level * @param integer $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param string $action Action to perform * @param array $access What can be accessed * @param array $areas Active area(s) * @return array */ public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null) { $return = 'html'; $active = $this->_name; $active_real = 'discussion'; // The output array we're returning $arr = array('html' => '', 'name' => $active); //get this area details $this_area = $this->onGroupAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas) && $limit) { if (!in_array($this_area['name'], $areas)) { $return = 'metadata'; } } $this->group = $group; $this->database = App::get('db'); require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php'; $model = \Components\Courses\Models\Courses::getInstance(); $filters = array('group' => $group->get('cn'), 'group_id' => $group->get('gidNumber'), 'count' => true); $arr['metadata']['count'] = $model->courses($filters); // Build the HTML if ($return == 'html') { $view = $this->view('default', 'display'); $view->option = $option; $view->group = $group; $view->filters = $filters; $view->filters['count'] = false; $view->filters['limit'] = Request::getState($option . '.plugin.courses.limit', 'limit', Config::get('list_limit'), 'int'); $view->filters['start'] = Request::getState($option . '.plugin.courses.limitstart', 'limitstart', 0, 'int'); $view->filters['sortby'] = Request::getState($option . '.plugin.courses.sortby', 'sortby', ''); $view->filters['search'] = Request::getState($option . '.plugin.courses.search', 'search', ''); $view->filters['index'] = ''; $view->filters['tag'] = ''; if (!in_array($view->filters['sortby'], array('alias', 'title', 'popularity'))) { $view->filters['sortby'] = 'title'; } switch ($view->filters['sortby']) { case 'popularity': $view->filters['sort'] = 'students'; $view->filters['sort_Dir'] = 'DESC'; break; case 'title': case 'alias': default: $view->filters['sort'] = $view->filters['sortby']; $view->filters['sort_Dir'] = 'ASC'; break; } $view->total = $arr['metadata']['count']; $view->results = $model->courses($view->filters); $arr['html'] = $view->loadTemplate(); } return $arr; }
/** * Display a list of sponsors * * @return void */ public function defaultTask() { // Incoming $filters = array('limit' => Request::getState($this->_option . '.plugins.sponsors.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.plugins.sponsors.limitstart', 'limitstart', 0, 'int'), 'sort' => Request::getState($this->_option . '.plugins.sponsors.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.plugins.sponsors.sortdir', 'filter_order_Dir', 'ASC')); $model = \Plugins\Resources\Sponsors\Models\Sponsor::all(); $rows = $model->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows(); // Instantiate a view $view = $this->view('default', 'admin')->set('rows', $rows)->set('filters', $filters)->set('option', $this->_option)->set('controller', $this->_controller)->set('task', $this->_task); return $view->setErrors($this->getErrors())->loadTemplate(); }
/** * Event call to return data for a specific member * * @param object $user User * @param object $member MembersProfile * @param string $option Component name * @param string $areas Plugins to return data * @return array Return array of html */ public function onMembers($user, $member, $option, $areas) { $returnhtml = true; // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (!array_intersect($areas, $this->onMembersAreas($user, $member)) && !array_intersect($areas, array_keys($this->onMembersAreas($user, $member)))) { $returnhtml = false; } } $arr = array('html' => '', 'metadata' => array('count' => 0)); $this->database = App::get('db'); $this->member = $member; require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'offering.php'; $model = \Components\Courses\Models\Offering::getInstance(); $roles = $model->roles(); $hasRoles = 0; if ($roles) { foreach ($roles as $i => $role) { $roles[$i]->total = $this->_getData('count', $role->alias); if ($roles[$i]->total > 0) { $hasRoles++; } $arr['metadata']['count'] += $roles[$i]->total; } } // Build the HTML if ($returnhtml) { $view = $this->view('default', 'display'); $view->option = $option; $view->member = $member; $view->roles = $roles; $view->hasRoles = $hasRoles; $view->filters = array(); $view->filters['limit'] = Request::getState($option . '.plugin.courses.limit', 'limit', Config::get('list_limit'), 'int'); $view->filters['start'] = Request::getState($option . '.plugin.courses.limitstart', 'limitstart', 0, 'int'); $view->filters['task'] = strtolower(Request::getVar('action', '')); $view->filters['sort'] = strtolower(Request::getWord('sort', 'enrolled')); if (!in_array($view->filters['sort'], array('enrolled', 'title'))) { $view->filters['sort'] = 'enrolled'; } $view->total = 0; $view->results = null; $view->active = null; $view->results = null; if ($view->hasRoles >= 1) { $found = false; if ($view->filters['task']) { foreach ($roles as $i => $role) { if ($view->filters['task'] == $role->alias && $role->total > 0) { $found = true; } } } if (!$found) { foreach ($roles as $i => $role) { if ($role->total > 0) { $view->filters['task'] = $role->alias; break; } } } } foreach ($view->roles as $i => $role) { if ($view->filters['task'] == $role->alias) { $view->active = $view->roles[$i]; $view->total = $view->roles[$i]->total; } } if (!is_null($view->active)) { $view->results = $this->_getData('list', $view->active->alias, $view->filters); } foreach ($this->getErrors() as $error) { $view->setError($error); } $arr['html'] = $view->loadTemplate(); } return $arr; }
/** * Show sent messages * * @param object $database Database * @param string $option Name of the component * @param object $member Current member * @return string */ public function sent($database, $option, $member) { // Filters for returning results $filters = array('limit' => Request::getState($option . '.plugin.messages.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($option . '.plugin.messages.limitstart', 'limitstart', 0, 'int'), 'created_by' => $member->get('id')); $recipient = Hubzero\Message\Message::blank(); $total = $recipient->getSentMessagesCount($filters); $rows = $recipient->getSentMessages($filters); // Output view $view = $this->view('sent', 'default')->set('option', $option)->set('member', $member)->set('filters', $filters)->set('total', $total)->set('rows', $rows); return $view->loadTemplate(); }