// Paste PHP Code
Index: core/objects/deki_site.php
===================================================================
--- core/objects/deki_site.php (revision 21296)
+++ core/objects/deki_site.php (working copy)
@@ -259,7 +259,9 @@
}
/***
- * Tickle the package import service
+ * Refresh the packages by forcing a reimport
+ * @note Does not reimport import-once packages
+ *
* @return DekiResult
*/
public static function refreshPackages()
@@ -269,17 +271,14 @@
$DekiPlug = DekiPlug::getInstance();
$Request = DekiRequest::getInstance();
- $SiteProperties = DekiSiteProperties::getInstance();
- // clear out all the old package properties to trigger the reload
- $SiteProperties->clearAllPackages();
-
$dekiPath = $wgApi . ($wgDekiApi{0} != '/' ? '/': '') . $wgDekiApi;
// tickle the template updater service
$data = array(
'update' => array(
- '@wikiid' => $wgDekiSiteId,
+ '@wikiid' => $wgDekiSiteId,
+ '@force' => 'true',
'uri' => $Request->getScheme() . '://' . $Request->getHost() . '/' . $dekiPath
)
);
Index: core/objects/deki_site_properties.php
===================================================================
--- core/objects/deki_site_properties.php (revision 21296)
+++ core/objects/deki_site_properties.php (working copy)
@@ -28,7 +28,9 @@
*/
protected $localHtmlRegions = array();
-
+ /**
+ * @return DekiSiteProperties
+ */
public static function getInstance()
{
if (is_null(self::$instance))
@@ -70,22 +72,6 @@
}
/**
- * This wipes all package information so the template updater service, when tickled, will do a fresh import
- */
- public function clearAllPackages()
- {
- $packages = $this->getAllPackages();
- if (!empty($packages))
- {
- foreach ($packages as $name => $value)
- {
- $this->remove($name, DekiSiteProperties::NS_PACKAGES);
- }
- $this->update();
- }
- }
-
- /**
* These will set the css & html based on the active skin/theme
* if the $skin & $theme parameters are omitted
*/
Index: cp/package_importer.php
===================================================================
--- cp/package_importer.php (revision 21296)
+++ cp/package_importer.php (working copy)
@@ -41,61 +41,43 @@
{
$this->executeAction('update');
}
-
- // helper function to locate packages on disk
- public function getPackagePath($permissions = self::FOLDER_PUBLIC, $name = null)
- {
- global $IP, $wgDekiSiteId;
- return $IP . '/packages/' . $wgDekiSiteId . '/' . $permissions . (!is_null($name) ? '/' . $name : '');
- }
-
+
protected function POST_update()
- {
- if ($this->Request->getFile('file'))
+ {
+ switch ($this->Request->getVal('action'))
{
- // try to move the file to the package location
- $file = $this->Request->getFile('file');
- if ($file['error'] == 0)
- {
- if (!move_uploaded_file($file['tmp_name'], $this->getPackagePath(self::FOLDER_PUBLIC, $file['name'])))
+ case 'update':
+ $this->refreshPackages();
+ break;
+
+ case 'custom':
+ $file = $this->Request->getFile('file');
+ if ($file['error'] != 0)
{
DekiMessage::error($this->View->msg('PackageImporter.error.upload'));
return false;
}
- }
- }
-
- // if we're successfully, give a list of packages that have been updated
- $Result = DekiSite::refreshPackages();
- if ($Result->handleResponse())
- {
- $packages = $Result->getAll('body/packages/package', null);
- if (!empty($packages))
- {
- foreach ($packages as $package)
+
+ // try to move the file to the package location
+ if (!move_uploaded_file($file['tmp_name'], $this->getPackagePath(self::FOLDER_PUBLIC, $file['name'])))
{
- $X = new XArray($package);
- if ($X->getVal('status/@code') == 'ok')
- {
- $preserve = $X->getVal('@preserve-local') == 'true' ? '': $this->View->msg('PackageImporter.overwritten');
- DekiMessage::success($this->View->msg('PackageImporter.success', $X->getVal('name'), $preserve));
- }
+ DekiMessage::error($this->View->msg('PackageImporter.error.upload'));
+ return false;
}
- }
- $return = true;
- }
- else
- {
- $return = false;
- }
+
+ $this->refreshPackages();
+ if ($this->Request->getBool('onetime'))
+ {
+ @unlink($this->getPackagePath(self::FOLDER_PUBLIC, $file['name']));
+ }
+ break;
+
+ default:
+ }
+
+ return true;
+ }
- if ($this->Request->getFile('file') && $this->Request->getVal('onetime'))
- {
- @unlink($this->getPackagePath(self::FOLDER_PUBLIC, $file['name']));
- }
- return $return;
- }
-
// main listing view
public function update()
{
@@ -138,6 +120,38 @@
$this->View->output();
}
+ protected function refreshPackages()
+ {
+ // if we're successfully, give a list of packages that have been updated
+ $Result = DekiSite::refreshPackages();
+ if (!$Result->handleResponse())
+ {
+ return false;
+ }
+
+ $packages = $Result->getAll('body/packages/package', null);
+ if (!empty($packages))
+ {
+ foreach ($packages as $package)
+ {
+ $X = new XArray($package);
+ if ($X->getVal('status/@code') == 'ok')
+ {
+ $preserve = $X->getVal('@preserve-local') == 'true' ? '': $this->View->msg('PackageImporter.overwritten');
+ DekiMessage::success($this->View->msg('PackageImporter.success', $X->getVal('name'), $preserve));
+ }
+ }
+ }
+
+ return true;
+ }
+
+ // helper function to locate packages on disk
+ protected function getPackagePath($permissions = self::FOLDER_PUBLIC, $name = null)
+ {
+ global $IP, $wgDekiSiteId;
+ return $IP . '/packages/' . $wgDekiSiteId . '/' . $permissions . (!is_null($name) ? '/' . $name : '');
+ }
}
new PackageImporter();
\ No newline at end of file
Index: cp/templates/package_importer/update.php
===================================================================
--- cp/templates/package_importer/update.php (revision 21296)
+++ cp/templates/package_importer/update.php (working copy)
@@ -7,7 +7,7 @@
<div class="cblock">
<form method="post" action="<?php $this->html('form.action');?>">
- <div class="button"><?php echo DekiForm::singleInput('button', 'update', 'update', array(), $this->msg('PackageImporter.button.manual')); ?></div>
+ <div class="button"><?php echo DekiForm::singleInput('button', 'action', 'update', array(), $this->msg('PackageImporter.button.manual')); ?></div>
<div class="description"><?php echo $this->msg('PackageImporter.description'); ?></div>
</form>
@@ -21,8 +21,8 @@
<div class="cblock">
<form method="post" enctype="multipart/form-data">
<?php echo DekiForm::singleInput('file', 'file'); ?>
- <?php echo DekiForm::singleInput('button', 'button', '', array(), $this->msg('PackageImporter.button.import'));?><br/>
- <small><?php echo DekiForm::singleInput('checkbox', 'onetime', 'onetime', array('checked' => 'checked'), $this->msg('PackageImporter.description.once')); ?></small>
+ <?php echo DekiForm::singleInput('button', 'action', 'custom', array(), $this->msg('PackageImporter.button.import'));?><br/>
+ <small><?php echo DekiForm::singleInput('checkbox', 'onetime', 'true', array('checked' => 'checked'), $this->msg('PackageImporter.description.once')); ?></small>
</form>
</div>
<?php endif; ?>
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by