Example #1
0
 /**
  * Method to set the home property for a list of items
  *
  * @since	1.6
  */
 function setDefault()
 {
     // Check for request forgeries
     Session::checkToken('request') or die(Lang::txt('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = Request::getVar('cid', array(), '', 'array');
     $data = array('setDefault' => 1, 'unsetDefault' => 0);
     $task = $this->getTask();
     $value = \Hubzero\Utility\Arr::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         throw new Exception(Lang::txt($this->text_prefix . '_NO_ITEM_SELECTED'), 500);
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         \Hubzero\Utility\Arr::toInteger($cid);
         // Publish the items.
         if (!$model->setHome($cid, $value)) {
             throw new Exception($model->getError(), 500);
         } else {
             if ($value == 1) {
                 $ntext = 'COM_MENUS_ITEMS_SET_HOME';
             } else {
                 $ntext = 'COM_MENUS_ITEMS_UNSET_HOME';
             }
             $this->setMessage(Lang::txts($ntext, count($cid)));
         }
     }
     $this->setRedirect(Route::url('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Example #2
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     Request::setVar('hidemainmenu', true);
     $isNew = $this->item->id == 0;
     $canDo = TemplatesHelper::getActions();
     Toolbar::title($isNew ? Lang::txt('COM_TEMPLATES_MANAGER_ADD_STYLE') : Lang::txt('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'thememanager');
     // If not checked out, can save the item.
     if ($canDo->get('core.edit')) {
         Toolbar::apply('style.apply');
         Toolbar::save('style.save');
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         Toolbar::save2copy('style.save2copy');
     }
     if (empty($this->item->id)) {
         Toolbar::cancel('style.cancel');
     } else {
         Toolbar::cancel('style.cancel', 'JTOOLBAR_CLOSE');
     }
     Toolbar::divider();
     // Get the help information for the template item.
     $lang = Lang::getRoot();
     $help = $this->get('Help');
     if ($lang->hasKey($help->url)) {
         $debug = $lang->setDebug(false);
         $url = Lang::txt($help->url);
         $lang->setDebug($debug);
     } else {
         $url = null;
     }
     Toolbar::help('style');
     //$help->key, false, $url);
 }
Example #3
0
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table.  The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param	mixed	An optional array of primary key values to update.  If not
  *					set the instance property value is used.
  * @param	integer The publishing state. eg. [0 = unpublished, 1 = published]
  * @param	integer The user id of the user performing the operation.
  * @return	boolean	True on success.
  * @since	1.6
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     // Sanitize input.
     \Hubzero\Utility\Arr::toInteger($pks);
     $userId = (int) $userId;
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(Lang::txt('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     // Build the WHERE clause for the primary keys.
     $where = $k . ' IN (' . implode(',', $pks) . ')';
     // Update the publishing state for rows with the given primary keys.
     $this->_db->setQuery('UPDATE ' . $this->_db->quoteName($this->_tbl) . ' SET ' . $this->_db->quoteName('state') . ' = ' . (int) $state . ' WHERE (' . $where . ')');
     $this->_db->query();
     // Check for a database error.
     if ($this->_db->getErrorNum()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
Example #4
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     // check if we can render
     if (!parent::canRender()) {
         return \Lang::txt('[This macro is designed for Groups only]');
     }
     // get args
     $args = $this->getArgs();
     //array of filters
     $filters = array('limit' => count($args) == 1 && is_numeric($args[0]) ? $args[0] : 12);
     // get members
     $members = $this->getGroupMembers($this->group, $filters);
     //are we a group member
     $isMember = in_array(\User::get('id'), $this->group->get('members')) ? true : false;
     //get the members plugin access for this group
     $memberAccess = \Hubzero\User\Group\Helper::getPluginAccess($this->group, 'members');
     // make sure we can actually display for the current user
     if ($memberAccess == 'anyone' || $memberAccess == 'registered' && !\User::isGuest() || $memberAccess == 'members' && $isMember) {
         $html = $this->renderMembers($this->group, $members);
     } else {
         $html = '';
     }
     //return rendered events
     return $html;
 }
Example #5
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     require_once dirname(__DIR__) . DS . 'models' . DS . 'poll.php';
     $options = \Components\Poll\Models\Poll::all()->whereEquals('published', 1)->rows()->raw();
     array_unshift($options, \Html::select('option', '0', '- ' . \Lang::txt('Select Poll') . ' -', 'id', 'title'));
     return \Html::select('genericlist', $options, $control_name . '[' . $name . ']', 'class="inputbox"', 'id', 'title', $value, $control_name . $name);
 }
Example #6
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     Request::setVar('hidemainmenu', 1);
     $isNew = empty($this->item->lang_id);
     $canDo = LanguagesHelper::getActions();
     Toolbar::title(Lang::txt($isNew ? 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_NEW_TITLE' : 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_EDIT_TITLE'), 'langmanager.png');
     // If a new item, can save.
     if ($isNew && $canDo->get('core.create')) {
         Toolbar::save('language.save');
     }
     //If an existing item, allow to Apply and Save.
     if (!$isNew && $canDo->get('core.edit')) {
         Toolbar::apply('language.apply');
         Toolbar::save('language.save');
     }
     // If an existing item, can save to a copy only if we have create rights.
     if ($canDo->get('core.create')) {
         Toolbar::save2new('language.save2new');
     }
     if ($isNew) {
         Toolbar::cancel('language.cancel');
     } else {
         Toolbar::cancel('language.cancel', 'JTOOLBAR_CLOSE');
     }
     Toolbar::divider();
     Toolbar::help('language');
 }
Example #7
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     // check if we can render
     if (!parent::canRender()) {
         return \Lang::txt('[This macro is designed for Groups only]');
     }
     // get args
     $args = $this->getArgs();
     // get details
     $type = $this->_getType($args, 'all');
     $limit = $this->_getLimit($args, 5);
     $class = $this->_getClass($args);
     //get resources
     $groupResources = $this->_getResources($type, $limit);
     $html = '<div class="resources ' . $class . '">';
     foreach ($groupResources as $resource) {
         $area = strtolower(preg_replace("/[^a-zA-Z0-9]/", '', $resource->area));
         $resourceLink = \Route::url('index.php?option=com_resources&id=' . $resource->id);
         $resourceTypeLink = \Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=resources&area=' . $area);
         $html .= '<a href="' . $resourceLink . '"><strong>' . $resource->title . '</strong></a>';
         $html .= '<p class="category"> in: <a href="' . $resourceTypeLink . '">' . $resource->area . '</a></p>';
         $html .= '<p>' . \Hubzero\Utility\String::truncate($resource->itext) . '</p>';
     }
     $html .= '</div>';
     return $html;
 }
Example #8
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     $canDo = LanguagesHelper::getActions();
     Toolbar::title(Lang::txt('COM_LANGUAGES_VIEW_LANGUAGES_TITLE'), 'langmanager.png');
     if ($canDo->get('core.create')) {
         Toolbar::addNew('language.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('language.edit');
         Toolbar::divider();
     }
     if ($canDo->get('core.edit.state')) {
         if ($this->state->get('filter.published') != 2) {
             Toolbar::publishList('languages.publish');
             Toolbar::unpublishList('languages.unpublish');
         }
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'languages.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::trash('languages.trash');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         // Add install languages link to the lang installer component
         Toolbar::appendButton('Link', 'extension', 'COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages');
         Toolbar::divider();
         Toolbar::preferences('com_languages');
         Toolbar::divider();
     }
     Toolbar::help('languages');
 }
Example #9
0
 /**
  * Returns a reference to a Format object, only creating it
  * if it doesn't already exist.
  *
  * @param   string  $type  The format to load
  * @return  object  Registry format handler
  */
 public static function getInstance($type)
 {
     // Initialize static variable.
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     // Sanitize format type.
     $type = strtolower(preg_replace('/[^A-Z0-9_]/i', '', $type));
     // Only instantiate the object if it doesn't already exist.
     if (!isset($instances[$type])) {
         // Only load the file the class does not exist.
         $class = __NAMESPACE__ . '\\Format\\' . $type;
         if (!class_exists($class)) {
             $path = __DIR__ . '/format/' . $type . '.php';
             if (is_file($path)) {
                 include_once $path;
             } else {
                 throw new Exception(Lang::txt('Format not found.'), 500, E_ERROR);
             }
         }
         $instances[$type] = new $class();
     }
     return $instances[$type];
 }
Example #10
0
 /**
  * Display the toolbar.
  *
  * @return  void
  *
  * @since   2.5
  */
 protected function addToolbar()
 {
     Request::setVar('hidemainmenu', 1);
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == User::get('id'));
     $canDo = UsersHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
     Toolbar::title(Lang::txt('COM_USERS_NOTES'), 'user');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || count(User::getAuthorisedCategories('com_users', 'core.create')))) {
         Toolbar::apply('note.apply');
         Toolbar::save('note.save');
     }
     if (!$checkedOut && count(User::getAuthorisedCategories('com_users', 'core.create'))) {
         Toolbar::save2new('note.save2new');
     }
     // If an existing item, can save to a copy.
     if (!$isNew && count(User::getAuthorisedCategories('com_users', 'core.create')) > 0) {
         Toolbar::save2copy('note.save2copy');
     }
     if (empty($this->item->id)) {
         Toolbar::cancel('note.cancel');
     } else {
         Toolbar::cancel('note.cancel', 'JTOOLBAR_CLOSE');
     }
     Toolbar::divider();
     Toolbar::help('note');
 }
Example #11
0
    /**
     * Displays either a CAPTCHA image or form field
     *
     * @return string
     */
    public function onGetCaptcha($error = '')
    {
        // make sure we have the needed recaptcha API keys
        if (!$this->params->get('public') || !$this->params->get('private')) {
            return '<p class="error">' . Lang::txt('PLG_HUBZERO_RECAPTCHA_API_NEEDED') . '</p>';
        }
        // recaptcha html structure
        // this has support for users with js off
        $html = '<label class="">&nbsp;</label><div class="field-wrap">';
        $html .= '<div class="g-recaptcha" data-type="' . $this->params->get('type', 'image') . '" data-theme="' . $this->params->get('theme', 'light') . '" data-sitekey="' . $this->params->get('public') . '"></div>
				  <noscript>
					  <div style="width: 302px; height: 352px;">
					    <div style="width: 302px; height: 352px; position: relative;">
					      <div style="width: 302px; height: 352px; position: absolute;">
					        <iframe src="' . static::$_jsFallbackUrl . $this->params->get('public') . '"
					                frameborder="0" scrolling="no"
					                style="width: 302px; height:352px; border-style: none;">
					        </iframe>
					      </div>
					      <div style="width: 250px; height: 80px; position: absolute; border-style: none;
					                  bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
					        <textarea id="g-recaptcha-response" name="g-recaptcha-response"
					                  class="g-recaptcha-response"
					                  style="width: 250px; height: 80px; border: 1px solid #c1c1c1;
					                         margin: 0px; padding: 0px; resize: none;" value="">
					        </textarea>
					      </div>
					    </div>
					  </div>
					</noscript>
				  <script type="text/javascript" src="' . static::$_jsUrl . '?hl=' . $this->params->get('language', 'en') . '" async defer></script>';
        $html .= '</div>';
        return $html;
    }
Example #12
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = NewsfeedsHelper::getActions($state->get('filter.category_id'));
     Toolbar::title(Lang::txt('COM_NEWSFEEDS_MANAGER_NEWSFEEDS'), 'newsfeeds.png');
     if (count(User::getAuthorisedCategories('com_newsfeeds', 'core.create')) > 0) {
         Toolbar::addNew('newsfeed.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('newsfeed.edit');
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('newsfeeds.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('newsfeeds.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::archiveList('newsfeeds.archive');
     }
     if ($canDo->get('core.admin')) {
         Toolbar::checkin('newsfeeds.checkin');
     }
     if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'newsfeeds.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::trash('newsfeeds.trash');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_newsfeeds');
         Toolbar::divider();
     }
     Toolbar::help('JHELP_COMPONENTS_NEWSFEEDS_FEEDS');
 }
 /**
  * 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)
 {
     $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('default_access', 'registered')->set('display_menu_tab', false);
     if ($describe) {
         return $response;
     }
     if (!($active = Request::getVar('active'))) {
         Request::setVar('active', $active = $this->_name);
     }
     if ($response->get('name') == $active) {
         // Things we need from the form
         $recvEmailOptionID = Request::getInt('memberoptionid', 0);
         $recvEmailOptionValue = Request::getInt('recvpostemail', 0);
         include_once __DIR__ . DS . 'memberoption.class.php';
         switch ($action) {
             case 'editmemberoptions':
                 $response->set('html', $this->edit($course, $user, $recvEmailOptionID, $recvEmailOptionValue));
                 break;
             case 'savememberoptions':
                 $response->set('html', $this->save($course, $user, $recvEmailOptionID, $recvEmailOptionValue));
                 break;
             default:
                 $response->set('html', $this->edit($course, $user, $recvEmailOptionID, $recvEmailOptionValue));
                 break;
         }
     }
     // Return the output
     return $response;
 }
Example #14
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $canDo = UsersHelper::getActions();
     Toolbar::title(Lang::txt('COM_USERS_VIEW_USERS_TITLE'), 'user');
     if ($canDo->get('core.create')) {
         //Toolbar::addNew('user.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('user.edit');
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('users.approve', 'COM_USERS_TOOLBAR_APPROVE', true);
         Toolbar::unpublish('users.block', 'COM_USERS_TOOLBAR_BLOCK', true);
         Toolbar::custom('users.unblock', 'unblock.png', 'unblock_f2.png', 'COM_USERS_TOOLBAR_UNBLOCK', true);
         Toolbar::divider();
     }
     if ($canDo->get('core.delete')) {
         Toolbar::deleteList('', 'users.delete');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_users');
         Toolbar::divider();
     }
     Toolbar::help('users');
 }
Example #15
0
 /**
  * Event call for displaying usage data
  *
  * @param      string $option        Component name
  * @param      string $task          Component task
  * @param      object $db            JDatabase
  * @param      array  $months        Month names (Jan -> Dec)
  * @param      array  $monthsReverse Month names in reverse (Dec -> Jan)
  * @param      string $enddate       Time period
  * @return     string HTML
  */
 public function onUsageDisplay($option, $task, $db, $months, $monthsReverse, $enddate)
 {
     // Check if our task is the area we want to return results for
     if ($task) {
         if (!in_array($task, $this->onUsageAreas()) && !in_array($task, array_keys($this->onUsageAreas()))) {
             return '';
         }
     }
     // Set some vars
     $thisyear = date("Y");
     $o = \Components\Usage\Helpers\Helper::options($db, $enddate, $thisyear, $monthsReverse, 'check_for_regiondata');
     // Build HTML
     $html = '<form method="post" action="' . Route::url('index.php?option=' . $option . '&task=' . $task) . '">' . "\n";
     $html .= "\t" . '<fieldset class="filters">' . "\n";
     $html .= "\t\t" . '<label>' . "\n";
     $html .= "\t\t\t" . Lang::txt('PLG_USAGE_SHOW_DATA_FOR') . ': ' . "\n";
     $html .= "\t\t\t" . '<select name="selectedPeriod" id="selectedPeriod">' . "\n";
     $html .= $o;
     $html .= "\t\t\t" . '</select>' . "\n";
     $html .= "\t\t" . '</label> <input type="submit" value="' . Lang::txt('PLG_USAGE_VIEW') . '" />' . "\n";
     $html .= "\t" . '</fieldset>' . "\n";
     $html .= '</form>' . "\n";
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 10, 1, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 17, 2, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 11, 3, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 9, 4, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 12, 5, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 19, 6, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 18, 7, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 7, 8, $enddate);
     // Return HTML
     return $html;
 }
