/** * Detect is this page are frontpage? * * @return boolean Is frontpage? */ public static function isHome() { $langPath = null; $tag = null; $lang = \JFactory::getLanguage(); // For multi language if (\JPluginHelper::isEnabled('system', 'languagefilter')) { $tag = $lang->getTag(); $langCodes = \JLanguageHelper::getLanguages('lang_code'); $langPath = $langCodes[$tag]->sef; } $uri = \JUri::getInstance(); $root = $uri::root(true); // Get site route $route = StringHelper::substr($uri->getPath(), StringHelper::strlen($root)); // Remove index.php $route = str_replace('index.php', '', $route); // If Multiple language enabled, we check first part of URI is language code or not. if ($langPath) { $params = ExtensionHelper::getParams('plg_system_languagefilter'); if ($tag == $lang->getDefault() && $params->get('remove_default_prefix', 0)) { $langPath = ''; } // If route equals lang path, means it is home route. if (trim($route, '/') == $langPath && !$uri->getVar('option')) { return true; } } else { if (!trim($route, '/') && !$uri->getVar('option')) { return true; } } return false; }
/** * Prepare data hook. * * @return void */ protected function prepareData() { $input = $this->container->get('input'); $data = $this->getData(); $data->params = $params = \Windwalker\System\ExtensionHelper::getParams('com_remoteimage'); $lang = $this->container->get('language'); $data->langCode = $lang->getTag(); $data->langCode = str_replace('-', '_', $data->langCode); $this->prepareScript(); if ('component' == $input->get('tmpl')) { $params->set('isModal', true); $data->modal = true; } else { $params->set('isModal', false); $data->modal = false; } $params->set('tabs', $data->modal); $params->set('height', $data->modal ? $input->get('height', 380) : 520); $params->set('fieldId', $input->get('fieldid')); $params->set('insertId', $input->get('insert_id')); $data->uploadMax = ini_get('upload_max_filesize'); $data->uploadNum = ini_get('max_file_uploads'); $this->setTitle(\JText::_('COM_REMOTEIMAGE_TITLE_MANAGER')); \JToolbarHelper::preferences('com_remoteimage'); }
/** * Prepare data hook. * * @return void */ protected function prepareData() { $data = $this->data; $data->formats = $this->get('Formats'); $data->format_form = $this->get('FormatForm'); $data->params = \Windwalker\System\ExtensionHelper::getParams('com_fbimporter'); }
/** * createInfoBox * * @param Container $container * @param \stdClass $article * @param mixed $params * * @return string */ public static function createInfoBox(Container $container, $article, $params = null) { // Include Component Core $param = ExtensionHelper::getParams('com_userxtd'); $doc = \JFactory::getDocument(); $app = $container->get('app'); LanguageHelper::loadLanguage('com_userxtd', 'admin'); // init params $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR'); $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE'); $include_css = $param->get('UserInfo_IncludeCSS_Article', 1); // Image params $width = $param->get('UserInfo_ImageWidth', 150); $height = $param->get('UserInfo_ImageHeight', 150); $crop = $param->get('UserInfo_ImageCrop', 1) ? \JImage::CROP_RESIZE : false; // Include CSS if ($include_css) { /** @var $asset \Windwalker\Helper\AssetHelper */ $asset = $container->get('helper.asset'); $asset->addCss('userxtd-userinfo.css', 'com_userxtd'); } $user = \UXFactory::getUser($article->created_by); // Images $image = $user->get($image_field); $thumb = new Thumb(null, 'com_userxtd'); $image = $thumb->resize($image, $width, $height, $crop); // Link $query = array('option' => 'com_users', 'view' => 'profile', 'id' => $user->get('id')); $link = \JRoute::_('index.php?' . http_build_query($query)); //Route::_('com_userxtd.user_id', array('id' => $user->get('id'))); // Website $website_link = $user->get($website_field); // Render return with(new FileLayout('userxtd.content.userinfo', null, array('component' => 'com_userxtd')))->render(array('params' => $param, 'article' => $article, 'link' => $link, 'website_link' => $website_link, 'image' => $image, 'user' => $user)); }
/** * Get component params. * * @return Registry */ public function getParams() { if ($this->params) { return $this->params; } $app = $this->getContainer()->get('app'); $comParams = ExtensionHelper::getParams($this->option); $menuParams = new Registry(); if ($menu = $app->getMenu()->getActive()) { $menuParams->loadString($menu->params); } $menuParams->merge($comParams); return $this->params = $menuParams; }
/** * Prepare data hook. * * @return void */ protected function prepareData() { parent::prepareData(); // Load content language $lang = JFactory::getLanguage(); $lang->load('com_content', JPATH_BASE, null, true, true); $lang->load('com_menus', JPATH_BASE, null, true, true); $data = $this->data; $data->params = \Windwalker\System\ExtensionHelper::getParams('com_quickcontent'); $data->formParams = $this->get('FormParams'); $data->listParams = $this->buildParamsInput('list'); $data->blogParams = $this->buildParamsInput('blog'); $data->articleParams = $this->buildParamsInput('article'); // Set Editor $editor = \JEditor::getInstance($data->params->get('editor', 'tinymce')); $params['mode'] = 2; $this->editor = $editor->display('jform[content]', $data->item->content, '650px', '500px', 650, 500, false, null, null, null, $params); }
/** * Utility method to act on a user after it has been saved. * * @param array $data Holds the new user data. * @param boolean $isNew True if a new user is stored. * @param boolean $result True if user was succesfully stored in the database. * @param string $error Message. * * @return void */ public function onUserAfterSave($data, $isNew, $result, $error = null) { $db = JFactory::getDbo(); // don't do anything when activate. $allowTask = array('register', 'save', 'apply', 'save2new', 'user.edit.save'); if (!in_array($this->input->get('task'), $allowTask)) { return; } // Init Framework // =============================================================== $this->initComponent(); $UXParams = \Windwalker\System\ExtensionHelper::getParams('com_userxtd'); // For Upload Event $this->user_data = $data; // Set Category $catid = $UXParams->get('CoreRegistration_Categories', array('*')); if (!is_array($catid)) { $catid = array($catid); } if (!in_array('*', $catid)) { $catid = implode(',', $catid); } else { $catid = null; } // Get Data and handle them $form = \Userxtd\Form\FormHelper::getFieldsByCategory($catid); $form->bind($data); $data['profile'] = $form->getDataForSave('profile'); $userId = JArrayHelper::getValue($data, 'id', 0, 'int'); // Start Building query // =============================================================== if ($userId && $result && isset($data['profile']) && count($data['profile'])) { try { //Sanitize the date // =============================================================== if (!empty($data['profile']['dob'])) { $date = new JDate($data['profile']['dob']); $data['profile']['dob'] = $date->format('Y-m-d'); } $query = $db->getQuery(true); $query->delete('#__userxtd_profiles')->where('user_id = ' . $userId); $db->setQuery($query)->execute(); $tuples = array(); $order = 1; $query = $db->getQuery(true); $query->columns(array($query->qn('user_id'), $query->qn('key'), $query->qn('value'), $query->qn('ordering'))); // Build query // =============================================================== foreach ($data['profile'] as $k => $v) { if (is_array($v) || is_object($v)) { $v = implode(',', (array) $v); } $query->values($userId . ', ' . $query->quote($k) . ', ' . $query->quote($v) . ', ' . $order++); } $query->insert('#__userxtd_profiles'); $db->setQuery($query)->execute(); } catch (RuntimeException $e) { $this->_subject->setError($e->getMessage()); return; } } return; }
/** * Reset cache position. * * @return void */ public function resetCachePosition() { if ($this->extension) { $params = ExtensionHelper::getParams($this->extension); } else { $params = new Registry(); } $this->config = new Registry(); $this->config['path.cache'] = Path::clean(JPATH_ROOT . $params->get('thumb.cache-path', '/cache/thumbs/cache')); $this->config['path.temp'] = Path::clean(JPATH_ROOT . $params->get('thumb.temp-path', '/cache/thumbs/temp')); $this->config['url.cache'] = $params->get('thumb.cache-url', '/cache/thumbs/cache'); $this->config['url.temp'] = $params->get('thumb.temp-url', '/cache/thumbs/cache'); }
/** * Method to auto-populate the model state. */ protected function populateState() { // Get the application object. $user_params = ExtensionHelper::getParams('com_users'); $userxtd_params = ExtensionHelper::getParams('com_userxtd'); $user_params->merge($userxtd_params); // Get the user id. $userId = JFactory::getApplication()->getUserState('com_userxtd.edit.profile.id'); $userId = !empty($userId) ? $userId : (int) JFactory::getUser()->get('id'); // Set the user id. $this->state->set('user.id', $userId); // Load the parameters. $this->state->set('params', $user_params); }