Beispiel #1
0
 function PommoTemplate()
 {
     global $pommo;
     // set theme -- TODO; extend this to the theme selector
     $this->_pommoTheme = 'default';
     // set smarty directories
     $this->_themeDir = $pommo->_baseDir . 'themes/';
     $this->template_dir = $this->_themeDir . $this->_pommoTheme;
     $this->config_dir = $this->template_dir . '/inc/config';
     $this->cache_dir = $pommo->_workDir . '/pommo/smarty';
     $this->compile_dir = $pommo->_workDir . '/pommo/smarty';
     $this->plugins_dir = array('plugins', $pommo->_baseDir . 'inc/lib/smarty-plugins/gettext', $pommo->_baseDir . 'inc/lib/smarty-plugins/pommo');
     // set base/core variables available to all template
     $this->assign('url', array('theme' => array('shared' => $pommo->_baseUrl . 'themes/shared/', 'this' => $pommo->_baseUrl . 'themes/' . $this->_pommoTheme . '/'), 'base' => $pommo->_baseUrl, 'http' => $pommo->_http));
     $this->assign('config', @array('app' => array('path' => $pommo->_baseDir, 'weblink' => '<a href="http://pommo.sourceforge.net/">' . Pommo::_T('poMMo Website') . '</a>', 'dateformat' => PommoHelper::timeGetFormat()), 'site_name' => $pommo->_config['site_name'], 'site_url' => $pommo->_config['site_url'], 'list_name' => $pommo->_config['list_name'], 'admin_email' => $pommo->_config['admin_email'], 'demo_mode' => $pommo->_config['demo_mode']));
     // set gettext overload functions (see block.t.php...)
     $this->_gettext_func = array('Pommo', '_T');
     // calls Pommo::_T($str)
     $this->_gettext_plural_func = array('Pommo', '_TP');
     // assign page title
     $this->assign('title', '. ..poMMo.. .');
     // assign section (used for sidebar template)
     $this->assign('section', $pommo->_section);
 }
Beispiel #2
0
 function subscriberData(&$in, $p = array())
 {
     $defaults = array('prune' => true, 'active' => true, 'log' => true, 'ignore' => false, 'ignoreInactive' => true, 'skipReq' => false);
     $p = PommoAPI::getParams($defaults, $p);
     global $pommo;
     $pommo->requireOnce($GLOBALS['pommo']->_baseDir . 'inc/helpers/fields.php');
     $logger =& $pommo->_logger;
     $fields = PommoField::get(array('active' => $p['active']));
     $valid = true;
     foreach ($fields as $id => $field) {
         $inactive = $field['active'] == 'on' ? false : true;
         if (!isset($in[$id]) && $p['skipReq']) {
             continue;
         }
         $in[$id] = @trim($in[$id]);
         if (empty($in[$id])) {
             unset($in[$id]);
             // don't include blank values
             if ($field['required'] == 'on') {
                 if ($p['log']) {
                     $logger->addErr(sprintf(Pommo::_T('%s is a required field.'), $field['prompt']));
                 }
                 $valid = false;
             }
             continue;
         }
         // shorten
         $in[$id] = substr($in[$id], 0, 255);
         switch ($field['type']) {
             case "checkbox":
                 if (strtolower($in[$id]) == 'true') {
                     $in[$id] = 'on';
                 }
                 if (strtolower($in[$id]) == 'false') {
                     $in[$id] = '';
                 }
                 if ($in[$id] != 'on' && $in[$id] != '') {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "multiple":
                 if (is_array($in[$id])) {
                     foreach ($in[$id] as $key => $val) {
                         if (!in_array($val, $field['array'])) {
                             if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                                 unset($in[$id]);
                                 break;
                             }
                             if ($p['log']) {
                                 $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                             }
                             $valid = false;
                         }
                     }
                 } elseif (!in_array($in[$id], $field['array'])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Illegal input for field %s.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "date":
                 // convert date to timestamp [float; using adodb time library]
                 if (is_numeric($in[$id])) {
                     $in[$id] = PommoHelper::timeToStr($in[$id]);
                 }
                 $in[$id] = PommoHelper::timeFromStr($in[$id]);
                 if (!$in[$id]) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a date (' . PommoHelper::timeGetFormat() . ').'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
             case "number":
                 if (!is_numeric($in[$id])) {
                     if ($p['ignore'] || $inactive && $p['ignoreInactive']) {
                         unset($in[$id]);
                         break;
                     }
                     if ($p['log']) {
                         $logger->addErr(sprintf(Pommo::_T('Field (%s) must be a number.'), $field['prompt']));
                     }
                     $valid = false;
                 }
                 break;
         }
     }
     // prune
     if ($p['prune']) {
         $in = PommoHelper::arrayIntersect($in, $fields);
     }
     return $valid;
 }