Example #16
0
 /**
  * Display a list of uninstalled extensions
  *
  * @return  void
  */
 public function displayTask()
 {
     $model = new Models\Database();
     // Get data from the model
     $this->view->state = $model->getState();
     $this->view->changeSet = $model->getItems();
     $this->view->errors = $this->view->changeSet->check();
     $this->view->results = $this->view->changeSet->getStatus();
     $this->view->schemaVersion = $this->getSchemaVersion();
     $this->view->updateVersion = $this->getUpdateVersion();
     $this->view->filterParams = $this->getDefaultTextFilters();
     $this->view->schemaVersion = $this->view->schemaVersion ? $this->view->schemaVersion : Lang::txt('JNONE');
     $this->view->updateVersion = $this->view->updateVersion ? $this->view->updateVersion : Lang::txt('JNONE');
     $this->view->pagination = $model->getPagination();
     $this->view->errorCount = count($this->errors);
     $errors = count($this->view->errors);
     if ($this->view->schemaVersion != $this->view->changeSet->getSchema()) {
         $this->view->errorCount++;
     }
     if (!$this->view->filterParams) {
         $this->view->errorCount++;
     }
     if (version_compare($this->view->updateVersion, JVERSION) != 0) {
         $this->view->errorCount++;
     }
     $this->view->ftp = \JClientHelper::setCredentialsFromRequest('ftp');
     $showMessage = false;
     if (is_object($this->view->state)) {
         $message1 = $this->view->state->get('message');
         $message2 = $this->view->state->get('extension_message');
         $showMessage = $message1 || $message2;
     }
     $this->view->showMessage = $showMessage;
     $this->view->display();
 }
