Ejemplo n.º 1
0
 public function confirmDelete()
 {
     $conf = new ilConfirmationGUI();
     $conf->setFormAction($this->ctrl->getFormAction($this));
     $conf->setHeaderText($this->pl->txt('msg_confirm_delete'));
     $conf->setConfirm($this->pl->txt('check_delete'), self::CMD_DELETE);
     $conf->setCancel($this->pl->txt('check_cancel'), self::CMD_INDEX);
     $this->tpl->setContent($conf->getHTML());
 }
Ejemplo n.º 2
0
 function _renderForm(&$page)
 {
     $pageName = $page->getAttribute('name');
     $tabPreview = array_slice($page->controller->_tabs, -2, 1);
     // can use either HTML_Template_Sigma or HTML_Template_ITX
     $tpl = new HTML_Template_ITX('./templates');
     // $tpl = new HTML_Template_Sigma('./templates');
     $tpl->loadTemplateFile('itdynamic.html');
     // on preview tab, add progress bar javascript and stylesheet
     if ($pageName == $tabPreview[0][0]) {
         $bar = $page->controller->createProgressBar();
         $tpl->setVariable(array('qf_style' => $bar->getStyle(), 'qf_script' => $bar->getScript()));
         $barElement = $page->getElement('progressBar');
         $barElement->setText($bar->toHtml());
     }
     $renderer = new HTML_QuickForm_Renderer_ITDynamic($tpl);
     $renderer->setElementBlock(array('buttons' => 'qf_buttons'));
     $page->accept($renderer);
     $tpl->show();
 }
Ejemplo n.º 3
0
 public static function carregarInterface($interface)
 {
     $base = APP . "view";
     if (strpos($interface, "_")) {
         $componente = substr($interface, 9, strpos($interface, "_") - 9);
         if (!file_exists("{$base}/{$interface}")) {
             $base = "Componentes/{$componente}/view";
         }
     } else {
         if ($interface) {
             $componente = substr($interface, 9, strlen($interface) - 9 - 5);
             if ($componente) {
                 $base = "Componentes/{$componente}/view";
             }
         }
     }
     if (!file_exists("{$base}/{$interface}")) {
         $base = APP . "view";
     }
     $view = new HTML_Template_ITX($base);
     $view->loadTemplateFile($interface);
     return $view;
 }
Ejemplo n.º 4
0
 /**
  * Returns the name of a block to use for element rendering
  * 
  * If a name was not explicitly set via setElementBlock(), it tries
  * the names '{prefix}_{element type}' and '{prefix}_{element}', where
  * prefix is either 'qf' or the name of the current group's block
  * 
  * @param HTML_QuickForm_element     form element being rendered
  * @access private
  * @return string    block name
  */
  function _matchBlock(&$element)
  {
      $name = $element->getName();
      $type = $element->getType();
      if (isset($this->_elementBlocks[$name]) && $this->_tpl->blockExists($this->_elementBlocks[$name])) {
          if (('group' == $type) || ($this->_elementBlocks[$name] . '_loop' != $this->_tpl->currentBlock)) {
              return $this->_elementBlocks[$name];
          }
      }
      if ('group' != $type && 'qf_main_loop' != $this->_tpl->currentBlock) {
          $prefix = substr($this->_tpl->currentBlock, 0, -5); // omit '_loop' postfix
      } else {
          $prefix = 'qf';
      }
      if ($this->_tpl->blockExists($prefix . '_' . $type)) {
          return $prefix . '_' . $type;
      } elseif ($this->_tpl->blockExists($prefix . '_' . $name)) {
          return $prefix . '_' . $name;
      } else {
          return $prefix . '_element';
      }
  }
 protected function chooseRole()
 {
     $this->tabs_gui->setSubTabActive('shib_role_assignment');
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $parser = new ilQueryParser($_SESSION['shib_role_ass']['search']);
     $parser->setMinWordLength(1, true);
     $parser->setCombination(QP_COMBINATION_AND);
     $parser->parse();
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($parser);
     $object_search->setFilter(array('role'));
     $res = $object_search->performSearch();
     $entries = $res->getEntries();
     include_once './Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php';
     $table = new ilRoleSelectionTableGUI($this, 'chooseRole');
     $table->setTitle($this->lng->txt('shib_role_selection'));
     $table->addMultiCommand('saveRoleSelection', $this->lng->txt('shib_choose_role'));
     $table->addCommandButton('roleAssignment', $this->lng->txt('cancel'));
     $table->parse($entries);
     $this->tpl->setContent($table->getHTML());
     return true;
 }
