Beispiel #1
0
 function load(Zikula_Form_View $view, &$params)
 {
     if (!$view->isPostBack()) {
         $classes = ModUtil::apiFunc('Content', 'Admin', 'getStyleClasses');
         $empty = array(array('text' => '', 'value' => ''));
         $classes = array_merge($empty, $classes);
         $this->setItems($classes);
     }
     parent::load($view, $params);
 }
Beispiel #2
0
 function load(Zikula_Form_View $view, &$params)
 {
     if (!$view->isPostBack()) {
         // Find the active modules
         $moduleList = ModUtil::apiFunc('Extensions', 'admin', 'listmodules', array('state' => ModUtil::STATE_ACTIVE));
         $modules = array();
         // Only list modules that have a User view
         foreach ($moduleList as $module) {
             if (isset($module['capabilities']['user'])) {
                 $modules[] = array('text' => $module['displayname'], 'value' => $module['name']);
             }
         }
         $empty = array(array('text' => '', 'value' => ''));
         $modules = array_merge($empty, $modules);
         $this->setItems($modules);
     }
     parent::load($view, $params);
 }
Beispiel #3
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     static $firstTime = true;
     $i18n = ZI18n::getInstance();
     if (!empty($this->defaultValue) && !$view->isPostBack()) {
         $d = strtolower($this->defaultValue);
         $now = getdate();
         $date = null;
         if ($d == 'now') {
             $date = time();
         } elseif ($d == 'today') {
             $date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
         } elseif ($d == 'monthstart') {
             $date = mktime(0, 0, 0, $now['mon'], 1, $now['year']);
         } elseif ($d == 'monthend') {
             $daysInMonth = date('t');
             $date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']);
         } elseif ($d == 'yearstart') {
             $date = mktime(0, 0, 0, 1, 1, $now['year']);
         } elseif ($d == 'yearend') {
             $date = mktime(0, 0, 0, 12, 31, $now['year']);
         } elseif ($d == 'custom') {
             $date = strtotime($this->initDate);
         }
         if ($date != null) {
             $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
         } else {
             $this->text = __('Unknown date');
         }
     }
     if ($view->isPostBack() && !empty($this->text)) {
         $date = strtotime($this->text);
         $this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
     }
     if ($firstTime) {
         $lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
         // map of the jscalendar supported languages
         $map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
         if (isset($map[$lang])) {
             $lang = $map[$lang];
         }
         $headers[] = 'javascript/jscalendar/calendar.js';
         if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
             $headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
         }
         $headers[] = 'javascript/jscalendar/calendar-setup.js';
         PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
         PageUtil::addVar('javascript', $headers);
     }
     $firstTime = false;
     $result = '';
     if ($this->useSelectionMode) {
         $hiddenInputField = str_replace(array('type="text"', ' *'), array('type="hidden"', ''), parent::render($view));
         $result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">';
         if ($this->text) {
             $result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat));
         } else {
             $result .= __('Select date');
         }
         $result .= '</span></div>';
         if ($this->mandatory && $this->mandatorysym) {
             $result .= '<span class="z-form-mandatory-flag">*</span>';
         }
     } else {
         $result .= '<span class="z-form-date" style="white-space: nowrap">';
         $result .= parent::render($view);
         $txt = __('Select date');
         $result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>";
     }
     // build jsCalendar script options
     $result .= "<script type=\"text/javascript\">\n            // <![CDATA[\n            Calendar.setup(\n            {\n                inputField : \"{$this->id}\",";
     if ($this->includeTime) {
         $this->initDate = str_replace('-', ',', $this->initDate);
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",\n                    showsTime      :    true,\n                    timeFormat     :    \"" . $i18n->locale->getTimeformat() . "\",\n                    singleClick    :    false,";
     } else {
         $result .= "\n                    ifFormat : \"" . $this->ifFormat . "\",";
     }
     if ($this->useSelectionMode) {
         $result .= "\n                    displayArea :    \"{$this->id}cal\",\n                    daFormat    :    \"{$this->daFormat}\",\n                    align       :    \"Bl\",\n                    singleClick :    true,";
     } else {
         $result .= "\n                    button : \"{$this->id}_img\",";
     }
     $result .= "\n                    firstDay: " . $i18n->locale->getFirstweekday() . "\n                }\n            );\n            // ]]>\n            </script>";
     return $result;
 }
Beispiel #4
0
 /**
  * Register a tab panel.
  *
  * Called by child panels to register themselves.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  * @param Zikula_Form_Plugin_TabbedPanel &$panel Panel object.
  * @param string $title Panel title.
  *
  * @return void
  */
 public function registerTabbedPanel(Zikula_Form_View $view, &$panel, $title)
 {
     $panel->panelSetId = $this->id;
     if (!$view->isPostBack()) {
         $panel->index = $this->registeredTabIndex++;
         $this->titles[] = $title;
     }
     $panel->selected = $this->selectedIndex == $panel->index;
 }