Example #17
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = TemplatesHelper::getActions();
     $isSite = $state->get('filter.client_id') == 0;
     Toolbar::title(Lang::txt('COM_TEMPLATES_MANAGER_STYLES'), 'thememanager');
     if ($canDo->get('core.edit.state')) {
         Toolbar::makeDefault('styles.setDefault', 'COM_TEMPLATES_TOOLBAR_SET_HOME');
         Toolbar::divider();
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('style.edit');
     }
     if ($canDo->get('core.create')) {
         Toolbar::custom('styles.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
         Toolbar::divider();
     }
     if ($canDo->get('core.delete')) {
         Toolbar::deleteList('', 'styles.delete');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_templates');
         Toolbar::divider();
     }
     Toolbar::help('styles');
 }
Example #18
0
 /**
  * Configure the Linkbar.
  *
  * @param	string	The name of the active view.
  */
 public static function addSubmenu($vName)
 {
     Submenu::addEntry(Lang::txt('COM_LANGUAGES_SUBMENU_INSTALLED_SITE'), Route::url('index.php?option=com_languages&view=installed&client=0'), $vName == 'installed');
     Submenu::addEntry(Lang::txt('COM_LANGUAGES_SUBMENU_INSTALLED_ADMINISTRATOR'), Route::url('index.php?option=com_languages&view=installed&client=1'), $vName == 'installed');
     Submenu::addEntry(Lang::txt('COM_LANGUAGES_SUBMENU_CONTENT'), Route::url('index.php?option=com_languages&view=languages'), $vName == 'languages');
     Submenu::addEntry(Lang::txt('COM_LANGUAGES_SUBMENU_OVERRIDES'), Route::url('index.php?option=com_languages&view=overrides'), $vName == 'overrides');
 }