Ejemplo n.º 6
0
function parsePages($intElmntId, $strCommand)
{
    global $objLang, $_CLEAN_POST, $objLiveUser, $_CONF, $_PATHS, $DBAConn, $objMultiUpload;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $blnUiError = Request::get('err', 0);
    switch ($strCommand) {
        case CMD_LIST:
            $objTpl->loadTemplatefile("multiview.tpl.htm");
            $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsElements", "menu"));
            $objElement = Element::selectByPK($intElmntId);
            if (empty($intElmntId)) {
                $strElmntName = "Website";
            } else {
                if (is_object($objElement)) {
                    $strElmntName = $objElement->getName();
                } else {
                    $strElmntName = "";
                }
            }
            if (is_object($objElement) || empty($intElmntId)) {
                if (empty($intElmntId)) {
                    $objElements = Elements::getFromParent(0, false);
                } else {
                    $objElements = $objElement->getElements(false);
                }
                if (is_object($objElements)) {
                    //*** Initiate child element loop.
                    $listCount = 0;
                    $intPosition = request("pos");
                    $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
                    $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
                    $objElements->seek($intPosition);
                    //*** Loop through the elements.
                    foreach ($objElements as $objSubElement) {
                        //if (Permissions::hasElementPermission(SPINCMS_ELEMENTS_READ, $objSubElement)) {
                        $objTemplate = Template::selectByPK($objSubElement->getTemplateId(), array('name'));
                        $strMeta = $objLang->get("editedBy", "label") . " " . $objSubElement->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objSubElement->getModified());
                        $objTpl->setCurrentBlock("multiview-item");
                        if ($objSubElement->getTypeId() != ELM_TYPE_LOCKED) {
                            $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button"));
                            $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:PElement.duplicate({$objSubElement->getId()});");
                            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
                            $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PElement.remove({$objSubElement->getId()});");
                        }
                        $objTpl->setVariable("MULTIITEM_VALUE", $objSubElement->getId());
                        //if (Permissions::hasElementPermission(SPINCMS_ELEMENTS_WRITE, $objSubElement)) {
                        $objTpl->setVariable("MULTIITEM_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&eid={$objSubElement->getId()}&cmd=" . CMD_EDIT . "\"");
                        //} else {
                        //	$objTpl->setVariable("MULTIITEM_HREF", "");
                        //}
                        if ($objSubElement->getActive() < 1) {
                            $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\"");
                        }
                        $strValue = htmlspecialchars($objSubElement->getName());
                        $strShortValue = getShortValue($strValue, 50);
                        $intSize = strlen($strValue);
                        $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue);
                        $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : "");
                        $strTypeClass = "";
                        if ($objSubElement->getTypeId() == ELM_TYPE_FOLDER) {
                            $strTypeClass = "folder";
                        } else {
                            $objChildElements = $objSubElement->getElements();
                            if (is_object($objChildElements) && $objChildElements->count() > 0) {
                                switch ($objSubElement->getTypeId()) {
                                    case ELM_TYPE_DYNAMIC:
                                        $strTypeClass = "widget-dynamic";
                                        break;
                                    case ELM_TYPE_LOCKED:
                                        $strTypeClass = "widget-locked";
                                        break;
                                    default:
                                        $strTypeClass = "widget";
                                }
                            } else {
                                switch ($objSubElement->getTypeId()) {
                                    case ELM_TYPE_DYNAMIC:
                                        $strTypeClass = "element-dynamic";
                                        break;
                                    case ELM_TYPE_LOCKED:
                                        $strTypeClass = "element-locked";
                                        break;
                                    default:
                                        $strTypeClass = "element";
                                }
                            }
                        }
                        $objTpl->setVariable("MULTIITEM_TYPE_CLASS", $strTypeClass);
                        if (is_object($objTemplate)) {
                            $objTpl->setVariable("MULTIITEM_TYPE", ", " . $objTemplate->getName());
                        }
                        $objTpl->setVariable("MULTIITEM_META", $strMeta);
                        $objTpl->parseCurrentBlock();
                        $listCount++;
                        if ($listCount >= $_SESSION["listCount"]) {
                            break;
                        }
                        //}
                    }
                    //*** Render page navigation.
                    $pageCount = ceil($objElements->count() / $_SESSION["listCount"]);
                    if ($pageCount > 0) {
                        $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]);
                        $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0;
                        $nextPos = $intPosition + $_SESSION["listCount"] < $objElements->count() ? $intPosition + $_SESSION["listCount"] : $intPosition;
                        $objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount));
                        $objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button"));
                        $objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;pos={$previousPos}");
                        $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button"));
                        $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;pos={$nextPos}");
                        //*** Top page navigation.
                        for ($intCount = 0; $intCount < $pageCount; $intCount++) {
                            $objTpl->setCurrentBlock("multiview-pagenavitem-top");
                            $position = $intCount * $_SESSION["listCount"];
                            if ($intCount != $intPosition / $_SESSION["listCount"]) {
                                $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;pos={$position}\"");
                            }
                            $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1);
                            $objTpl->parseCurrentBlock();
                        }
                        //*** Bottom page navigation.
                        for ($intCount = 0; $intCount < $pageCount; $intCount++) {
                            $objTpl->setCurrentBlock("multiview-pagenavitem-bottom");
                            $position = $intCount * $_SESSION["listCount"];
                            if ($intCount != $intPosition / $_SESSION["listCount"]) {
                                $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;pos={$position}\"");
                            }
                            $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1);
                            $objTpl->parseCurrentBlock();
                        }
                    }
                }
            }
            //*** Render list action pulldown.
            if (!is_object($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) {
                $arrActions[$objLang->get("choose", "button")] = 0;
                $arrActions[$objLang->get("delete", "button") . "&nbsp;&nbsp;"] = "delete";
                $arrActions[$objLang->get("duplicate", "button") . "&nbsp;&nbsp;"] = "duplicate";
                $arrActions[$objLang->get("activate", "button") . "&nbsp;&nbsp;"] = "activate";
                $arrActions[$objLang->get("deactivate", "button") . "&nbsp;&nbsp;"] = "deactivate";
                if (is_object($objElement)) {
                    $arrActions[$objLang->get("export", "button") . "&nbsp;&nbsp;"] = "export";
                }
                foreach ($arrActions as $key => $value) {
                    $objTpl->setCurrentBlock("multiview-listactionitem");
                    $objTpl->setVariable("LIST_ACTION_TEXT", $key);
                    $objTpl->setVariable("LIST_ACTION_VALUE", $value);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Render the rest of the page.
            $objTpl->setCurrentBlock("multiview");
            $objTpl->setVariable("ACTIONS_OPEN", $objLang->get("pcmsOpenActionsMenu", "menu"));
            $objTpl->setVariable("ACTIONS_CLOSE", $objLang->get("pcmsCloseActionsMenu", "menu"));
            $objTpl->setVariable("LIST_LENGTH_HREF_10", "href=\"?list=10&amp;cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}\"");
            $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&amp;cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}\"");
            $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&amp;cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}\"");
            switch ($_SESSION["listCount"]) {
                case 10:
                    $objTpl->setVariable("LIST_LENGTH_HREF_10", "");
                    break;
                case 25:
                    $objTpl->setVariable("LIST_LENGTH_HREF_25", "");
                    break;
                case 100:
                    $objTpl->setVariable("LIST_LENGTH_HREF_100", "");
                    break;
            }
            $objTpl->setVariable("LIST_LENGTH_HREF", "&amp;cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}");
            if (!is_object($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) {
                $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label"));
                $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button"));
                $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:PElement.multiSelect()");
                $objTpl->setVariable("LIST_ACTION_ONCHANGE", "PElement.multiDo(this, this[this.selectedIndex].value)");
            }
            $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label"));
            if (!isset($objElement) || $objElement->getTypeId() != ELM_TYPE_DYNAMIC && $objElement->getTypeId() != ELM_TYPE_LOCKED) {
                $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newElement", "button"));
                $objDefaultLang = ContentLanguage::getDefault();
                if (!is_object($objDefaultLang)) {
                    $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "javascript:alert('" . $objLang->get("elementBeforeLanguage", "alert") . "')");
                } else {
                    $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_ADD);
                }
                $objTpl->setVariable("BUTTON_NEWFOLDER", $objLang->get("newFolder", "button"));
                $objTpl->setVariable("BUTTON_NEWFOLDER_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_ADD_FOLDER);
                if ($objLiveUser->checkRight($_CONF['app']['navRights'][NAV_PCMS_TEMPLATES] == true)) {
                    $objTpl->setVariable("BUTTON_EXPORT_ELEMENT", $objLang->get("export", "button"));
                    $objTpl->setVariable("BUTTON_EXPORT_ELEMENT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_EXPORT_ELEMENT);
                    $objTpl->setVariable("BUTTON_IMPORT_ELEMENT", $objLang->get("import", "button"));
                    $objTpl->setVariable("BUTTON_IMPORT_ELEMENT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_IMPORT_ELEMENT);
                }
            }
            if (!isset($objElement) || $objElement->getTypeId() != ELM_TYPE_LOCKED) {
                $objTpl->setVariable("BUTTON_NEWDYNAMIC", $objLang->get("newDynamic", "button"));
                $objTpl->setVariable("BUTTON_NEWDYNAMIC_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_ADD_DYNAMIC);
                if ($intElmntId > 0) {
                    $objElement = Element::selectByPK($intElmntId);
                    $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button"));
                    $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_EDIT);
                }
            }
            $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("elementsIn", "label") . " ");
            $objTpl->setVariable("SUBJECT_NAME", $strElmntName);
            $objTpl->setVariable("EID", $intElmntId);
            $objTpl->parseCurrentBlock();
            break;
        case CMD_REMOVE:
            if (strpos($intElmntId, ',') !== false) {
                //*** Multiple elements submitted.
                $arrElements = explode(',', $intElmntId);
                $objElements = Element::selectByPK($arrElements);
                $intParent = $objElements->current()->getParentId();
                foreach ($objElements as $objElement) {
                    $objElement->delete();
                }
            } else {
                //*** Single element submitted.
                $objElement = Element::selectByPK($intElmntId);
                $intParent = $objElement->getParentId();
                $objElement->delete();
            }
            //*** Redirect the page.
            $strReturnTo = request('returnTo');
            if (empty($strReturnTo)) {
                header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent);
                exit;
            } else {
                header("Location: " . Request::getURI() . $strReturnTo);
                exit;
            }
            break;
        case CMD_DUPLICATE:
            if (strpos($intElmntId, ',') !== false) {
                //*** Multiple elements submitted.
                $arrElements = explode(',', $intElmntId);
                $objElements = Element::selectByPK($arrElements);
                $intParent = $objElements->current()->getParentId();
                foreach ($objElements as $objElement) {
                    $objElement->setUsername($objLiveUser->getProperty("name"));
                    $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label"));
                    //*** Update the search index.
                    $objSearch = new Search();
                    $objSearch->updateIndex($objDuplicate->getId());
                }
            } else {
                //*** Single element submitted.
                $objElement = Element::selectByPK($intElmntId);
                $intParent = $objElement->getParentId();
                $objElement->setUsername($objLiveUser->getProperty("name"));
                $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label"));
                //*** Update the search index.
                $objSearch = new Search();
                $objSearch->updateIndex($objDuplicate->getId());
            }
            //*** Redirect the page.
            $strReturnTo = request('returnTo');
            if (empty($strReturnTo)) {
                header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent);
                exit;
            } else {
                header("Location: " . Request::getURI() . $strReturnTo);
                exit;
            }
            break;
        case CMD_ACTIVATE:
        case CMD_DEACTIVATE:
            if (strpos($intElmntId, ',') !== false) {
                //*** Multiple elements submitted.
                $arrElements = explode(',', $intElmntId);
                $objElements = Element::selectByPK($arrElements);
                $intParent = $objElements->current()->getParentId();
                foreach ($objElements as $objElement) {
                    if ($strCommand == CMD_ACTIVATE) {
                        $objElement->setActive(1);
                    } else {
                        $objElement->setActive(0);
                    }
                    $objElement->save();
                }
            } else {
                //*** Single element submitted.
                $objElement = Element::selectByPK($intElmntId);
                $intParent = $objElement->getParentId();
                if ($strCommand == CMD_ACTIVATE) {
                    $objElement->setActive(1);
                } else {
                    $objElement->setActive(0);
                }
                $objElement->save();
            }
            //*** Redirect the page.
            $strReturnTo = request('returnTo');
            if (empty($strReturnTo)) {
                header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent);
                exit;
            } else {
                header("Location: " . Request::getURI() . $strReturnTo);
                exit;
            }
            break;
        case CMD_ADD:
        case CMD_EDIT:
        case CMD_ADD_FOLDER:
        case CMD_ADD_DYNAMIC:
            $objTpl->loadTemplatefile("elementfields.tpl.htm");
            $blnError = false;
            $blnIsFolder = false;
            $blnIsDynamic = false;
            //*** Check the element type (element or folder)
            if ($strCommand == CMD_EDIT) {
                $objElement = Element::selectByPK($intElmntId);
                if (is_object($objElement) && $objElement->getTypeId() == ELM_TYPE_FOLDER) {
                    $blnIsFolder = true;
                } else {
                    if (is_object($objElement) && $objElement->getTypeId() == ELM_TYPE_DYNAMIC) {
                        $blnIsDynamic = true;
                    }
                }
            } else {
                if ($strCommand == CMD_ADD_FOLDER) {
                    $blnIsFolder = true;
                } else {
                    if ($strCommand == CMD_ADD_DYNAMIC) {
                        $blnIsDynamic = true;
                    }
                }
            }
            //*** Check if the rootfolder has been submitted.
            if ($strCommand == CMD_EDIT && $intElmntId == 0) {
                //*** Redirect to list mode.
                header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intElmntId);
                exit;
            }
            //*** Check if an invalid element has been submitted.
            if ($strCommand == CMD_EDIT && !is_object($objElement)) {
                //*** Redirect to list mode.
                header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=0");
                exit;
            }
            //*** Set section title.
            if ($blnIsFolder) {
                if ($strCommand == CMD_EDIT) {
                    $objTpl->setVariable("MAINTITLE", $objLang->get("folderDetailsFor", "label"));
                    $objTpl->setVariable("MAINSUB", $objElement->getName());
                } else {
                    $objTpl->setVariable("MAINTITLE", $objLang->get("folderDetails", "label"));
                }
            } else {
                if ($blnIsDynamic) {
                    if ($strCommand == CMD_EDIT) {
                        $objTpl->setVariable("MAINTITLE", $objLang->get("dynamicDetailsFor", "label"));
                        $objTpl->setVariable("MAINSUB", $objElement->getName());
                    } else {
                        $objTpl->setVariable("MAINTITLE", $objLang->get("dynamicDetails", "label"));
                    }
                } else {
                    if ($strCommand == CMD_EDIT) {
                        $objTpl->setVariable("MAINTITLE", $objLang->get("pageDetailsFor", "label"));
                        $objTpl->setVariable("MAINSUB", $objElement->getName());
                    } else {
                        $objTpl->setVariable("MAINTITLE", $objLang->get("pageDetails", "label"));
                    }
                }
            }
            //*** Post the element form if submitted.
            if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addElement") {
                //*** The element form has been posted.
                //*** Check sanitized input.
                if (is_null($_CLEAN_POST["frm_active"])) {
                    $objTpl->setVariable("ERROR_ACTIVE_ON", " error");
                    $objTpl->setVariable("ERROR_ACTIVE", $objLang->get("active", "formerror"));
                    $blnError = true;
                }
                if ($strCommand == CMD_ADD_FOLDER || $blnIsFolder) {
                    if (is_null($_CLEAN_POST["frm_ispage"])) {
                        $objTpl->setVariable("ERROR_ISPAGE_ON", " error");
                        $objTpl->setVariable("ERROR_ISPAGE", $objLang->get("isPage", "formerror"));
                        $blnError = true;
                    }
                }
                if ($strCommand == CMD_ADD_DYNAMIC || $blnIsDynamic) {
                    if (is_null($_CLEAN_POST["frm_feed"])) {
                        $objTpl->setVariable("ERROR_FEED_ON", " error");
                        $objTpl->setVariable("ERROR_FEED", $objLang->get("feed", "formerror"));
                        $blnError = true;
                    }
                    if (is_null($_CLEAN_POST["frm_feedpath"])) {
                        $objTpl->setVariable("ERROR_FEEDPATH_ON", " error");
                        $objTpl->setVariable("ERROR_FEEDPATH", $objLang->get("feedPath", "formerror"));
                        $blnError = true;
                    }
                    if (is_null($_CLEAN_POST["frm_maxitems"])) {
                        $objTpl->setVariable("ERROR_MAXITEMS_ON", " error");
                        $objTpl->setVariable("ERROR_MAXITEMS", $objLang->get("maxItems", "formerror"));
                        $blnError = true;
                    }
                }
                if (is_null($_CLEAN_POST["frm_name"])) {
                    $objTpl->setVariable("ERROR_NAME_ON", " error");
                    $objTpl->setVariable("ERROR_NAME", $objLang->get("templateName", "formerror"));
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_apiname"])) {
                    $objTpl->setVariable("ERROR_APINAME_ON", " error");
                    $objTpl->setVariable("ERROR_APINAME", $objLang->get("commonTypeWord", "formerror"));
                    $blnError = true;
                }
                /*
                if (is_null($_CLEAN_POST["frm_alias"])) {
                	$objTpl->setVariable("ERROR_ALIAS_ON", " error");
                	$objTpl->setVariable("ERROR_ALIAS", $objLang->get("commonTypeWord", "formerror"));
                	$blnError = true;
                }
                */
                if (is_null($_CLEAN_POST["frm_template"]) && !$blnIsFolder) {
                    $objTpl->setVariable("ERROR_TEMPLATE_ON", " error");
                    $objTpl->setVariable("ERROR_TEMPLATE", $objLang->get("commonTypeText", "formerror"));
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_description"])) {
                    $objTpl->setVariable("ERROR_NOTES_ON", " error");
                    $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror"));
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["dispatch"])) {
                    $blnError = true;
                }
                //*** Check element specific fields.
                //*** TODO!!
                if ($blnError === true) {
                    //*** Display global error.
                    if ($blnIsFolder) {
                        $objTpl->setVariable("FORM_ISPAGE_VALUE", isset($_POST["frm_ispage"]) && $_POST["frm_ispage"] == "on" ? "checked=\"checked\"" : "");
                    }
                    $objTpl->setVariable("FORM_ACTIVE_VALUE", isset($_POST["frm_active"]) && $_POST["frm_active"] == "on" ? "checked=\"checked\"" : "");
                    $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]);
                    $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]);
                    //$objTpl->setVariable("FORM_ALIAS_VALUE", $_POST["frm_alias"]);
                    if ($blnIsDynamic) {
                        $objTpl->setVariable("FORM_MAXITEMS_VALUE", $_POST["frm_maxitems"]);
                    }
                    $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]);
                    $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror"));
                    //*** Display element specific errors.
                    //*** TODO!!
                } else {
                    //*** Input is valid. Save the element.
                    if ($strCommand == CMD_EDIT) {
                        $objElement = Element::selectByPK($intElmntId);
                        $objParent = Element::selectByPK($objElement->getParentId());
                    } else {
                        $objParent = Element::selectByPK($_POST["eid"]);
                        $objPermissions = new ElementPermission();
                        if (is_object($objParent)) {
                            $objPermissions->setUserId($objParent->getPermissions()->getUserId());
                            $objPermissions->setGroupId($objParent->getPermissions()->getGroupId());
                        }
                        $objElement = new Element();
                        $objElement->setParentId($_POST["eid"]);
                        $objElement->setAccountId($_CONF['app']['account']->getId());
                        $objElement->setPermissions($objPermissions);
                    }
                    $objElement->setActive(empty($_CLEAN_POST["frm_active"]) ? 0 : 1);
                    $objElement->setIsPage(empty($_CLEAN_POST["frm_ispage"]) ? 0 : 1);
                    $objElement->setName($_CLEAN_POST["frm_name"]);
                    $objElement->setApiName($_CLEAN_POST["frm_apiname"]);
                    $objElement->setDescription($_CLEAN_POST["frm_description"]);
                    $objElement->setUsername($objLiveUser->getProperty("name"));
                    //*** Get remote settings.
                    $strServer = Setting::getValueByName('ftp_server');
                    $strUsername = Setting::getValueByName('ftp_username');
                    $strPassword = Setting::getValueByName('ftp_password');
                    $strRemoteFolder = Setting::getValueByName('ftp_remote_folder');
                    if ($blnIsFolder) {
                        $objElement->setTypeId(ELM_TYPE_FOLDER);
                    } else {
                        if ($blnIsDynamic) {
                            $objElement->setTypeId(ELM_TYPE_DYNAMIC);
                            $objElement->setTemplateId($_CLEAN_POST["frm_template"]);
                        } else {
                            $objElement->setTypeId(ELM_TYPE_ELEMENT);
                            $objElement->setTemplateId($_CLEAN_POST["frm_template"]);
                        }
                    }
                    $objElement->save();
                    if ($blnIsDynamic) {
                        $intFeedId = $_CLEAN_POST["frm_feed"];
                        if (empty($intFeedId)) {
                            $intFeedId = $objParent->getFeed()->getFeedId();
                        }
                        $objElementFeed = new ElementFeed();
                        $objElementFeed->setFeedId($intFeedId);
                        $objElementFeed->setFeedPath($_CLEAN_POST["frm_feedpath"]);
                        $objElementFeed->setMaxItems($_CLEAN_POST["frm_maxitems"]);
                        if ($_CLEAN_POST["frm_dynamic_alias_check"]) {
                            $objElementFeed->setAliasField($_CLEAN_POST["frm_dynamic_alias"]);
                        } else {
                            $objElementFeed->setAliasField("");
                        }
                        $objElement->setFeed($objElementFeed);
                    }
                    //*** Handle the publish values.
                    $objElement->clearSchedule();
                    $objSchedule = new ElementSchedule();
                    if (!empty($_CLEAN_POST["publish_start"])) {
                        $strDate = $_CLEAN_POST["publish_start_date"];
                        if (empty($strDate)) {
                            $strDate = strftime($_CONF['app']['universalDate']);
                        }
                        $strDate = Date::convertDate($strDate, $_CONF['app']['universalDate'], "%d %B %Y");
                        $strHour = empty($_CLEAN_POST["publish_start_hour"]) ? "00" : $_CLEAN_POST["publish_start_hour"];
                        $strMinute = empty($_CLEAN_POST["publish_start_minute"]) ? "00" : $_CLEAN_POST["publish_start_minute"];
                        $strDate = $strDate . " " . $strHour . ":" . $strMinute . ":00";
                        $objSchedule->setStartActive(1);
                        $objSchedule->setStartDate(Date::toMysql($strDate));
                    } else {
                        //*** If not set we set the date to 0. This is nessecary for the client side library,
                        $objSchedule->setStartActive(0);
                        $objSchedule->setStartDate(APP_DEFAULT_STARTDATE);
                    }
                    if (!empty($_CLEAN_POST["publish_end"])) {
                        $strDate = $_CLEAN_POST["publish_end_date"];
                        if (empty($strDate)) {
                            $strDate = strftime($_CONF['app']['universalDate']);
                        }
                        $strDate = Date::convertDate($strDate, $_CONF['app']['universalDate'], "%d %B %Y");
                        $strHour = empty($_CLEAN_POST["publish_end_hour"]) ? "00" : $_CLEAN_POST["publish_end_hour"];
                        $strMinute = empty($_CLEAN_POST["publish_end_minute"]) ? "00" : $_CLEAN_POST["publish_end_minute"];
                        $strDate = $strDate . " " . $strHour . ":" . $strMinute . ":00";
                        $objSchedule->setEndActive(1);
                        $objSchedule->setEndDate(Date::toMysql($strDate));
                    } else {
                        //*** If not set we set the date in the far future. This is nessecary for the client side library,
                        $objSchedule->setEndActive(0);
                        $objSchedule->setEndDate(APP_DEFAULT_ENDDATE);
                    }
                    $objElement->setSchedule($objSchedule);
                    //*** Handle the meta values.
                    if ($objElement->isPage()) {
                        $objElement->clearMeta();
                        $objElement->clearAliases();
                        $arrFields = array("title", "keywords", "description");
                        $objContentLangs = ContentLanguage::select();
                        foreach ($objContentLangs as $objContentLanguage) {
                            //*** Insert the value by language.
                            foreach ($arrFields as $value) {
                                $objMeta = new ElementMeta();
                                $arrCascades = explode(",", request("frm_meta_{$value}_cascades"));
                                $blnCascade = in_array($objContentLanguage->getId(), $arrCascades) ? 1 : 0;
                                $objMeta->setName($value);
                                $objMeta->setValue(request("frm_meta_{$value}_{$objContentLanguage->getId()}"));
                                $objMeta->setLanguageId($objContentLanguage->getId());
                                $objMeta->setCascade($blnCascade);
                                $objElement->setMeta($objMeta);
                            }
                            $objAlias = new Alias();
                            $arrCascades = explode(",", request("frm_meta_alias_cascades"));
                            $blnCascade = in_array($objContentLanguage->getId(), $arrCascades) ? 1 : 0;
                            $objAlias->setAlias(request("frm_meta_alias_{$objContentLanguage->getId()}"));
                            $objAlias->setLanguageId($objContentLanguage->getId());
                            $objAlias->setCascade($blnCascade);
                            $objElement->setAlias($objAlias);
                        }
                    }
                    //*** Handle element values.
                    if (!$blnIsFolder) {
                        //*** Cache and clear values.
                        $objCachedFields = $objElement->getFields(true);
                        $objElement->clearFields();
                        $objElement->clearLanguages();
                        //*** Insert the active flag by language.
                        $arrActives = explode(",", request("language_actives"));
                        $objContentLangs = ContentLanguage::select();
                        foreach ($objContentLangs as $objContentLanguage) {
                            $blnActive = in_array($objContentLanguage->getId(), $arrActives) ? true : false;
                            $objElement->setLanguageActive($objContentLanguage->getId(), $blnActive);
                            if ($strCommand == CMD_ADD && !isset($_POST['language_actives'])) {
                                $objElement->setLanguageActive($objContentLanguage->getId(), true);
                            }
                        }
                        //*** Cache to handsome array.
                        $arrFieldCache = array();
                        foreach ($objCachedFields as $objCacheField) {
                            foreach ($objContentLangs as $objContentLanguage) {
                                if ($objCacheField->getTypeId() == FIELD_TYPE_FILE || $objCacheField->getTypeId() == FIELD_TYPE_IMAGE) {
                                    $arrFieldCache[$objCacheField->getTemplateFieldId()][$objContentLanguage->getId()] = $objCacheField->value[$objContentLanguage->getId()]->getValue();
                                }
                            }
                        }
                        foreach ($_REQUEST as $key => $value) {
                            //*** Template Fields.
                            if (substr($key, 0, 4) == "efv_") {
                                //*** Get the template Id from the request
                                $intTemplateFieldId = substr($key, 4);
                                //*** Is the Id really an Id?
                                if (is_numeric($intTemplateFieldId)) {
                                    $objTemplateField = TemplateField::selectByPK($intTemplateFieldId);
                                    $objField = new ElementField();
                                    $objField->setElementId($objElement->getId());
                                    $objField->setTemplateFieldId($intTemplateFieldId);
                                    $objField->save();
                                    //*** Get the cascade value for the currentfield.
                                    $arrCascades = explode(",", request("efv_{$intTemplateFieldId}_cascades"));
                                    //*** Loop through the languages to insert the value by language.
                                    $objContentLangs = ContentLanguage::select();
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        //*** Insert the value by language.
                                        in_array($objContentLanguage->getId(), $arrCascades) ? $blnCascade = true : ($blnCascade = false);
                                        $strValue = request("efv_{$intTemplateFieldId}_{$objContentLanguage->getId()}");
                                        //*** Check for certain type requirements.
                                        switch ($objTemplateField->getTypeId()) {
                                            case FIELD_TYPE_FILE:
                                            case FIELD_TYPE_IMAGE:
                                                $cacheFileValue = "";
                                                $arrCurrent = is_array($strValue) ? $strValue : array();
                                                foreach ($arrCurrent as $value) {
                                                    if (!empty($value)) {
                                                        $arrFile = explode(":", $value);
                                                        if (count($arrFile) > 1 && !empty($arrFile[1])) {
                                                            $cacheFileValue .= $value . "\n";
                                                            //*** Remove file from cache.
                                                            if (isset($arrFieldCache[$intTemplateFieldId]) && isset($arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()])) {
                                                                $arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()] = str_replace($value, "", $arrFieldCache[$intTemplateFieldId][$objContentLanguage->getId()]);
                                                            }
                                                        }
                                                    }
                                                }
                                                //*** Multifile SWFUpload
                                                foreach ($arrCurrent as $value) {
                                                    if (!empty($value)) {
                                                        $arrFile = explode(":", $value);
                                                        if (count($arrFile) > 1 && empty($arrFile[1])) {
                                                            //*** Any image manipulation?
                                                            $strLocalValue = ImageField::filename2LocalName($arrFile[0]);
                                                            $objImageField = new ImageField($intTemplateFieldId);
                                                            $arrSettings = $objImageField->getSettings();
                                                            if (count($arrSettings) > 1) {
                                                                foreach ($arrSettings as $key => $arrSetting) {
                                                                    $strFileName = FileIO::add2Base($strLocalValue, $arrSetting['key']);
                                                                    if (copy($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strFileName)) {
                                                                        if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSetting['width']) || !empty($arrSetting['height']))) {
                                                                            //*** Check if the image has the right size.
                                                                            $blnResize = true;
                                                                            $arrSize = getimagesize($_PATHS['upload'] . $strFileName);
                                                                            if ($arrSize !== false) {
                                                                                if ($arrSize[0] == $arrSetting['width'] && $arrSize[1] == $arrSetting['height']) {
                                                                                    //*** Skip image resize.
                                                                                    $blnResize = false;
                                                                                }
                                                                            }
                                                                            //*** Resize the image.
                                                                            if ($blnResize) {
                                                                                $intQuality = empty($arrSetting['quality']) ? 75 : $arrSetting['quality'];
                                                                                ImageResizer::resize($_PATHS['upload'] . $strFileName, $arrSetting['width'], $arrSetting['height'], $arrSetting['scale'], $intQuality, true, NULL, false, $arrSetting['grayscale']);
                                                                            }
                                                                        }
                                                                        //*** Move file to remote server.
                                                                        $objUpload = new SingleUpload();
                                                                        if (!$objUpload->moveToFTP($strFileName, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
                                                                            Log::handleError("File could not be moved to remote server. " . $objUpload->errorMessage());
                                                                        }
                                                                    }
                                                                }
                                                                //*** Move original file.
                                                                if (rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strLocalValue)) {
                                                                    $objUpload = new SingleUpload();
                                                                    if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
                                                                        Log::handleError("File could not be moved to remote server. " . $objUpload->errorMessage());
                                                                    }
                                                                }
                                                                //*** Unlink original file.
                                                                @unlink($_PATHS['upload'] . $arrFile[0]);
                                                            } else {
                                                                if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSettings[0]['width']) || !empty($arrSettings[0]['height']))) {
                                                                    $strFileName = FileIO::add2Base($strLocalValue, $arrSettings[0]['key']);
                                                                    //*** Resize the image.
                                                                    if (rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strFileName)) {
                                                                        //*** Check if the image has the right size.
                                                                        $blnResize = true;
                                                                        $arrSize = getimagesize($_PATHS['upload'] . $strFileName);
                                                                        if ($arrSize !== false) {
                                                                            if ($arrSize[0] == $arrSettings[0]['width'] && $arrSize[1] == $arrSettings[0]['height']) {
                                                                                //*** Skip image resize.
                                                                                $blnResize = false;
                                                                            }
                                                                        }
                                                                        if ($blnResize) {
                                                                            $intQuality = empty($arrSettings[0]['quality']) ? 75 : $arrSettings[0]['quality'];
                                                                            ImageResizer::resize($_PATHS['upload'] . $strFileName, $arrSettings[0]['width'], $arrSettings[0]['height'], $arrSettings[0]['scale'], $intQuality, true, NULL, false, $arrSettings[0]['grayscale']);
                                                                        }
                                                                        //*** Move file to remote server.
                                                                        $objUpload = new SingleUpload();
                                                                        if (!$objUpload->moveToFTP($strFileName, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
                                                                            Log::handleError("File could not be moved to remote server.");
                                                                        }
                                                                    }
                                                                }
                                                                //*** Move original file.
                                                                if (file_exists($_PATHS['upload'] . $arrFile[0]) && rename($_PATHS['upload'] . $arrFile[0], $_PATHS['upload'] . $strLocalValue)) {
                                                                    //*** Move file to remote server.
                                                                    $objUpload = new SingleUpload();
                                                                    if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
                                                                        Log::handleError("File could not be moved to remote server.");
                                                                    }
                                                                }
                                                                //*** Unlink original file.
                                                                @unlink($_PATHS['upload'] . $arrFile[0]);
                                                            }
                                                            //*** Set file value.
                                                            $cacheFileValue .= $arrFile[0] . ":" . $strLocalValue . "\n";
                                                        }
                                                    }
                                                }
                                                //*** Check newly uploaded files.
                                                $strFiles = "efv_{$intTemplateFieldId}_{$objContentLanguage->getId()}_new";
                                                $fileValue = $cacheFileValue;
                                                if (isset($_FILES[$strFiles])) {
                                                    if ($objTemplateField->getTypeId() == FIELD_TYPE_FILE) {
                                                        $objValue = $objTemplateField->getValueByName("tfv_file_extension");
                                                        $strExtensions = is_object($objValue) ? $objValue->getValue() : "";
                                                        if (!empty($strExtensions)) {
                                                            $strExtensions = str_replace("%s", Setting::getValueByName('file_upload_extensions'), $strExtensions);
                                                            $objMultiUpload->setExtensions(explode(" ", strtolower($strExtensions)));
                                                        } else {
                                                            $objMultiUpload->setExtensions(explode(" ", strtolower(Setting::getValueByName('file_upload_extensions'))));
                                                        }
                                                    } else {
                                                        $objMultiUpload->setExtensions(explode(" ", strtolower(Setting::getValueByName('image_upload_extensions'))));
                                                    }
                                                    $objMultiUpload->setTempNames($_FILES[$strFiles]['tmp_name']);
                                                    $objMultiUpload->setOriginalNames($_FILES[$strFiles]['name']);
                                                    $objMultiUpload->setErrors($_FILES[$strFiles]['error']);
                                                    $objMultiUpload->uploadFiles();
                                                    if ($objMultiUpload->getTotalFiles() == $objMultiUpload->getSuccessFiles()) {
                                                        //*** Everything is cool.
                                                        $localValues = $objMultiUpload->getLocalNames();
                                                        //*** Any image manipulation?
                                                        $blnResize = false;
                                                        $objImageField = new ImageField($intTemplateFieldId);
                                                        $arrSettings = $objImageField->getSettings();
                                                        if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSettings[0]['width']) || !empty($arrSettings[0]['height']))) {
                                                            $blnResize = true;
                                                        }
                                                        foreach ($objMultiUpload->getOriginalNames() as $subkey => $subvalue) {
                                                            if (!empty($subvalue)) {
                                                                $fileValue .= $subvalue . ":" . $localValues[$subkey] . "\n";
                                                                //*** Check if the image has the right size.
                                                                if ($blnResize) {
                                                                    $arrSize = getimagesize($_PATHS['upload'] . $localValues[$subkey]);
                                                                    if ($arrSize !== false) {
                                                                        if ($arrSize[0] == $arrSettings[0]['width'] && $arrSize[1] == $arrSettings[0]['height']) {
                                                                            //*** Skip image resize.
                                                                            $blnResize = false;
                                                                        }
                                                                    }
                                                                }
                                                                //*** Resize the image.
                                                                if ($blnResize) {
                                                                    $intQuality = empty($arrSettings[0]['quality']) ? 75 : $arrSettings[0]['quality'];
                                                                    ImageResizer::resize($_PATHS['upload'] . $localValues[$subkey], $arrSettings[0]['width'], $arrSettings[0]['height'], $arrSettings[0]['scale'], $intQuality, true, NULL, false, $arrSettings[0]['grayscale']);
                                                                }
                                                            }
                                                        }
                                                        //*** Move file to remote server.
                                                        if (!$objMultiUpload->moveToFTP($strServer, $strUsername, $strPassword, $strRemoteFolder)) {
                                                            $strMessage = $objLang->get("moveToFTP", "alert");
                                                            $fileValue = $cacheFileValue;
                                                        }
                                                    } else {
                                                        $strMessage = $objMultiUpload->errorMessage() . "<br />";
                                                        $strMessage .= "Files: " . $objMultiUpload->getTotalFiles() . " and Success: " . $objMultiUpload->getSuccessFiles();
                                                    }
                                                }
                                                $strValue = $fileValue;
                                                break;
                                            case FIELD_TYPE_BOOLEAN:
                                                if ($strValue == "1") {
                                                    $strValue = "true";
                                                }
                                                if (empty($strValue)) {
                                                    $strValue = "false";
                                                }
                                                break;
                                        }
                                        $objValue = $objField->getNewValueObject();
                                        $objValue->setValue($strValue);
                                        $objValue->setLanguageId($objContentLanguage->getId());
                                        $objValue->setCascade($blnCascade ? 1 : 0);
                                        $objField->setValueObject($objValue);
                                    }
                                }
                            }
                            //*** Feed Fields.
                            if (substr($key, 0, 4) == "tpf_") {
                                //*** Get the template Id from the request
                                $intTemplateFieldId = substr($key, 4);
                                //*** Is the Id really an Id?
                                if (is_numeric($intTemplateFieldId)) {
                                    //*** Get the cascade value for the currentfield.
                                    $arrCascades = explode(",", request("efv_{$intTemplateFieldId}_cascades"));
                                    //*** Loop through the languages to insert the value by language.
                                    $objContentLangs = ContentLanguage::select();
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        //*** Insert the value by language.
                                        in_array($objContentLanguage->getId(), $arrCascades) ? $blnCascade = true : ($blnCascade = false);
                                        $strValue = request("tpf_{$intTemplateFieldId}_{$objContentLanguage->getId()}");
                                        $objFeedField = new ElementFieldFeed();
                                        $objFeedField->setElementId($objElement->getId());
                                        $objFeedField->setTemplateFieldId($intTemplateFieldId);
                                        $objFeedField->setFeedPath(str_replace("----", "/", $strValue));
                                        $objFeedField->setXpath(str_replace("----", "/", $strValue));
                                        $objFeedField->setLanguageId($objContentLanguage->getId());
                                        $objFeedField->setCascade($blnCascade ? 1 : 0);
                                        $objFeedField->save();
                                    }
                                }
                            }
                        }
                        //*** Remove deleted files.
                        $objFtp = new FTP($strServer, NULL, NULL, true);
                        $objFtp->login($strUsername, $strPassword);
                        $objFtp->pasv(true);
                        foreach ($arrFieldCache as $intTemplateFieldId => $arrLanguage) {
                            foreach ($arrLanguage as $strValue) {
                                $arrValues = explode("\n", $strValue);
                                foreach ($arrValues as $value) {
                                    if (!empty($value)) {
                                        //*** Find file name.
                                        $arrFile = explode(":", $value);
                                        if (count($arrFile) > 1 && count($arrFile) < 3) {
                                            //*** Check if the file is used by other elements.
                                            if (!ElementField::fileHasDuplicates($value)) {
                                                //*** Remove file.
                                                $strFile = $strRemoteFolder . $arrFile[1];
                                                $objFtp->delete($strFile);
                                                //*** Resized variations?
                                                $objImageField = new ImageField($intTemplateFieldId);
                                                $arrSettings = $objImageField->getSettings();
                                                foreach ($arrSettings as $key => $arrSetting) {
                                                    if (!empty($arrSetting['width']) || !empty($arrSetting['height'])) {
                                                        //*** Remove file.
                                                        $strFile = $strRemoteFolder . FileIO::add2Base($arrFile[1], $arrSetting['key']);
                                                        $objFtp->delete($strFile);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //*** Update the search index.
                        $objSearch = new Search();
                        $objSearch->updateIndex($objElement->getId());
                        //*** Clear cache if caching enabled.
                        $objElement->clearCache($objFtp);
                        $objElement->clearZeroCache($objFtp);
                    } else {
                        //*** Activate all languages for the folder type.
                        $objContentLangs = ContentLanguage::select();
                        foreach ($objContentLangs as $objContentLanguage) {
                            $objElement->setLanguageActive($objContentLanguage->getId(), true);
                        }
                    }
                    //*** Redirect the page.
                    if (empty($strMessage)) {
                        $intForward = $objElement->getParentId();
                        $varCmd = CMD_LIST;
                        $intForwardToElement = null;
                        $varValue = Setting::getValueByName("edit_after_save");
                        if ($varValue && $strCommand == CMD_ADD) {
                            $intForwardToElement = $objElement->getId();
                            $varCmd = CMD_EDIT;
                        } else {
                            if (Setting::getValueByName('next_after_save') && $intForward > 0) {
                                //*** Try to get first child element
                                if (Setting::getValueByName("next_is_child")) {
                                    $objChildren = $objElement->getElements();
                                    if (is_object($objChildren) && $objChildren->count() > 0) {
                                        $objChild = $objChildren->current();
                                        $intForwardToElement = $objChild->getId();
                                        if ($intForwardToElement > 0) {
                                            $varCmd = CMD_EDIT;
                                        }
                                    }
                                }
                                //*** Get next sibling
                                $objParent = Element::selectByPK($objElement->getParentId());
                                $objChildren = $objParent->getElements();
                                $blnBreak = false;
                                if (is_object($objChildren) && is_null($intForwardToElement)) {
                                    foreach ($objChildren as $objChild) {
                                        if ($blnBreak) {
                                            $intForwardToElement = $objChild->getId();
                                            $varCmd = CMD_EDIT;
                                            break;
                                        }
                                        if ($objElement->getId() == $objChild->getId()) {
                                            $blnBreak = true;
                                        }
                                    }
                                }
                            }
                        }
                        if (!empty($intForwardToElement) && $intForwardToElement !== 0) {
                            $intForward = $intForwardToElement;
                        }
                        header("Location: " . Request::getUri() . "/?cid=" . $_POST["cid"] . "&cmd=" . $varCmd . "&eid=" . $intForward);
                        exit;
                    } else {
                        $_SESSION['uiError'] = $strMessage;
                        header("Location: " . Request::getUri() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_EDIT . "&eid=" . $objElement->getId() . "&err=1");
                        exit;
                    }
                }
            }
            //*** Parse the page.
            $objElement = Element::selectByPK($intElmntId);
            //*** Errors.
            if ($blnUiError) {
                $objTpl->setCurrentBlock("error-main");
                $objTpl->setVariable("ERROR_MAIN", $_SESSION['uiError']);
                $objTpl->parseCurrentBlock();
            }
            //*** Render the template pulldown.
            if ($blnIsFolder) {
                $objTpl->setCurrentBlock("headertitel_simple");
                $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label"));
                $objTpl->parseCurrentBlock();
                $objTemplates = NULL;
            } else {
                $objTpl->setCurrentBlock("headertitel_simple");
                $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label"));
                $objTpl->parseCurrentBlock();
                if (is_object($objElement)) {
                    if ($strCommand == CMD_EDIT) {
                        $objTemplate = Template::selectByPK($objElement->getTemplateId());
                        $objTemplates = new DBA__Collection();
                        $objTemplates->addObject($objTemplate);
                    } else {
                        $objTemplates = $objElement->getSubTemplates();
                    }
                } else {
                    $strSql = sprintf("SELECT * FROM pcms_template WHERE parentId = '0' AND accountId = '%s'", $_CONF['app']['account']->getId());
                    $objTemplates = Template::select($strSql);
                }
            }
            if (is_object($objTemplates)) {
                foreach ($objTemplates as $objTemplate) {
                    $objTpl->setCurrentBlock("list_template");
                    $objTpl->setVariable("TEMPLATELIST_VALUE", $objTemplate->getId());
                    $objTpl->setVariable("TEMPLATELIST_TEXT", $objTemplate->getName());
                    $objTpl->parseCurrentBlock();
                }
                //*** Render fields if there is only one template.
                if ($objTemplates->count() == 1 || $strCommand == CMD_EDIT) {
                    $strLanguageBlock = $blnIsDynamic ? "feed.list_language" : "list_language";
                    $intDefaultLanguage = ContentLanguage::getDefault()->getId();
                    $intSelectLanguage = $intDefaultLanguage;
                    $objContentLangs = ContentLanguage::select();
                    foreach ($objContentLangs as $objContentLanguage) {
                        $objTpl->setCurrentBlock($strLanguageBlock);
                        $objTpl->setVariable("LANGUAGELIST_VALUE", $objContentLanguage->getId());
                        if ($intDefaultLanguage == $objContentLanguage->getId()) {
                            $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName() . " (" . $objLang->get("default", "label") . ")");
                        } else {
                            $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName());
                        }
                        if ($intSelectLanguage == $objContentLanguage->getId()) {
                            $objTpl->setVariable("LANGUAGELIST_SELECTED", " selected=\"selected\"");
                        }
                        $objTpl->parseCurrentBlock();
                    }
                    $objTemplates->rewind();
                    $objFields = $objTemplates->current()->getFields();
                    $objTpl->setVariable("LABEL_ELEMENT_FIELDS", $objLang->get("elementFields", "label"));
                    $strFields = "";
                    if (!$blnIsDynamic) {
                        foreach ($objFields as $objField) {
                            $objFieldTpl = new HTML_Template_ITX($_PATHS['templates']);
                            $objFieldTpl->loadTemplatefile("elementfield.tpl.htm");
                            //*** Get the field value from the element.
                            $strValue = "";
                            if (is_object($objElement)) {
                                $strValue = $objElement->getValueByTemplateField($objField->getId());
                            }
                            $strDescription = $objField->getDescription();
                            //*** Get the field type object.
                            $objType = TemplateFieldType::selectByPK($objField->getTypeId());
                            $intMaxFileCount = null;
                            switch ($objField->getTypeId()) {
                                case FIELD_TYPE_DATE:
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.date', 'elementfield_date.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.{$objType->getInput()}.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId(), true);
                                            $strValue = Date::fromMysql($_CONF['app']['universalDate'], $strValue);
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", htmlspecialchars($strValue));
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    $objValue = $objField->getValueByName("tfv_field_format");
                                    $strFormatValue = is_object($objValue) ? $objValue->getValue() : "";
                                    $objFieldTpl->setCurrentBlock("field.date");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_DATE_FORMAT", $strFormatValue);
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_LARGETEXT:
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.simpletext', 'elementfield_textarea.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.simpletext.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()));
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    //*** Calculate and set the textarea height.
                                    $minHeight = 115;
                                    $maxHeight = 400;
                                    $intHeight = $minHeight;
                                    $objValue = $objField->getValueByName("tfv_field_max_characters");
                                    $strMaxChar = is_object($objValue) ? $objValue->getValue() : "";
                                    if (!empty($strMaxChar) && is_numeric($strMaxChar)) {
                                        $intHeight = ($strMaxChar - 500) * 0.05 + $minHeight;
                                        if ($intHeight < $minHeight) {
                                            $intHeight = $minHeight;
                                        }
                                        if ($intHeight > $maxHeight) {
                                            $intHeight = $maxHeight;
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.simpletext");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    $objFieldTpl->setVariable("FIELD_HEIGHT", "{$intHeight}px");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_SELECT_LIST_SINGLE:
                                case FIELD_TYPE_SELECT_LIST_MULTI:
                                    if ($objField->getTypeId() == FIELD_TYPE_SELECT_LIST_SINGLE) {
                                        $objDefaultValue = $objField->getValueByName("tfv_list_default");
                                        $objValue = $objField->getValueByName("tfv_list_value");
                                        $strFieldClass = "select-one";
                                        $strMultiple = "";
                                    } else {
                                        $objDefaultValue = $objField->getValueByName("tfv_multilist_default");
                                        $objValue = $objField->getValueByName("tfv_multilist_value");
                                        $strFieldClass = "select-multiple";
                                        $strMultiple = "multiple=\"multiple\"";
                                    }
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.select', 'elementfield_selectlist.tpl.htm');
                                    $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : "";
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.select.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        //*** Determine the selected value for the list.
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId());
                                        } else {
                                            $strValue = NULL;
                                        }
                                        if (!empty($strValue) || !is_null($strValue)) {
                                            //*** Do Nothing.
                                        } elseif (!empty($strTemplValue)) {
                                            $strValue = $strTemplValue;
                                        }
                                        $arrDefaultValue = explode("\n", $strValue);
                                        $arrValue = array();
                                        foreach ($arrDefaultValue as $value) {
                                            $value = trim($value);
                                            if (!empty($value)) {
                                                array_push($arrValue, $value);
                                            }
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", implode(",", $arrValue));
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    //*** Render options for the list.
                                    $strListValue = is_object($objValue) ? $objValue->getValue() : "";
                                    $arrValues = explode("\n", $strListValue);
                                    foreach ($arrValues as $value) {
                                        if (!empty($value)) {
                                            //*** Determine if we have a label.
                                            $arrValue = explode(":", $value);
                                            if (count($arrValue) > 1) {
                                                $optionLabel = trim($arrValue[0]);
                                                $optionValue = trim($arrValue[1]);
                                            } else {
                                                $optionLabel = trim($value);
                                                $optionValue = trim($value);
                                            }
                                            $objFieldTpl->setCurrentBlock("field.select.option");
                                            $objFieldTpl->setVariable("FIELD_VALUE", $optionValue);
                                            $objFieldTpl->setVariable("FIELD_TEXT", xhtmlsave($optionLabel));
                                            $objFieldTpl->parseCurrentBlock();
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.select");
                                    $objFieldTpl->setVariable("FIELD_SELECT_SIZE", 1);
                                    $objFieldTpl->setVariable("FIELD_CLASS", $strFieldClass);
                                    $objFieldTpl->setVariable("FIELD_MULTIPLE", $strMultiple);
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_CHECK_LIST_SINGLE:
                                case FIELD_TYPE_CHECK_LIST_MULTI:
                                    if ($objField->getTypeId() == FIELD_TYPE_CHECK_LIST_SINGLE) {
                                        $objDefaultValue = $objField->getValueByName("tfv_list_default");
                                        $objValue = $objField->getValueByName("tfv_list_value");
                                        $strType = "radio";
                                    } else {
                                        $objDefaultValue = $objField->getValueByName("tfv_multilist_default");
                                        $objValue = $objField->getValueByName("tfv_multilist_value");
                                        $strType = "checkbox";
                                    }
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.check', 'elementfield_checklist.tpl.htm');
                                    $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : "";
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.check.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        //*** Determine the selected value for the list.
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId());
                                        } else {
                                            $strValue = NULL;
                                        }
                                        if (!empty($strValue) || !is_null($strValue)) {
                                            //*** Do Nothing.
                                        } elseif (!empty($strTemplValue)) {
                                            $strValue = $strTemplValue;
                                        }
                                        $arrDefaultValue = explode("\n", $strValue);
                                        $arrValue = array();
                                        foreach ($arrDefaultValue as $value) {
                                            $value = trim($value);
                                            if (!empty($value)) {
                                                array_push($arrValue, $value);
                                            }
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", implode(",", $arrValue));
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    //*** Render options for the list.
                                    $strListValue = is_object($objValue) ? $objValue->getValue() : "";
                                    $arrValues = explode("\n", $strListValue);
                                    $intCount = 0;
                                    foreach ($arrValues as $value) {
                                        if (!empty($value)) {
                                            //*** Determine if we have a label.
                                            $arrValue = explode(":", $value);
                                            if (count($arrValue) > 1) {
                                                $optionLabel = trim($arrValue[0]);
                                                $optionValue = trim($arrValue[1]);
                                            } else {
                                                $optionLabel = trim($value);
                                                $optionValue = trim($value);
                                            }
                                            $objFieldTpl->setCurrentBlock("field.check.item");
                                            $objFieldTpl->setVariable("SUBFIELD_TYPE", $strType);
                                            $objFieldTpl->setVariable("SUBFIELD_VALUE", $optionValue);
                                            $objFieldTpl->setVariable("SUBFIELD_TEXT", $optionLabel);
                                            $objFieldTpl->setVariable("SUBFIELD_ID", "efv_{$objField->getId()}_sub_{$intCount}");
                                            $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                            $objFieldTpl->parseCurrentBlock();
                                            $intCount++;
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.list");
                                    $objFieldTpl->setVariable("SUBFIELD_TYPE", $strType);
                                    $objFieldTpl->parseCurrentBlock();
                                    $objFieldTpl->setCurrentBlock("field.check");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_IMAGE:
                                    $objValue = $objField->getValueByName('tfv_image_count');
                                    $intMaxFileCount = is_object($objValue) ? $objValue->getValue() : 10000;
                                    $strCurrentTitle = $objLang->get("imagesCurrent", "label");
                                    $strNewTitle = $objLang->get("imagesNew", "label");
                                    $strThumbPath = Setting::getValueByName("web_server") . Setting::getValueByName("file_folder");
                                    $strUploadPath = Request::getURI() . $_CONF['app']['baseUri'] . "files/";
                                case FIELD_TYPE_FILE:
                                    if (!isset($intMaxFileCount)) {
                                        $objValue = $objField->getValueByName('tfv_file_count');
                                        $intMaxFileCount = is_object($objValue) ? $objValue->getValue() : 10000;
                                        $strCurrentTitle = $objLang->get("filesCurrent", "label");
                                        $strNewTitle = $objLang->get("filesNew", "label");
                                        $strThumbPath = Setting::getValueByName("web_server") . Setting::getValueByName("file_folder");
                                        $strUploadPath = Request::getURI() . $_CONF['app']['baseUri'] . "files/";
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                    }
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.file', 'elementfield_file.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId(), true);
                                        } else {
                                            $strValue = "";
                                        }
                                        $intFileCount = 0;
                                        if (!empty($strValue)) {
                                            $arrValues = explode("\n", $strValue);
                                            foreach ($arrValues as $value) {
                                                if (!empty($value)) {
                                                    $arrValue = explode(":", $value);
                                                    if (count($arrValue) > 1) {
                                                        $strValue = $arrValue[1];
                                                        $strLabel = $arrValue[0];
                                                        //*** Media library item?
                                                        if (count($arrValue) > 2) {
                                                            $strValue = $arrValue[1] . ":" . $arrValue[2];
                                                        }
                                                    } else {
                                                        $strValue = $arrValue[0];
                                                        $strLabel = $arrValue[0];
                                                    }
                                                    $intFileCount++;
                                                    $objFieldTpl->setCurrentBlock("field.file.edit");
                                                    $objFieldTpl->setVariable("FIELD_LANGUAGE_ID_COUNT", "efv_{$objField->getId()}_{$objContentLanguage->getId()}_{$intFileCount}");
                                                    $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                                    $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", "{$strLabel}:{$strValue}");
                                                    $objFieldTpl->parseCurrentBlock();
                                                }
                                            }
                                        }
                                        $objFieldTpl->setCurrentBlock("field.file.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_CURRENT_FILES", $intFileCount);
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ALTTEXT_VALUE", "");
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    $intFileCount = 0;
                                    if (!empty($strValue)) {
                                        $arrValues = explode("\n", $strValue);
                                        foreach ($arrValues as $value) {
                                            if (!empty($value)) {
                                                $arrValue = explode(":", $value);
                                                if (count($arrValue) > 1) {
                                                    $strValue = $arrValue[1];
                                                    $strLabel = $arrValue[0];
                                                } else {
                                                    $strValue = $arrValue[0];
                                                    $strLabel = $arrValue[0];
                                                }
                                                if ($objField->getTypeId() == FIELD_TYPE_IMAGE) {
                                                    $objFieldTpl->setCurrentBlock("thumbnail");
                                                    $objFieldTpl->setVariable("FIELD_ORIGINAL_VALUE", $strLabel);
                                                    $objFieldTpl->setVariable("FIELD_VALUE", $strValue);
                                                    $objFieldTpl->parseCurrentBlock();
                                                }
                                                $objFieldTpl->setCurrentBlock("field.{$objType->getInput()}.edit");
                                                $objFieldTpl->setVariable("FIELD_FILE_ID", "efv_{$objField->getId()}");
                                                $objFieldTpl->setVariable("FIELD_ORIGINAL_VALUE", $strLabel);
                                                $objFieldTpl->setVariable("FIELD_VALUE", $strValue);
                                                $objFieldTpl->parseCurrentBlock();
                                                $intFileCount++;
                                            }
                                        }
                                    }
                                    //*** Parse the rest of the block.
                                    $objFieldTpl->setCurrentBlock("field.file.select-type.library");
                                    $objFieldTpl->setVariable("LABEL_LIBRARY", $objLang->get("pcmsInlineStorage", "menu"));
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    $objFieldTpl->parseCurrentBlock();
                                    $objFieldTpl->setCurrentBlock("field.file.select-type.upload");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    $objFieldTpl->parseCurrentBlock();
                                    $objFieldTpl->setCurrentBlock("field.file");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    $objFieldTpl->setVariable("FIELD_BROWSE_NAME", $objLang->get("browseImage", "label"));
                                    //$objFieldTpl->setVariable("FIELD_ALT_NAME", $objLang->get("altImage", "label"));
                                    $objFieldTpl->setVariable("FIELD_CURRENT_FILES", $intFileCount);
                                    $objFieldTpl->setVariable("FIELD_MAX_FILES", $intMaxFileCount);
                                    $objFieldTpl->setVariable("FIELD_THUMB_PATH", $strThumbPath);
                                    $objFieldTpl->setVariable("FIELD_UPLOAD_PATH", $strUploadPath);
                                    $objFieldTpl->setVariable("FIELD_MAX_CHAR", 60);
                                    $objFieldTpl->setVariable("STORAGE_ITEMS", StorageItems::getFolderListHTML());
                                    $objFieldTpl->setVariable("LABEL_CHOOSE_FOLDER", $objLang->get("chooseFolder", "label"));
                                    $objFieldTpl->setVariable("FIELD_HEADER_CURRENT", $strCurrentTitle);
                                    $objFieldTpl->setVariable("FIELD_HEADER_NEW", $strNewTitle);
                                    $objFieldTpl->setVariable("FIELD_LABEL_REMOVE", $objLang->get("delete", "button"));
                                    $objFieldTpl->setVariable("FIELD_LABEL_CANCEL", strtolower($objLang->get("cancel", "button")));
                                    $objFieldTpl->setVariable("FIELD_LABEL_ALT", $objLang->get("alttag", "button"));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElementField)) {
                                        $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                    }
                                    if ($objField->getTypeId() == FIELD_TYPE_FILE) {
                                        $objValue = $objField->getValueByName("tfv_file_extension");
                                        $strExtensions = is_object($objValue) ? $objValue->getValue() : "";
                                        if (!empty($strExtensions)) {
                                            $strExtensions = str_replace("%s", Setting::getValueByName('file_upload_extensions'), $strExtensions);
                                        } else {
                                            $strExtensions = strtolower(Setting::getValueByName('file_upload_extensions'));
                                        }
                                    } else {
                                        $strExtensions = strtolower(Setting::getValueByName('image_upload_extensions'));
                                    }
                                    $objFieldTpl->setVariable("FIELD_FILE_TYPE", "*" . implode("; *", explode(" ", $strExtensions)));
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_SMALLTEXT:
                                case FIELD_TYPE_NUMBER:
                                case FIELD_TYPE_LINK:
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.text', 'elementfield_text.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.text.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()));
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                        if ($objField->getTypeId() == FIELD_TYPE_LINK) {
                                            $objFieldTpl->setCurrentBlock("field.text.elementvalue");
                                            $objFieldTpl->setVariable("FIELD_ELEMENT_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                            $objFieldTpl->setVariable("ELEMENT_FIELD_ID", "efv_{$objField->getId()}");
                                            $objFieldTpl->setVariable("FIELD_CLASS", "deeplink");
                                            $elementTrail = Element::generateElementTrailString($strValue);
                                            $objFieldTpl->setVariable("FIELD_ELEMENT_VALUE", htmlentities($elementTrail));
                                            $objFieldTpl->parseCurrentBlock();
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.text");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_MOVABLECANVAS_COORDINATES:
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.mccoordinates', 'elementfield_mccoordinates.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.mccoordinates.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()));
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    $objFieldTpl->setCurrentBlock("field.mccoordinates");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    $objFieldTpl->setVariable("MC-API-ID", $objField->getValueByName("tfv_field_api_key")->getValue());
                                    $objFieldTpl->setVariable("MC-MAP-ID", $objField->getValueByName("tfv_field_map_key")->getValue());
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_SIMPLETEXT:
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.simpletext', 'elementfield_simpletext.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.simpletext.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = htmlspecialchars($objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId()));
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    //*** Calculate and set the textarea height.
                                    $minHeight = 115;
                                    $maxHeight = 400;
                                    $intHeight = $minHeight;
                                    $objValue = $objField->getValueByName("tfv_field_max_characters");
                                    $strMaxChar = is_object($objValue) ? $objValue->getValue() : "";
                                    if (!empty($strMaxChar) && is_numeric($strMaxChar)) {
                                        $intHeight = ($strMaxChar - 500) * 0.05 + $minHeight;
                                        if ($intHeight < $minHeight) {
                                            $intHeight = $minHeight;
                                        }
                                        if ($intHeight > $maxHeight) {
                                            $intHeight = $maxHeight;
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.simpletext");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    $objFieldTpl->setVariable("FIELD_HEIGHT", "{$intHeight}px");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_USER:
                                    $strFieldClass = "select-one";
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.select', 'elementfield_selectlist.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.select.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        //*** Determine the selected value for the list.
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId());
                                        } else {
                                            $strValue = "";
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    //*** Render options for the list.
                                    global $objLiveAdmin;
                                    $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId())));
                                    $objUsers = $objLiveAdmin->getUsers($filters);
                                    if (is_array($objUsers)) {
                                        foreach ($objUsers as $objUser) {
                                            $objFieldTpl->setCurrentBlock("field.select.option");
                                            $objFieldTpl->setVariable("FIELD_VALUE", $objUser["perm_user_id"]);
                                            $objFieldTpl->setVariable("FIELD_TEXT", xhtmlsave($objUser["handle"]));
                                            $objFieldTpl->parseCurrentBlock();
                                        }
                                    }
                                    $objFieldTpl->setCurrentBlock("field.select");
                                    $objFieldTpl->setVariable("FIELD_SELECT_SIZE", 1);
                                    $objFieldTpl->setVariable("FIELD_CLASS", $strFieldClass);
                                    $objFieldTpl->setVariable("FIELD_MULTIPLE", "");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                                case FIELD_TYPE_BOOLEAN:
                                    $objDefaultValue = $objField->getValueByName("tfv_boolean_default");
                                    $strTemplValue = is_object($objDefaultValue) ? $objDefaultValue->getValue() : "";
                                    $objFieldTpl->addBlockfile('ELEMENT_FIELD', 'field.checkbox', 'elementfield_checkbox.tpl.htm');
                                    foreach ($objContentLangs as $objContentLanguage) {
                                        $objFieldTpl->setCurrentBlock("field.checkbox.value");
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_ID", "efv_{$objField->getId()}_{$objContentLanguage->getId()}");
                                        if (is_object($objElement)) {
                                            $strValue = $objElement->getValueByTemplateField($objField->getId(), $objContentLanguage->getId());
                                        } else {
                                            $strValue = NULL;
                                        }
                                        if (!empty($strValue) || !is_null($strValue)) {
                                            //*** Do Nothing.
                                        } elseif (!empty($strTemplValue)) {
                                            $strValue = $strTemplValue;
                                        }
                                        $objFieldTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                        $objFieldTpl->parseCurrentBlock();
                                    }
                                    $objFieldTpl->setCurrentBlock("field.checkbox");
                                    $objFieldTpl->setVariable("FIELD_ID", "efv_{$objField->getId()}");
                                    if ($objField->getRequired()) {
                                        $objFieldTpl->setVariable("FIELD_REQUIRED", "* ");
                                    }
                                    $objFieldTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                                    $objFieldTpl->setVariable("FIELD_VALUE", $strValue);
                                    if (!empty($strDescription)) {
                                        $objFieldTpl->setVariable("FIELD_DESCRIPTION", $objField->getDescription());
                                    }
                                    if (is_object($objElement)) {
                                        $objElementField = $objElement->getFieldByTemplateField($objField->getId());
                                        if (is_object($objElementField)) {
                                            $objFieldTpl->setVariable("FIELD_CASCADES", implode(",", $objElementField->getCascades()));
                                        }
                                    }
                                    $objFieldTpl->parseCurrentBlock();
                                    break;
                            }
                            $strFields .= $objFieldTpl->get();
                        }
                    }
                    if (!empty($strFields)) {
                        $objTpl->setVariable("ELEMENT_FIELDS", $strFields);
                    }
                    if (!$blnIsDynamic) {
                        $objTpl->setVariable("LABEL_LANGUAGE", $objLang->get("language", "form"));
                        $objTpl->setVariable("ACTIVE_LANGUAGE", $intDefaultLanguage);
                        $objTpl->setVariable("DEFAULT_LANGUAGE", $intDefaultLanguage);
                    } else {
                        $objTpl->setCurrentBlock("feedlanguage");
                        $objTpl->setVariable("LABEL_LANGUAGE", $objLang->get("language", "form"));
                        $objTpl->setVariable("ACTIVE_LANGUAGE", $intDefaultLanguage);
                        $objTpl->setVariable("DEFAULT_LANGUAGE", $intDefaultLanguage);
                        $objTpl->parseCurrentBlock();
                    }
                    //*** Meta tab.
                    if (is_object($objElement) && $objElement->isPage()) {
                        $objTpl->setCurrentBlock("meta-title");
                        $objTpl->setVariable("HEADER", $objLang->get("meta", "label"));
                        $objTpl->parseCurrentBlock();
                        $objTpl->setCurrentBlock("description-meta");
                        $objTpl->setVariable("LABEL", $objLang->get("metaInfo", "form"));
                        $objTpl->parseCurrentBlock();
                        //*** Meta specific labels
                        $objTpl->setVariable("LABEL_META_ALIAS", $objLang->get("alias", "form"));
                        $objTpl->setVariable("LABEL_META_TITLE", $objLang->get("metaTitle", "label"));
                        $objTpl->setVariable("LABEL_META_KEYWORDS", $objLang->get("metaKeywords", "label"));
                        $objTpl->setVariable("LABEL_META_DESCRIPTION", $objLang->get("metaDescription", "label"));
                        $objTpl->setVariable("META_KEYWORDS_NOTE", $objLang->get("metaKeywords", "tip"));
                        $objTpl->setVariable("META_DESCRIPTION_NOTE", $objLang->get("metaDescription", "tip"));
                        $objTpl->setVariable("META_ALIAS_NOTE", $objLang->get("alias", "tip"));
                        $objTpl->setVariable("ACTIVE_META_LANGUAGE", $intSelectLanguage);
                        $objTpl->setVariable("DEFAULT_META_LANGUAGE", $intDefaultLanguage);
                        $objTpl->setVariable("LABEL_META_LANGUAGE", $objLang->get("language", "form"));
                        //*** Meta languages
                        $objContentLangs = ContentLanguage::select();
                        foreach ($objContentLangs as $objContentLanguage) {
                            $objTpl->setCurrentBlock("list_meta-language");
                            $objTpl->setVariable("LANGUAGELIST_VALUE", $objContentLanguage->getId());
                            if ($intDefaultLanguage == $objContentLanguage->getId()) {
                                $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName() . " (" . $objLang->get("default", "label") . ")");
                            } else {
                                $objTpl->setVariable("LANGUAGELIST_TEXT", $objContentLanguage->getName());
                            }
                            if ($intSelectLanguage == $objContentLanguage->getId()) {
                                $objTpl->setVariable("LANGUAGELIST_SELECTED", " selected=\"selected\"");
                            }
                            $objTpl->parseCurrentBlock();
                        }
                        //*** Meta language values.
                        foreach ($objContentLangs as $objContentLanguage) {
                            $strValue = $strCommand != CMD_ADD ? $objElement->getAlias($objContentLanguage->getId()) : '';
                            $objTpl->setCurrentBlock("field.meta_alias.value");
                            $objTpl->setVariable("FIELD_ALIAS_ID", "frm_meta_alias_{$objContentLanguage->getId()}");
                            $objTpl->setVariable("FIELD_ALIAS_VALUE", $strValue);
                            $objTpl->parseCurrentBlock();
                            $objMeta = is_object($objElement) && $strCommand != CMD_ADD ? $objElement->getMeta($objContentLanguage->getId()) : NULL;
                            $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "title") : "";
                            $objTpl->setCurrentBlock("field.meta_title.value");
                            $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_title_{$objContentLanguage->getId()}");
                            $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                            $objTpl->parseCurrentBlock();
                            $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "keywords") : "";
                            $objTpl->setCurrentBlock("field.meta_keywords.value");
                            $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_keywords_{$objContentLanguage->getId()}");
                            $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                            $objTpl->parseCurrentBlock();
                            $strValue = is_object($objMeta) ? $objMeta->getValueByValue("name", "description") : "";
                            $objTpl->setCurrentBlock("field.meta_description.value");
                            $objTpl->setVariable("FIELD_LANGUAGE_ID", "frm_meta_description_{$objContentLanguage->getId()}");
                            $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                            $objTpl->parseCurrentBlock();
                        }
                        //*** Meta language cascades.
                        if ($strCommand != CMD_ADD) {
                            $objTpl->setVariable("META_ALIAS_CASCADES", implode(",", Alias::getCascades($objElement->getId())));
                            $objTpl->setVariable("META_TITLE_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "title")));
                            $objTpl->setVariable("META_KEYWORDS_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "keywords")));
                            $objTpl->setVariable("META_DESCRIPTION_CASCADES", implode(",", ElementMeta::getCascades($objElement->getId(), "description")));
                        }
                    }
                }
                //*** Feeds if dynamic.
                if ($blnIsDynamic) {
                    if ($strCommand == CMD_EDIT) {
                        $objElementFeed = $objElement->getFeed();
                        $objFeed = Feed::selectByPK($objElementFeed->getFeedId());
                        $objFeeds = new DBA__Collection();
                        $objFeeds->addObject($objFeed);
                        $objParent = Element::selectByPK($objElement->getParentId());
                    } else {
                        $objFeeds = Feed::select();
                        $objParent = Element::selectByPK($intElmntId);
                    }
                    if (isset($objParent) && $objParent->getTypeId() == ELM_TYPE_DYNAMIC) {
                        $objNodes = $objParent->getFeed()->getStructuredNodes();
                        $objTpl->setCurrentBlock("list_feedpath");
                        $objTpl->setVariable("VALUE", "");
                        $objTpl->setVariable("TEXT", "Basepath");
                        $objTpl->parseCurrentBlock();
                        $objTpl->setCurrentBlock("list_feedpath");
                        $objTpl->setVariable("VALUE", "");
                        $objTpl->setVariable("TEXT", "-------------");
                        $objTpl->parseCurrentBlock();
                        if (count($objNodes) > 0) {
                            foreach ($objNodes as $objSubElement) {
                                $objTpl->setCurrentBlock("list_feedpath");
                                $objTpl->setVariable("VALUE", $objSubElement->getName());
                                $objTpl->setVariable("TEXT", $objSubElement->getName());
                                $objTpl->parseCurrentBlock();
                            }
                        }
                    } else {
                        if (is_object($objFeeds)) {
                            foreach ($objFeeds as $objFeed) {
                                $objTpl->setCurrentBlock("list_feed");
                                $objTpl->setVariable("FEEDLIST_VALUE", $objFeed->getId());
                                $objTpl->setVariable("FEEDLIST_TEXT", $objFeed->getName());
                                $objTpl->parseCurrentBlock();
                            }
                        }
                    }
                    if ($strCommand == CMD_EDIT) {
                        $blnDynamicAlias = false;
                        $objFeedFields = $objElementFeed->getStructuredNodes();
                        foreach ($objFeedFields as $objFeedField) {
                            $objTpl->setCurrentBlock("list_feed_field");
                            $objTpl->setVariable("FEEDLIST_VALUE", $objFeedField->getName());
                            $objTpl->setVariable("FEEDLIST_TEXT", $objFeedField->getName());
                            if ($objElementFeed->getAliasField() == $objFeedField->getName()) {
                                $objTpl->setVariable("FEEDLIST_SELECTED", "selected=\"selected\"");
                                $blnDynamicAlias = true;
                            }
                            $objTpl->parseCurrentBlock();
                        }
                        if ($blnDynamicAlias) {
                            $objTpl->setVariable("FORM_DYNAMIC_ALIAS_VALUE", "checked=\"checked\"");
                        }
                        $objTpl->setVariable("FORM_MAXITEMS_VALUE", $objElementFeed->getMaxItems());
                        //*** Template fields.
                        foreach ($objFields as $objField) {
                            foreach ($objContentLangs as $objContentLanguage) {
                                $objTpl->setCurrentBlock("feed.field.value");
                                $objTpl->setVariable("FIELD_LANGUAGE_ID", "tpf_{$objField->getId()}_{$objContentLanguage->getId()}");
                                if (is_object($objElement)) {
                                    $strValue = htmlspecialchars($objElement->getFeedValueByTemplateField($objField->getId(), $objContentLanguage->getId()));
                                } else {
                                    $strValue = "";
                                }
                                $objTpl->setVariable("FIELD_LANGUAGE_VALUE", $strValue);
                                $objTpl->parseCurrentBlock();
                            }
                            $objTpl->setCurrentBlock("feed.field");
                            $objTpl->setVariable("FIELD_ID", "tpf_{$objField->getId()}");
                            $objTpl->setVariable("FIELD_NAME", html_entity_decode($objField->getName()));
                            if (is_object($objElement)) {
                                $objFeedField = $objElement->getFeedFieldByTemplateField($objField->getId());
                                if (is_object($objFeedField)) {
                                    $objTpl->setVariable("FIELD_CASCADES", implode(",", $objFeedField->getCascades()));
                                }
                            }
                            $objTpl->parseCurrentBlock();
                        }
                        //*** Feed fields.
                        $objFeedFields = $objElementFeed->getStructuredNodes();
                        $strFields = renderRecursiveFeedFields($objFeedFields);
                        $objTpl->setCurrentBlock("feed.tag");
                        $objTpl->setVariable("FEEDFIELDS", $strFields);
                        $objTpl->parseCurrentBlock();
                    }
                }
            }
            //*** Render the element form.
            $objTpl->setCurrentBlock("description-details");
            $objTpl->setVariable("LABEL", $objLang->get("requiredFields", "form"));
            $objTpl->parseCurrentBlock();
            $objTpl->setVariable("LABEL_ACTIVE", $objLang->get("active", "form"));
            $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form"));
            $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form"));
            //$objTpl->setVariable("LABEL_ALIAS", $objLang->get("alias", "form"));
            $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip"));
            //$objTpl->setVariable("ALIAS_NOTE", $objLang->get("alias", "tip"));
            $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button"));
            if (isset($objElement) && $objElement->getTypeId() == ELM_TYPE_LOCKED) {
                $objTpl->setVariable("DISABLED_SAVE", "disabled=\"disabled\"");
            }
            if ($blnIsFolder) {
                $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("folderName", "form"));
                $objTpl->setVariable("LABEL_ISPAGE", $objLang->get("pageContainer", "form"));
                if ($blnError === false && is_object($objElement)) {
                    $objTpl->setVariable("FORM_ISPAGE_VALUE", $objElement->getIsPage() ? "checked=\"checked\"" : "");
                }
            } else {
                $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("elementName", "form"));
                $objTpl->setVariable("LABEL_TEMPLATENAME", $objLang->get("template", "form"));
                if ($blnIsDynamic) {
                    if (isset($objParent) && $objParent->getTypeId() == ELM_TYPE_DYNAMIC) {
                        $objTpl->setVariable("LABEL_FEEDPATH", $objLang->get("basepath", "form"));
                    } else {
                        $objTpl->setVariable("LABEL_FEEDNAME", $objLang->get("feed", "form"));
                    }
                    $objTpl->setVariable("LABEL_MAXITEMS", $objLang->get("maxItems", "form"));
                }
            }
            //*** Predefine schedule variables.
            $intStartHour = 8;
            $intStartMinute = 0;
            $intEndHour = 17;
            $intEndMinute = 0;
            //*** Insert values if action is edit.
            if ($strCommand == CMD_EDIT) {
                if ($blnError === false) {
                    $objTpl->setVariable("FORM_ACTIVE_VALUE", $objElement->getActive() ? "checked=\"checked\"" : "");
                    $objTpl->setVariable("FORM_NAME_VALUE", str_replace("\"", "&quot;", $objElement->getName()));
                    $objTpl->setVariable("FORM_APINAME_VALUE", $objElement->getApiname());
                    //$objTpl->setVariable("FORM_ALIAS_VALUE", $objElement->getAlias());
                    $objTpl->setVariable("FORM_NOTES_VALUE", $objElement->getDescription());
                }
                $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$objElement->getParentId()}&amp;cmd=" . CMD_LIST);
                $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$objElement->getParentId()}&amp;cmd=" . CMD_LIST);
                if (!$blnIsFolder && $objElement->getTypeId() != ELM_TYPE_DYNAMIC) {
                    $objTpl->setVariable("ACTIVES_LANGUAGE", implode(",", $objElement->getLanguageActives()));
                }
                //*** Publish specific values.
                $objSchedule = $objElement->getSchedule();
                if ($objSchedule->getStartActive()) {
                    $strValue = Date::fromMysql("%d %B %Y", $objSchedule->getStartDate());
                    $objTpl->setVariable("START_DATE_DISPLAY", empty($strValue) ? "&nbsp;" : $strValue);
                    $objTpl->setVariable("START_DATE_VALUE", Date::fromMysql($_CONF['app']['universalDate'], $objSchedule->getStartDate()));
                    $strValue = Date::fromMysql("%H", $objSchedule->getStartDate());
                    if (!empty($strValue)) {
                        $intStartHour = $strValue;
                    }
                    $strValue = Date::fromMysql("%M", $objSchedule->getStartDate());
                    if (!empty($strValue)) {
                        $intStartMinute = $strValue;
                    }
                    $objTpl->setVariable("START_DATE_ACTIVE", "checked=\"checked\"");
                } else {
                    $objTpl->setVariable("START_DATE_DISPLAY", "&nbsp;");
                }
                if ($objSchedule->getEndActive()) {
                    $strValue = Date::fromMysql("%d %B %Y", $objSchedule->getEndDate());
                    $objTpl->setVariable("END_DATE_DISPLAY", empty($strValue) ? "&nbsp;" : $strValue);
                    $objTpl->setVariable("END_DATE_VALUE", Date::fromMysql($_CONF['app']['universalDate'], $objSchedule->getEndDate()));
                    $strValue = Date::fromMysql("%H", $objSchedule->getEndDate());
                    if (!empty($strValue)) {
                        $intEndHour = $strValue;
                    }
                    $strValue = Date::fromMysql("%M", $objSchedule->getEndDate());
                    if (!empty($strValue)) {
                        $intEndMinute = $strValue;
                    }
                    $objTpl->setVariable("END_DATE_ACTIVE", "checked=\"checked\"");
                } else {
                    $objTpl->setVariable("END_DATE_DISPLAY", "&nbsp;");
                }
            } else {
                if ($blnError === false) {
                    if (Setting::getValueByName('elmnt_active_state') == 1) {
                        $objTpl->setVariable("FORM_ACTIVE_VALUE", "checked=\"checked\"");
                    }
                }
                $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_LIST);
                $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_LIST);
                //*** Publish specific values.
                $objTpl->setVariable("START_DATE_DISPLAY", "&nbsp;");
                $objTpl->setVariable("END_DATE_DISPLAY", "&nbsp;");
            }
            //*** Render tabs.
            if (is_object($objTemplates) && ($objTemplates->count() == 1 || $strCommand == CMD_EDIT)) {
                if (!$blnIsFolder) {
                    //*** Fields tab.
                    $objTpl->setCurrentBlock("field-title");
                    $objTpl->setVariable("HEADER", $objLang->get("fields", "label"));
                    $objTpl->parseCurrentBlock();
                    $objTpl->setCurrentBlock("description-fields");
                    $objTpl->setVariable("LABEL", $objLang->get("requiredFields", "form"));
                    $objTpl->parseCurrentBlock();
                    //*** Set all language as active by default for a new element
                    if ($strCommand == CMD_ADD) {
                        $objContentLangs = ContentLanguage::select();
                        $aActiveLanguages = array();
                        foreach ($objContentLangs as $objContentLang) {
                            $aActiveLanguages[] = $objContentLang->getId();
                        }
                        $objTpl->setVariable("ACTIVES_LANGUAGE", implode(",", $aActiveLanguages));
                    }
                }
                //*** Permissions tab.
                //				$objTpl->setCurrentBlock("permission-title");
                //				$objTpl->setVariable("HEADER", $objLang->get("permissions", "label"));
                //				$objTpl->parseCurrentBlock();
                //				$objTpl->setCurrentBlock("description-permission");
                //				$objTpl->setVariable("LABEL", $objLang->get("permissionInfo", "form"));
                //				$objTpl->parseCurrentBlock();
            }
            //*** Publish tab.
            $objTpl->setCurrentBlock("publish-title");
            $objTpl->setVariable("HEADER", $objLang->get("publish", "label"));
            $objTpl->parseCurrentBlock();
            $objTpl->setCurrentBlock("description-publish");
            $objTpl->setVariable("LABEL", $objLang->get("publishInfo", "form"));
            $objTpl->parseCurrentBlock();
            //*** Publish specific labels
            $objTpl->setVariable("LABEL_START_DATE", $objLang->get("startDate", "label"));
            $objTpl->setVariable("LABEL_END_DATE", $objLang->get("endDate", "label"));
            $objTpl->setVariable("LABEL_DATE", $objLang->get("date", "label"));
            $objTpl->setVariable("LABEL_TIME", $objLang->get("time", "label"));
            foreach (range(0, 23) as $hour) {
                $objTpl->setCurrentBlock("date.start.hour");
                $objTpl->setVariable("VALUE", $hour);
                $objTpl->setVariable("LABEL", str_pad($hour, 2, 0, STR_PAD_LEFT));
                if (trim($intStartHour) == $hour) {
                    $objTpl->setVariable("SELECTED", "selected=\"selected\"");
                }
                $objTpl->parseCurrentBlock();
            }
            foreach (range(0, 45, 15) as $minute) {
                $objTpl->setCurrentBlock("date.start.minute");
                $objTpl->setVariable("VALUE", $minute);
                $objTpl->setVariable("LABEL", str_pad($minute, 2, 0, STR_PAD_LEFT));
                if (trim($intStartMinute) == $minute) {
                    $objTpl->setVariable("SELECTED", "selected=\"selected\"");
                }
                $objTpl->parseCurrentBlock();
            }
            foreach (range(0, 23) as $hour) {
                $objTpl->setCurrentBlock("date.end.hour");
                $objTpl->setVariable("VALUE", $hour);
                $objTpl->setVariable("LABEL", str_pad($hour, 2, 0, STR_PAD_LEFT));
                if (trim($intEndHour) == $hour) {
                    $objTpl->setVariable("SELECTED", "selected=\"selected\"");
                }
                $objTpl->parseCurrentBlock();
            }
            foreach (range(0, 45, 15) as $minute) {
                $objTpl->setCurrentBlock("date.end.minute");
                $objTpl->setVariable("VALUE", $minute);
                $objTpl->setVariable("LABEL", str_pad($minute, 2, 0, STR_PAD_LEFT));
                if (trim($intEndMinute) == $minute) {
                    $objTpl->setVariable("SELECTED", "selected=\"selected\"");
                }
                $objTpl->parseCurrentBlock();
            }
            $objTpl->setVariable("LANG", strtolower($objLang->get("abbr")));
            //*** Render the element form.
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button"));
            $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS);
            $objTpl->setVariable("CMD", $strCommand);
            $objTpl->setVariable("EID", $intElmntId);
            break;
        case CMD_EXPORT_ELEMENT:
            $objTpl->loadTemplatefile("export.tpl.htm");
            $arrElementIds = NULL;
            // export via selection of (multiple) elements
            if (isset($_GET['sel'])) {
                $arrElementIds = explode(',', $intElmntId);
                $objChild = Element::selectByPK($arrElementIds[0]);
                $objElement = Element::selectByPK($objChild->getParentId());
            } else {
                $objElement = Element::selectByPK($intElmntId);
            }
            //*** Set section title.
            $objTpl->setVariable("MAINTITLE", $objLang->get("export", "label"));
            //*** Set tab title.
            $objTpl->setCurrentBlock("headertitel_simple");
            $objTpl->setVariable("HEADER_TITLE", $objLang->get("exportOptions", "label"));
            $objTpl->parseCurrentBlock();
            $objTpl->setVariable("FORM_NAME", "exportForm");
            //*** Handle request & create export
            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                $arrElementFilters = array();
                $arrTemplateFilters = array();
                foreach ($_POST['elem'] as $id => $val) {
                    $arrElementFilters[] = intval($id);
                    $objTmpElement = Element::selectByPK(intval($id));
                    if (!in_array($objTmpElement->getTemplateId(), $arrTemplateFilters)) {
                        $arrTemplateFilters[] = $objTmpElement->getTemplateId();
                    }
                }
                if ($_POST['sel'] == 1) {
                    $includeSelf = false;
                    $arrElementIds = explode(',', $intElmntId);
                    $objChild = Element::selectByPK($arrElementIds[0]);
                    $objElement = Element::selectByPK($objChild->getParentId());
                } else {
                    $includeSelf = true;
                    $objElement = Element::selectByPK($intElmntId);
                }
                $strZipFile = ImpEx::exportFrom($objElement->getId(), $objElement->getTemplateId(), $arrElementFilters, $arrTemplateFilters, $_CONF['app']['account']->getId(), true, true, $includeSelf);
                //*** Return XML.
                header("HTTP/1.1 200 OK");
                header("Pragma: public");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Cache-Control: private", false);
                header('Content-Type: application/octetstream; charset=utf-8');
                header("Content-Length: " . (string) filesize($strZipFile));
                header('Content-Disposition: attachment; filename="' . date("Y-m-d") . '_exportElements.zip"');
                header("Content-Transfer-Encoding: binary\n");
                readfile($strZipFile);
                unlink($strZipFile);
                exit;
            }
            //*** Create element checkboxes
            $objTpl->setVariable("SELECT_ITEMS", $objLang->get("selectElements", "label"));
            $objTpl->setVariable("FORM_CHECKBOXES", createElementTree($objElement, isset($_GET['sel']), $arrElementIds));
            //*** Set form buttons
            $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_LIST);
            $objTpl->setCurrentBlock("singleview");
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button"));
            $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("LABEL_SAVE", $objLang->get("export", "button"));
            $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS);
            $objTpl->setVariable("CMD", CMD_EXPORT_ELEMENT);
            $objTpl->setVariable("EID", $intElmntId);
            $objTpl->setVariable("SEL", isset($_GET['sel']) ? '1' : '0');
            $objTpl->parseCurrentBlock();
            break;
        case CMD_IMPORT_ELEMENT:
            $objTpl->loadTemplatefile("import.tpl.htm");
            //*** Parse the template.
            $objElement = Element::selectByPK($intElmntId);
            //*** Set section title.
            $objTpl->setVariable("MAINTITLE", $objLang->get("import", "label"));
            //*** Set tab title.
            $objTpl->setCurrentBlock("headertitel_simple");
            $objTpl->setVariable("HEADER_TITLE", $objLang->get("importOptions", "label"));
            $objTpl->parseCurrentBlock();
            //*** Handle request & do import
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_FILES["file"]["name"])) {
                if ($_FILES["file"]["error"] > 0) {
                    $objTpl->setVariable('ERROR_MAIN', 'Error: ' . $_FILES["file"]["error"]);
                } else {
                    if (end(explode(".", $_FILES["file"]["name"])) !== 'zip') {
                        $objTpl->setVariable('ERROR_MAIN', 'Error: Only *.ZIP files allowed');
                    } else {
                        if (!ImpEx::importIn($_FILES["file"]["tmp_name"], $objElement->getId(), $objElement->getTemplateId(), $_CONF['app']['account']->getId(), false, true, true)) {
                            $objTpl->setVariable('ERROR_MAIN', 'Templates and/or fields of templates in file do not match the destination templates');
                        }
                    }
                }
            }
            $objTpl->setVariable('CUR_LOCATION', $objElement->getName());
            $objTpl->setVariable("IMPORT_FILE", $objLang->get("importFile", "label"));
            $objTpl->setVariable("IMPORT_FILE_TIP", $objLang->get("importFile", "tip"));
            //*** Set form buttons
            $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&amp;eid={$intElmntId}&amp;cmd=" . CMD_LIST);
            $objTpl->setCurrentBlock("singleview");
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button"));
            $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("LABEL_SAVE", $objLang->get("import", "button"));
            $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS);
            $objTpl->setVariable("CMD", CMD_IMPORT_ELEMENT);
            $objTpl->setVariable("EID", $intElmntId);
            $objTpl->parseCurrentBlock();
            break;
    }
    return $objTpl->get();
}
Ejemplo n.º 7
0
function parseUsers($intElmntId, $strCommand)
{
    global $_PATHS, $objLang, $objLiveAdmin, $_CONF;
    $objTpl = new HTML_Template_ITX($_PATHS['templates']);
    $objTpl->loadTemplatefile("users.tpl.htm");
    switch ($intElmntId) {
        case NAV_MYPUNCH_USERS_USER:
            $objTpl->addBlockfile('USER_EDIT', 'users.users', 'users_users.tpl.htm');
            //*** Fetch all users.
            $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId())));
            $objUsers = $objLiveAdmin->getUsers($filters);
            if (is_array($objUsers)) {
                foreach ($objUsers as $objUser) {
                    $objTpl->setCurrentBlock("main-items");
                    $objTpl->setVariable("VALUE", $objUser["perm_user_id"]);
                    $objTpl->setVariable("TEXT", $objUser["handle"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Fetch all rights.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $filters = array('filters' => array('application_id' => $objApp['application_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                    $objAreas = $objLiveAdmin->perm->getAreas($filters);
                    foreach ($objAreas as $objArea) {
                        $filters = array('filters' => array('area_id' => $objArea['area_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                        $objRights = $objLiveAdmin->perm->getRights($filters);
                        foreach ($objRights as $objRight) {
                            $objTpl->setCurrentBlock("user-allrights");
                            $objTpl->setVariable("VALUE", $objRight['right_id']);
                            $objTpl->setVariable("TEXT", $objApp['application_define_name'] . "::" . $objArea['area_define_name'] . "::" . $objRight['right_define_name']);
                            $objTpl->parseCurrentBlock();
                        }
                    }
                }
            }
            //*** Fetch all groups.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objGroups = $objLiveAdmin->perm->getGroups($filters);
            if (is_array($objGroups)) {
                foreach ($objGroups as $objGroup) {
                    $objTpl->setCurrentBlock("user-allgroups");
                    $objTpl->setVariable("VALUE", $objGroup["group_id"]);
                    $objTpl->setVariable("TEXT", $objGroup["group_define_name"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Specific parsing.
            $objTpl->setVariable("ACTIVE_LABEL", $objLang->get("active", "usersLabel"));
            $objTpl->setVariable("USER_TYPE_LABEL", $objLang->get("userType", "usersLabel"));
            $objTpl->setVariable("USER_ANONYMOUS_LABEL", $objLang->get("typeAnonymous", "usersLabel"));
            $objTpl->setVariable("USER_USER_LABEL", $objLang->get("typeUser", "usersLabel"));
            $objTpl->setVariable("USER_ADMIN_LABEL", $objLang->get("typeAdmin", "usersLabel"));
            $objTpl->setVariable("USER_AREA_ADMIN_LABEL", $objLang->get("typeAreaAdmin", "usersLabel"));
            $objTpl->setVariable("USER_SUPER_ADMIN_LABEL", $objLang->get("typeSuperAdmin", "usersLabel"));
            $objTpl->setVariable("USER_MASTER_ADMIN_LABEL", $objLang->get("typeMasterAdmin", "usersLabel"));
            $objTpl->setVariable("USER_USERNAME_LABEL", $objLang->get("userName", "usersLabel"));
            $objTpl->setVariable("NAME_LABEL", $objLang->get("name", "usersLabel"));
            $objTpl->setVariable("USER_EMAIL_LABEL", $objLang->get("emailAddress", "usersLabel"));
            $objTpl->setVariable("USER_PASSWORD_LABEL", $objLang->get("password", "usersLabel"));
            $objTpl->setVariable("RIGHTS_LABEL", $objLang->get("rights", "usersLabel"));
            $objTpl->setVariable("SELECTED_RIGHTS_LABEL", $objLang->get("selectedRights", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_RIGHTS_LABEL", $objLang->get("availableRights", "usersLabel"));
            $objTpl->setVariable("GROUPS_LABEL", $objLang->get("groups", "usersLabel"));
            $objTpl->setVariable("SELECTED_GROUPS_LABEL", $objLang->get("selectedGroups", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_GROUPS_LABEL", $objLang->get("availableGroups", "usersLabel"));
            //*** General parsing.
            $objTpl->setVariable("SUBTITLE", $objLang->get("userDetails", "usersLabel"));
            $objTpl->setVariable("BUTTON_NEW", $objLang->get("new", "button"));
            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("BUTTON_SAVE", $objLang->get("save", "button"));
            $objTpl->setVariable("LISTTITLE", $objLang->get("users", "usersLabel"));
            $objTpl->setVariable("OBJECT", "User");
            $objTpl->setVariable("FORM", "userForm");
            $objTpl->setVariable("ACTIVE_USER", " class=\"active\"");
            break;
        case NAV_MYPUNCH_USERS_GROUP:
            $objTpl->addBlockfile('USER_EDIT', 'users.groups', 'users_groups.tpl.htm');
            //*** Fetch all groups.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objGroups = $objLiveAdmin->perm->getGroups($filters);
            if (is_array($objGroups)) {
                foreach ($objGroups as $objGroup) {
                    $objTpl->setCurrentBlock("main-items");
                    $objTpl->setVariable("VALUE", $objGroup["group_id"]);
                    $objTpl->setVariable("TEXT", $objGroup["group_define_name"]);
                    $objTpl->parseCurrentBlock();
                    $objTpl->setCurrentBlock("group-allsubgroups");
                    $objTpl->setVariable("VALUE", $objGroup["group_id"]);
                    $objTpl->setVariable("TEXT", $objGroup["group_define_name"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Fetch all rights.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $filters = array('filters' => array('application_id' => $objApp['application_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                    $objAreas = $objLiveAdmin->perm->getAreas($filters);
                    foreach ($objAreas as $objArea) {
                        $filters = array('filters' => array('area_id' => $objArea['area_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                        $objRights = $objLiveAdmin->perm->getRights($filters);
                        foreach ($objRights as $objRight) {
                            $objTpl->setCurrentBlock("group-allrights");
                            $objTpl->setVariable("VALUE", $objRight['right_id']);
                            $objTpl->setVariable("TEXT", $objApp['application_define_name'] . "::" . $objArea['area_define_name'] . "::" . $objRight['right_define_name']);
                            $objTpl->parseCurrentBlock();
                        }
                    }
                }
            }
            //*** Fetch all users.
            $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId())));
            $objUsers = $objLiveAdmin->getUsers($filters);
            if (is_array($objUsers)) {
                foreach ($objUsers as $objUser) {
                    $objTpl->setCurrentBlock("group-allusers");
                    $objTpl->setVariable("VALUE", $objUser["perm_user_id"]);
                    $objTpl->setVariable("TEXT", $objUser["handle"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Specific parsing.
            $objTpl->setVariable("ACTIVE_LABEL", $objLang->get("active", "usersLabel"));
            $objTpl->setVariable("NAME_LABEL", $objLang->get("name", "usersLabel"));
            $objTpl->setVariable("GROUP_LEVEL_LABEL", $objLang->get("groupLevel", "usersLabel"));
            $objTpl->setVariable("LEVEL_USER_LABEL", $objLang->get("levelUser", "usersLabel"));
            $objTpl->setVariable("LEVEL_GROUP_LABEL", $objLang->get("levelGroup", "usersLabel"));
            $objTpl->setVariable("LEVEL_ALL_LABEL", $objLang->get("levelAll", "usersLabel"));
            $objTpl->setVariable("RIGHTS_LABEL", $objLang->get("rights", "usersLabel"));
            $objTpl->setVariable("SELECTED_RIGHTS_LABEL", $objLang->get("selectedRights", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_RIGHTS_LABEL", $objLang->get("availableRights", "usersLabel"));
            $objTpl->setVariable("SUBGROUPS_LABEL", $objLang->get("subGroups", "usersLabel"));
            $objTpl->setVariable("SELECTED_GROUPS_LABEL", $objLang->get("selectedGroups", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_GROUPS_LABEL", $objLang->get("availableGroups", "usersLabel"));
            $objTpl->setVariable("USERS_LABEL", $objLang->get("users", "usersLabel"));
            $objTpl->setVariable("SELECTED_USERS_LABEL", $objLang->get("selectedUsers", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_USERS_LABEL", $objLang->get("availableUsers", "usersLabel"));
            //*** General parsing.
            $objTpl->setVariable("SUBTITLE", $objLang->get("groupDetails", "usersLabel"));
            $objTpl->setVariable("BUTTON_NEW", $objLang->get("new", "button"));
            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("BUTTON_SAVE", $objLang->get("save", "button"));
            $objTpl->setVariable("LISTTITLE", $objLang->get("groups", "usersLabel"));
            $objTpl->setVariable("OBJECT", "Group");
            $objTpl->setVariable("FORM", "groupForm");
            $objTpl->setVariable("ACTIVE_GROUP", " class=\"active\"");
            break;
        case NAV_MYPUNCH_USERS_APPLICATION:
            $objTpl->addBlockfile('USER_EDIT', 'users.apps', 'users_apps.tpl.htm');
            //*** Fetch all applications.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $objTpl->setCurrentBlock("main-items");
                    $objTpl->setVariable("VALUE", $objApp["application_id"]);
                    $objTpl->setVariable("TEXT", $objApp["application_define_name"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Specific parsing.
            $objTpl->setVariable("NAME_LABEL", $objLang->get("name", "usersLabel"));
            $objTpl->setVariable("AREAS_LABEL", $objLang->get("areas", "usersLabel"));
            $objTpl->setVariable("SELECTED_AREAS_LABEL", $objLang->get("selectedAreas", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_AREAS_LABEL", $objLang->get("availableAreas", "usersLabel"));
            //*** General parsing.
            $objTpl->setVariable("SUBTITLE", $objLang->get("applicationDetails", "usersLabel"));
            $objTpl->setVariable("BUTTON_NEW", $objLang->get("new", "button"));
            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("BUTTON_SAVE", $objLang->get("save", "button"));
            $objTpl->setVariable("LISTTITLE", $objLang->get("applications", "usersLabel"));
            $objTpl->setVariable("OBJECT", "Application");
            $objTpl->setVariable("FORM", "applicationForm");
            $objTpl->setVariable("ACTIVE_APP", " class=\"active\"");
            break;
        case NAV_MYPUNCH_USERS_AREA:
            $objTpl->addBlockfile('USER_EDIT', 'users.areas', 'users_areas.tpl.htm');
            //*** Fetch all applications.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $objTpl->setCurrentBlock("area-application");
                    $objTpl->setVariable("VALUE", $objApp["application_id"]);
                    $objTpl->setVariable("TEXT", $objApp["application_define_name"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Fetch all areas.
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $filters = array('filters' => array('application_id' => $objApp["application_id"], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                    $objAreas = $objLiveAdmin->perm->getAreas($filters);
                    if (is_array($objAreas)) {
                        foreach ($objAreas as $objArea) {
                            $objTpl->setCurrentBlock("main-items");
                            $objTpl->setVariable("VALUE", $objArea["area_id"]);
                            $objTpl->setVariable("TEXT", $objApp["application_define_name"] . "::" . $objArea["area_define_name"]);
                            $objTpl->parseCurrentBlock();
                        }
                    }
                }
            }
            //*** Fetch all users.
            $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId())));
            $objUsers = $objLiveAdmin->getUsers($filters);
            if (is_array($objUsers)) {
                foreach ($objUsers as $objUser) {
                    if ($objUser['perm_type'] >= 3) {
                        $objTpl->setCurrentBlock("area-allusers");
                        $objTpl->setVariable("VALUE", $objUser["perm_user_id"]);
                        $objTpl->setVariable("TEXT", $objUser["handle"]);
                        $objTpl->parseCurrentBlock();
                    }
                }
            }
            //*** Specific parsing.
            $objTpl->setVariable("NAME_LABEL", $objLang->get("name", "usersLabel"));
            $objTpl->setVariable("APPLICATION_LABEL", $objLang->get("application", "usersLabel"));
            $objTpl->setVariable("AREA_ADMINS_LABEL", $objLang->get("areaAdmins", "usersLabel"));
            $objTpl->setVariable("SELECTED_ADMINS_LABEL", $objLang->get("selectedAdmins", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_ADMINS_LABEL", $objLang->get("availableAdmins", "usersLabel"));
            $objTpl->setVariable("RIGHTS_LABEL", $objLang->get("rights", "usersLabel"));
            $objTpl->setVariable("SELECTED_RIGHTS_LABEL", $objLang->get("selectedRights", "usersLabel"));
            //*** General parsing.
            $objTpl->setVariable("SUBTITLE", $objLang->get("areaDetails", "usersLabel"));
            $objTpl->setVariable("BUTTON_NEW", $objLang->get("new", "button"));
            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("BUTTON_SAVE", $objLang->get("save", "button"));
            $objTpl->setVariable("LISTTITLE", $objLang->get("areas", "usersLabel"));
            $objTpl->setVariable("OBJECT", "Area");
            $objTpl->setVariable("FORM", "areaForm");
            $objTpl->setVariable("ACTIVE_AREA", " class=\"active\"");
            break;
        case NAV_MYPUNCH_USERS_RIGHT:
            $objTpl->addBlockfile('USER_EDIT', 'users.rights', 'users_rights.tpl.htm');
            //*** Fetch all rights.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $filters = array('filters' => array('application_id' => $objApp['application_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                    $objAreas = $objLiveAdmin->perm->getAreas($filters);
                    if (is_array($objAreas)) {
                        foreach ($objAreas as $objArea) {
                            $filters = array('filters' => array('area_id' => $objArea["area_id"], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                            $objRights = $objLiveAdmin->perm->getRights($filters);
                            if (is_array($objRights)) {
                                foreach ($objRights as $objRight) {
                                    //*** List all rights.
                                    // TODO: Parse optgroup fields for shorter option values.
                                    $objTpl->setCurrentBlock("main-items");
                                    $strRight = $objApp['application_define_name'] . "::" . $objArea["area_define_name"] . "::" . $objRight["right_define_name"];
                                    $strOptionTitle = strlen($strRight) > 20 ? " title=\"{$strRight}\"" : "";
                                    $objTpl->setVariable("VALUE", $objRight["right_id"]);
                                    $objTpl->setVariable("OPT_TITLE", $strOptionTitle);
                                    $objTpl->setVariable("TEXT", $objApp['application_define_name'] . "::" . $objArea["area_define_name"] . "::" . $objRight["right_define_name"]);
                                    $objTpl->parseCurrentBlock();
                                    //*** List all rights for implied rights.
                                    $objTpl->setCurrentBlock("right-allrights");
                                    $objTpl->setVariable("VALUE", $objRight["right_id"]);
                                    $objTpl->setVariable("TEXT", $objApp['application_define_name'] . "::" . $objArea["area_define_name"] . "::" . $objRight["right_define_name"]);
                                    $objTpl->parseCurrentBlock();
                                }
                            }
                        }
                    }
                }
            }
            //*** Fetch all areas.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objApps = $objLiveAdmin->perm->getApplications($filters);
            if (is_array($objApps)) {
                foreach ($objApps as $objApp) {
                    $filters = array('filters' => array('application_id' => $objApp['application_id'], 'account_id' => array('0', $_CONF['app']['account']->getId())));
                    $objAreas = $objLiveAdmin->perm->getAreas($filters);
                    if (is_array($objAreas)) {
                        foreach ($objAreas as $objArea) {
                            $objTpl->setCurrentBlock("right-area");
                            $objTpl->setVariable("VALUE", $objArea["area_id"]);
                            $objTpl->setVariable("TEXT", $objApp['application_define_name'] . "::" . $objArea["area_define_name"]);
                            $objTpl->parseCurrentBlock();
                        }
                    }
                }
            }
            //*** Fetch all groups.
            $filters = array('filters' => array('account_id' => array('0', $_CONF['app']['account']->getId())));
            $objGroups = $objLiveAdmin->perm->getGroups($filters);
            if (is_array($objGroups)) {
                foreach ($objGroups as $objGroup) {
                    $objTpl->setCurrentBlock("right-allgroups");
                    $objTpl->setVariable("VALUE", $objGroup["group_id"]);
                    $objTpl->setVariable("TEXT", $objGroup["group_define_name"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Fetch all users.
            $filters = array('container' => 'auth', 'filters' => array('account_id' => array($_CONF['app']['account']->getId())));
            $objUsers = $objLiveAdmin->getUsers($filters);
            if (is_array($objUsers)) {
                foreach ($objUsers as $objUser) {
                    $objTpl->setCurrentBlock("right-allusers");
                    $objTpl->setVariable("VALUE", $objUser["perm_user_id"]);
                    $objTpl->setVariable("TEXT", $objUser["handle"]);
                    $objTpl->parseCurrentBlock();
                }
            }
            //*** Specific parsing.
            $objTpl->setVariable("NAME_LABEL", $objLang->get("name", "usersLabel"));
            $objTpl->setVariable("AREA_LABEL", $objLang->get("area", "usersLabel"));
            $objTpl->setVariable("IMPLIED_RIGHTS_LABEL", $objLang->get("impliedRights", "usersLabel"));
            $objTpl->setVariable("SELECTED_RIGHTS_LABEL", $objLang->get("selectedRights", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_RIGHTS_LABEL", $objLang->get("availableRights", "usersLabel"));
            $objTpl->setVariable("GROUPS_LABEL", $objLang->get("groups", "usersLabel"));
            $objTpl->setVariable("SELECTED_GROUPS_LABEL", $objLang->get("selectedGroups", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_GROUPS_LABEL", $objLang->get("availableGroups", "usersLabel"));
            $objTpl->setVariable("USERS_LABEL", $objLang->get("users", "usersLabel"));
            $objTpl->setVariable("SELECTED_USERS_LABEL", $objLang->get("selectedUsers", "usersLabel"));
            $objTpl->setVariable("AVAILABLE_USERS_LABEL", $objLang->get("availableUsers", "usersLabel"));
            //*** General parsing.
            $objTpl->setVariable("SUBTITLE", $objLang->get("rightDetails", "usersLabel"));
            $objTpl->setVariable("BUTTON_NEW", $objLang->get("new", "button"));
            $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
            $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("cancel", "button"));
            $objTpl->setVariable("BUTTON_SAVE", $objLang->get("save", "button"));
            $objTpl->setVariable("LISTTITLE", $objLang->get("rights", "usersLabel"));
            $objTpl->setVariable("OBJECT", "Right");
            $objTpl->setVariable("FORM", "rightForm");
            $objTpl->setVariable("ACTIVE_RIGHT", " class=\"active\"");
            break;
    }
    $objTpl->setVariable("TITLE", $objLang->get("pageTitle"));
    $objTpl->setVariable("MAINTITLE", $objLang->get("mypunchUsers", "menu"));
    $strReturn = $objTpl->get();
    return $strReturn;
}
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * An example for the usage of ITX::addBlockfile
 *
 * @version CVS: $Id: sample_itx_addblockfile.php,v 1.1 2006/07/11 21:56:05 dsp Exp $
 */
require_once 'HTML/Template/ITX.php';
$data = array(array('packagename' => 'mypackage', 'version' => '1.0', 'changelog' => array('fix bug #002', 'add author FOO to AUTHORS')), array('packagename' => 'mypackage', 'version' => '1.0 RC 1', 'changelog' => array('fix bug #002', 'added method foo()')));
$tpl = new HTML_Template_ITX('./templates');
$tpl->loadTemplatefile('addblockfile_main.tpl.htm', true, true);
// The complete content of "addblockfile_main.tpl.htm" will be loaded into a block
// called "list_template". The placeholder {DESCRIPTION} will be replaced
// with the added block "list_template".
$tpl->addBlockfile('DESCRIPTION', 'list_template', 'addblockfile_list.tpl.htm');
// we now have the following blocks loaded:
// __global__, row, list_template and listelement
// lets assign the data.
foreach ($data as $entry) {
    // assign data to the inner block (listelement) of list_template.
    $tpl->setCurrentBlock('listelement');
    foreach ($entry['changelog'] as $changelogentry) {
        $tpl->setVariable('ENTRY', $changelogentry);
        $tpl->parseCurrentBlock();
    }
    // assign data to the added list_template block
    $tpl->setCurrentBlock('list_template');
    $tpl->setVariable('LISTNAME', $entry['version']);
    $tpl->parseCurrentBlock();
    // back in the original templatefile we assign data to the row block
Ejemplo n.º 9
0
	|                                                                             |
	| This program is free software; you can redistribute it and/or               |
	| modify it under the terms of the GNU General Public License                 |
	| as published by the Free Software Foundation; either version 2              |
	| of the License, or (at your option) any later version.                      |
	|                                                                             |
	| This program is distributed in the hope that it will be useful,             |
	| but WITHOUT ANY WARRANTY; without even the implied warranty of              |
	| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
	| GNU General Public License for more details.                                |
	|                                                                             |
	| You should have received a copy of the GNU General Public License           |
	| along with this program; if not, write to the Free Software                 |
	| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
	+-----------------------------------------------------------------------------+
*/
while (!file_exists('./ilias.ini.php')) {
    chdir('..');
}
require_once 'include/inc.get_pear.php';
include "Services/Init/classes/class.ilIniFile.php";
$ini = new ilIniFile("ilias.ini.php");
$ini->read();
$latex_converter = $ini->readVariable("tools", "latex");
require_once "HTML/Template/ITX.php";
$tpl = new HTML_Template_ITX();
$tpl->loadTemplatefile(dirname(__FILE__) . "/tpl.latex.html", TRUE, TRUE);
$tpl->setVariable("LATEX_CODE", "");
$tpl->setVariable("URL_PREVIEW", $latex_converter);
$tpl->setVariable("HREF_LATEX_CONVERTER", $latex_converter);
$tpl->show();
Ejemplo n.º 10
0
    WEBPAGE::$lang = $_GET['lang'];
} else {
    WEBPAGE::$lang = 'esp';
}
$_LABELS = WEBPAGE::getCacheData(sprintf(WEBPAGE::_APP_LABELS_FILE, WEBPAGE::$lang));
$_CONF = WEBPAGE::getCacheData(sprintf(WEBPAGE::_APP_CONF_FILE, WEBPAGE::$lang));
$data = WEBPAGE::$dbh->getAll(sprintf("select\r\n    lmd.master_id,\r\n    l.xp_cancel_date,\r\n    l.xp_num_pmt,\r\n    lt.payment_frequency,\r\n    lcd.xp_pmt_date,\r\n    lcd.loan_id,\r\n    lcd.xp_pmt,\r\n    lcd.cn_delay,\r\n    lcd.cn_penalties,\r\n    lm.program_id, prg.program,\r\n    lm.zone_id, z.short_name,\r\n    concat(c.first,' ',c.last) cliente,\r\n    c.code govID,\r\n    s.name grupo,\r\n    u.username,\r\n    count(p.id)+1 cuota,\r\n    fa.p_pmt_receipt_flag_a pmt_receipt_flag_a,\r\n    fb.p_pmt_receipt_flag_b pmt_receipt_flag_b\r\nfrom\r\n    (\r\n    tblLoansCurrentData lcd,\r\n    tblLoansMasterDetails lmd,\r\n    tblLoansMaster lm,\r\n    tblLoans l,\r\n    tblLoanTypes lt,\r\n    tblClients c,\r\n    tblPrograms prg,\r\n    tblZones z,\r\n    tblUsers u\r\n    )\r\nleft join\r\n    tblSocieties s on s.id = c.society_id\r\nleft join\r\n    tblPayments p on p.loan_id = lcd.loan_id and p.special = 0\r\nleft join\r\n    (select fap.loan_id p_loan_id, count(far.flag_a) p_pmt_receipt_flag_a FROM tblPayments fap, tblReceipts far, tblLinkReceiptsPayments falrp, tblLoansCurrentData falcd where falcd.loan_id = fap.loan_id and falcd.xp_pmt_date <= date_add(now(), interval 7 day) and far.flag_a = '1' and falrp.payment_id = fap.id and falrp.receipt_id = far.id group by fap.loan_id) fa on fa.p_loan_id = lcd.loan_id\r\nleft join\r\n    (select fbp.loan_id p_loan_id, count(fbr.flag_b) p_pmt_receipt_flag_b FROM tblPayments fbp, tblReceipts fbr, tblLinkReceiptsPayments fblrp, tblLoansCurrentData fblcd where fblcd.loan_id = fbp.loan_id and fblcd.xp_pmt_date <= date_add(now(), interval 7 day) and fbr.flag_b = '1' and fblrp.payment_id = fbp.id and fblrp.receipt_id = fbr.id group by fbp.loan_id) fb on fb.p_loan_id = lcd.loan_id\r\nwhere\r\n        lcd.xp_pmt_date <= date_add(now(), interval 1 month)\r\n    and lmd.loan_id = lcd.loan_id\r\n    and lm.id = lmd.master_id\r\n    and l.id = lcd.loan_id\r\n    and lt.id = l.loan_type_id\r\n    and c.id = l.client_id\r\n    and prg.id = lm.program_id\r\n    and z.id = lm.zone_id\r\n    and u.id = l.advisor_id\r\ngroup by\r\n    lcd.loan_id\r\norder by\r\n    lcd.loan_id"));
$head = array('id' => 'ID', 'client' => 'Cliente', 'num_pmt' => 'No cuota', 'xp_num_pmt' => 'Total de cuotas', 'payment_frequency' => 'Frec. Pagos', 'xp_pmt_date' => 'Fecha pago', 'xp_cancel_date' => 'Fecha vencimiento', 'xp_pmt' => 'Monto cuota', 'cn_penalties' => 'Punitorios', 'pmt_receipt_flag_a' => $_CONF['pmt_receipt_flag_a'] ? $_CONF['pmt_receipt_flag_a'] : '-', 'pmt_receipt_flag_b' => $_CONF['pmt_receipt_flag_b'] ? $_CONF['pmt_receipt_flag_b'] : '-', 'username' => 'Asesor', 'program' => 'Programa', 'branch' => 'Sucursal', 'print' => 'Imprimir');
foreach ($data as $key => $val) {
    $master[$val['master_id']]['id'] = $val['master_id'];
    $master[$val['master_id']]['client'] = $counter[$val['master_id']] ? $val['grupo'] : $val['cliente'] . ' : ' . $val['govID'];
    //  $master[$val['master_id']]['client']           = $val['grupo'] ? $val['grupo'] : $val['cliente'];
    $master[$val['master_id']]['num_pmt'] = $val['cuota'];
    $master[$val['master_id']]['xp_num_pmt'] = $val['xp_num_pmt'];
    $master[$val['master_id']]['payment_frequency'] = $val['payment_frequency'];
    $master[$val['master_id']]['xp_pmt_date'] = $val['xp_pmt_date'];
    $master[$val['master_id']]['xp_cancel_date'] = $val['xp_cancel_date'];
    $master[$val['master_id']]['xp_pmt'] += $val['xp_pmt'];
    $master[$val['master_id']]['cn_penalties'] += $val['cn_penalties'];
    $master[$val['master_id']]['pmt_receipt_flag_a'] = $_CONF['pmt_receipt_flag_a'] ? $val['pmt_receipt_flag_a'] ? $val['pmt_receipt_flag_a'] : 0 : '-';
    $master[$val['master_id']]['pmt_receipt_flag_b'] = $_CONF['pmt_receipt_flag_b'] ? $val['pmt_receipt_flag_b'] ? $val['pmt_receipt_flag_b'] : 0 : '-';
    $master[$val['master_id']]['username'] = $val['username'];
    $master[$val['master_id']]['program'] = $val['program'];
    $master[$val['master_id']]['branch'] = $val['short_name'];
    $master[$val['master_id']]['print'] = sprintf('<a href="index.receipt.php?advisor=%s&client=%s&xp_pmt_date=%s&num_pmt=%s&xp_num_pmt=%s&xp_pmt=%s">Imprimir</a>', $master[$val['master_id']]['username'], $master[$val['master_id']]['client'], $master[$val['master_id']]['xp_pmt_date'], $master[$val['master_id']]['num_pmt'], $master[$val['master_id']]['xp_num_pmt'], $master[$val['master_id']]['xp_pmt']);
    $counter[$val['master_id']]++;
}
$tpl = new HTML_Template_ITX('.');
$tpl->loadTemplateFile('index.compactCS.tpl');
$tpl->setVariable('chart', count($master) ? WEBPAGE::printchart($master, $head) : $_LABELS['noData']);
$tpl->show();
Ejemplo n.º 11
0
function send_confirmation_email($custID, $orderID, $connection)
{
    $template = new HTML_Template_ITX(D_TEMPLATES);
    $template->loadTemplatefile(T_EMAIL, true, true);
    // Find customer information
    $query = "SELECT * FROM customer, users\n            WHERE customer.cust_id = {$custID}\n            AND users.cust_id = customer.cust_id";
    $result = $connection->query($query);
    if (DB::isError($result)) {
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
    // Start by setting up the "To:" email address
    $to = "{$row["firstname"]} {$row["surname"]} <{$row["user_name"]}>";
    // Now setup all the customer fields
    $template->setVariable("TITLE", showTitle($row["title_id"], $connection));
    $template->setVariable("SURNAME", $row["surname"]);
    $template->setVariable("CUST_ID", $custID);
    $template->setVariable("ORDER_ID", $orderID);
    $template->setVariable("FIRSTNAME", $row["firstname"]);
    $template->setVariable("INITIAL", $row["initial"]);
    $template->setVariable("ADDRESS", $row["address"]);
    $template->setVariable("CITY", $row["city"]);
    $template->setVariable("STATE", $row["state"]);
    $template->setVariable("COUNTRY", showCountry($row["country_id"], $connection));
    $template->setVariable("ZIPCODE", $row["zipcode"]);
    $orderTotalPrice = 0;
    // list the particulars of each item in the order
    $query = "SELECT  i.qty, w.wine_name, i.price, \n                     w.wine_id, w.year, wi.winery_name\n             FROM    items i, wine w, winery wi\n             WHERE   i.cust_id = {$custID}\n             AND     i.order_id = {$orderID}\n             AND     i.wine_id = w.wine_id\n             AND     w.winery_id = wi.winery_id\n             ORDER BY item_id";
    $result = $connection->query($query);
    if (DB::isError($result)) {
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    // Add each item to the email
    while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
        // Work out the cost of this line item
        $itemsPrice = $row["qty"] * $row["price"];
        $orderTotalPrice += $itemsPrice;
        $wineDetail = showWine($row["wine_id"], $connection);
        $template->setCurrentBlock("row");
        $template->setVariable("QTY", str_pad($row["qty"], 9));
        $template->setVariable("WINE", str_pad(substr($wineDetail, 0, 53), 55));
        $template->setVariable("PRICE", str_pad(sprintf("\$%4.2f", $row["price"]), 11));
        $template->setVariable("TOTAL", str_pad(sprintf("\$%4.2f", $itemsPrice), 12));
        $template->parseCurrentBlock("row");
    }
    $template->setCurrentBlock("items");
    $template->setVariable("ORDER_TOTAL", sprintf("\$%4.2f\n", $orderTotalPrice));
    $template->parseCurrentBlock("items");
    $template->setCurrentBlock();
    $template->parseCurrentBlock();
    $out = $template->get();
    if (USE_PEAR == false) {
        // --------------------------------------------
        // The internal PHP mail() function is used only if USE_PEAR is false
        // Now, setup the "Subject:" line
        $subject = "Hugh and Dave's Online Wines: Order Confirmation";
        // And, last (before we build the email), set up some mail headers
        $headers = "From: Hugh and Dave's Online Wines " . "<*****@*****.**>\r\n";
        $headers .= "X-Sender: <*****@*****.**>\r\n";
        $headers .= "X-Mailer: PHP\r\n";
        $headers .= "Return-Path: <*****@*****.**>\r\n";
        // Send the email!
        mail($to, $subject, $out, $headers);
        // --------------------------------------------
    } else {
        // --------------------------------------------
        // Use the PEAR Mail package and SMTP since USE_PEAR is true
        // Now, setup the "Subject:" line
        $headers["Subject"] = "Hugh and Dave's Online Wines: Order Confirmation";
        // And, last (before we build the email), set up some mail headers
        $headers["From"] = "Hugh and Dave's Online Wines " . "<*****@*****.**>";
        $headers["X-Sender"] = "<*****@*****.**>";
        $headers["X-Mailer"] = "PHP";
        $headers["Return-Path"] = "<*****@*****.**>";
        $smtpMail =& Mail::factory("smtp");
        $smtpMail->send($to, $headers, $out);
        // --------------------------------------------
    }
}
Ejemplo n.º 12
0
require_once("HTML/Template/ITX.php");

page_open(array("sess" => "rpts_Session"
	,"auth" => "rpts_Challenge_Auth"
	//"perm" => "rpts_Perm"
	));


global $auth;
global $sess;

$sessionvar= $sess->url("");
$user=$auth->auth;
$inModule = trim($_REQUEST['module']);

$tpl=new HTML_Template_ITX(".");
if($inModule == "assm") {
	$tpl->loadTemplatefile("personrptopsearch.htm");
	$target = "RPTOPDetails.php";
}
else {
	$tpl->loadTemplatefile("personduesearch.htm");
	$target = "CalculateRPTOPDetails.php";
}
$tpl->setVariable("module",$inModule);
	

$inLastName = trim($_REQUEST['lastName']);
$inFirstName = trim($_REQUEST['firstName']);
$inMiddleName = trim($_REQUEST['middleName']);
Ejemplo n.º 13
0
 static function printchart_ii($mdata, $head, $totals, $styles, $flags)
 {
     /*
     example for each param
     $mdata = array($data_0,$data_1);
       with:
        $data_0[row_0][col_0]='val_0_00';
        $data_0[row_0][col_1]='val_0_01';
        $data_1[row_0][col_0]='val_1_00';
        $data_1[row_0][col_1]='val_1_01';
     $head = array('col_0'=>'col_0_name', 'col_1'=>'col_1_name');
     $totals = array('totals'=>true,'subtotals'=>true,'cols'=>array('col_1'));
          // only calculate totals for 'col_1';
          // also show subtotals for each data set
          // and grand total row
     $styles = array(  'header'    => array('cell'=>'header_cell_class','row'=>''),
                       'subtotals' => array('cell'=>'subtotals_cell_class','row'=>'subtotals_row_class'),
                       'totals'    => array('cell'=>'totals_cell_class','row'=>'totals_row_class'),
                       'data_0'     => array('cell'=>'data_0_cells_class','row'=>'data_0_row_class'),
                       'data_1'     => array('cell'=>'data_1_cells_class','row'=>'data_1_row_class'));
     $flags = array('cache','legend');
     $flags['cache'] = true; // Save results in hd cache - makes for excel download.
     $flags['legend'] = true; // Prints legend.
     */
     global $_LABELS;
     if (!is_array($mdata)) {
         return $_LABELS['noData'];
     }
     foreach ($mdata as $inx => $data) {
         if (!count($data)) {
             unset($mdata[$inx]);
         }
     }
     if (!count($mdata)) {
         return $_LABELS['noData'];
     }
     //if style info is empty, then create default styles
     if (!count($styles)) {
         $styles['header']['cell'] = 'header';
         $styles['header']['row'] = '';
         $styles['subtotals']['cell'] = 'subtotals';
         $styles['subtotals']['row'] = 'subtotalsOff';
         $styles['totals']['cell'] = 'totals';
         $styles['totals']['row'] = 'totalsOff';
         foreach ($mdata as $inx => $data) {
             if (count($data)) {
                 $row_style = $row_style == 'rowOff_ii' ? 'rowOff_ii_alt' : 'rowOff_ii';
                 $styles[$inx]['cell'] = 'activeChart';
                 $styles[$inx]['row'] = $row_style;
             }
         }
     }
     // to make sure we create a cache file to open in excel upon request
     $c = 0;
     foreach ($mdata as $inx => $data) {
         foreach ($data as $k => $v) {
             $cdata[$c] = $v;
             $c++;
             if (is_array($totals['cols'])) {
                 foreach ($v as $col => $val) {
                     if (in_array($col, $totals['cols'])) {
                         $subtotals[$inx][$col] += $val;
                         $ctotals[$col] += $val;
                     } else {
                         $subtotals[$inx][$col] = '-';
                         $ctotals[$col] = '-';
                     }
                 }
             }
         }
     }
     if (is_array($ctotals)) {
         $cdata[$c] = $ctotals;
     }
     array_unshift($cdata, $head);
     $flags['cache'] ? self::makecachefile($cdata, self::$queryCache) : '';
     array_shift($cdata);
     //print html chart
     $tpl = new HTML_Template_ITX('./templates');
     $tpl->loadTemplateFile('ST.chart_ii.tpl');
     //print header row
     $tpl->setCurrentBlock("header");
     $tpl->setVariable('column_name', '#');
     $tpl->setVariable('header_class', $styles['header']['cell']);
     $tpl->parseCurrentBlock("header");
     foreach ($head as $key => $val) {
         $tpl->setCurrentBlock("header");
         $tpl->setVariable('column_name', $val);
         $tpl->setVariable('header_class', $styles['header']['cell']);
         $tpl->parseCurrentBlock("header");
     }
     //print each data set, row by row
     //including subtotal for each set
     $c = 1;
     foreach ($mdata as $inx => $data) {
         $row_style = $styles[$inx]['row'];
         //print regular rows
         foreach ($data as $key => $row) {
             $tpl->setCurrentBlock("row");
             $tpl->setVariable('cell_class', $styles[$inx]['cell']);
             $tpl->setVariable('item', sprintf('%s.&nbsp;', $c++));
             $tpl->parseCurrentBlock("row");
             foreach ($row as $col => $val) {
                 $tpl->setCurrentBlock("row");
                 $tpl->setVariable('cell_class', $styles[$inx]['cell']);
                 $tpl->setVariable('item', $val);
                 $tpl->parseCurrentBlock("row");
             }
             $tpl->setCurrentBlock("results");
             $tpl->setVariable('row_class', $row_style);
             $tpl->parseCurrentBlock("results");
         }
         //print subtotals
         if ($totals['subtotals'] && is_array($subtotals[$inx])) {
             $tpl->setCurrentBlock("row");
             $tpl->setVariable('cell_class', $styles['subtotals']['cell']);
             $tpl->setVariable('item', $_LABELS['subtotal']);
             $tpl->parseCurrentBlock("row");
             foreach ($subtotals[$inx] as $col => $val) {
                 $tpl->setCurrentBlock("row");
                 $tpl->setVariable('cell_class', $styles['subtotals']['cell']);
                 $tpl->setVariable('item', is_numeric($val) ? round($val, 2) : $val);
                 $tpl->parseCurrentBlock("row");
             }
             $tpl->setCurrentBlock("results");
             $tpl->setVariable('row_class', $styles['subtotals']['row']);
             $tpl->parseCurrentBlock("results");
         }
     }
     //print totals row
     if ($totals['totals'] && is_array($totals['cols'])) {
         $tpl->setCurrentBlock("row");
         $tpl->setVariable('cell_class', $styles['totals']['cell']);
         $tpl->setVariable('item', $_LABELS['total']);
         $tpl->parseCurrentBlock("row");
         foreach ($ctotals as $col => $val) {
             $tpl->setCurrentBlock("row");
             $tpl->setVariable('cell_class', $styles['totals']['cell']);
             $tpl->setVariable('item', is_numeric($val) ? round($val, 2) : $val);
             $tpl->parseCurrentBlock("row");
         }
         $tpl->setCurrentBlock("results");
         $tpl->setVariable('row_class', $styles['totals']['row']);
         $tpl->parseCurrentBlock("results");
     }
     //print legend
     if ($flags['legend']) {
         foreach ($mdata as $inx => $val) {
             if ($styles[$inx]['row']) {
                 $tpl->setCurrentBlock("legend");
                 $tpl->setVariable('style', $styles[$inx]['row']);
                 $tpl->setVariable('legend_text', $_LABELS[$inx] ? $_LABELS[$inx] : $inx);
                 $tpl->parseCurrentBlock("legend");
             }
         }
     }
     //finalize and print excel link
     $tpl->setCurrentBlock("chart");
     $cache ? $tpl->setVariable('xls_download', $_LABELS['RP.SCR.ChartCacheToXLS']) : '';
     $tpl->parseCurrentBlock("chart");
     return $tpl->get();
 }
Ejemplo n.º 14
0
page_open(array("sess" => "rpts_Session"
	,"auth" => "rpts_Challenge_Auth"
	//"perm" => "rpts_Perm"
	));


global $auth;
global $sess;

//print_r($sess);
$sessionvar= $sess->url("");

$user=$auth->auth;
	
$tpl=new HTML_Template_ITX(".");
$tpl->loadTemplatefile("rptopsearch.htm");

$tpl->setVariable("lastName",$_REQUEST['lastName']);
$tpl->setVariable("firstName",$_REQUEST['firstName']);
$tpl->setVariable("midName",$_REQUEST['midName']);

$tpl->setCurrentBlock("RPTOPLIST");

$tpl->setVariable("uname",$user["uname"]);
$tpl->setVariable("today", date("F j, Y"));
$tpl->setVariable("session",$sessionvar);
$tpl->setVariable("ownerName", $_POST['ownerName']);

if($_REQUEST['lastName']<>"" || $_REQUEST['firstName']<>"" || $_REQUEST['midName']<>""){
	$start=$_REQUEST['startpage'];
Ejemplo n.º 15
0
function myFunctionHandler($progressValue, &$bar)
{
    $bar->sleep();
    $str = ' ';
    if ($progressValue > 25) {
        $str = ' - DB schema generated';
    }
    if ($progressValue > 50) {
        $str = ' - Config file created';
    }
    if ($progressValue == 100) {
        $str = ' - All done !';
    }
    $bar->setString(sprintf("Installation in progress ... %01s%s %s", $progressValue, '%', $str));
}
$tpl = new HTML_Template_ITX('.');
$tpl->loadTemplateFile('installing.html');
$vars = array("L_SETUP_APP_TITLE" => "SW4P", "L_APPNAME" => basename(__FILE__), "L_APPCOPYRIGHT" => "&copy 2003 SW4P Team ");
$tpl->setVariable($vars);
$form = new HTML_QuickForm('form');
$form->addElement('submit', 'launch', 'Launch', 'style="width:100px;"');
$styles = array('none' => 'none', 'solid' => 'solid', 'dashed' => 'dashed', 'dotted' => 'dotted', 'inset' => 'inset', 'outset' => 'outset');
$form->addElement('select', 'border', 'border style:', $styles);
$colors = array('#FFFFFF' => 'white', '#0000FF' => 'blue', '#7B7B88' => '#7B7B88');
$form->addElement('select', 'color', 'border color:', $colors);
$defaultValues['border'] = 'solid';
$defaultValues['color'] = '#7B7B88';
$form->setDefaults($defaultValues);
if ($form->validate()) {
    $arr = $form->getElementValue('border');
    $border = $arr[0];