Пример #1
0
 /**
  * Attempt Upgrade
  * 
  * Upgrades the user data if possible based on the data_version_date timestamp
  *
  * @return bool - true on upgrade, false if not upgraded.
  */
 private function AttemptUpgrade()
 {
     // Debug
     $success = OnePanelDebug::Track('Attempting data upgrade');
     // Which versions can we upgrade from?
     $upgradeable_versions = array(1224025200, 1224111600, 1237093200);
     $data_version_date = (int) self::$operational_data[0]['data_version_date'];
     if (!in_array($data_version_date, $upgradeable_versions)) {
         define('ONE_PANEL_DATA_NOT_UPGRADED', true);
         // TODO do we ever use this?
         $success->Fail();
         return false;
         // Cannot upgrade.
     } else {
         // We can attempt an upgrade.
         switch ($data_version_date) {
             case 1224025200:
                 // 2.0 Beta 2
                 // Update the Localization Tool's meta information
                 if (is_object(self::$operational_data[1]['LocalizationModule'])) {
                     $new_localization_module = new LocalizationModule();
                     $new_localization_help_text = $new_localization_module->GetHelpText();
                     $new_localization_description = $new_localization_module->GetDescription();
                     $new_localization_short_description = $new_localization_module->GetShortDescription();
                     $new_localization_keywords = $new_localization_module->GetKeywords();
                     $our_localization_module =& self::$operational_data[1]['LocalizationModule'];
                     $our_localization_module->SetHelpText($new_localization_help_text);
                     $our_localization_module->SetDescription($new_localization_description);
                     $our_localization_module->SetShortDescription($new_localization_short_description);
                     $our_localization_module->SetKeywords($new_localization_keywords);
                 }
             case 1224111600:
                 // 2.0 Beta 3
                 // Update the descriptions for the skins module.
                 if (is_object(self::$operational_data[1]['SkinModule'])) {
                     $new_skins_module = new SkinModule();
                     $new_skins_description = $new_skins_module->GetDescription();
                     $new_skins_short_description = $new_skins_module->GetShortDescription();
                     $our_skins_module =& self::$operational_data[1]['SkinModule'];
                     $our_skins_module->SetDescription($new_skins_description);
                     $our_skins_module->SetShortDescription($new_skins_short_description);
                 }
                 break;
         }
         // Set the new data_version and data_version_date
         self::$operational_data[0]['data_version'] = ONE_PANEL_VERSION;
         self::$operational_data[0]['data_version_date'] = ONE_PANEL_VERSION_DATE;
         // Pack the new data
         self::PackData();
         define('ONE_PANEL_DATA_UPGRADED', true);
         $success->Affirm();
         return true;
         // Upgrade Successful
     }
 }
Пример #2
0
 public function Render()
 {
     if (OnePanel::GetDefaultSkin() == $this) {
         $response = $this->RenderNoDeactivate();
     } else {
         $response = $this->RenderOnOff();
     }
     // Get WordPress' uploads data TODO turn this in to a function
     $wp_uploads_data = wp_upload_dir();
     $upload_directory = $wp_uploads_data['path'];
     if (is_writable($upload_directory)) {
         foreach ($this->images as $name => &$image) {
             $response .= '<div class="skin_title">' . $name . ' &darr;</div>';
             $response .= '<div class="skin_desc"><strong>Permalink:</strong> <a target="_blank" href="' . $image . '">URL</a></div>';
             // TODO
             $response .= '<form action="admin-ajax.php" method="post" target="upload_target" enctype="multipart/form-data">';
             $response .= '<input type="hidden" name="action" value="opcp_SkinModuleDoUpload"/>';
             $response .= '<div class="skin_content">';
             $response .= '<div id="upload_preview_' . str_replace(' ', '_', $name) . '"><img src="' . $image . '" class="popup_upload_preview" /></div>';
             $response .= '<div class="upload_form" align="center">';
             $response .= '<input type="hidden" name="MAX_FILE_SIZE" value="1000000"/>';
             $response .= '<input type="hidden" name="feature_key" value="' . SkinModule::GetSkinKey($this->title) . '"/>';
             $response .= '<input type="hidden" name="image_key" value="' . $name . '"/>';
             $response .= '<label for="image_upload">Image File &rarr;&nbsp;&nbsp;&nbsp;</label>';
             $response .= '<input name="userfile" type="file"/>';
             $response .= '</div>';
             $response .= '<div class="buttons" align="center">';
             $response .= '<input class="upload_file" type="submit" value="&nbsp;"/>';
             $response .= '<input class="use_default_file" type="button" value="&nbsp;" onclick="op_admin.Skins.ResetImage( \'' . SkinModule::GetSkinKey($this->title) . '\', \'' . $name . '\' )"/>';
             $response .= '</div>';
             $response .= '<div style="clear:both;"></div>';
             $response .= '</div>';
             $response .= '<div class="DropShadowBlue"></div>';
             // TODO Needs Work First $response .=	'<div style="float:right;"><span class="ie_top"><a class="popup_top" href="#top" onclick="backToTop(); return false">Top &uarr;</a></span></div>';
             $response .= '</form>';
             $response .= '<div style="clear:both;height:10px;"></div>';
         }
     } else {
         // LEE - don't remove the dot ;)
         $response .= '<div class="module_error"><div class="module_error_stroke" style="line-height:22px;"><strong>NOTE: wp-content/uploads is not currently writable...</strong><br />Your uploads directory doesn\'t seem to be writable at the moment. This means that One Panel isn\'t allowed to add files to your server. Please make the "wp-content/uploads" directory writable and return to this page.</div></div>';
     }
     return $response;
 }