Example #19
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ModulesHelper::getActions();
     Toolbar::title(Lang::txt('COM_MODULES_MANAGER_MODULES'), 'module.png');
     if ($canDo->get('core.create')) {
         //Toolbar::addNew('module.add');
         Toolbar::appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_modules&amp;view=select&amp;tmpl=component', 850, 400);
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('module.edit');
     }
     if ($canDo->get('core.create')) {
         Toolbar::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::checkin('modules.checkin');
     }
     if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::trash('modules.trash');
         Toolbar::divider();
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_modules');
         Toolbar::divider();
     }
     Toolbar::help('modules');
 }
Example #20
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     Request::setVar('hidemainmenu', 1);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     $canDo = UsersHelper::getActions();
     Toolbar::title(Lang::txt($isNew ? 'COM_USERS_VIEW_NEW_LEVEL_TITLE' : 'COM_USERS_VIEW_EDIT_LEVEL_TITLE'), 'levels-add');
     if ($canDo->get('core.edit') || $canDo->get('core.create')) {
         Toolbar::apply('level.apply');
         Toolbar::save('level.save');
     }
     if ($canDo->get('core.create')) {
         Toolbar::save2new('level.save2new');
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         Toolbar::save2copy('level.save2copy');
     }
     if (empty($this->item->id)) {
         Toolbar::cancel('level.cancel');
     } else {
         Toolbar::cancel('level.cancel', 'JTOOLBAR_CLOSE');
     }
     Toolbar::divider();
     Toolbar::help('level');
 }
