/** * Method to determine if script owns the path. * * @param string $path Path to check ownership. * * @return boolean True if the php script owns the path passed. */ public static function isOwner($path) { if (!self::$owner) { $dir = JFactory::getConfig()->get('tmp_path'); $tmp = 'jj'.md5(mt_rand()); $test = $dir . '/' . $tmp; // Create the test file $content = 'test'; $success = KunenaFile::write($test, $content, false); if (!$success) { return false; } self::$owner = fileowner($test); // Delete the test file KunenaFile::delete($test); } // Test ownership return (self::$owner == fileowner($path)); }
public function getTemplatePaths($path = '', $fullpath = false) { if ($path) { $path = KunenaPath::clean("/{$path}"); } $array = array(); $array[] = ($fullpath ? KPATH_ADMIN : KPATH_COMPONENT_RELATIVE) . '/template/joomla25' . $path; return $array; }
public function template() { $name = JRequest::getString('name', JRequest::getString('kunena_template', '', 'COOKIE')); if ($name) { $name = KunenaPath::clean($name); if (!is_readable(KPATH_SITE . "/template/{$name}/template.xml")) { $name = 'blue_eagle'; } setcookie('kunena_template', $name, 0, JUri::root(true) . '/'); } else { setcookie('kunena_template', null, time() - 3600, JUri::root(true) . '/'); } $this->setRedirect(KunenaRoute::_('index.php?option=com_kunena', false)); }
/** * Create new re-sized version of the original image. * * @param string $file Incoming file * @param string $folder Folder for the new image. * @param string $filename Filename for the new image. * @param int $maxWidth Maximum width for the image. * @param int $maxHeight Maximum height for the image. * @param int $quality Quality for the file (1-100). * @param int $scale See available KunenaImage constants. * @param int $crop Define if you want crop the image. * * @return bool True on success. */ public static function version($file, $folder, $filename, $maxWidth = 800, $maxHeight = 800, $quality = 70, $scale = KunenaImage::SCALE_INSIDE, $crop = 0) { try { // Create target directory if it does not exist. if (!KunenaFolder::exists($folder) && !KunenaFolder::create($folder)) { return false; } // Make sure that index.html exists in the folder. KunenaFolder::createIndex($folder); $info = KunenaImage::getImageFileProperties($file); if ($info->width > $maxWidth || $info->height > $maxHeight) { // Make sure that quality is in allowed range. if ($quality < 1 || $quality > 100) { $quality = 70; } // Calculate quality for PNG. if ($info->type == IMAGETYPE_PNG) { $quality = intval(($quality - 1) / 10); } $options = array('quality' => $quality); // Resize image and copy it to temporary file. $image = new KunenaImage($file); if ($crop && $info->width > $info->height) { $image = $image->resize($info->width * $maxHeight / $info->height, $maxHeight, false, $scale); $image = $image->crop($maxWidth, $maxHeight); } elseif ($crop && $info->width < $info->height) { $image = $image->resize($maxWidth, $info->height * $maxWidth / $info->width, false, $scale); $image = $image->crop($maxWidth, $maxHeight); } else { $image = $image->resize($maxWidth, $maxHeight, false, $scale); } $temp = KunenaPath::tmpdir() . '/kunena_' . md5(rand()); $image->toFile($temp, $info->type, $options); unset($image); // Move new file to its proper location. if (!KunenaFile::move($temp, "{$folder}/{$filename}")) { unlink($temp); return false; } } else { // Copy original file to the new location. if (!KunenaFile::copy($file, "{$folder}/{$filename}")) { return false; } } } catch (Exception $e) { return false; } return true; }
/** * Set attachment file. * * Copies the attachment into proper location and makes sure that all the unset fields get properly assigned. * * @param string $source Absolute path to the upcoming attachment. * @param string $basename Filename without extension. * @param string $extension File extension. * @param bool $unlink Whether to delete the original file or not. * @param bool $overwrite If not allowed, throw exception if the file exists. * * @return bool * @throws InvalidArgumentException * @throws RuntimeException * * @since K4.0 */ public function saveFile($source, $basename = null, $extension = null, $unlink = false, $overwrite = false) { if (!is_file($source)) { throw new InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . '(): Attachment file not found.'); } // Hash, size and MIME are set during saving, so let's deal with all other variables. $this->userid = is_null($this->userid) ? KunenaUserHelper::getMyself() : $this->userid; $this->folder = is_null($this->folder) ? "media/kunena/attachments/{$this->userid}" : $this->folder; $this->protected = is_null($this->protected) ? (bool) KunenaConfig::getInstance()->attachment_protection : $this->protected; if (!$this->filename_real) { $this->filename_real = $this->filename; } if (!$this->filename || $this->filename == $this->filename_real) { if (!$basename || !$extension) { throw new InvalidArgumentException(__CLASS__ . '::' . __METHOD__ . '(): Parameters $basename or $extension not provided.'); } // Find available filename. $this->filename = KunenaAttachmentHelper::getAvailableFilename($this->folder, $basename, $extension, $this->protected); } // Create target directory if it does not exist. if (!KunenaFolder::exists(JPATH_ROOT . "/{$this->folder}") && !KunenaFolder::create(JPATH_ROOT . "/{$this->folder}")) { throw new RuntimeException(JText::_('Failed to create attachment directory.')); } $destination = JPATH_ROOT . "/{$this->folder}/{$this->filename}"; // Move the file into the final location (if not already in there). if ($source != $destination) { // Create target directory if it does not exist. if (!$overwrite && is_file($destination)) { throw new RuntimeException(JText::sprintf('Attachment %s already exists.'), $this->filename_real); } if ($unlink) { @chmod($source, 0644); } $success = KunenaFile::copy($source, $destination); if (!$success) { throw new RuntimeException(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_NOT_MOVED', $destination)); } KunenaPath::setPermissions($destination); if ($unlink) { unlink($source); } } return $this->save(); }
/** * Upload file by passing it by HTML input * * @param array $fileInput The file object returned by JInput * @param string $destination The path of destination of file uploaded * @param string $type The type of file uploaded: attachment or avatar * * @return object */ public function upload($fileInput, $destination, $type = 'attachment') { $file = new stdClass(); $file->ext = JFile::getExt($fileInput['name']); $file->size = $fileInput['size']; $file->tmp_name = $fileInput['tmp_name']; $file->error = $fileInput['error']; $file->destination = $destination . '.' . $file->ext; $file->success = false; $file->isAvatar = false; if ($type != 'attachment') { $file->isAvatar = true; } if (!is_uploaded_file($file->tmp_name)) { $exception = $this->checkUpload($fileInput); if ($exception) { throw $exception; } } elseif ($file->error != 0) { throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_NOT_UPLOADED'), 500); } // Check if file extension matches any allowed extensions (case insensitive) foreach ($this->validExtensions as $ext) { $extension = JString::substr($file->tmp_name, -JString::strlen($ext)); if (JString::strtolower($extension) == JString::strtolower($ext)) { // File must contain one letter before extension $name = JString::substr($file->tmp_name, 0, -JString::strlen($ext)); $extension = JString::substr($extension, 1); if (!$name) { throw new RuntimeException(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_EXTENSION_FILE', implode(', ', $this->validExtensions)), 400); } } } if (!$this->checkFileSize($file->size, true)) { if ($file->isAvatar) { throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_AVATAR_EXCEED_LIMIT_IN_CONFIGURATION'), 500); } else { throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_FILE_EXCEED_LIMIT_IN_CONFIGURATION'), 500); } } if (!KunenaFile::copy($file->tmp_name, $file->destination)) { throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_FILE_RIGHT_MEDIA_DIR'), 500); } unlink($file->tmp_name); KunenaPath::setPermissions($file->destination); $file->success = true; return $file; }
function uploadFile($uploadPath, $input = 'kattachment', $filename = '', $ajax = true) { $this->resetStatus(); // create upload directory if it does not exist if (!JFolder::exists($uploadPath)) { if (!JFolder::create($uploadPath)) { $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_CREATE_DIR')); return false; } } KunenaFolder::createIndex($uploadPath); // Get file name and validate with path type $this->fileName = JRequest::getString($input . '_name', '', 'post'); $this->fileSize = 0; $chunk = JRequest::getInt('chunk', 0); $chunks = JRequest::getInt('chunks', 0); if ($chunks && $chunk >= $chunks) { $this->error = JText::_('COM_KUNENA_UPLOAD_ERROR_EXTRA_CHUNK'); } //If uploaded by using normal form (no AJAX) if ($ajax == false || isset($_REQUEST["multipart"])) { $file = JRequest::getVar($input, null, 'files', 'array'); // File upload if (!empty($file['error'])) { // Any errors the server registered on uploading switch ($file['error']) { case 0: // UPLOAD_ERR_OK : break; case 1: // UPLOAD_ERR_INI_SIZE : // UPLOAD_ERR_INI_SIZE : case 2: // UPLOAD_ERR_FORM_SIZE : $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_SIZE') . 'DEBUG: file[error]' . htmlspecialchars($file['error'], ENT_COMPAT, 'UTF-8')); break; case 3: // UPLOAD_ERR_PARTIAL : $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_PARTIAL')); break; case 4: // UPLOAD_ERR_NO_FILE : $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_NO_FILE')); break; case 5: // UPLOAD_ERR_NO_TMP_DIR : $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_NO_TMP_DIR')); break; case 7: // UPLOAD_ERR_CANT_WRITE, PHP 5.1.0 $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_CANT_WRITE')); break; case 8: // UPLOAD_ERR_EXTENSION, PHP 5.2.0 $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_PHP_EXTENSION')); break; default: $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_UNKNOWN')); } return false; } elseif (!is_uploaded_file($file['tmp_name'])) { $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_NOT_UPLOADED')); return false; } $this->fileTemp = $file['tmp_name']; $this->fileSize = $file['size']; if (!$this->fileName) { // Need to add additonal path type check as array getVar does not $this->fileName = $file['name']; } } else { // Currently not in use: this is meant for experimental AJAX uploads // Open temp file $this->fileTemp = KunenaPath::tmpdir() . '/kunena_' . md5($this->_my->id . '/' . $this->_my->username . '/' . $this->fileName); $out = fopen($this->fileTemp, $chunk == 0 ? "wb" : "ab"); if ($out) { // Read binary input stream and append it to temp file $in = fopen("php://input", "rb"); if ($in) { while (($buff = fread($in, 8192)) != false) { fwrite($out, $buff); } } else { $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_NO_INPUT')); } clearstatcache(); $fileInfo = fstat($out); $this->fileSize = $fileInfo['size']; fclose($out); if (!$this->error) { $this->checkFileSize($this->fileSize); } if ($chunk + 1 < $chunks) { $this->status = empty($this->error); return $this->status; } } else { $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_CANT_WRITE')); } } // Terminate early if we already hit an error if ($this->error) { return false; } // assume the extension is false until we know its ok $extOk = false; $fileparts = $this->getValidExtension($this->validFileExts); $uploadedFileExtension = ''; if ($fileparts) { $this->_isfile = true; $extOk = true; $uploadedFileBasename = $fileparts[0]; $uploadedFileExtension = $fileparts[1]; } $fileparts = $this->getValidExtension($this->validImageExts); if ($fileparts) { $this->_isimage = true; $extOk = true; $uploadedFileBasename = $fileparts[0]; $uploadedFileExtension = $fileparts[1]; } if ($extOk == false) { $imglist = implode(', ', $this->validImageExts); $filelist = implode(', ', $this->validFileExts); if ($imglist && $filelist) { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_EXTENSION', $imglist, $filelist)); } else { if ($imglist && !$filelist) { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_EXTENSION_FILE', $this->_config->filetypes)); } else { if (!$imglist && $filelist) { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_EXTENSION_IMAGE', $this->_config->imagetypes)); } else { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_NOT_ALLOWED', $filelist)); } } } $this->not_valid_img_ext = false; return false; } // Special processing for images if ($this->_isimage) { $this->imageInfo = CKunenaImageHelper::getProperties($this->fileTemp); // Let see if we need to check the MIME type if ($this->_config->checkmimetypes) { // check against whitelist of MIME types $validFileTypes = explode(",", $this->_config->imagemimetypes); //if the temp file does not have a width or a height, or it has a non ok MIME, return if (!is_int($this->imageInfo->width) || !is_int($this->imageInfo->height) || !in_array($this->imageInfo->mime, $validFileTypes)) { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_MIME', $this->imageInfo->mime, $this->_config->imagetypes)); return false; } } // If image is not inside allowed size limits, resize it if ($this->fileSize > $this->imagesize || $this->imageInfo->width > $this->imagewidth || $this->imageInfo->height > $this->imageheight) { $options = array('quality' => $this->imagequality); $imageRaw = new CKunenaImage($this->fileTemp); if ($imageRaw->getError()) { $this->fail(JText::_($imageRaw->getError())); return false; } $image = $imageRaw->resize($this->imagewidth, $this->imageheight); $type = $imageRaw->getType(); unset($imageRaw); $image->toFile($this->fileTemp, $type, $options); clearstatcache(); // Re-calculate physical file size: image has been shrunk $stat = stat($this->fileTemp); if (!$stat) { $this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_STAT', htmlspecialchars($this->fileTemp, ENT_COMPAT, 'UTF-8'))); return false; } $this->fileSize = $stat['size']; } } $this->checkFileSize($this->fileSize); // Check again for error and terminate early if we already hit an error if ($this->error) { return false; } // Populate hash, file size and other info // Get a hash value from the file $this->fileHash = md5_file($this->fileTemp); // Override filename if given in the parameter if ($filename) { $uploadedFileBasename = $filename; } $uploadedFileBasename = KunenaFile::makeSafe($uploadedFileBasename); if (empty($uploadedFileBasename)) { $uploadedFileBasename = 'h' . substr($this->fileHash, 2, 7); } // Rename file if there is already one with the same name $newFileName = $uploadedFileBasename . "." . $uploadedFileExtension; $newFileName = preg_replace('/[[:space:]]/', '', $newFileName); $uploadedFileBasename = preg_replace('/[[:space:]]/', '', $uploadedFileBasename); if (file_exists($uploadPath . '/' . $newFileName)) { $newFileName = $uploadedFileBasename . "." . $uploadedFileExtension; for ($i = 2; file_exists("{$uploadPath}/{$newFileName}"); $i++) { $newFileName = $uploadedFileBasename . "-{$i}." . $uploadedFileExtension; } } $this->fileName = $newFileName; // All the processing is complete - now we need to move the file(s) into the final location @chmod($this->fileTemp, 0644); if (!JFile::copy($this->fileTemp, $uploadPath . '/' . $this->fileName)) { $this->fail(JText::sprintf('COM_KUNENA_UPLOAD_ERROR_NOT_MOVED', htmlspecialchars($uploadPath . '/' . $this->fileName, ENT_COMPAT, 'UTF-8'))); unlink($this->fileTemp); return false; } unlink($this->fileTemp); JPath::setPermissions($uploadPath . '/' . $this->fileName); $this->ready = true; return $this->status = true; }
public static function version($file, $newpath, $newfile, $maxwidth = 800, $maxheight = 800, $quality = 70, $scale = CKunenaImage::SCALE_INSIDE) { require_once KPATH_SITE . '/lib/kunena.file.class.php'; // create upload directory if it does not exist $imageinfo = self::getProperties($file); if (!$imageinfo) { return false; } if (!JFolder::exists($newpath)) { if (!JFolder::create($newpath)) { return false; } } KunenaFolder::createIndex($newpath); if ($imageinfo->width > $maxwidth || $imageinfo->height > $maxheight) { $image = new CKunenaImage($file); if ($image->getError()) { return false; } if ($quality < 1 || $quality > 100) { $quality = 70; } $options = array('quality' => $quality); $image = $image->resize($maxwidth, $maxheight, true, $scale); $type = $image->getType(); $temp = KunenaPath::tmpdir() . '/kunena_' . md5(rand()); $image->toFile($temp, $type, $options); unset($image); if (!KunenaFile::move($temp, $newpath . '/' . $newfile)) { unlink($temp); return false; } } else { if (!KunenaFile::copy($file, $newpath . '/' . $newfile)) { return false; } } return true; }
/** * Returns the global KunenaTemplate object, only creating it if it doesn't already exist. * * @access public * @param int $name Template name or null for default/selected template in your configuration * @return KunenaTemplate The template object. * @since 1.6 */ public static function getInstance($name = null) { $app = JFactory::getApplication(); if (!$name) { $name = JRequest::getString('kunena_template', KunenaFactory::getConfig()->template, 'COOKIE'); } $name = KunenaPath::clean($name); if (empty(self::$_instances[$name])) { // Find overridden template class (use $templatename to avoid creating new objects if the template doesn't exist) $templatename = $name; $classname = "KunenaTemplate{$templatename}"; if (!is_file(KPATH_SITE . "/template/{$templatename}/template.xml") && !is_file(KPATH_SITE . "/template/{$templatename}/config.xml")) { // If template xml doesn't exist, raise warning and use blue eagle instead $file = JPATH_THEMES . "/{$app->getTemplate()}/html/com_kunena/template.php"; $templatename = 'blue_eagle'; $classname = "KunenaTemplate{$templatename}"; if (is_dir(KPATH_SITE . "/template/{$templatename}")) { KunenaError::warning(JText::sprintf('COM_KUNENA_LIB_TEMPLATE_NOTICE_INCOMPATIBLE', $name, $templatename)); } } if (!class_exists($classname) && $app->isSite()) { $file = KPATH_SITE . "/template/{$templatename}/template.php"; if (!is_file($file)) { $classname = "KunenaTemplateBlue_Eagle"; $file = KPATH_SITE . "/template/blue_eagle/template.php"; } if (is_file($file)) { require_once $file; } } if (class_exists($classname)) { self::$_instances[$name] = new $classname($templatename); } else { self::$_instances[$name] = new KunenaTemplate($templatename); } } return self::$_instances[$name]; }
/** * Load a template file -- first look in the templates folder for an override * * @param string $tpl The name of the template source file ... * automatically searches the template paths and compiles as needed. * @param array $hmvcParams Extra parameters for HMVC. * @return string The output of the the template script. */ public function loadTemplateFile($tpl = null, $hmvcParams = null) { KUNENA_PROFILER ? $this->profiler->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; // HMVC legacy support. $view = $this->getName(); $layout = $this->getLayout(); list($name, $override) = $this->ktemplate->mapLegacyView("{$view}/{$layout}_{$tpl}"); $hmvc = KunenaLayout::factory($name)->setLayout($override); if ($hmvc->getPath()) { if ($hmvcParams) { $hmvc->setProperties($hmvcParams); } KUNENA_PROFILER ? $this->profiler->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; return $hmvc->setLegacy($this); } // Create the template file name based on the layout $file = isset($tpl) ? $layout . '_' . $tpl : $layout; if (!isset($this->templatefiles[$file])) { // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; // Load the template script $filetofind = $this->_createFileName('template', array('name' => $file)); $this->templatefiles[$file] = KunenaPath::find($this->_path['template'], $filetofind); } $this->_template = $this->templatefiles[$file]; if ($this->_template != false) { $templatefile = preg_replace('%' . KunenaPath::clean(JPATH_ROOT, '/') . '/%', '', KunenaPath::clean($this->_template, '/')); // Unset so as not to introduce into template scope unset($tpl); unset($file); // Never allow a 'this' property if (isset($this->this)) { unset($this->this); } // Start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope // (this will execute the view logic). include $this->_template; // Done with the requested template; get the buffer and // clear it. $output = ob_get_contents(); ob_end_clean(); if (JDEBUG || $this->config->get('debug')) { $output = trim($output); $output = "\n<!-- START {$templatefile} -->\n{$output}\n<!-- END {$templatefile} -->\n"; } } else { $output = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $this->getName() . '/' . $file)); } KUNENA_PROFILER ? $this->profiler->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null; return $output; }
/** * Method to get the layout path. If layout file isn't found, fall back to default layout. * * @param string $layout The layout name, defaulting to the current one. * * @return mixed The layout file name if found, false otherwise. */ public function getPath($layout = null) { if (!$layout) { $layout = $this->getLayout(); } $paths = array(); foreach ($this->includePaths as $path) { $paths[] = $path; } // Find the layout file path. $path = KunenaPath::find($paths, "{$layout}.php"); if (!$path) { $path = KunenaPath::find($paths, 'default.php'); } return $path; }
/** * @param JForm $form A form object. * @param mixed $data The data expected for the form. * @param string $group Form group. * * @return mixed True if successful. * @throws Exception if there is an error in the form event. * @since 1.6 */ protected function preprocessForm(JForm $form, $data, $group = 'content') { $folder = $this->getState('item.folder'); $element = $this->getState('item.element'); $lang = JFactory::getLanguage(); // Load the core and/or local language sys file(s) for the ordering field. $db = JFactory::getDbo(); $query = 'SELECT element' . ' FROM #__extensions' . ' WHERE (type =' . $db->Quote('plugin') . 'AND folder=' . $db->Quote($folder) . ')'; $db->setQuery($query); $elements = $db->loadColumn(); foreach ($elements as $elementa) { $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_PLUGINS . '/' . $folder . '/' . $elementa, null, false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_' . $folder . '_' . $elementa . '.sys', JPATH_PLUGINS . '/' . $folder . '/' . $elementa, $lang->getDefault(), false, false); } if (empty($folder) || empty($element)) { $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_kunena&view=plugins', false)); } $formFile = KunenaPath::clean(JPATH_PLUGINS . '/' . $folder . '/' . $element . '/' . $element . '.xml'); if (!is_file($formFile)) { throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element . '.xml')); } // Load the core and/or local language file(s). $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_PLUGINS . '/' . $folder . '/' . $element, null, false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_' . $folder . '_' . $element, JPATH_PLUGINS . '/' . $folder . '/' . $element, $lang->getDefault(), false, false); if (is_file($formFile)) { // Get the plugin form. if (!$form->loadFile($formFile, false, '//config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } } // Attempt to load the xml file. if (!($xml = simplexml_load_file($formFile))) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/extension/help'); if (!empty($help)) { $helpKey = trim((string) $help[0]['key']); $helpURL = trim((string) $help[0]['url']); $this->helpKey = $helpKey ? $helpKey : $this->helpKey; $this->helpURL = $helpURL ? $helpURL : $this->helpURL; } // Trigger the default form events. parent::preprocessForm($form, $data, $group); }
/** * */ function chooseless() { $template = $this->app->input->getArray(array('cid' => '')); $templatename = array_shift($template['cid']); $this->app->setUserState('kunena.templatename', $templatename); $tBaseDir = KunenaPath::clean(KPATH_SITE . '/template'); if (!is_dir($tBaseDir . '/' . $templatename . '/less')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_NO_LESS'), 'warning'); return; } $this->setRedirect(KunenaRoute::_($this->baseurl . "&layout=chooseless", false)); }