/**
  * Get all polls and return them as array
  * @return array
  */
 public function getPolls()
 {
     $arrPolls = array();
     $objPolls = $this->Database->execute("SELECT id, title FROM tl_poll" . (\Poll::checkMultilingual() ? " WHERE lid=0" : "") . " ORDER BY title");
     while ($objPolls->next()) {
         $arrPolls[$objPolls->id] = $objPolls->title;
     }
     return $arrPolls;
 }
Esempio n. 2
0
 * @author  Codefog <http://codefog.pl>
 * @author  Kamil Kuzminski <*****@*****.**>
 * @license LGPL
 */
/**
 * Load tl_module language files
 */
System::loadLanguageFile('tl_module');
/**
 * Table tl_poll
 */
$GLOBALS['TL_DCA']['tl_poll'] = array('config' => array('dataContainer' => 'Table', 'ctable' => array('tl_poll_option'), 'switchToEdit' => true, 'enableVersioning' => true, 'sql' => array('keys' => array('id' => 'primary'))), 'list' => array('sorting' => array('mode' => 1, 'fields' => array('title'), 'flag' => 1, 'panelLayout' => 'filter;search,limit'), 'label' => array('fields' => array('title'), 'format' => '%s', 'label_callback' => array('tl_poll', 'addStatus')), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['edit'], 'href' => 'table=tl_poll_option', 'icon' => 'edit.gif', 'attributes' => 'class="contextmenu"'), 'editheader' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['editheader'], 'href' => 'act=edit', 'icon' => 'header.gif', 'attributes' => 'class="edit-header"'), 'copy' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['copy'], 'href' => 'act=copy', 'icon' => 'copy.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'), 'toggle' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['toggle'], 'icon' => 'visible.gif', 'attributes' => 'onclick="Backend.getScrollOffset(); return AjaxRequest.toggleVisibility(this, %s);"', 'button_callback' => array('tl_poll', 'toggleIcon')), 'feature' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['feature'], 'icon' => 'featured.gif', 'attributes' => 'onclick="Backend.getScrollOffset(); return AjaxRequest.toggleFeatured(this, %s);"', 'button_callback' => array('tl_poll', 'iconFeatured')), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['show'], 'href' => 'act=show', 'icon' => 'show.gif'))), 'palettes' => array('default' => '{title_legend},title,type,voteInterval,protected,featured,active_behaviorNotVoted,active_behaviorVoted,inactive_behaviorNotVoted,inactive_behaviorVoted;{redirect_legend:hide},jumpTo;{publish_legend},published,closed,activeStart,activeStop,showStart,showStop'), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'lid' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'language' => array('sql' => "varchar(2) NOT NULL default ''"), 'title' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['title'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 255), 'sql' => "varchar(255) NOT NULL default ''"), 'type' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['type'], 'default' => 'single', 'exclude' => true, 'inputType' => 'select', 'options' => array('single', 'multiple'), 'reference' => &$GLOBALS['TL_LANG']['tl_poll']['type'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(8) NOT NULL default ''"), 'voteInterval' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['voteInterval'], 'default' => 86400, 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'protected' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['protected'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'featured' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['featured'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'active_behaviorNotVoted' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['active_behaviorNotVoted'], 'default' => 'opt1', 'exclude' => true, 'inputType' => 'select', 'options' => array('opt1', 'opt2', 'opt3'), 'reference' => &$GLOBALS['TL_LANG']['tl_poll']['behaviorNotVoted'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(4) NOT NULL default ''"), 'active_behaviorVoted' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['active_behaviorVoted'], 'default' => 'opt1', 'exclude' => true, 'inputType' => 'select', 'options' => array('opt1', 'opt2', 'opt3'), 'reference' => &$GLOBALS['TL_LANG']['tl_poll']['behaviorVoted'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(4) NOT NULL default ''"), 'inactive_behaviorNotVoted' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['inactive_behaviorNotVoted'], 'default' => 'opt1', 'exclude' => true, 'inputType' => 'select', 'options' => array('opt1', 'opt2', 'opt3'), 'reference' => &$GLOBALS['TL_LANG']['tl_poll']['behaviorNotVoted'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(4) NOT NULL default ''"), 'inactive_behaviorVoted' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['inactive_behaviorVoted'], 'default' => 'opt1', 'exclude' => true, 'inputType' => 'select', 'options' => array('opt1', 'opt2', 'opt3'), 'reference' => &$GLOBALS['TL_LANG']['tl_poll']['behaviorVoted'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(4) NOT NULL default ''"), 'jumpTo' => array('label' => &$GLOBALS['TL_LANG']['tl_module']['jumpTo'], 'exclude' => true, 'filter' => true, 'inputType' => 'pageTree', 'eval' => array('fieldType' => 'radio', 'tl_class' => 'clr'), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'published' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['published'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('doNotCopy' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'closed' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['closed'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('doNotCopy' => true, 'tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'activeStart' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['activeStart'], 'exclude' => true, 'search' => true, 'flag' => 8, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'activeStop' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['activeStop'], 'exclude' => true, 'search' => true, 'flag' => 8, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'showStart' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['showStart'], 'exclude' => true, 'search' => true, 'flag' => 8, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'showStop' => array('label' => &$GLOBALS['TL_LANG']['tl_poll']['showStop'], 'exclude' => true, 'search' => true, 'flag' => 8, 'inputType' => 'text', 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''")));
/**
 * Provide support for DC_Multilingual
 */
if (\Poll::checkMultilingual()) {
    $GLOBALS['TL_DCA']['tl_poll']['config']['dataContainer'] = 'Multilingual';
    $GLOBALS['TL_DCA']['tl_poll']['config']['languages'] = Poll::getAvailableLanguages();
    $GLOBALS['TL_DCA']['tl_poll']['config']['pidColumn'] = 'lid';
    $GLOBALS['TL_DCA']['tl_poll']['config']['fallbackLang'] = Poll::getFallbackLanguage();
    // Make "title" field translatable
    $GLOBALS['TL_DCA']['tl_poll']['fields']['title']['eval']['translatableFor'] = '*';
}
/**
 * Provide miscellaneous methods that are used by the data configuration array.
 */
class tl_poll extends Backend
{
    /**
     * Add the poll status
     * @param array