Example #21
0
 /**
  * Parse the URL parameters and map each parameter (in order) to the given array of names
  *
  * @param		array varNames: Array of names to map the URL parameters to
  * @return		object: Object with properties named after var names mapped to URL parameters
  */
 protected function getParams($varNames)
 {
     $i = 0;
     // Strict processing doesn't allow extra or missing parameters in the URL
     $strictProcessing = false;
     $params = false;
     // check if there are more parameters than needed
     $extraParameter = Request::getVar('p' . count($varNames), '');
     if ($strictProcessing && !empty($extraParameter)) {
         // too many parameters in the URL
         //throw new \Exception('Too many parameters');
         App::abort(404, Lang::txt('Page Not Found'));
     }
     // Go through each var name and assign a sequential URL parameter's value to it
     foreach ($varNames as $varName) {
         $value = Request::getVar('p' . $i, '');
         if (!empty($value)) {
             $params->{$varName} = $value;
         } else {
             if ($strictProcessing) {
                 // missing parameter in the URL
                 //throw new \Exception('Too few parameters');
                 App::abort(404, Lang::txt('Page Not Found'));
             }
             break;
         }
         $i++;
     }
     return $params;
 }
Example #22
0
 /**
  * Prepares the document
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = \App::get('menu');
     $title = null;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     } else {
         $this->params->def('page_heading', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE'));
     }
     $title = $this->params->def('page_title', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE'));
     if (Config::get('sitename_pagetitles', 0) == 1) {
         $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title);
     } elseif (Config::get('sitename_pagetitles', 0) == 2) {
         $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename'));
     }
     $this->document->setTitle($title);
     Pathway::append($title, '');
     if ($this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
 }
Example #23
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = ContentHelper::getActions($this->state->get('filter.category_id'));
     Toolbar::title(Lang::txt('COM_CONTENT_FEATURED_TITLE'), 'featured.png');
     if ($canDo->get('core.create')) {
         Toolbar::addNew('article.add');
     }
     if ($canDo->get('core.edit')) {
         Toolbar::editList('article.edit');
     }
     if ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
         Toolbar::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         Toolbar::divider();
         Toolbar::archiveList('articles.archive');
         Toolbar::checkin('articles.checkin');
         Toolbar::custom('featured.delete', 'remove.png', 'remove_f2.png', 'JTOOLBAR_REMOVE', true);
     }
     if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         Toolbar::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
         Toolbar::divider();
     } elseif ($canDo->get('core.edit.state')) {
         Toolbar::divider();
         Toolbar::trash('articles.trash');
     }
     if ($canDo->get('core.admin')) {
         Toolbar::preferences('com_content');
         Toolbar::divider();
     }
     Toolbar::help('featured');
 }
Example #24
0
 /**
  * @param	int $itemid	The menu item id
  */
 static function association($itemid)
 {
     // Get the associations
     $associations = MenusHelper::getAssociations($itemid);
     // Get the associated menu items
     $db = App::get('db');
     $query = $db->getQuery(true);
     $query->select('m.*');
     $query->select('mt.title as menu_title');
     $query->from('#__menu as m');
     $query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype');
     $query->where('m.id IN (' . implode(',', array_values($associations)) . ')');
     $query->leftJoin('#__languages as l ON m.language=l.lang_code');
     $query->select('l.image');
     $query->select('l.title as language_title');
     $db->setQuery($query);
     $items = $db->loadObjectList('id');
     // Check for a database error.
     if ($error = $db->getErrorMsg()) {
         throw new Exception($error, 500);
         return false;
     }
     // Construct html
     $text = array();
     foreach ($associations as $tag => $associated) {
         if ($associated != $itemid) {
             $text[] = Lang::txt('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', Html::asset('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title);
         }
     }
     return JHtml::_('tooltip', implode('<br />', $text), Lang::txt('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png');
 }
Example #25
0
 /**
  * {@inheritdoc}
  */
 public function read($path)
 {
     if ($this->isFile($path)) {
         return file_get_contents($path);
     }
     throw new FileNotFoundException(\Lang::txt('File does not exist at path %s', $path));
 }
Example #26
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 (isset($segments[0])) {
         $vars['controller'] = $segments[0];
         // The next url segment should be the id
         // Task should already be set by the loader
         if (isset($segments[1])) {
             if (is_numeric($segments[1])) {
                 $vars['id'] = $segments[1];
                 // Read needs to be set explictly because read, list, and the api docblock all use GETs
                 if (\App::get('request')->method() == 'GET') {
                     $vars['task'] = 'read';
                 }
             } else {
                 throw new Exception(Lang::txt("COM_SUPPORT_TASK_NOT_FOUND"), 404);
             }
         } else {
             if (\App::get('request')->method() == 'GET') {
                 $vars['task'] = 'list';
             }
         }
     }
     return $vars;
 }
 /**
  * Output the autocompleter
  *
  * @param   string  $what   The component to call
  * @param   string  $name   Name of the input field
  * @param   string  $value  The value of the input field
  * @param   string  $id     ID of the input field
  * @param   string  $class  CSS class(es) for the input field
  * @param   string  $size   The size of the input field
  * @param   string  $wsel   AC autopopulates a select list based on choice?
  * @param   string  $type   Allow single or multiple entries
  * @param   string  $dsabl  Readonly input
  * @return  string
  * @throws  \InvalidArgumentException  If wrong type passed
  */
 public function __invoke($what = null, $name = null, $value = null, $id = null, $class = null, $size = null, $wsel = false, $type = 'multi', $dsabl = false)
 {
     if (!in_array($what, array('tags', 'members', 'groups'))) {
         throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter for "%s" not supported.', $what));
     }
     $id = $id ?: str_replace(array('[', ']'), '', $name);
     switch ($type) {
         case 'multi':
             $event = 'onGetMultiEntry';
             break;
         case 'single':
             $event = 'onGetSingleEntry';
             if ($wsel) {
                 $event = 'onGetSingleEntryWithSelect';
             }
             break;
         default:
             throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter type "%s" not supported.', $type));
             break;
     }
     $results = \Event::trigger('hubzero.' . $event, array(array($what, $name, $id, $class, $value, $size, $wsel, $type, $dsabl)));
     if (count($results) > 0) {
         $results = implode("\n", $results);
     } else {
         $results = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" />';
     }
     return $results;
 }
Example #28
0
 /**
  * Validate data
  *
  * @return  boolean  True if data is valid
  */
 public function check()
 {
     $this->uid = intval($this->uid);
     if (!$this->uid) {
         $this->setError(\Lang::txt('Entry must have a user ID.'));
     }
     $this->type = trim($this->type);
     if (!$this->type) {
         $this->setError(\Lang::txt('Entry must have a type (e.g., deposit, withdraw).'));
     }
     $this->category = trim($this->category);
     if (!$this->category) {
         $this->setError(\Lang::txt('Entry must have a category.'));
     }
     if ($this->getError()) {
         return false;
     }
     $this->referenceid = intval($this->referenceid);
     $this->amount = intval($this->amount);
     $this->balance = intval($this->balance);
     if (!$this->created) {
         $this->created = \Date::toSql();
     }
     return true;
 }
Example #29
0
 /**
  * Prepares the document.
  *
  * @since	1.6
  */
 protected function prepareDocument()
 {
     $menus = \App::get('menu');
     $title = null;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     } else {
         $this->params->def('page_heading', Lang::txt('COM_USERS_RESET'));
     }
     $title = $this->params->get('page_title', '');
     if (empty($title)) {
         $title = Config::get('sitename');
     } elseif (Config::get('sitename_pagetitles', 0) == 1) {
         $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title);
     } elseif (Config::get('sitename_pagetitles', 0) == 2) {
         $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename'));
     }
     $this->document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
 }
Example #30
0
 /**
  * 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;
 }