',
$options->getTitle($optName), $optName, $optName, $selected,
_tpMsg("$msg"));
}
/**
* Prints out the drop down menu asking where to play the videos
* (normally, new window, popup, in youtube, etc.)
*/
function printHTML_player($options) {
$locationVars = $options->getPlayerLocationNames();
WordPressOptionsPage::_printHTML_optionHeader("");
printf('
%s
',
$options->getTitle(TP_OPT_PLAYIN));
printf('
";
WordPressOptionsPage::_printHTML_optionFooter();
}
/**
* Prints out the meta value checkboxes. Fascinating stuff here!
*/
function printHTML_meta($options)
{
WordPressOptionsPage::_printHTML_optionHeader(_tpMsg("META"));
$metas = TubePressVideo::getMetaNames();
echo "
";
WordPressOptionsPage::_printHTML_optionFooter();
}
/**
* Prints out the mode options. Simple!
*/
function printHTML_modes($options)
{
WordPressOptionsPage::_printHTML_optionHeader(_tpMsg("MODE_HEADER"));
$modes = TubePressOptionsPackage::getModeNames();
foreach ($modes as $mode) {
if ($mode == TP_MODE_REL) {
continue;
}
$selected = "";
if ($mode == $options->getValue(TP_OPT_MODE)) {
$selected = "CHECKED";
}
$inputBox = "";
/* The idea here is only the "featured" mode doesn't need any kind of input */
if ($mode != TP_MODE_FEATURED) {
$inputBox = WordPressOptionsPage::_printHTML_quickSrchVal($mode,
$options, 20);
}
/* handle the "popular" mode */
if ($mode == TP_MODE_POPULAR) {
$name = TP_OPT_POPVAL;
$inputBox = sprintf('';
}
$title = "";
$desc = "";
switch($mode) {
case TP_MODE_POPULAR:
$title = _tpMsg("MODE_POPULAR_TITLE");
break;
case TP_MODE_FEATURED:
$title = _tpMsg("MODE_FEAT_TITLE");
break;
case TP_MODE_FAV:
$title = _tpMsg("MODE_FAV_TITLE");
$desc = _tpMsg("MODE_FAV_DESC");
break;
case TP_MODE_PLST:
$title = _tpMsg("MODE_PLST_TITLE");
$desc = _tpMsg("MODE_PLST_DESC");
break;
case TP_MODE_TAG:
$title = _tpMsg("MODE_TAG_TITLE");
break;
case TP_MODE_USER:
$title = _tpMsg("MODE_USER_TITLE");
break;
default:
}
printf('
%s
' .
'
%s %s
',
$title, TP_OPT_MODE, $mode, $mode, $selected, $inputBox,
$desc);
}
echo "*mode supports pagination";
WordPressOptionsPage::_printHTML_optionFooter();
}
/**
* Prints out the success or failure message after updating
*/
function printStatusMsg($msg, $cssClass)
{
printf('
%s
',
$cssClass, $msg);
}
/**
* Go through all the post variables and update the corresponding
* database entries.
*/
function update()
{
$errors = false;
/* get what we have in the db */
$oldOpts = new WordPressOptionsPackage();
if (PEAR::isError($oldOpts)) {
WordPressOptionsPage::printStatusMsg($oldOpts->message, TP_CSS_FAILURE);
return;
}
/* go through the post variables and try to update */
foreach (array_keys($oldOpts->_allOptions) as $optName) {
if (($optName == TP_OPT_DEBUG)
|| ($optName == TP_OPT_GREYBOXON)
|| ($optName == TP_OPT_LWON)
|| in_array($optName, TubePressVideo::getMetaNames())
|| in_array($optName, TubePressOptionsPackage::getPlayerLocationNames())
|| in_array($optName, TubePressOptionsPackage::getModeNames())) {
continue;
}
$result = $oldOpts->setValue($optName, $_POST[$optName]);
if (PEAR::isError($result)) {
$errors = true;
WordPressOptionsPage::printStatusMsg($result->message, TP_CSS_FAILURE);
return;
}
}
/* Do the booleans */
$metaOptions = TubePressVideo::getMetaNames();
foreach ($metaOptions as $metaOption) {
if (!WordPressOptionsPage::_updateBoolean($metaOption, $oldOpts, $errors,
in_array($metaOption, $_POST['meta']))) {
return;
}
}
if (!WordPressOptionsPage::_updateBoolean(TP_OPT_DEBUG, $oldOpts,
$errors, isset($_POST[TP_OPT_DEBUG]))) {
return;
}
if (!WordPressOptionsPage::_updateBoolean(TP_OPT_GREYBOXON, $oldOpts,
$errors, isset($_POST[TP_OPT_GREYBOXON]))) {
return;
}
if (!WordPressOptionsPage::_updateBoolean(TP_OPT_LWON, $oldOpts,
$errors, isset($_POST[TP_OPT_LWON]))) {
return;
}
/* now actually update is we didn't have any errors */
if (!$errors) {
update_option(TP_OPTION_NAME, $oldOpts->_allOptions);
} else {
return;
}
/* make sure the store happened */
$oldOpts = new WordPressOptionsPackage();
if (PEAR::isError($oldOpts)) {
WordPressOptionsPage::printStatusMsg($oldOpts->msg, TP_CSS_FAILURE);
} else {
WordPressOptionsPage::printStatusMsg(_tpMsg("OPTSUCCESS"), TP_CSS_SUCCESS);
}
}
function _updateBoolean($optName, &$options, &$errors, $newValue) {
$result = $options->setValue($optName, $newValue);
if (PEAR::isError($result)) {
$errors = true;
WordPressOptionsPage::printStatusMsg($result->message, TP_CSS_FAILURE);
return false;
}
return true;
}
/**
* Spits out a bit of HTML at the bottom of each option group
*/
function _printHTML_optionFooter() {
echo "";
}
/**
* Spits out a bit of HTML at the top of each option group
*/
function _printHTML_optionHeader($arrayName)
{
echo "