Ejemplo n.º 1
0
 /**
  *  Save an existing or a new mood form POST
  */
 public function apply()
 {
     CommunityLicenseHelper::_();
     JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $scss = $jinput->post->get('scss', null, 'array');
     $settings = $jinput->post->get('settings', null, 'array');
     if (JString::strtoupper($jinput->getMethod()) != 'POST') {
         $mainframe->redirect('index.php?option=com_community&view=moods', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error');
     }
     if (!is_null($scss)) {
         CommunityThemeHelper::parseScss($scss, 'general');
     }
     // Handle image uploads
     $images['frontpage-image'] = $jinput->files->get('frontpage-image-new', '', 'NONE');
     foreach ($images as $key => $image) {
         if (!empty($image['tmp_name']) && isset($image['name']) && !empty($image['name'])) {
             $imagePath = COMMUNITY_PATH_ASSETS;
             // same as the image path
             //check the file extension first and only allow jpg or png
             $ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION));
             if (!in_array($ext, array('jpg', 'png')) || $image['type'] != 'image/png' && $image['type'] != 'image/jpeg') {
             }
             $imageJpg = $imagePath . '/' . $key . '.jpg';
             $imagePng = $imagePath . '/' . $key . '.png';
             //check if existing image exist, if yes, delete it
             if (file_exists($imageJpg)) {
                 unlink($imageJpg);
             }
             if (file_exists($imagePng)) {
                 unlink($imagePng);
             }
             //let move the tmp image to the actual path
             $finalPath = $imagePath . $key . '.' . $ext;
             move_uploaded_file($image['tmp_name'], $finalPath);
             require JPATH_ROOT . "/components/com_community/helpers/image.php";
             CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 1000, 1000);
             $settings[$key] = $ext;
         }
     }
     // Parse settings finish
     CommunityThemeHelper::parseSettings($settings, 'general');
     $message = JText::_('COM_COMMUNITY_THEME_GENERAL_UPDATED');
     $mainframe->redirect('index.php?option=com_community&view=themegeneral', $message, 'message');
     // Get the view type
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     // Get the view
     $viewName = JRequest::getCmd('view', 'community');
     $view = $this->getView($viewName, $viewType);
     $view->setLayout('edit');
     $model = $this->getModel($viewName, 'CommunityAdminModel');
     if ($model) {
         $view->setModel($model, $viewName);
     }
     $view->display();
 }
Ejemplo n.º 2
0
 /**
  *  Save an existing or a new mood form POST
  */
 public function apply()
 {
     CommunityLicenseHelper::_();
     JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN'));
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $scss = $jinput->post->get('scss', null, 'array');
     if (JString::strtoupper($jinput->getMethod()) != 'POST') {
         $mainframe->redirect('index.php?option=com_community&view=moods', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error');
     }
     if (!is_null($scss)) {
         CommunityThemeHelper::parseScss($scss, 'colors');
     }
     $message = JText::_('COM_COMMUNITY_THEME_COLORS_UPDATED');
     $mainframe->redirect('index.php?option=com_community&view=themecolors', $message, 'message');
 }
Ejemplo n.º 3
0
 /**
  * update SCSS if applicable
  */
 private function _updateSCSS()
 {
     // Regenerate scss if this is an upgrade
     require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
     JTable::addIncludePath(JPATH_COMPONENT . '/tables');
     $themeTable = JTable::getInstance('Theme', 'CommunityTable');
     $themeTable->load('scss');
     if (!is_null($themeTable->value)) {
         require_once JPATH_COMPONENT . '/helpers/theme.php';
         // Set the tables path
         $scssSettings = json_decode($themeTable->value, true);
         $colorSettings = $scssSettings['colors'];
         $generalSettings = $scssSettings['general'];
         if (!is_null($colorSettings)) {
             CommunityThemeHelper::parseScss($colorSettings, 'colors');
         }
         if (!is_null($generalSettings)) {
             CommunityThemeHelper::parseScss($generalSettings, 'general');
         }
     }
 }