/**
  * @see	\wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
  */
 public function uninstall()
 {
     // fetch ACP templates from log
     $sql = "SELECT\ttemplateName, application\n\t\t\tFROM\twcf" . WCF_N . "_acp_template\n\t\t\tWHERE\tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->installation->getPackageID()));
     $templates = array();
     while ($row = $statement->fetchArray()) {
         if (!isset($templates[$row['application']])) {
             $templates[$row['application']] = array();
         }
         $templates[$row['application']][] = 'acp/templates/' . $row['templateName'] . '.tpl';
     }
     foreach ($templates as $application => $templateNames) {
         $this->installation->deleteFiles(Application::getDirectory($application), $templateNames, false, $this->installation->getPackage()->isApplication);
         // delete log entries
         parent::uninstall();
     }
 }
 /**
  * @see	\wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
  */
 public function uninstall()
 {
     // fetch files from log
     $sql = "SELECT\tfilename, application\n\t\t\tFROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\tWHERE\tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->installation->getPackageID()));
     $files = array();
     while ($row = $statement->fetchArray()) {
         if (!isset($files[$row['application']])) {
             $files[$row['application']] = array();
         }
         $files[$row['application']][] = $row['filename'];
     }
     foreach ($files as $application => $filenames) {
         $this->installation->deleteFiles(Application::getDirectory($application), $filenames);
         // delete log entries
         parent::uninstall();
     }
 }
Exemplo n.º 3
0
 /**
  * Compiles LESS stylesheets.
  * 
  * @param	\wcf\data\style\Style	$style
  */
 public function compile(Style $style)
 {
     // read stylesheets by dependency order
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("filename REGEXP ?", array('style/([a-zA-Z0-9\\_\\-\\.]+)\\.less'));
     $sql = "SELECT\t\tfilename, application\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tpackageID";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $files = array();
     while ($row = $statement->fetchArray()) {
         $files[] = Application::getDirectory($row['application']) . $row['filename'];
     }
     // get style variables
     $variables = $style->getVariables();
     $individualLess = '';
     if (isset($variables['individualLess'])) {
         $individualLess = $variables['individualLess'];
         unset($variables['individualLess']);
     }
     // add style image path
     $imagePath = '../images/';
     if ($style->imagePath) {
         $imagePath = FileUtil::getRelativePath(WCF_DIR . 'style/', WCF_DIR . $style->imagePath);
         $imagePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($imagePath));
     }
     $variables['style_image_path'] = "'{$imagePath}'";
     // apply overrides
     if (isset($variables['overrideLess'])) {
         $lines = explode("\n", StringUtil::unifyNewlines($variables['overrideLess']));
         foreach ($lines as $line) {
             if (preg_match('~^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\\.\\(\\)\\%\\#-]+);$~', $line, $matches)) {
                 $variables[$matches[1]] = $matches[2];
             }
         }
         unset($variables['overrideLess']);
     }
     $this->compileStylesheet(WCF_DIR . 'style/style-' . $style->styleID, $files, $variables, $individualLess, new Callback(function ($content) use($style) {
         return "/* stylesheet for '" . $style->styleName . "', generated on " . gmdate('r') . " -- DO NOT EDIT */\n\n" . $content;
     }));
 }
Exemplo n.º 4
0
 /**
  * Loads an application.
  * 
  * @param	\wcf\data\application\Application		$application
  * @param	boolean						$isDependentApplication
  * @return	\wcf\system\application\IApplication
  */
 protected function loadApplication(Application $application, $isDependentApplication = false)
 {
     $applicationObject = null;
     $package = PackageCache::getInstance()->getPackage($application->packageID);
     // package cache might be outdated
     if ($package === null) {
         $package = new Package($application->packageID);
         // package cache is outdated, discard cache
         if ($package->packageID) {
             PackageEditor::resetCache();
         } else {
             // package id is invalid
             throw new SystemException("application identified by package id '" . $application->packageID . "' is unknown");
         }
     }
     $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($application->packageID);
     $packageDir = FileUtil::getRealPath(WCF_DIR . $package->packageDir);
     self::$autoloadDirectories[$abbreviation] = $packageDir . 'lib/';
     $className = $abbreviation . '\\system\\' . strtoupper($abbreviation) . 'Core';
     if (class_exists($className) && ClassUtil::isInstanceOf($className, 'wcf\\system\\application\\IApplication')) {
         // include config file
         $configPath = $packageDir . PackageInstallationDispatcher::CONFIG_FILE;
         if (file_exists($configPath)) {
             require_once $configPath;
         } else {
             throw new SystemException('Unable to load configuration for ' . $package->package);
         }
         // register template path if not within ACP
         if (!class_exists('wcf\\system\\WCFACP', false)) {
             // add template path and abbreviation
             $this->getTPL()->addApplication($abbreviation, $packageDir . 'templates/');
         }
         // init application and assign it as template variable
         self::$applicationObjects[$application->packageID] = call_user_func(array($className, 'getInstance'));
         $this->getTPL()->assign('__' . $abbreviation, self::$applicationObjects[$application->packageID]);
     } else {
         unset(self::$autoloadDirectories[$abbreviation]);
         throw new SystemException("Unable to run '" . $package->package . "', '" . $className . "' is missing or does not implement 'wcf\\system\\application\\IApplication'.");
     }
     // register template path in ACP
     if (class_exists('wcf\\system\\WCFACP', false)) {
         $this->getTPL()->addApplication($abbreviation, $packageDir . 'acp/templates/');
     } else {
         if (!$isDependentApplication) {
             // assign base tag
             $this->getTPL()->assign('baseHref', $application->getPageURL());
         }
     }
     // register application
     self::$applications[$abbreviation] = $application;
     return self::$applicationObjects[$application->packageID];
 }