/**
  * Return's settings element html by given properties
  *
  * @param integer $id      Field id
  * @param string  $name    Html input name of the field
  * @param string  $title   Name/Title of the field
  * @param string  $value   Value of the field
  * @param string  $info    Info about the field
  * @param integer $type    Type of the settings field
  * @param string  $options options array
  * @param string  $special integer value of special field
  *
  * @return string Html of the setting field
  */
 function _getSettingProperties($id, $name, $title, $value, $info, $type, $options, $special)
 {
     global $_ARRAYLANG, $_CORELANG;
     $arrSetting = array();
     switch (intval($type)) {
         case 1:
             //input text
             $output = '<input type="text" style="width: 250px;" name="settings[' . $name . ']" value="' . $value . '" />';
             break;
         case 2:
             //textarea
             $output = '<textarea style="width: 250px; height: 60px;" name="settings[' . $name . ']">' . $value . '"</textarea>';
             break;
         case 3:
             //radio
             switch ($name) {
                 case 'placeData':
                 case 'placeDataHost':
                     $addBreak = true;
                     break;
                 default:
                     $addBreak = false;
                     break;
             }
             $arrOptions = array();
             if (!empty($options)) {
                 $arrOptions = explode(",", $options);
                 $first = true;
                 foreach ($arrOptions as $key => $label) {
                     $checked = $key + 1 == $value ? 'checked="checked"' : '';
                     $output .= !$first && $addBreak ? "<br />" : '';
                     $output .= '<label><input type="radio" ' . $checked . ' value="' . ($key + 1) . '" name="settings[' . $name . ']" />&nbsp;' . $_ARRAYLANG[$label] . '</label>';
                     $first = false;
                 }
             }
             break;
         case 4:
             //checkbox
             $arrOptions = array();
             if (!empty($options)) {
                 $arrOptions = explode(",", $options);
                 foreach ($arrOptions as $key => $label) {
                     $checked = $key == $value ? 'checked="checked"' : '';
                     $output .= '<label><input type="checkbox" ' . $checked . ' value="' . $key . '" name="settings[' . $name . ']" />&nbsp;' . $_ARRAYLANG[$label] . '</label>';
                 }
             } else {
                 $checked = $value == '1' ? 'checked="checked"' : '';
                 $value = '<input type="checkbox" ' . $checked . ' value="1" name="settings[' . $name . ']" />';
             }
             break;
         case 5:
             //dropdown
             if (!empty($options)) {
                 $options = explode(",", $options);
                 $output = '<select style="width: 252px;" name="settings[' . $name . ']" >';
                 foreach ($options as $key => $title) {
                     $checked = $key == $value ? 'selected="selected"' : '';
                     $output .= '<option ' . $checked . ' value="' . $key . '" />' . $_ARRAYLANG[$title] . '</option>';
                 }
                 $output .= '</select>';
             }
             if (!empty($special)) {
                 switch ($special) {
                     case 'getCategoryDorpdown':
                         $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true);
                         $objCategoryManager->getCategoryList();
                         $output = '<select style="width: 252px;" name="settings[' . $name . ']" >';
                         $output .= $objCategoryManager->getCategoryDropdown(intval($value), 1);
                         $output .= '</select>';
                         break;
                     case 'getPlaceDataDorpdown':
                         $objMediadirForms = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, 'MediaDir');
                         $objMediadirForms->getForms();
                         $objMediadirForms->listForms($objTpl, 4);
                         $output = $_ARRAYLANG['TXT_CALENDAR_SELECT_FORM_MEDIADIR'] . ": <br />";
                         $output .= '<select style="width: 252px;" name="settings[' . $name . ']" >';
                         $output .= $objMediadirForms->listForms($objTpl, 4, intval($value));
                         $output .= '</select>';
                         break;
                 }
             }
             break;
         case 6:
             //checkbox multi-select
             $arrOptions = array();
             if (!empty($options)) {
                 $arrOptions = explode(",", $options);
                 $arrValue = explode(',', $value);
                 foreach ($arrOptions as $key => $label) {
                     $checked = in_array($key, $arrValue) ? 'checked="checked"' : '';
                     $output .= '<label><input type="checkbox" ' . $checked . ' value="' . $key . '" name="settings[' . $name . '][]" />&nbsp;' . $_ARRAYLANG[$label] . '</label>';
                 }
             } else {
                 $checked = $value == '1' ? 'checked="checked"' : '';
                 $value = '<input type="checkbox" ' . $checked . ' value="1" name="settings[' . $name . '][]" />';
             }
             break;
         case 7:
             if ($special == 'listPreview') {
                 $output = "<div id='listPreview'></div>";
             } elseif ($special == 'detailPreview') {
                 $output = "<div id='detailPreview'></div>";
             }
             break;
     }
     if (!empty($info)) {
         $infobox = '&nbsp;<span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$info] . '</span>';
     } else {
         $infobox = '';
     }
     $arrSetting['output'] = $output;
     $arrSetting['infobox'] = $infobox;
     return $arrSetting;
 }
 /**
  * Do something after content is loaded from DB
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $mediadirCheck, $objTemplate, $_CORELANG, $objInit;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $mediadirCheck = array();
             for ($i = 1; $i <= 10; ++$i) {
                 if ($objTemplate->blockExists('mediadirLatest_row_' . $i)) {
                     array_push($mediadirCheck, $i);
                 }
             }
             if ($mediadirCheck || $objTemplate->blockExists('mediadirLatest')) {
                 $objInit->loadLanguageData('MediaDir');
                 $objMediadir = new MediaDirectory('', $this->getName());
                 $objTemplate->setVariable('TXT_MEDIADIR_LATEST', $_CORELANG['TXT_DIRECTORY_LATEST']);
             }
             if ($mediadirCheck) {
                 $objMediadir->getHeadlines($mediadirCheck);
             }
             if ($objTemplate->blockExists('mediadirLatest')) {
                 $objMediadirForms = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, 'MediaDir');
                 $foundOne = false;
                 foreach ($objMediadirForms->getForms() as $key => $arrForm) {
                     if ($objTemplate->blockExists('mediadirLatest_form_' . $arrForm['formCmd'])) {
                         $objMediadir->getLatestEntries($key, 'mediadirLatest_form_' . $arrForm['formCmd']);
                         $foundOne = true;
                     }
                 }
                 //for the backward compatibility
                 if (!$foundOne) {
                     $objMediadir->getLatestEntries();
                 }
             }
             break;
         default:
             break;
     }
 }