public function display($tpl = null) { // Set the titlebar text JToolBarHelper::title(JText::_('COM_COMMUNITY_CONFIGURATION_THEME_COLORS'), 'colors'); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::custom('reset', '', '', JText::_('COM_COMMUNITY_THEME_COLORS_RESET'), false); // Get Moods by type (preset & custom) $scssTable = JTable::getInstance('Theme', 'CommunityTable'); $this->assign('scss', $scssTable->getByKey('scss')); $this->assign('scss_default', CommunityThemeHelper::getDefault('scss')); parent::display($tpl); }
/** * 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'); }
/** * 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'); } } }
/** * Save the profile information */ public function apply() { CommunityLicenseHelper::_(); JRequest::checkToken() or jexit(JText::_('COM_COMMUNITY_INVALID_TOKEN')); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (JString::strtoupper($jinput->getMethod()) != 'POST') { $mainframe->redirect('index.php?option=com_community&view=themeprofile', JText::_('COM_COMMUNITY_PERMISSION_DENIED'), 'error'); } $settings = $jinput->post->get('settings', array(), 'array'); $configs = $jinput->post->get('config', null, 'array'); // save the config first $model = $this->getModel('Configuration'); if (!empty($configs)) { $model->save($configs); } // First, parse the Cover Info fields and unset the extra keys $helper = new CommunityThemeHelper(); $settings['tagline'] = $helper->prepareCoverInfo($settings); // Handle image uploads #echo "<pre>";var_dump($post);die(); $images['default-cover'] = $jinput->files->get('default-cover-new', '', 'NONE'); $images['default-cover-male'] = $jinput->files->get('default-cover-male-new', '', 'NONE'); $images['default-cover-female'] = $jinput->files->get('default-cover-female-new', '', 'NONE'); $images['default-male-avatar'] = $jinput->files->get('default-male-avatar-new', '', 'NONE'); $images['default-female-avatar'] = $jinput->files->get('default-female-avatar-new', '', 'NONE'); $images['default-general-avatar'] = $jinput->files->get('default-general-avatar-new', '', 'NONE'); foreach ($images as $key => $image) { if (!empty($image['tmp_name']) && isset($image['name']) && !empty($image['name'])) { try { CImageHelper::autorotate($image['tmp_name']); } catch (Exception $e) { } $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', 'jpeg', 'png')) || $image['type'] != 'image/png' && $image['type'] != 'image/jpeg') { $mainframe->redirect('index.php?option=com_community&view=themeprofile', JText::_('COM_COMMUNITY_THEME_IMAGE_ERROR'), 'error'); } $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; $finalPathThumb = $imagePath . $key . '-thumb.' . $ext; move_uploaded_file($image['tmp_name'], $finalPath); require_once JPATH_ROOT . "/components/com_community/helpers/image.php"; if (strstr($key, 'avatar')) { //avatars // Check 1:1 $size = CImageHelper::getSize($finalPath); if ($size->height != $size->width) { $message = JTEXT::_('COM_COMMUNITY_THEME_AVATAR_RESIZED'); } CImageHelper::resize($finalPath, $finalPath, "image/{$ext}", 160, 160); // thumb CImageHelper::resize($finalPath, $finalPathThumb, "image/{$ext}", 64, 64); } else { // other images CImageHelper::resizeProportional($finalPath, $finalPath, "image/{$ext}", 1000, 1000); } $settings[$key] = $ext; } } // Parse the rest of the settings afterwards $helper->parseSettings($settings, 'profile'); // There isn't much that can go wrong, no validation required if (!$message) { $message = JText::_('COM_COMMUNITY_THEME_PROFILE_UPDATED'); } $mainframe->redirect('index.php?option=com_community&view=themeprofile', $message, 'message'); }
/** * 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(); }