00001 <?php
00002
00016 import('form.Form');
00017
00018 class CmsRssSettingsForm extends Form {
00020 var $journalId;
00021
00023 var $plugin;
00024
00026 var $errors;
00027
00032 function CmsRssSettingsForm(&$plugin, $journalId) {
00033
00034 parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
00035
00036 $this->journalId = $journalId;
00037 $this->plugin =& $plugin;
00038
00039 $this->addCheck(new FormValidatorArray($this, 'urls', 'required', 'plugins.generic.cmsrss.requiredFields', array('pageName', 'url')));
00040 $this->addCheck(new FormValidatorCustom($this, 'months', 'required', 'plugins.generic.cmsrss.monthsRequired', create_function('$months', 'return is_numeric($months) && $months >= 0;')));
00041 }
00042
00046 function initData() {
00047 $journalId = $this->journalId;
00048 $plugin =& $this->plugin;
00049
00050 $templateMgr = &TemplateManager::getManager();
00051 $this->_data = array(
00052 'urls' => array()
00053 );
00054
00055 $urls = $plugin->getSetting($journalId, 'urls');
00056 $months = $plugin->getSetting($journalId, 'months');
00057 if ( !($months > 0) ) $months = 3;
00058 $aggregate = $plugin->getSetting($journalId, 'aggregate');
00059
00060 for ($i=0, $count=count($urls); $i < $count; $i++) {
00061 array_push(
00062 $this->_data['urls'],
00063 array(
00064 'urlId' => $urls[$i]['urlId'],
00065 'pageName' => $urls[$i]['pageName'],
00066 'url' => $urls[$i]['url']
00067 )
00068 );
00069 }
00070 $this->setData('months', $months);
00071 $this->setData('aggregate', $aggregate);
00072 }
00073
00077 function readInputData() {
00078 $this->readUserVars(
00079 array(
00080 'months',
00081 'aggregate',
00082 'urls',
00083 'deletedUrls'
00084 )
00085 );
00086 }
00087
00091 function execute() {
00092 $plugin =& $this->plugin;
00093 $journalId = $this->journalId;
00094
00095
00096 $urls = $this->getData('urls');
00097 usort($urls, array(&$this, '_urlSort'));
00098
00099
00100 $plugin->updateSetting($journalId, 'urls', $urls);
00101 $this->_data['urls'] = $urls;
00102
00103 $plugin->updateSetting($journalId, 'months', $this->getData('months'));
00104 $plugin->updateSetting($journalId, 'aggregate', $this->getData('aggregate'));
00105
00106 }
00107
00111 function _urlSort( $a, $b) {
00112 $a = $a['pageName'];
00113 $b = $b['pageName'];
00114
00115 return strcmp($a, $b);
00116 }
00117
00118 }
00119
00120 ?>