/**
 * Show the export course page.
 */
function WPCW_showPage_ImportExport_export()
{
    $page = new PageBuilder(true);
    $page->showPageHeader(__('Export Training Course', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Show form of courses that can be exported.
    $form = new FormBuilder('wpcw_export');
    $form->setSubmitLabel(__('Export Course', 'wp_courseware'));
    // Course selection
    $formElem = new FormElement('export_course_id', __('Course to Export', 'wp_courseware'), true);
    $formElem->setTypeAsComboBox(WPCW_courses_getCourseList(__('--- Select a course to export ---', 'wp_courseware')));
    $form->addFormElement($formElem);
    // Options for what to export
    $formElem = new FormElement('what_to_export', __('What to Export', 'wp_courseware'), true);
    $formElem->setTypeAsRadioButtons(array('whole_course' => __('<b>All</b> - The whole course - including modules, units and quizzes.', 'wp_courseware'), 'just_course' => __('<b>Just the Course</b> - Just the course title, description and settings (no modules, units or quizzes).', 'wp_courseware'), 'course_modules' => __('<b>Course and Modules</b> - Just the course settings and module settings (no units or quizzes).', 'wp_courseware'), 'course_modules_and_units' => __('<b>Course, Modules and Units</b> - The course settings and module settings and units (no quizzes).', 'wp_courseware')));
    $form->addFormElement($formElem);
    $form->setDefaultValues(array('what_to_export' => 'whole_course'));
    if ($form->formSubmitted()) {
        // Do the full export
        if ($form->formValid()) {
            // If data is valid, export will be handled by export class.
        } else {
            $page->showListOfErrors($form->getListOfErrors(), __('Sorry, but unfortunately there were some errors. Please fix the errors and try again.', 'wp_courseware'));
        }
    }
    // Show selection menu for import/export to save pages
    WPCW_showPage_ImportExport_menu('export');
    printf('<p class="wpcw_doc_quick">');
    _e('When you export a course, you\'ll get an <b>XML file</b>, which you can then <b>import into another WordPress website</b> that\'s running <b>WP Courseware</b>.<br/> 
	    When you export the course units with a course, just the <b>HTML to render images and video</b> will be copied, but the <b>actual images and video files will not be exported</b>.', 'wp_courseware');
    printf('</p>');
    echo $form->toString();
    $page->showPageFooter();
}
Example #2
0
 /**
  * Load the form object with the default values from an associative array mapping
  * field name => field value.
  * @param Array $valueList The list of values to load as defaults into the form.
  */
 public function loadDefaults($valueList)
 {
     if (!$valueList || !is_array($valueList)) {
         error_log('EasyForm:loadDefaults() - $valueList is empty');
         return;
     }
     // Filter the default values before they are loaded into the form.
     if ($this->filterBeforeLoadDefaultsFunction && function_exists($this->filterBeforeLoadDefaultsFunction)) {
         $valueList = call_user_func($this->filterBeforeLoadDefaultsFunction, $valueList);
     }
     $this->formObj->setDefaultValues($valueList);
 }
Example #3
0
/**
 * Show the main settings page.
 */
function WPPortfolio_showSettingsPage()
{
    ?>
	<div class="wrap">
	<div id="icon-options-general" class="icon32">
	<br/>
	</div>
	<h2>WP Portfolio - <?php 
    _e('General Settings');
    ?>
</h2>
<?php 
    $settingsList = WPPortfolio_getSettingList(true, false);
    // Get all the options from the database for the form
    $settings = array();
    foreach ($settingsList as $settingName => $settingDefault) {
        $settings[$settingName] = stripslashes(get_option('WPPortfolio_' . $settingName));
    }
    // If we don't have the version in the settings, we're not installed
    if (!get_option('WPPortfolio_version')) {
        WPPortfolio_showMessage(sprintf(__('No %s settings were found, so it appears that the plugin has been uninstalled. Please <b>deactivate</b> and then <b>activate</b> the %s plugin again to fix this.', 'wp-portfolio'), 'WP Portfolio', 'WP Portfolio'), true);
        return false;
    }
    // #### UNINSTALL - Uninstall plugin?
    if (WPPortfolio_getArrayValue($_GET, 'uninstall') == "yes") {
        if ($_GET['confirm'] == "yes") {
            WPPortfolio_uninstall();
        } else {
            WPPortfolio_showMessage(sprintf(__('Are you sure you want to delete all %s settings and data? This action cannot be undone!', 'wp-portfolio'), 'WP Portfolio') . '</strong><br/><br/><a href="' . WPP_SETTINGS . '&uninstall=yes&confirm=yes">' . __('Yes, delete.', 'wp-portfolio') . '</a> &nbsp; <a href="' . WPP_SETTINGS . '">' . __('NO!', 'wp-portfolio') . '</a>');
        }
        return false;
    } else {
        if (isset($_POST) && isset($_POST['clear_thumb_cache'])) {
            $actualThumbPath = WPPortfolio_getThumbPathActualDir();
            // Delete all contents of directory but not the root
            WPPortfolio_unlinkRecursive($actualThumbPath, false);
            WPPortfolio_showMessage(__('Thumbnail cache has now been emptied.', 'wp-portfolio'));
        } else {
            if (WPPortfolio_getArrayValue($_POST, 'update') == 'general-settings') {
                // Copy settings from $_POST
                $settings = array();
                foreach ($settingsList as $settingName => $settingDefault) {
                    $settings[$settingName] = WPPortfolio_getArrayValue($_POST, $settingName);
                }
                // Validate keys
                if (WPPortfolio_isValidKey($settings['setting_stw_access_key']) && WPPortfolio_isValidKey($settings['setting_stw_secret_key'])) {
                    // Save settings
                    foreach ($settingsList as $settingName => $settingDefault) {
                        update_option('WPPortfolio_' . $settingName, $settings[$settingName]);
                    }
                    WPPortfolio_showMessage();
                } else {
                    WPPortfolio_showMessage(__('The keys must only contain letters and numbers. Please check that they are correct.', 'wp-portfolio'), true);
                }
            } else {
                if (WPPortfolio_getArrayValue($_POST, 'update') == 'tables_force_upgrade') {
                    WPPortfolio_showMessage(__('Upgrading WP Portfolio Tables...', 'wp-portfolio'));
                    flush();
                    WPPortfolio_install_upgradeTables(true, false, false);
                    WPPortfolio_showMessage(sprintf(__('%s tables have successfully been upgraded.', 'wp-portfolio'), 'WP Portfolio'));
                } else {
                    if (WPPortfolio_getArrayValue($_POST, 'update') == 'codepage_upgrade') {
                        // Handle the codepage upgrades from default MySQL latin1_swedish_ci to utf8_general_ci to help deal with
                        // other languages
                        global $wpdb;
                        $wpdb->show_errors;
                        // Table names
                        $table_websites = $wpdb->prefix . TABLE_WEBSITES;
                        $table_groups = $wpdb->prefix . TABLE_WEBSITE_GROUPS;
                        $table_debug = $wpdb->prefix . TABLE_WEBSITE_DEBUG;
                        // Website
                        $wpdb->query("ALTER TABLE `{$table_websites}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
                        $wpdb->query("ALTER TABLE `{$table_websites}` CHANGE `sitename` \t     `sitename`    \t    VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_websites}` CHANGE `siteurl` \t\t `siteurl` \t\t\tVARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_websites}` CHANGE `sitedescription` `sitedescription`  TEXT \t\t   CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_websites}` CHANGE `customthumb` \t `customthumb` \t\tVARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        // Groups
                        $wpdb->query("ALTER TABLE `{$table_groups}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
                        $wpdb->query("ALTER TABLE `{$table_groups}` CHANGE `groupname` \t    `groupname`    \t   VARCHAR( 150 )  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_groups}` CHANGE `groupdescription` `groupdescription` TEXT \t\t   CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        // Debug Log
                        $wpdb->query("ALTER TABLE `{$table_debug}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
                        $wpdb->query("ALTER TABLE `{$table_debug}` CHANGE `request_url` \t `request_url`    VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_debug}` CHANGE `request_detail` `request_detail` TEXT \t\t     CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        $wpdb->query("ALTER TABLE `{$table_debug}` CHANGE `request_type`   `request_type`   VARCHAR( 25 )  CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
                        WPPortfolio_showMessage(sprintf(__('%s tables have successfully been upgraded to UTF-8.', 'wp-portfolio'), 'WP Portfolio'));
                    } else {
                        if (WPPortfolio_getArrayValue($_POST, 'update') == 'change_cache_location') {
                            $oldCacheLoc = get_option(WPP_CACHE_SETTING);
                            $newCacheLoc = WPPortfolio_getArrayValue($_POST, 'new_cache_location');
                            // Check that we've changed something
                            if ($newCacheLoc && $newCacheLoc != $oldCacheLoc) {
                                // Update the options setting
                                update_option(WPP_CACHE_SETTING, $newCacheLoc);
                                $newLoc = WPPortfolio_getCacheSetting();
                                $oldLoc = $newLoc == 'wpcontent' ? 'plugin' : 'wpcontent';
                                // Get the full directory paths we need to manipluate the cache files
                                $newDirPath = WPPortfolio_getThumbPathActualDir($newLoc);
                                $oldDirPath = WPPortfolio_getThumbPathActualDir($oldLoc);
                                $newURLPath = WPPortfolio_getThumbPathActualDir($newLoc);
                                // Create new cache directory
                                WPPortfolio_createCacheDirectory($newLoc);
                                // Copy the files...
                                WPPortfolio_fileCopyRecursive($oldDirPath, $newDirPath);
                                // Remove the old files
                                WPPortfolio_unlinkRecursive($oldDirPath, false);
                                WPPortfolio_showMessage(sprintf(__('The cache location has successfully been changed. The new cache location is now:<br/><br/><code>%s</code>', 'wp-portfolio'), $newURLPath));
                            } else {
                                WPPortfolio_showMessage(__('The cache location has not changed, therefore there is nothing to do.', 'wp-portfolio'));
                            }
                        }
                    }
                }
            }
        }
    }
    $form = new FormBuilder('general-settings');
    $formElem = new FormElement("setting_stw_access_key", __('STW Access Key ID', 'wp-portfolio'));
    $formElem->value = $settings['setting_stw_access_key'];
    $formElem->description = sprintf(__('The <a href="%s#doc-stw">Shrink The Web</a> Access Key ID is around 15 characters.', 'wp-portfolio'), WPP_DOCUMENTATION);
    $form->addFormElement($formElem);
    $formElem = new FormElement("setting_stw_secret_key", __('STW Secret Key', 'wp-portfolio'));
    $formElem->value = $settings['setting_stw_secret_key'];
    $formElem->description = sprintf(__('The <a href="%s#doc-stw">Shrink The Web</a> Secret Key is around 5-10 characters. This key is never shared, it is only stored in your settings and used to generate thumbnails for this website.', 'wp-portfolio'), WPP_DOCUMENTATION) . "<a name=\"stw-account\"></a>";
    // The anchor for the option below
    $form->addFormElement($formElem);
    $formElem = new FormElement("setting_stw_account_type", __("STW Account Type", 'wp-portfolio'));
    $formElem->value = $settings['setting_stw_account_type'];
    $formElem->setTypeAsComboBox(array('' => __('-- Select an account type --', 'wp-portfolio'), 'free' => __('Free Account', 'wp-portfolio'), 'paid' => __('Paid (Basic or Plus) Account', 'wp-portfolio')));
    $formElem->description = sprintf('&bull; ' . __('The type of account you have with <a href="%s#doc-stw">Shrink The Web</a>. ', 'wp-portfolio'), WPP_DOCUMENTATION) . __('Either a <i>free account</i>, or a <i>paid (basic or plus) account</i>. Your account type determines how the portfolio works.', 'wp-portfolio') . '<br/>' . sprintf('&bull; ' . __('Learn more about account types in the <a href="%s" target="_new"> FAQ section.</a>', 'wp-portfolio'), 'http://wordpress.org/extend/plugins/wp-portfolio/faq/');
    $form->addFormElement($formElem);
    $form->addBreak('wpp-thumbnails', '<div class="wpp-settings-div">' . __('Thumbnail Settings', 'wp-portfolio') . '</div>');
    // Thumbnail sizes - Paid Only
    if (WPPortfolio_isPaidAccount()) {
        $formElem = new FormElement("setting_stw_thumb_size_type", __('What thumbnail sizes do you want to use?', 'wp-portfolio'));
        $formElem->value = $settings['setting_stw_thumb_size_type'];
        $formElem->setTypeAsComboBox(array('standard' => __('Standard STW Sizes', 'wp-portfolio'), 'custom' => __('My own custom sizes', 'wp-portfolio')));
        $formElem->cssclass = 'wpp-size-type';
        $form->addFormElement($formElem);
        $formElem = new FormElement("setting_stw_thumb_size_custom", __('Custom Thumbnail Size (Width)', 'wp-portfolio'));
        $formElem->value = $settings['setting_stw_thumb_size_custom'];
        $formElem->cssclass = 'wpp-size-custom';
        $formElem->description = '&bull; ' . __('Specify your desired width for the custom thumbnail. STW will resize the thumbnail to be in a 4:3 ratio.', 'wp-portfolio') . '<br/>' . '&bull; ' . __('This feature requires a STW Paid (Basic or Plus) account with custom thumbnail support.', 'wp-portfolio');
        $formElem->afterFormElementHTML = '<div class="wpp-size-custom-other"></div>';
        $form->addFormElement($formElem);
    }
    // Thumbnail sizes - Basic
    $thumbsizes = array("sm" => __('Small (120 x 90)', 'wp-portfolio'), "lg" => __('Large (200 x 150)', 'wp-portfolio'), "xlg" => __('Extra Large (320 x 240)', 'wp-portfolio'));
    $formElem = new FormElement("setting_stw_thumb_size", __('Thumbnail Size', 'wp-portfolio'));
    $formElem->value = $settings['setting_stw_thumb_size'];
    $formElem->setTypeAsComboBox($thumbsizes);
    $formElem->cssclass = 'wpp-size-select';
    $form->addFormElement($formElem);
    // Cache days
    $cachedays = array("3" => "3 " . __('days', 'wp-portfolio'), "5" => "5 " . __('days', 'wp-portfolio'), "7" => "7 " . __('days', 'wp-portfolio'), "10" => "10 " . __('days', 'wp-portfolio'), "15" => "15 " . __('days', 'wp-portfolio'), "20" => "20 " . __('days', 'wp-portfolio'), "30" => "30 " . __('days', 'wp-portfolio'), "0" => __('Never Expire Thumbnails', 'wp-portfolio'));
    $formElem = new FormElement("setting_cache_days", __('Number of Days to Cache Thumbnail', 'wp-portfolio'));
    $formElem->value = $settings['setting_cache_days'];
    $formElem->setTypeAsComboBox($cachedays);
    $formElem->description = __('The number of days to hold thumbnails in the cache. Set to a longer time period if website homepages don\'t change very often', 'wp-portfolio');
    $form->addFormElement($formElem);
    // Thumbnail Fetch Method
    $fetchmethod = array("curl" => __('cURL (recommended)', 'wp-portfolio'), "fopen" => __("fopen", 'wp-portfolio'));
    $formElem = new FormElement("setting_fetch_method", __('Thumbnail Fetch Method', 'wp-portfolio'));
    $formElem->value = $settings['setting_fetch_method'];
    $formElem->setTypeAsComboBox($fetchmethod);
    $formElem->description = __('The type of HTTP call used to fetch thumbnails. fopen is usually less secure and disabled by most web hosts, hence why cURL is recommended.', 'wp-portfolio');
    $form->addFormElement($formElem);
    // Custom Thumbnail Scale Method
    $scalemethod = array("scale-height" => __('Match height of website thumbnails', 'wp-portfolio'), "scale-width" => __('Match width of website thumbnails', 'wp-portfolio'), "scale-both" => __('Ensure thumbnail is same size or smaller than website thumbnails (default)', 'wp-portfolio'));
    $formElem = new FormElement("setting_scale_type", __('Custom Thumbnail Scale Method', 'wp-portfolio'));
    $formElem->value = $settings['setting_scale_type'];
    $formElem->setTypeAsComboBox($scalemethod);
    $formElem->description = __('How custom thumbnails are scaled to match the size of other website thumbnails. This is mostly a matter of style. The thumbnails can match either:', 'wp-portfolio') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;' . __('a) <strong>the height</strong> of the website thumbnails (with the width resized to keep the scale of the original image)', 'wp-portfolio') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;' . __('b) <strong>the width</strong> of the website thumbnails  (with the height resized to keep the scale of the original image)', 'wp-portfolio') . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;' . __('c) <strong>the width and the height</strong> of the website thumbnails, where the custom thumbnail is never larger than a website thumbnail, but still scaled correctly.', 'wp-portfolio') . '<br/>' . __('After changing this option, it\'s recommended to clear the cache so that all custom thumbnails are sized correctly.', 'wp-portfolio');
    $form->addFormElement($formElem);
    $form->addBreak('wpp-thumbnails', '<div class="wpp-settings-div">' . __('Miscellaneous Settings', 'wp-portfolio') . '</div>');
    // Debug mode
    $formElem = new FormElement("setting_enable_debug", __('Enable Debug Mode', 'wp-portfolio'));
    $formElem->value = $settings['setting_enable_debug'];
    $formElem->setTypeAsCheckbox("Enable debug logging");
    $formElem->description = __('Enables logging of successful thumbnail requests too (all errors are logged regardless).', 'wp-portfolio');
    $form->addFormElement($formElem);
    // Show credit link
    $formElem = new FormElement("setting_show_credit", __('Show Credit Link', 'wp-portfolio'));
    $formElem->value = $settings['setting_show_credit'];
    $formElem->setTypeAsCheckbox(__('Creates a link back to WP Portfolio and to WPDoctors.co.uk', 'wp-portfolio'));
    $formElem->description = __("<strong>I've worked hard on this plugin, please consider keeping the link back to my website!</strong> It's the link back to my site that keeps this plugin free!", 'wp-portfolio');
    $form->addFormElement($formElem);
    $form->addButton("clear_thumb_cache", __("Clear Thumbnail Cache", 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	<p>&nbsp;</p><p>&nbsp;</p>
	<h2><?php 
    _e("Server Compatibility Checker", "wp-portfolio");
    ?>
</h2>	
	<table id="wpp-checklist">
		<tbody>
			<tr>
				<td><?php 
    _e("PHP Version", "wp-portfolio");
    ?>
</td>
				<td><?php 
    echo phpversion();
    ?>
</td>
				<td>
					<?php 
    if (version_compare(phpversion(), '5.0.0', '>')) {
        ?>
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_tick.png" alt="Yes" />

                    <?php 
    } else {
        ?>
        
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_stop.png" alt="No" />
						<span class="wpp-error-info"><?php 
        echo __('WP Portfolio requires PHP 5 or above.', 'wp-portfolio');
        ?>
</span>
					<?php 
    }
    ?>
				</td>
			</tr>	
			
			<tr>
				<?php 
    // Check for cache path
    $cachePath = WPPortfolio_getThumbPathActualDir();
    $isWriteable = file_exists($cachePath) && is_dir($cachePath) && is_writable($cachePath);
    ?>
				<td><?php 
    _e("Writeable Cache Folder", "wp-portfolio");
    ?>
</td>
				<?php 
    if ($isWriteable) {
        ?>
					<td><?php 
        _e('Yes');
        ?>
</td>
					<td>					
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_tick.png" alt="Yes" />
					</td>
				<?php 
    } else {
        ?>
					<td><?php 
        _e('No');
        ?>
</td>
					<td>        
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_stop.png" alt="No" />
						<span class="wpp-error-info"><?php 
        echo __('WP Portfolio requires a directory for the cache that\'s writeable.', 'wp-portfolio');
        ?>
</span>
					</td>
				<?php 
    }
    ?>
			</tr>	
			
			<tr>
				<?php 
    // Check for open_basedir restriction
    $openBaseDirSet = ini_get('open_basedir');
    ?>
				<td><?php 
    echo __("open_basedir Restriction", "wp-portfolio");
    ?>
</td>
				<?php 
    if (!$openBaseDirSet) {
        ?>
					<td><?php 
        _e('Not Set');
        ?>
</td>
					<td>					
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_tick.png" alt="Yes" />
					</td>
				<?php 
    } else {
        ?>
					<td><?php 
        _e('Set');
        ?>
</td>
					<td>        
						<img src="<?php 
        echo WPPortfolio_getPluginPath();
        ?>
/imgs/icon_stop.png" alt="No" />
						<span class="wpp-error-info"><?php 
        _e("The PHP ini open_basedir setting can cause problems with fetching thumbnails.", "wp-portfolio");
        ?>
</span>
					</td>
				<?php 
    }
    ?>
			</tr>
						
		</tbody>
	</table>
	
	
	
	<p>&nbsp;</p><p>&nbsp;</p>
	<h2><?php 
    _e("Change Cache Location", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __('You can either have the thumbnail cache stored in the <b>plugin directory</b> (which gets deleted when you upgrade the plugin), or you can have the thumbnail cache stored in the <b>wp-content directory</b> (which doesn\'t get deleted when you upgrade wp-portfolio). This is only useful if your thumbnails are set to never be updated and you don\'t want to lose the cached thumbnails.', 'wp-portfolio');
    ?>
</p>
	<dl>
		<dt><?php 
    _e('Plugin Location', 'wp-portfolio');
    ?>
: <?php 
    if (WPPortfolio_getCacheSetting() == 'plugin') {
        printf('&nbsp;&nbsp;<i class="wpp-cache-selected">(%s)</i>', __('Currently Selected', 'wp-portfolio'));
    }
    ?>
</dt>
		<dd><code><?php 
    echo WPPortfolio_getThumbPathURL('plugin');
    ?>
</code></dd>	
		
		<dt><?php 
    echo 'wp-content' . __(' Location', 'wp-portfolio');
    ?>
: <?php 
    if (WPPortfolio_getCacheSetting() == 'wpcontent') {
        printf('&nbsp;&nbsp;<i class="wpp-cache-selected">(%s)</i>', __('Currently Selected', 'wp-portfolio'));
    }
    ?>
</dt>
		<dd><code><?php 
    echo WPPortfolio_getThumbPathURL('wpcontent');
    ?>
</code></dd>
	</dl>
	
	<?php 
    $form = new FormBuilder('change_cache_location');
    // List of Cache Locations
    $cacheLocations = array('setting_cache_plugin' => __('Plugin Directory (Recommended)', 'wp-portfolio'), 'setting_cache_wpcontent' => __('wp-content Directory', 'wp-portfolio'));
    $formElem = new FormElement('new_cache_location', __('New Cache Location', 'wp-portfolio'));
    $formElem->setTypeAsComboBox($cacheLocations);
    $form->addFormElement($formElem);
    // Set the default location based on current setting.
    $form->setDefaultValues(array('new_cache_location' => get_option(WPP_CACHE_SETTING, true)));
    $form->setSubmitLabel(__('Change Cache Location', 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	
	<p>&nbsp;</p>
	<hr>
	
	<h2><?php 
    _e("Upgrade Tables", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __("<p>If you're getting any errors relating to tables, you can force an upgrade of the database tables relating to WP Portfolio.", 'wp-portfolio');
    ?>
</p>
	<?php 
    $form = new FormBuilder('tables_force_upgrade');
    $form->setSubmitLabel(__('Force Table Upgrade', 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	<hr>
	
	<h2><?php 
    _e("Upgrade Tables to UTF-8 Codepage (Advanced)", "wp-portfolio");
    ?>
</h2>
	<p><?php 
    echo __('As of V1.18, WP Portfolio uses UTF-8 as the default codepage for all text fields. Previously, for non Latin-based languages, the lack of UTF-8 support caused rendering issues with characters (such as using question marks and blocks for certain characters).', 'wp-portfolio');
    echo __('To upgrade to the new UTF-8 support, just click the button below. If you\'re <b>not experiencing problems</b> with website names and descriptions, then there\'s no need to click this button.</p>', 'wp-portfolio');
    ?>
	<?php 
    $form = new FormBuilder('codepage_upgrade');
    $form->setSubmitLabel(__('Upgrade Codepage to UTF-8', 'wp-portfolio'));
    echo $form->toString();
    ?>
		
		
		
	<hr>
	<h2><?php 
    _e('Uninstalling WP Portfolio', 'wp-portfolio');
    ?>
</h2>
	<p><?php 
    echo sprintf(__('If you\'re going to permanently uninstall WP Portfolio, you can also <a href="%s">remove all settings and data</a>.</p>', 'wp-portfolio'), 'admin.php?page=WPP_show_settings&uninstall=yes');
    ?>
		
	<p>&nbsp;</p>	
	<p>&nbsp;</p>
	</div>
	<?php 
}
Example #4
0
 /**
  * Show the form for editing the specific courses a user can access based on what level that they have access to.
  * @param PageBuilder $page The page rendering object.
  * @param Array $levelDetails The list of level details
  */
 private function showMembershipMappingLevels_specificLevel($page, $levelDetails)
 {
     // Show a nice summary of what level is being edited.
     printf('<div id="wpcw_member_level_name_title">%s</div>', sprintf(__('Editing permissions for <b>%s</b> level with <b>%s</b>:', 'wp_courseware'), $levelDetails['name'], $this->extensionName));
     // Get a list of course IDs that exist
     $courses = WPCW_courses_getCourseList(false);
     // Get list of courses already associated with level.
     $courseListInDB = $this->getCourseAccessListForLevel($levelDetails['id']);
     // Create the summary URL to return
     $summaryURL = admin_url('admin.php?page=' . $this->extensionID);
     // Update form...
     $form = new FormBuilder('wpcw_member_levels_edit');
     $form->setSubmitLabel(__('Save Changes', 'wp_courseware'));
     // Create list of courses using checkboxes (max of 2 columns)
     $elem = new FormElement('level_courses', __('Courses user can access at this level', 'wp_courseware'), false);
     $elem->setTypeAsCheckboxList($courses);
     $elem->checkboxListCols = 2;
     $form->addFormElement($elem);
     // Normally would check for errors too, but there's not a lot to check here.
     if ($form->formSubmitted()) {
         if ($form->formValid()) {
             $mapplingList = $form->getValue('level_courses');
             global $wpdb, $wpcwdb;
             $wpdb->show_errors();
             // Remove all previous level mappings (as some will have been removed)
             $wpdb->query($wpdb->prepare("\n\t\t\t\t\t\tDELETE \n\t\t\t\t\t\tFROM {$wpcwdb->map_member_levels} \n\t\t\t\t\t\tWHERE member_level_id = %s\n\t\t\t\t\t", $levelDetails['id']));
             // Add all of the new mappings the user has chosen.
             if ($mapplingList && count($mapplingList) > 0) {
                 foreach ($mapplingList as $courseID => $itemState) {
                     $wpdb->query($wpdb->prepare("\n\t\t\t\t\t\t\t\tINSERT INTO {$wpcwdb->map_member_levels} \n\t\t\t\t\t\t\t\t(course_id, member_level_id)  \n\t\t\t\t\t\t\t\tVALUES (%d, %s)\n\t\t\t\t\t\t\t", $courseID, $levelDetails['id']));
                 }
             }
             // Show a success message.
             $page->showMessage(__('Level and course permissions successfully updated.', 'wp_courseware') . '<br/><br/>' . sprintf(__('Want to return to the <a href="%s">Course Access Settings summary</a>?', 'wp_courseware'), $summaryURL));
         }
         // if ($form->formValid())
     } else {
         $form->setDefaultValues(array('level_courses' => $courseListInDB));
     }
     // Show the form
     echo $form->toString();
     printf('<a href="%s" class="button-secondary">%s</a>', $summaryURL, __('&laquo; Return to Course Access Settings summary', 'wp_courseware'));
 }