コード例 #1
0
ファイル: template.php プロジェクト: anawu2006/PeerLearning
 public function compileLess($inputFile, $outputFile)
 {
     if (!class_exists('lessc')) {
         require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php';
     }
     // Load the cache.
     $cacheDir = JPATH_CACHE . '/kunena';
     if (!is_dir($cacheDir)) {
         KunenaFolder::create($cacheDir);
     }
     $cacheFile = "{$cacheDir}/kunena.bootstrap.{$inputFile}.cache";
     if (is_file($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = KPATH_MEDIA . '/less/bootstrap/' . $inputFile;
     }
     $outputFile = KPATH_MEDIA . '/css/joomla25/' . $outputFile;
     $less = new lessc();
     //$less->setVariables($this->style_variables);
     $newCache = $less->cachedCompile($cache);
     if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) {
         $cache = serialize($newCache);
         KunenaFile::write($cacheFile, $cache);
         KunenaFile::write($outputFile, $newCache['compiled']);
     }
 }
コード例 #2
0
ファイル: folder.php プロジェクト: kosmosby/medicine-prof
	/**
	 * Create index.html file into the given folder, if it doesn't exist.
	 *
	 * @param $folder
	 */
	static function createIndex($folder) {
		// Make sure we have an index.html file in the current folder
		if (!KunenaFile::exists($folder.'/index.html')) {
			$contents = '<html><body></body></html>';
			KunenaFile::write($folder.'/index.html', $contents);
		}
	}
コード例 #3
0
ファイル: path.php プロジェクト: BillVGN/PortalPRP
	/**
	 * 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));
	}
コード例 #4
0
ファイル: template.php プロジェクト: r-ahmadi/Kunena-Forum
 function compileLess($inputFile, $outputFile)
 {
     if (!class_exists('lessc')) {
         require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php';
     }
     // Load the cache.
     $cacheDir = JPATH_CACHE . '/kunena';
     if (!is_dir($cacheDir)) {
         KunenaFolder::create($cacheDir);
     }
     $cacheFile = "{$cacheDir}/kunena.{$this->name}.{$inputFile}.cache";
     if (is_file($cacheFile)) {
         $cache = unserialize(file_get_contents($cacheFile));
     } else {
         $cache = JPATH_SITE . '/' . $this->getFile($inputFile, false, 'less');
     }
     $outputDir = KPATH_MEDIA . "/cache/{$this->name}/css";
     if (!is_dir($outputDir)) {
         KunenaFolder::create($outputDir);
     }
     $outputFile = "{$outputDir}/{$outputFile}";
     $less = new lessc();
     $class = $this;
     $less->registerFunction('url', function ($arg) use($class) {
         list($type, $q, $values) = $arg;
         $value = reset($values);
         return "url({$q}{$class->getFile($value, true, 'media', 'media/kunena')}{$q})";
     });
     $less->setVariables($this->style_variables);
     $newCache = $less->cachedCompile($cache);
     if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) {
         $cache = serialize($newCache);
         KunenaFile::write($cacheFile, $cache);
         KunenaFile::write($outputFile, $newCache['compiled']);
     }
 }
コード例 #5
0
ファイル: templates.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Method to save param.ini file on filesystem.
  *
  * @param   string $template The name of the template.
  *
  *
  * @since    3.0.0
  */
 protected function _saveParamFile($template)
 {
     $params = $this->app->input->get('jform', array(), 'post', 'array');
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = KPATH_SITE . '/template/' . $template . '/params.ini';
     if (count($params)) {
         $registry = new JRegistry();
         $registry->loadArray($params);
         $txt = $registry->toString('INI');
         $return = KunenaFile::write($file, $txt);
         if (!$return) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_OPERATION_FAILED') . ': ' . JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_FAILED_WRITE_FILE', $file));
             $this->app->redirect(KunenaRoute::_($this->baseurl, false));
         }
     }
 }