コード例 #1
0
 /**
  * Saves the css
  *
  */
 function savecss()
 {
     $mainframe =& JFactory::getApplication();
     JRequest::checkToken() or die('Invalid Token');
     // Initialize some variables
     $option = JRequest::getVar('option');
     $filename = JRequest::getVar('filename', '', 'post', 'cmd');
     $filecontent = JRequest::getVar('filecontent', '', '', '', JREQUEST_ALLOWRAW);
     if (!$filecontent) {
         $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_OPERATION_FAILED') . ': ' . JText::_('COM_REDEVENT_CONTENT_EMPTY'));
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = JPATH_SITE . DS . 'components' . DS . 'com_redevent' . DS . 'assets' . DS . 'css' . DS . $filename;
     // Try to make the css file writeable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', 'COULD NOT MAKE CSS FILE WRITABLE');
     }
     jimport('joomla.filesystem.file');
     $return = JFile::write($file, $filecontent);
     // Try to make the css file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', 'COULD NOT MAKE CSS FILE UNWRITABLE');
     }
     if ($return) {
         $task = JRequest::getVar('task');
         switch ($task) {
             case 'applycss':
                 $mainframe->redirect('index.php?option=' . $option . '&view=editcss', JText::_('COM_REDEVENT_CSS_FILE_SUCCESSFULLY_ALTERED'));
                 break;
             case 'savecss':
             default:
                 $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_CSS_FILE_SUCCESSFULLY_ALTERED'));
                 break;
         }
     } else {
         $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_OPERATION_FAILED') . ': ' . JText::sprintf('COM_REDEVENT_FAILED_ TO_OPEN_FILE_FOR_WRITING_S', $file));
     }
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: jaanusnurmoja/redjoomla
 /**
  * Image selection List
  *
  * @since 0.9
  */
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $document =& JFactory::getDocument();
     if ($this->getLayout() == 'uploadimage') {
         $this->_displayuploadimage($tpl);
         return;
     }
     //get vars
     $task = JRequest::getVar('task');
     $search = $mainframe->getUserStateFromRequest($option . '.search', 'search', '', 'string');
     $search = trim(JString::strtolower($search));
     //set variables
     switch ($task) {
         case 'selecteventimg':
             $folder = 'events';
             $task = 'eventimg';
             $redi = 'selecteventimg';
             break;
         case 'selectvenueimg':
             $folder = 'venues';
             $task = 'venueimg';
             $redi = 'selectvenueimg';
             break;
         case 'selectcategoryimg':
             $folder = 'categories';
             $task = 'categoryimg';
             $redi = 'selectcategoryimg';
             break;
     }
     JRequest::setVar('folder', $folder);
     // Do not allow cache
     JResponse::allowCache(false);
     //add css
     $document->addStyleSheet('components/com_redevent/assets/css/redeventbackend.css');
     //get images
     $images = $this->get('images');
     $pageNav =& $this->get('Pagination');
     if (count($images) > 0 || $search) {
         $this->assignRef('images', $images);
         $this->assignRef('folder', $folder);
         $this->assignRef('task', $redi);
         $this->assignRef('search', $search);
         $this->assignRef('state', $this->get('state'));
         $this->assignRef('pageNav', $pageNav);
         parent::display($tpl);
     } else {
         //no images in the folder, redirect to uploadscreen and raise notice
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', JText::_('COM_REDEVENT_NO_IMAGES_AVAILABLE'));
         $this->setLayout('uploadimage');
         JRequest::setVar('task', $task);
         $this->_displayuploadimage($tpl);
         return;
     }
 }