function executeUpdateScript(HTML_Template_IT &$objTpl) { if (!verifyVersion($GLOBALS["_CONF"]["app"]["version"])) { $objTpl->setCurrentBlock("update"); $objTpl->setVariable("VERSION", $GLOBALS["_CONF"]["app"]["version"]); $objTpl->parseCurrentBlock(); } }
/** * Function to build view * * @access public * @author Kristine <*****@*****.**> * @param number $parameters['a'] first summand * @param number $parameters['b'] second summand * @param number $parameters['sum'] sum */ public static function buildView($parameters) { require_once "HTML/Template/IT.php"; $tpl = new \HTML_Template_IT(dirname(__FILE__) . "/"); $tpl->loadTemplatefile("HArjutus.html", true, true); $tpl->setCurrentBlock("form"); $tpl->setVariable(array('URL-BEGIN' => BEGINNING_OF_URL, 'SUMMAND' => $parameters['a'], 'SUMMAND2' => $parameters['b'], 'SUM' => $parameters['sum'])); $tpl->parseCurrentBlock("form"); $tpl->show(); }
function parseHelp($intElmntId, $strCommand) { global $_PATHS, $objLang; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("help.tpl.htm"); $objTpl->setVariable("HELP", $objLang->get("help", "label")); $objTpl->setCurrentBlock("paragraph"); $objTpl->setVariable("HEADER", $objLang->get("docHeader", "help")); $objTpl->setVariable("BODY", $objLang->get("docBody", "help")); $objTpl->parseCurrentBlock(); $strBody = $objLang->get("hotkeysBody", "help"); if (!empty($strBody)) { $objTpl->setCurrentBlock("paragraph"); $objTpl->setVariable("HEADER", $objLang->get("hotkeysHeader", "help")); $objTpl->setVariable("BODY", $strBody); $objTpl->parseCurrentBlock(); } return $objTpl->get(); }
function getNews(&$db, $newsCategory) { $query = " SELECT news_id AS id, DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date, news_title AS title, news_content AS content FROM news WHERE news_category = '$newsCategory' AND news_id<>0 ORDER BY date ASC"; $news = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC, true); if (PEAR::isError($news)) { die($news->getMessage() . ' ' . $news->getUserinfo()); } else { $tpl = new HTML_Template_IT('./'); $tpl->loadTemplatefile('news.tpl', true, true); foreach ($news as $name) { $tpl->setCurrentBlock('row'); $tpl->setVariable('DATE', $name['date']); $tpl->setVariable('TITLE', $name['title']); $tpl->setVariable('CONTENT', $name['content']); $tpl->parseCurrentBlock('row'); } return $tpl->get(); } }
<?php require_once "HTML/Template/IT.php"; $listitems = array('Computer Science', 'Nuclear Physics', 'Rocket Science'); $tplfile = 'tpl0.tpl'; $tpl = new HTML_Template_IT('./'); $tpl->loadTemplateFile($tplfile); $tpl->setVariable('title', 'IT List Examples'); foreach ($listitems as $item) { $tpl->setCurrentBlock('listentry'); $tpl->setVariable('entry_text', $item); $tpl->parseCurrentBlock('cell'); } $tpl->show();
." FROM TB_MOVIE m" ." LEFT JOIN TB_MOVIE_SCH s ON s.MOVIE_SEQ = m.SEQ" ." AND s.CLASS_ID = '$p_class_id'" ." WHERE s.PLAN_ILSI > '0000-00-01'"; $res =& $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } // 편집 $iCol=0; $sColHeader=array(); while ($res->fetchInto($row)) { if (!$tpl->setCurrentBlock("col_header")) Error("setCurrentBlock"); $tpl->setVariable("COL_HEADER", $row[0]); $tpl->parseCurrentBlock("col_header"); // parse outter block if (!$tpl->parse("col_header")) Error("parseCurrentBlock"); $sColHeader[$iCol++] = $row[0]; } // 점검 /* echo("<br>"); foreach( $sColHeader as $ccc) { echo($ccc.":"); } echo("<br>"); */
<?php require_once "HTML/Template/IT.php"; $data = array("0" => array("Stig", "Bakken"), "1" => array("Martin", "Jansen"), "2" => array("Alexander", "Merz")); $tpl = new HTML_Template_IT("./templates"); $tpl->loadTemplatefile("main.tpl.htm", true, true); foreach ($data as $name) { foreach ($name as $cell) { // Assign data to the inner block $tpl->setCurrentBlock("cell"); $tpl->setVariable("DATA", $cell); $tpl->parseCurrentBlock("cell"); } // Assign data and the inner block to the // outer block $tpl->setCurrentBlock("row"); $tpl->parseCurrentBlock("row"); } // print the output $tpl->show();
function generateItemFile($itemId, $path, $idx, $itemsData) { global $db; $row =& $db->getRow(CMD_SEL_ITEM, array($itemId), DB_FETCHMODE_ASSOC); if (PEAR::isError($row)) { print $row->getMessage() . "\n"; return; } print "Generate item page... {$itemId} \n"; // Новый объект if ($row["item_id"] == 0) { $fields = getViewFields(); $imgUrl = IMAGES_BASE . getNormImagePath("new" . $row["id"]); } else { $categId =& $db->getOne("SELECT category_id FROM items WHERE id = ?", array($row["item_id"])); if (PEAR::isError($categId)) { $fields = getViewFields(); } else { $fields = getViewFields($categId); } $imgUrl = IMAGES_BASE . getNormImagePath($row["item_id"]); } $fields = removeFields($fields[0], $fields[1]); $fields = array_unique($fields); ob_start(); $tpl = new HTML_Template_IT(""); $tpl->loadTemplatefile(ITEM_TPL_FILE, true, true); $params = array("itemData" => $itemsData, "perPage" => 1, "delta" => 3, "append" => false, "expanded" => true, "fileName" => "?popup=[%d]", "mode" => "Sliding", "path" => "", "prevImg" => "<prev", "nextImg" => "next>"); $pager = new ExtendedPager1($params); $pager->ext = BASE_INDEX_URL_POPUP; $pager->infoStr = NAV_INFO_STR; $pager->prev = NAV_PREV; $pager->prevDis = NAV_PREV_DIS; $pager->next = NAV_NEXT; $pager->nextDis = NAV_NEXT_DIS; $pager->prevPages = NAV_PREV_PAGES; $pager->prevPagesDis = NAV_PREV_PAGES_DIS; $pager->nextPages = NAV_NEXT_PAGES; $pager->nextPagesDis = NAV_NEXT_PAGES_DIS; $pager->currentPage = $idx + 1; $navigation = $pager->getLinks(); $navigation = $pager->replaceLinks($navigation); $navigation = str_replace("/http://", "http://", $navigation); $navigation = str_replace(".http://", "http://", $navigation); $tpl->setVariable("NAVIGATION", $navigation); $row["name"] = stripslashes($row["name"]); $tpl->setVariable("name1", $row["name"]); $tpl->setVariable("HTMLTITLE", $row["name"] . START_PATH_TITLE); foreach ($fields as $field) { if (!isset($row[$field])) { continue; } if (strlen(trim($row[$field])) == 0) { continue; } $row[$field] = stripslashes($row[$field]); $tpl->setCurrentBlock($field); $tpl->setVariable($field, $row[$field]); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("image"); $tpl->setVariable("image", $imgUrl); $tpl->parseCurrentBlock(); $tpl->show(); $contents = ob_get_contents(); ob_end_clean(); $fName = str_replace(" ", "-", trim($row['art'])); $fName = str_replace("/", "-", $fName); FileUtils::saveContents(OUTPUT_DIR . "/popup/" . $fName . ".html", $contents); }
/** * This method builds a menu. * * @access private * @author Kalmer Piiskop * @param string $parameters['id'] the ID of the object * @param boolean $parameters['isError'] Are we in the error state? * @param string $parameters['type'] the type of the object * @param string $parameters['suffix'] the suffix * @param integer $parameters['width'] the width of <code>body</code> in * pixels * @return string the parsed menu * @uses ALIAS_HUMAN_LIST for the translation of the list of humans * @uses ALIAS_OF_LANGUAGES for the list of languages * @uses ALT_LANGUAGE for the alternative text of the update indicator * @uses DOMAIN for addressing * @uses IMAGES_FOLDER for displaying images * @uses O_FOLDER for the common files * @uses LANGUAGE for languages * @uses TITLE_LANGUAGE for the explanation of the change of the * language */ private static function buildLanguageMenu($parameters) { if (!isset($parameters['isError']) || !$parameters['isError']) { require_once 'HTML/Template/IT.php'; $tpl = new \HTML_Template_IT(sprintf('%1$s/../assets/tpl/%2$u', dirname(__FILE__), $parameters['width'])); $tpl->loadTemplatefile('languages.tpl'); require_once O_FOLDER . '/keeled/Language.php'; $language = new Language(); if (isset($_SESSION['language'])) { $language->setId($_SESSION['language']); $idOfLanguageToExclude = $_SESSION['language']; } else { $language->setId(DEFAULT_LANGUAGE); $idOfLanguageToExclude = DEFAULT_LANGUAGE; } $language->setLanguage(); require_once O_FOLDER . 'errors/Error.php'; // echo ' 1658: ', $parameters['type']; $languagesInUse = Language::createLanguagesInUse(array('classes' => array('SystemMenuItem', 'Page', 'PageNews', 'SystemString'), 'idOfLanguageToExclude' => $idOfLanguageToExclude, 'object' => isset($parameters['id']) ? Error::requireFile(array('id' => $parameters['id'], 'type' => $parameters['type'], 'isInstance' => TRUE, 'isToBeCompleted' => TRUE, 'isView' => FALSE)) : NULL)); // echo ' 1675: <pre>';print_r($languageInUse); echo '</pre>'; $numberOfLanguage = 0; foreach ($languagesInUse as $languageInUse) { $numberOfLanguage++; if ($numberOfLanguage < 3) { switch ($parameters['type']) { case 'Error': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId('errors_Error_error'); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; case 'Feedback': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId('configuration_formOfFeedback'); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; case 'Hierarchy': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId('configuration_hierarchy'); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; case 'Humans': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId(ALIAS_HUMAN_LIST); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; case 'Pages': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId('configuration_pages'); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; case 'SystemStrings': require_once O_FOLDER . '/keeled/SystemString.php'; $systemString = new SystemString(); $systemString->setId('configuration_systemStrings'); $systemString->setCompleteSystemString(); $alias = $systemString->translate(array('block' => 'title')); break; default: require_once O_FOLDER . '/errors/Error.php'; $object = Error::requireFile(array('id' => $parameters['id'], 'type' => $parameters['type'], 'isInstance' => TRUE, 'isToBeCompleted' => TRUE, 'typeOfError' => 'JSON', 'isInstance' => TRUE, 'isView' => FALSE)); $object->setIdOfLanguage($languageInUse['id']); $title = $object->translate(array('block' => 'title')); // echo ' 1717: ', $title; require_once O_FOLDER . 'Slug.php'; $alias = Slug::slugify(array('original' => $title)); } $currentLanguage = new Language(); $currentLanguage->setId($languageInUse['id']); $currentLanguage->setLanguage(); $tpl->setCurrentBlock('language-in-menu'); $tpl->setVariable(array('ALIAS-OF-LANGUAGE' => $alias, 'DESIGNATION-OF-LANGUAGE-IN-MENU' => $currentLanguage->getNaming(), 'ID-OF-LANGUAGE-IN-MENU' => $languageInUse['id'], 'LOCATION-OF-LANGUAGE' => DOMAIN)); $tpl->parseCurrentBlock(); } } if (count($languagesInUse) > 2) { require_once O_FOLDER . 'FormRowView.php'; $tpl->setCurrentBlock('box-for-languages'); $tpl->setVariable(array('ALIAS-IN-RIGHT-SIDEBAR' => $alias, 'ALIAS-OF-LANGUAGES' => ALIAS_OF_LANGUAGES, 'ALT-LANGUAGE' => ALT_LANGUAGE, 'BEGINNING-OF-URL-IN-RIGHT-SIDEBAR' => DOMAIN, 'FIELD-OF-LANGUAGE' => FormRowView::buildFormFieldWithMessageField(array('class' => ' Language', 'dataFieldName' => 'language', 'isInfoAbove' => FALSE, 'mainTypeOfDataField' => 'Input', 'typeOfBox' => 'input', 'suffix' => $parameters['suffix'], 'title' => TITLE_LANGUAGE, 'value' => $language->getNaming())), 'ID-OF-LANGUAGE' => isset($_SESSION['language']) ? $_SESSION['language'] : DEFAULT_LANGUAGE, 'PATH-TO-IMAGES-IN-RIGHT-SIDEBAR' => IMAGES_FOLDER, 'SUFFIX-IN-RIGHT-SIDEBAR' => $parameters['suffix'])); $tpl->parseCurrentBlock(); } $tpl->parse('languages'); return $tpl->get('languages'); } else { return ''; } }
function parseMenu($intCatId, $strCommand) { global $_PATHS, $objLang, $_CONF, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("menu.tpl.htm"); //*** Parse the header links. $objTpl->setVariable("LOGGEDIN", $objLang->get("loggedInAs", "head")); $objTpl->setVariable("LOGOUT", $objLang->get("logout", "head")); $objTpl->setVariable("COMPANY_NAME", htmlentities($_CONF['app']['account']->getName())); $objTpl->setVariable("USER_NAME", $objLiveUser->getProperty('name')); if ($objLiveUser->checkRight(MYPUNCH_PROFILE_VIEW)) { $objTpl->setVariable("PROFILE_LINK", "href=\"?cid=" . NAV_MYPUNCH_PROFILE . "\""); } //*** Parse the main menu buttons. foreach ($_CONF['app']['msMypunch'] as $key => $value) { if (is_array($value)) { //*** Nested MyPunch menu items. foreach ($value as $subKey => $subValue) { if ($objLiveUser->checkRight($_CONF['app']['navRights'][$subValue]) == true && $_CONF['app']['account']->hasProduct(constant('PRODUCT_' . strtoupper($subKey))) == true) { $objTpl->setCurrentBlock("mypunch.{$key}"); $objTpl->setVariable("LABEL_MYPUNCH_" . strtoupper($key), $objLang->get($subKey, "menu")); $objTpl->setVariable("CID_MYPUNCH_" . strtoupper($key), $subValue); if ($intCatId == $subValue || in_array($intCatId, $_CONF['app']['ms' . ucfirst($subKey)])) { //*** Render product sub menu. foreach ($_CONF['app']['ms' . ucfirst($subKey)] as $productKey => $productValue) { if ($objLiveUser->checkRight($_CONF['app']['navRights'][$productValue]) == true) { $objTpl->setVariable("LABEL_" . strtoupper($subKey) . "_" . strtoupper($productKey), $objLang->get($subKey . ucfirst($productKey), "menu")); $objTpl->setVariable("CID_" . strtoupper($subKey) . "_" . strtoupper($productKey), $productValue); //*** Activate sub button. if ($intCatId == $productValue) { $objTpl->setVariable("ACTIVE_" . strtoupper($subKey) . "_" . strtoupper($productKey), "class=\"active\""); } } } //*** Activate main button. $objTpl->setVariable("ACTIVE_MYPUNCH_" . strtoupper($key), "class=\"active\""); } $objTpl->parseCurrentBlock(); } } } else { if ($objLiveUser->checkRight($_CONF['app']['navRights'][$value]) == true) { //*** Plain MyPunch menu items. $objTpl->setVariable("LABEL_MYPUNCH_" . strtoupper($key), $objLang->get("mypunch" . ucfirst($key), "menu")); $objTpl->setVariable("CID_MYPUNCH_" . strtoupper($key), $value); //*** Activate menu item. if ($intCatId == $value) { $objTpl->setVariable("ACTIVE_MYPUNCH_" . strtoupper($key), "class=\"active\""); //*** Render MyPunch tab button. $objTpl->setVariable("LABEL_MYPUNCHSUB_" . strtoupper($key), $objLang->get("mypunch" . ucfirst($key), "menu")); $objTpl->setVariable("CID_MYPUNCHSUB_" . strtoupper($key), $value); $objTpl->setVariable("ACTIVE_MYPUNCHSUB_" . strtoupper($key), "class=\"active\""); } } } } return $objTpl->get(); }
<?php require_once 'HTML/Template/IT.php'; $data = array ( '0' => array('Stig', 'Bakken'), '1' => array('Martin', 'Jansen'), '2' => array('Alexander', 'Merz') ); $tpl = new HTML_Template_IT('./templates'); $tpl->loadTemplatefile('main.tpl.htm', true, true); foreach ($data as $name) { foreach ($name as $cell) { // Assign data to the inner block $tpl->setCurrentBlock('cell'); $tpl->setVariable('DATA', $cell); $tpl->parseCurrentBlock(); } // Assign data and the inner block to the // outer block $tpl->setCurrentBlock('row'); $tpl->parseCurrentBlock(); } // print the output $tpl->show(); ?>
/** * Initialize a TemplateObject, add a title, and icon and add JS and CSS for DHTML * * @param string $file filename of the template file * @param string $title (optional) title of the page * @param string $icon (optional) iconhandle for this page * @param boolean $useDHTML (optional) add JS and CSS for DHTML-features * * @access private * * @return object Object of HTML/IT - Template - Class */ function _initTemplate($file, $title = '', $icon = '', $useDHTML = true) { $tpl = new HTML_Template_IT(dirname(__FILE__) . "/Web"); $tpl->loadTemplateFile($file); $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("ImgPEAR", $_SERVER["PHP_SELF"] . '?img=pear'); if ($title) { $tpl->setVariable("Title", $title); } if ($icon) { $tpl->setCurrentBlock("TitleBlock"); $tpl->setVariable("_InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("_Title", $title); $tpl->setVariable("_Icon", $icon); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock(); if ($useDHTML && Net_UserAgent_Detect::getBrowser('ie5up') == 'ie5up') { $dhtml = true; } else { $dhtml = false; } if ($dhtml) { $tpl->setVariable("JS", 'dhtml'); $css = '<link rel="stylesheet" href="' . $_SERVER['PHP_SELF'] . '?css=dhtml" />'; $tpl->setVariable("DHTMLcss", $css); } else { $tpl->setVariable("JS", 'nodhtml'); } if (!isset($_SESSION['_PEAR_Frontend_Web_js']) || $_SESSION['_PEAR_Frontend_Web_js'] == false) { $tpl->setCurrentBlock('JSEnable'); $tpl->setVariable('RedirectURL', $_SERVER['REQUEST_URI'] . (!empty($_GET) ? '&' : '?') . 'enableJS=1'); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock(); } return $tpl; }
function parseTemplates($intElmntId, $strCommand) { global $_PATHS, $objLang, $_CONF, $_CLEAN_POST, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); switch ($strCommand) { case CMD_LIST: $objTpl->loadTemplatefile("multiview.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsTemplates", "menu")); $objTemplate = Template::selectByPK($intElmntId); if (empty($intElmntId)) { $strTemplateName = "Website"; } else { if (is_object($objTemplate)) { $strTemplateName = $objTemplate->getName(); } else { $strTemplateName = ""; } } if (is_object($objTemplate)) { $objFields = $objTemplate->getFields(); if (is_object($objFields)) { //*** Initiate field loop. $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objFields->seek($intPosition); //*** Loop through the fields. foreach ($objFields as $objField) { $objFieldType = TemplateFieldType::selectByPK($objField->getTypeId()); $strMeta = $objLang->get("editedBy", "label") . " " . $objField->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objField->getModified()); $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button")); $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:PTemplateField.duplicate({$objField->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PTemplateField.remove({$objField->getId()});"); $objTpl->setVariable("MULTIITEM_VALUE", $objField->getId()); $objTpl->setVariable("MULTIITEM_HREF", "href=\"?cid=" . NAV_PCMS_TEMPLATES . "&eid={$objField->getId()}&cmd=" . CMD_EDIT_FIELD . "\""); $strValue = htmlspecialchars($objField->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $objTpl->setVariable("MULTIITEM_TYPE", ", " . $objFieldType->getName()); $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "field"); $objTpl->setVariable("MULTIITEM_META", $strMeta); $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } //*** Render page navigation. $pageCount = ceil($objFields->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"] < $objFields->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_TEMPLATES . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&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_TEMPLATES . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } //*** Top 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_TEMPLATES . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; $arrActions[$objLang->get("duplicate", "button")] = "duplicate"; 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&cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_TEMPLATES . "&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", "&cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}"); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "PTemplateField.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:PTemplateField.multiSelect()"); $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newTemplate", "button")); $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_ADD); $objTpl->setVariable("BUTTON_NEWSTRUCTURE", $objLang->get("newStructure", "button")); $objTpl->setVariable("BUTTON_NEWSTRUCTURE_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_ADD_STRUCTURE); if (is_object($objTemplate)) { $objTpl->setVariable("BUTTON_NEWFIELD", $objLang->get("newField", "button")); $objTpl->setVariable("BUTTON_NEWFIELD_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_ADD_FIELD); $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button")); $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_EDIT); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("removeTemplate", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PTemplate.remove({$intElmntId});"); $objTpl->setVariable("BUTTON_MAIN_DUPLICATE", $objLang->get("duplicateTemplate", "button")); $objTpl->setVariable("BUTTON_MAIN_DUPLICATE_HREF", "javascript:PTemplate.duplicate({$intElmntId});"); $objTpl->setVariable("BUTTON_EXPORT_TEMPLATE", $objLang->get("export", "button")); $objTpl->setVariable("BUTTON_EXPORT_TEMPLATE_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_EXPORT_TEMPLATE); $objTpl->setVariable("BUTTON_IMPORT_TEMPLATE", $objLang->get("import", "button")); $objTpl->setVariable("BUTTON_IMPORT_TEMPLATE_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_IMPORT_TEMPLATE); } $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("fieldsFor", "label") . " "); $objTpl->setVariable("SUBJECT_NAME", $strTemplateName); $objTpl->parseCurrentBlock(); break; case CMD_REMOVE: $objTemplate = Template::selectByPK($intElmntId); $intParent = $objTemplate->getParentId(); $objTemplate->delete(); header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_DUPLICATE: $objTemplate = Template::selectByPK($intElmntId); $intParent = $objTemplate->getParentId(); $objTemplate->setUsername($objLiveUser->getProperty("name")); $objDuplicate = $objTemplate->duplicate($objLang->get("copyOf", "label")); //*** 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_REMOVE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getTemplateId(); foreach ($objFields as $objField) { $objField->delete(); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getTemplateId(); $objField->delete(); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_DUPLICATE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getTemplateId(); foreach ($objFields as $objField) { $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getTemplateId(); $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_ADD: case CMD_EDIT: $objTpl->loadTemplatefile("template.tpl.htm"); //*** 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; } //*** Post the template form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addTemplate") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_ispage"])) { $objTpl->setVariable("ERROR_ISPAGE_ON", " error"); $objTpl->setVariable("ERROR_ISPAGE", $objLang->get("isPage", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_iscontainer"])) { $objTpl->setVariable("ERROR_ISCONTAINER_ON", " error"); $objTpl->setVariable("ERROR_ISCONTAINER", $objLang->get("isContainer", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_forcecreation"])) { $objTpl->setVariable("ERROR_FORCECREATION_ON", " error"); $objTpl->setVariable("ERROR_FORCECREATION", $objLang->get("forceCreation", "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_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; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "templateForm"); $objTpl->setVariable("FORM_ISPAGE_VALUE", isset($_POST["frm_ispage"]) && $_POST["frm_ispage"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the template. if ($strCommand == CMD_EDIT) { $objTemplate = Template::selectByPK($intElmntId); } else { $objTemplate = new Template(); $objTemplate->setParentId($_POST["eid"]); $objTemplate->setAccountId($_CONF['app']['account']->getId()); } $objTemplate->setIsPage(empty($_CLEAN_POST["frm_ispage"]) ? 0 : 1); $objTemplate->setIsContainer(empty($_CLEAN_POST["frm_iscontainer"]) ? 0 : 1); $objTemplate->setForceCreation(empty($_CLEAN_POST["frm_forcecreation"]) ? 0 : 1); $objTemplate->setName($_CLEAN_POST["frm_name"]); $objTemplate->setApiName($_CLEAN_POST["frm_apiname"]); $objTemplate->setDescription($_CLEAN_POST["frm_description"]); $objTemplate->save(); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objTemplate->getId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "templateForm"); } //*** Parse the template. $objTemplate = Template::selectByPK($intElmntId); //*** Set section title. if ($strCommand == CMD_EDIT) { $objTpl->setVariable("MAINTITLE", $objLang->get("templateDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objTemplate->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("templateDetails", "label")); } //*** Set tab title. $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("templateadd"); //*** Insert values if action is edit. if ($strCommand == CMD_EDIT) { $objTpl->setVariable("FORM_ISPAGE_VALUE", $objTemplate->getIsPage() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_ISCONTAINER_VALUE", $objTemplate->getIsContainer() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_FORCECREATION_VALUE", $objTemplate->getForceCreation() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objTemplate->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objTemplate->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objTemplate->getDescription()); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$objTemplate->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$objTemplate->getParentId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_PAGECONTAINER", $objLang->get("pageContainer", "form")); $objTpl->setVariable("LABEL_ISCONTAINER", $objLang->get("container", "form")); $objTpl->setVariable("ISCONTAINER_NOTE", $objLang->get("containerNote", "tip")); $objTpl->setVariable("LABEL_FORCECREATION", $objLang->get("forceCreation", "form")); $objTpl->setVariable("FORCECREATION_NOTE", $objLang->get("forceCreationNote", "tip")); $objTpl->setVariable("LABEL_TEMPLATENAME", $objLang->get("templateName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->parseCurrentBlock(); $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("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_TEMPLATES); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_ADD_FIELD: case CMD_EDIT_FIELD: $objTpl->loadTemplatefile("templatefield.tpl.htm"); //*** Post the templateField form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addTemplateField") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_required"])) { $objTpl->setVariable("ERROR_REQUIRED_ON", " error"); $objTpl->setVariable("ERROR_REQUIRED", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("fieldName", "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_description"])) { $objTpl->setVariable("ERROR_NOTES_ON", " error"); $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_field_type"])) { $objTpl->setVariable("ERROR_FIELDTYPE_ON", " error"); $objTpl->setVariable("ERROR_FIELDTYPE", $objLang->get("fieldType", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "templateFieldForm"); $objTpl->setVariable("FORM_REQUIRED_VALUE", isset($_POST["frm_required"]) && $_POST["frm_required"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the template. if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); } else { $objField = new TemplateField(); $objField->setTemplateId($_POST["eid"]); } $objField->setRequired(empty($_CLEAN_POST["frm_required"]) ? 0 : 1); $objField->setName($_CLEAN_POST["frm_name"]); $objField->setApiName($_CLEAN_POST["frm_apiname"]); $objField->setDescription($_CLEAN_POST["frm_description"]); $objField->setTypeId($_CLEAN_POST["frm_field_type"]); $objField->setUsername($objLiveUser->getProperty("name")); $objField->save(); $objField->clearValues(); //*** Add type values to the field. foreach ($_REQUEST as $key => $value) { if (is_array($value)) { $intCount = 0; foreach ($value as $subKey => $subValue) { $objValue = new TemplateFieldValue(); $objValue->setName($key . "_" . $intCount); $objValue->setValue($subValue); $objValue->setFieldId($objField->getId()); $objValue->save(); $intCount++; } } else { if ($value != "" && substr($key, 0, 4) == "tfv_") { $objValue = new TemplateFieldValue(); $objValue->setName($key); $objValue->setValue($value); $objValue->setFieldId($objField->getId()); $objValue->save(); } } } header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objField->getTemplateId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "templateFieldForm"); } $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("details", "label")); $objTpl->parseCurrentBlock(); $typeValue = 0; if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); $typeValue = $objField->getTypeId(); } $objTypes = TemplateFieldTypes::getTypes(); if (is_object($objTypes)) { foreach ($objTypes as $objType) { $objTpl->setCurrentBlock("list_fieldtype"); if ($typeValue == $objType->getId()) { $objTpl->setVariable("FIELDTYPE_SELECTED", "selected=\"selected\""); } $objTpl->setVariable("FIELDTYPE_VALUE", $objType->getId()); $objTpl->setVariable("FIELDTYPE_TEXT", xhtmlsave($objType->getName())); $objTpl->parseCurrentBlock(); } } //*** Set section title. if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("MAINTITLE", $objLang->get("templateFieldDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objField->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("templateFieldDetails", "label")); } //*** Image crop settings. $arrValues = array(1, 2, 3, 4); $arrLabels = array("Resize cropped", "Resize fit cropped", "Resize distorted", "Resize to fit"); $arrSettings = array(); $arrImageSettings = array(); if ($strCommand == CMD_EDIT_FIELD) { $objFieldValues = $objField->getValues(); if (is_object($objFieldValues)) { foreach ($objFieldValues as $objFieldValue) { switch (strtoupper($objFieldValue->getName())) { case "TFV_BOOLEAN_DEFAULT": if ($objFieldValue->getValue()) { $arrSettings[$objFieldValue->getName()] = "checked=\"checked\""; } break; default: $arrKey = explode("_", $objFieldValue->getName()); $intIndex = array_pop($arrKey); if (is_numeric($intIndex)) { $strValue = $objFieldValue->getValue(); $arrImageSettings[$intIndex][implode("_", $arrKey)] = xhtmlsave($strValue); } else { $strValue = $objFieldValue->getValue(); $arrSettings[$objFieldValue->getName()] = xhtmlsave($strValue); } } } if (count($arrImageSettings) > 0) { //*** Image settings. $arrImageSettings = array_reverse($arrImageSettings); foreach ($arrImageSettings as $key => $objValue) { $objTpl->setCurrentBlock("image.settings"); foreach ($objValue as $setting => $value) { switch (strtoupper($setting)) { case "TFV_IMAGE_SCALE": $strValue = ""; foreach ($arrValues as $settingKey => $settingValue) { $selected = $settingValue == $value ? " selected=\"selected\"" : ""; $strValue .= "<option value=\"{$arrValues[$settingKey]}\"{$selected}>{$arrLabels[$settingKey]}</option>\n"; } $objTpl->setVariable(strtoupper($setting), $strValue); break; case "TFV_IMAGE_GRAYSCALE": if ($value) { $objTpl->setVariable(strtoupper($setting), "checked=\"checked\""); } break; default: $objTpl->setVariable(strtoupper($setting), xhtmlsave($value)); } } if (count($arrImageSettings) == 1) { $objTpl->setVariable("API_STYLE", "display:none"); } if ($key == 0) { $objTpl->setVariable("REMOVE_STYLE", "display:none"); } $objTpl->parseCurrentBlock(); } } } } $objTpl->setCurrentBlock("templatefieldadd"); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_REQUIREDFIELD", $objLang->get("requiredField", "form")); $objTpl->setVariable("LABEL_FIELDNAME", $objLang->get("fieldName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->setVariable("LABEL_FIELDTYPE", $objLang->get("fieldType", "form")); $objTpl->setVariable("LABEL_FIELDTYPE_OPTIONS", $objLang->get("typeOptions", "label")); $objTpl->setVariable("TFV_LIST_NOTES", $objLang->get("templateListType", "tip")); $objTpl->setVariable("TFV_FORMAT_NOTES", $objLang->get("templateDateType", "tip")); $objTpl->setVariable("TFV_QUALITY_NOTES", $objLang->get("templateImageType", "tip")); $objTpl->setVariable("TFV_EXTENSION_NOTES", $objLang->get("templateFileType", "tip")); //*** Render image scale pulldown. if (count($arrImageSettings) == 0) { $strValue = ""; foreach ($arrValues as $key => $value) { $strValue .= "<option value=\"{$arrValues[$key]}\">{$arrLabels[$key]}</option>\n"; } $objTpl->setVariable("TFV_IMAGE_SCALE", $strValue); $objTpl->setVariable("API_STYLE", "display:none"); $objTpl->setVariable("REMOVE_STYLE", "display:none"); } //*** Insert values if action is edit. if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("FORM_REQUIRED_VALUE", $objField->getRequired() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objField->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objField->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objField->getDescription()); //*** Insert values for the field type. if (count($arrSettings) > 0) { foreach ($arrSettings as $name => $value) { switch (strtoupper($name)) { case "TFV_BOOLEAN_DEFAULT": if ($value) { $objTpl->setVariable(strtoupper($name), "checked=\"checked\""); } break; case "TFV_IMAGE_SCALE": //*** Skip. Already set. break; default: $objTpl->setVariable(strtoupper($name), xhtmlsave($value)); } } } } $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("singleview"); if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$objField->getTemplateId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$objField->getTemplateId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_TEMPLATES); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_ADD_STRUCTURE: case CMD_ADD_STRUCTURE_DETAIL: $objTpl->loadTemplatefile("structure.tpl.htm"); $blnRenderSelects = false; //*** Post the structure form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addStructure") { //*** The structure form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_structure"])) { $objTpl->setVariable("ERROR_STRUCTURE_ON", " error"); $objTpl->setVariable("ERROR_STRUCTURE", $objLang->get("structure", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "structureForm"); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Import the structure. if (Structure::hasSelect($_CLEAN_POST["frm_structure"]) && $strCommand == CMD_ADD_STRUCTURE) { $blnRenderSelects = true; } else { Structure::addById($_CLEAN_POST["frm_structure"], $intElmntId); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $intElmntId); exit; } } } else { $objTpl->setVariable("FORM_NAME", "structureForm"); } //*** Parse the template. $objTemplate = Template::selectByPK($intElmntId); //*** Set section title. $objTpl->setVariable("MAINTITLE", $objLang->get("structureAdd", "label")); //*** Set tab title. $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("structureDetails", "label")); $objTpl->parseCurrentBlock(); if (!$blnRenderSelects) { $objElements = Structure::selectBySection("template"); foreach ($objElements as $objElement) { $objTpl->setCurrentBlock("structure.item"); $objTpl->setVariable("VALUE", $objElement->getId()); $objTpl->setVariable("LABEL", $objElement->getName()); $objTpl->parseCurrentBlock(); } foreach ($objElements as $objElement) { $objTpl->setCurrentBlock("structure.description"); $objTpl->setVariable("VALUE", $objElement->getId()); $objTpl->setVariable("BODY", $objElement->getDescription()); if ($objElements->key() > 0) { $objTpl->setVariable("HIDE", "display:none"); } $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("structureadd.description"); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("structureAdd", "tip")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("structureadd"); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("LABEL_STRUCTURENAME", $objLang->get("structureName", "form")); $objTpl->parseCurrentBlock(); } else { $objSelects = Structure::getSelectsById($_CLEAN_POST["frm_structure"]); foreach ($objSelects as $objSelect) { switch ($objSelect->getType()) { case "language": $objContentLangs = ContentLanguage::select(); foreach ($objContentLangs as $objContentLang) { $objTpl->setCurrentBlock("select.language.item"); $objTpl->setVariable("LABEL", $objContentLang->getName()); $objTpl->setVariable("VALUE", $objContentLang->getId()); $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("select.language"); $objTpl->setVariable("LABEL", $objLang->get("sSelectLanguage", "form")); $objTpl->setVariable("DESCRIPTION", $objSelect->getDescription()); $objTpl->setVariable("SELECT_NAME", "frm_select_" . $objSelect->getId()); $objTpl->parseCurrentBlock(); break; case "element": $objTpl->setCurrentBlock("select.element"); $objTpl->setVariable("DESCRIPTION", $objSelect->getDescription()); $objTpl->setVariable("SELECT_NAME", "frm_select_" . $objSelect->getId()); $objTpl->setVariable("FORM_NAME", "detailsForm"); $objTpl->parseCurrentBlock(); break; } } $objTpl->setCurrentBlock("structureadd.description"); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("structureSelects", "tip")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("structureselects"); $objTpl->setVariable("FRM_STRUCURE", $_CLEAN_POST["frm_structure"]); $objTpl->parseCurrentBlock(); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&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("insert", "button")); $objTpl->setVariable("CID", NAV_PCMS_TEMPLATES); $objTpl->setVariable("CMD", !$blnRenderSelects ? CMD_ADD_STRUCTURE : CMD_ADD_STRUCTURE_DETAIL); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); if ($blnRenderSelects) { $objTpl->setVariable("FORM_NAME", "detailsForm"); } break; case CMD_EXPORT_TEMPLATE: $objTpl->loadTemplatefile("export.tpl.htm"); //*** Parse the template. $objTemplate = Template::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' && !empty($_POST['export_type'])) { //*** The template form has been posted. $arrTemplateFilters = array(); foreach ($_POST['tmpl'] as $id => $val) { $arrTemplateFilters[] = intval($id); } $exportElements = $_POST['export_type'] == 'templates_elements' ? true : false; $strZipFile = ImpEx::exportFrom(NULL, $objTemplate->getId(), NULL, $arrTemplateFilters, $_CONF['app']['account']->getId(), $exportElements); //*** 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") . '_exportTemplates.zip"'); header("Content-Transfer-Encoding: binary\n"); readfile($strZipFile); unlink($strZipFile); exit; } //*** Create template checkboxes $objTpl->setVariable("FORM_CHECKBOXES", createTemplateTree($objTemplate)); $objTpl->setVariable("EXPORT", $objLang->get("export", "label")); $objTpl->setVariable("EXPORT_TEMPLATES_ELEMENTS", $objLang->get("templatesElements", "label")); $objTpl->setVariable("EXPORT_TEMPLATES", $objLang->get("templates", "label")); $objTpl->setVariable("SELECT_ITEMS", $objLang->get("selectTemplates", "label")); //*** Set form buttons $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_TEMPLATES . "&eid={$intElmntId}&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_TEMPLATES); $objTpl->setVariable("CMD", CMD_EXPORT_TEMPLATE); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_IMPORT_TEMPLATE: $objTpl->loadTemplatefile("import.tpl.htm"); //*** Parse the template. $objTemplate = Template::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 { $importElements = $_POST['import_type'] === 'templates_elements' ? true : false; if (!ImpEx::importIn($_FILES["file"]["tmp_name"], NULL, $objTemplate->getId(), $_CONF['app']['account']->getId(), true, $importElements, false)) { $objTpl->setVariable('ERROR_MAIN', 'Templates and/or fields of templates in file do not match the destination templates'); } } } } $objTpl->setVariable("IMPORT", $objLang->get("import", "label")); $objTpl->setVariable("IMPORT_TEMPLATES_ELEMENTS", $objLang->get("templatesElements", "label")); $objTpl->setVariable("IMPORT_TEMPLATES", $objLang->get("templates", "label")); $objTpl->setVariable("IMPORT_ELEMENTS", $objLang->get("elements", "label")); $objTpl->setVariable('CUR_LOCATION', $objTemplate->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_TEMPLATES . "&eid={$intElmntId}&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_TEMPLATES); $objTpl->setVariable("CMD", CMD_IMPORT_TEMPLATE); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; } return $objTpl->get(); }
$tpl->loadTemplatefile("index.tpl", true, true); // data for the news $news_id = $walnut_db->fetchDataDB('news', 'news_id', 'desc'); $news_author = $walnut_db->fetchDataDB('news', 'news_author', 'desc'); $news_title = $walnut_db->fetchDataDB('news', 'news_title', 'desc'); $news_date = $walnut_db->fetchDataDB('news', 'news_date', 'desc'); $news_content = $walnut_db->fetchDataDB('news', 'news_content', 'desc'); $num = count($news_id); for ($i = 0; $i < $num; $i++) { $tpl->setCurrentBlock("news"); $tpl->setVariable("TIT_NEWS", $news_title[$i]); $tpl->setVariable("AUTHOR_NEWS", $news_author[$i]); $tpl->setVariable("DATE_NEWS", $news_date[$i]); $news_content[$i] = nl2br($news_content[$i]); $tpl->setVariable("CONTENT_NEWS", $news_content[$i]); $tpl->parseCurrentBlock("news"); } /// data from database // data for title and logo url $title = $walnut_db->fetchDataDB('settings', 'title'); $logo = $walnut_db->fetchDataDB('settings', 'logo_url'); // data for the menu $menu_id = $walnut_db->fetchDataDB('menu', 'id'); $menu_name = $walnut_db->fetchDataDB('menu', 'name'); $menu_ref = $walnut_db->fetchDataDB('menu', 'ref'); $num = count($menu_id); for ($i = 0; $i < $num; $i++) { $tpl->setCurrentBlock("menu"); $tpl->setVariable("REF", $menu_ref[$i]); $tpl->setVariable("NAME", $menu_name[$i]); $tpl->setVariable("ID", $menu_id[$i]);
function SetItemImage(&$tpl, $itemName, $itemProjectId) { $itemimage_tpl = new HTML_Template_IT("./"); $itemimage_tpl->loadTemplatefile("itemimage.tpl.html", true, true); if (ItemHasImage($itemName, $itemProjectId)) { $itemimage_tpl->setCurrentBlock("image_available"); $itemimage_tpl->setVariable("ITEM_NAME", urlencode($itemName)); $itemimage_tpl->setVariable("ITEM_PROJECT_ID", $itemProjectId); $itemimage_tpl->parseCurrentBlock("image_available"); } else { $itemimage_tpl->setCurrentBlock("no_image_available"); $itemimage_tpl->parseCurrentBlock("no_image_available"); } $tpl->setVariable("ITEM_IMAGE", $itemimage_tpl->get()); }
function parseAdmin($eId, $cmd) { global $_PATHS, $_CONF, $objLiveAdmin; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("admin.tpl.htm"); switch ($cmd) { case CMD_ADD: $strDispatch = Request::get('dispatch'); $strUserHandle = request('frm_admin_handle'); $strUserName = request('frm_admin_name'); $strUserPass = request('frm_admin_pass'); $strUserEmail = request('frm_admin_email'); if ($strDispatch == "editAdmin") { //*** Create new admin. $data = array('handle' => $strUserHandle, 'name' => $strUserName, 'passwd' => $strUserPass, 'is_active' => true, 'email' => $strUserEmail, 'account_id' => 0, 'perm_type' => 5); $intPermId = $objLiveAdmin->addUser($data); $strOutput = "<p>Admin successfully created.</p>\n"; $strOutput .= "<p><a href=\"index.php\">Login</a> with the new admin credentials.</p>\n"; $objTpl->setCurrentBlock("text"); $objTpl->setVariable('BODY', $strOutput); $objTpl->parseCurrentBlock(); } else { $objTpl->setCurrentBlock("form.add"); $objTpl->setVariable('CID', NAV_ADMIN); $objTpl->setVariable('CMD', $cmd); $objTpl->parseCurrentBlock(); } break; } //*** Return the output. return $objTpl->get(); }
function parseFeeds($intFeedId, $strCommand) { global $_PATHS, $_CLEAN_POST, $_CONF, $objLang, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("feed.tpl.htm"); $blnError = false; switch ($strCommand) { case CMD_LIST: case CMD_ADD: case CMD_EDIT: //*** Post the profile form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editFeed") { //*** The element form has been posted. //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_active"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_name"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_feed"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_basepath"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_refresh"])) { $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_FEED_VALUE", $_POST["frm_feed"]); $objTpl->setVariable("FORM_BASEPATH_VALUE", $_POST["frm_basepath"]); $objTpl->setVariable("FORM_REFRESH_VALUE", $_POST["frm_refresh"]); $objTpl->setVariable("ERROR_FEED_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the feed. if ($strCommand == CMD_EDIT) { $objFeed = Feed::selectByPK($intFeedId); } else { $objFeed = new Feed(); } $objFeed->setAccountId($_CONF['app']['account']->getId()); $objFeed->setActive($_POST["frm_active"] == "on" ? 1 : 0); $objFeed->setName($_CLEAN_POST["frm_name"]); $objFeed->setFeed($_CLEAN_POST["frm_feed"]); $objFeed->setBasepath($_CLEAN_POST["frm_basepath"]); $objFeed->setRefresh($_CLEAN_POST["frm_refresh"]); $objFeed->setLastUpdate(Date::toMysql()); $objFeed->save(); //*** Cache feed. $objFeed->cache(); header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_FEEDS); exit; } } //*** Initiate child element loop. $objFeeds = Feed::selectSorted(); $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objFeeds->seek($intPosition); foreach ($objFeeds as $objFeed) { $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("MULTIITEM_VALUE", $objFeed->getId()); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Feed.remove({$objFeed->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_FEEDS . "&eid={$objFeed->getId()}&cmd=" . CMD_EDIT); $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "feed"); $objTpl->setVariable("MULTIITEM_NAME", $objFeed->getName()); $objTpl->setVariable("MULTIITEM_POINTS_TO", $objLang->get("pointsTo", "label")); $objTpl->setVariable("MULTIITEM_FEED", $objFeed->getFeed()); $objTpl->setVariable("MULTIITEM_FEED_HREF", $objFeed->getFeed()); if (!$objFeed->getActive()) { $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\""); } $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } //*** Render page navigation. $pageCount = ceil($objFeeds->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"] < $objFeeds->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_FEEDS . "&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_FEEDS . "&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_FEEDS . "&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_FEEDS . "&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; foreach ($arrActions as $key => $value) { $objTpl->setCurrentBlock("multiview-listactionitem"); $objTpl->setVariable("LIST_ACTION_TEXT", $key); $objTpl->setVariable("LIST_ACTION_VALUE", $value); $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("multiview"); $objTpl->setVariable("LIST_LENGTH_HREF_10", "href=\"?list=10&cid=" . NAV_PCMS_FEEDS . "\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_FEEDS . "\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_FEEDS . "\""); 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", "&cid=" . NAV_PCMS_FEEDS); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "Feed.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:Feed.multiSelect()"); $objTpl->parseCurrentBlock(); $objTpl->setVariable("FEEDS", $objLang->get("feeds", "label")); $objTpl->setVariable("BUTTON_ADD", $objLang->get("feedAdd", "button")); //*** Form variables. if ($strCommand == CMD_EDIT) { $objFeed = Feed::selectByPK($intFeedId); $objTpl->setVariable("FORM_ACTIVE_VALUE", $objFeed->getActive() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objFeed->getName()); $objTpl->setVariable("FORM_FEED_VALUE", $objFeed->getFeed()); $objTpl->setVariable("FORM_BASEPATH_VALUE", $objFeed->getBasepath()); $objTpl->setVariable("FORM_REFRESH_VALUE", $objFeed->getRefresh()); $objTpl->setVariable("FRM_HEADER", $objLang->get("editFeed", "form")); $objTpl->setVariable("FRM_STYLE", ""); $objTpl->setVariable("CMD", CMD_EDIT); } else { $objTpl->setVariable("FORM_ACTIVE_VALUE", "checked=\"checked\""); $objTpl->setVariable("FRM_HEADER", $objLang->get("addFeed", "form")); if (!$blnError) { $objTpl->setVariable("FRM_STYLE", " style=\"display:none\""); } $objTpl->setVariable("CMD", CMD_ADD); $objElements = Elements::getFromParent(0); foreach ($objElements as $objElement) { $objTpl->setCurrentBlock("elements.item"); $objTpl->setVariable("VALUE", $objElement->getId()); $objTpl->setVariable("LABEL", $objElement->getName()); $objTpl->parseCurrentBlock(); } } $objTpl->setVariable("FRM_LABEL_ACTIVE", $objLang->get("active", "form")); $objTpl->setVariable("FRM_LABEL_FEED", $objLang->get("feed", "form")); $objTpl->setVariable("FRM_DESCR_FEED", $objLang->get("feed", "tip")); $objTpl->setVariable("FRM_LABEL_BASEPATH", $objLang->get("basepath", "form")); $objTpl->setVariable("FRM_DESCR_BASEPATH", $objLang->get("basepath", "tip")); $objTpl->setVariable("FRM_LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("FRM_DESCR_REFRESH", $objLang->get("refresh", "tip")); $objTpl->setVariable("FRM_LABEL_REFRESH", $objLang->get("refresh", "form")); $objTpl->setVariable("FRM_LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_FEEDS); $objTpl->setVariable("EID", $intFeedId); $objTpl->parseCurrentBlock(); $strReturn = $objTpl->get(); break; case CMD_REMOVE: if (strpos($intFeedId, ',') !== false) { //*** Multiple elements submitted. $arrFeeds = explode(',', $intFeedId); $objFeeds = Feed::selectByPK($arrFeeds); foreach ($objFeeds as $objFeed) { $objFeed->delete(); } } else { //*** Single element submitted. $objFeed = Feed::selectByPK($intFeedId); $objFeed->delete(); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; } return $strReturn; }
function parseForms($intElmntId, $strCommand) { global $_PATHS, $objLang, $_CONF, $_CLEAN_POST, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); switch ($strCommand) { case CMD_LIST: $objTpl->loadTemplatefile("multiview.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); $objForm = Form::selectByPK($intElmntId); if (empty($intElmntId)) { $strFormName = "Website"; } else { if (is_object($objForm)) { $strFormName = $objForm->getName(); } else { $strFormName = ""; } } if (is_object($objForm)) { $objFields = $objForm->getFields(); if (is_object($objFields)) { //*** Initiate field loop. $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objFields->seek($intPosition); //*** Loop through the fields. foreach ($objFields as $objField) { $objFieldType = TemplateFieldType::selectByPK($objField->getTypeId()); $strMeta = "Aangepast door " . $objField->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objField->getModified()); $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button")); $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:PTemplateField.duplicate({$objField->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PTemplateField.remove({$objField->getId()});"); $objTpl->setVariable("MULTIITEM_VALUE", $objField->getId()); $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getId()}&cmd=" . CMD_EDIT_FIELD); $strValue = htmlspecialchars($objField->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $objTpl->setVariable("MULTIITEM_TYPE", ", " . $objFieldType->getName()); $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "field"); $objTpl->setVariable("MULTIITEM_META", $strMeta); $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } //*** Render page navigation. $pageCount = ceil($objFields->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"] < $objFields->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_FORMS . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&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_FORMS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } //*** Top 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_FORMS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; $arrActions[$objLang->get("duplicate", "button")] = "duplicate"; 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&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_FORMS . "&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", "&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}"); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "PTemplateField.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:PTemplateField.multiSelect()"); if (is_object($objForm)) { $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button")); $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_EDIT); $objTpl->setVariable("BUTTON_NEWFIELD", $objLang->get("newField", "button")); $objTpl->setVariable("BUTTON_NEWFIELD_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_ADD_FIELD); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("removeForm", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Form.remove({$intElmntId});"); } else { $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newForm", "button")); $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_ADD); } $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("fieldsFor", "label") . " "); $objTpl->setVariable("SUBJECT_NAME", $strFormName); $objTpl->parseCurrentBlock(); break; case CMD_REMOVE: $objForm = Form::selectByPK($intElmntId); $intParent = $objForm->getParentId(); $objForm->delete(); header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_REMOVE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getFormId(); foreach ($objFields as $objField) { $objField->delete(); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getFormId(); $objField->delete(); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_DUPLICATE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getFormId(); foreach ($objFields as $objField) { $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getFormId(); $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_ADD: case CMD_EDIT: $objTpl->loadTemplatefile("forms.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); //*** Post the template form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addForm") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("formName", "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_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; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "formForm"); $objTpl->setVariable("FORM_ISPAGE_VALUE", isset($_POST["frm_ispage"]) && $_POST["frm_ispage"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the form. if ($strCommand == CMD_EDIT) { $objForm = Form::selectByPK($intElmntId); } else { $objForm = new Form(); $objForm->setAccountId($_CONF['app']['account']->getId()); } $objForm->setName($_CLEAN_POST["frm_name"]); $objForm->setApiName($_CLEAN_POST["frm_apiname"]); $objForm->setDescription($_CLEAN_POST["frm_description"]); $objForm->save(); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objForm->getId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "formForm"); } //*** Parse the form. $objForm = Form::selectByPK($intElmntId); $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("formDetails", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("formadd"); //*** Insert values if action is edit. if ($strCommand == CMD_EDIT) { $objTpl->setVariable("FORM_ISPAGE_VALUE", $objForm->getIsPage() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_ISCONTAINER_VALUE", $objForm->getIsContainer() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objForm->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objForm->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objForm->getDescription()); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objForm->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objForm->getParentId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_PAGECONTAINER", $objLang->get("pageContainer", "form")); $objTpl->setVariable("LABEL_CONTAINER", $objLang->get("container", "form")); $objTpl->setVariable("LABEL_FORMNAME", $objLang->get("formName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("singleview"); $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("CID", NAV_PCMS_FORMS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_ADD_FIELD: case CMD_EDIT_FIELD: $objTpl->loadTemplatefile("templatefield.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); //*** Post the templateField form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addTemplateField") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_required"])) { $objTpl->setVariable("ERROR_REQUIRED_ON", " error"); $objTpl->setVariable("ERROR_REQUIRED", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("fieldName", "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_description"])) { $objTpl->setVariable("ERROR_NOTES_ON", " error"); $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_field_type"])) { $objTpl->setVariable("ERROR_FIELDTYPE_ON", " error"); $objTpl->setVariable("ERROR_FIELDTYPE", $objLang->get("fieldType", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "templateFieldForm"); $objTpl->setVariable("FORM_REQUIRED_VALUE", isset($_POST["frm_required"]) && $_POST["frm_required"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the template. if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); } else { $objField = new TemplateField(); $objField->setFormId($_POST["eid"]); } $objField->setRequired(empty($_CLEAN_POST["frm_required"]) ? 0 : 1); $objField->setName($_CLEAN_POST["frm_name"]); $objField->setApiName($_CLEAN_POST["frm_apiname"]); $objField->setDescription($_CLEAN_POST["frm_description"]); $objField->setTypeId($_CLEAN_POST["frm_field_type"]); $objField->setUsername($objLiveUser->getProperty("name")); $objField->save(); $objField->clearValues(); //*** Add type values to the field. foreach ($_REQUEST as $key => $value) { if ($value != "" && substr($key, 0, 4) == "tfv_") { $objValue = new TemplateFieldValue(); $objValue->setName($key); $objValue->setValue($value); $objValue->setFieldId($objField->getId()); $objValue->save(); } } header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objField->getFormId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "templateFieldForm"); } $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("templateFieldDetails", "label")); $objTpl->parseCurrentBlock(); $typeValue = 0; if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); $typeValue = $objField->getTypeId(); } $objTypes = TemplateFieldTypes::getTypes(); if (is_object($objTypes)) { foreach ($objTypes as $objType) { $objTpl->setCurrentBlock("list_fieldtype"); if ($typeValue == $objType->getId()) { $objTpl->setVariable("FIELDTYPE_SELECTED", "selected=\"selected\""); } $objTpl->setVariable("FIELDTYPE_VALUE", $objType->getId()); $objTpl->setVariable("FIELDTYPE_TEXT", $objType->getName()); $objTpl->parseCurrentBlock(); } } $objTpl->setCurrentBlock("templatefieldadd"); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_REQUIREDFIELD", $objLang->get("requiredField", "form")); $objTpl->setVariable("LABEL_FIELDNAME", $objLang->get("fieldName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->setVariable("LABEL_FIELDTYPE", $objLang->get("fieldType", "form")); $objTpl->setVariable("LABEL_FIELDTYPE_OPTIONS", $objLang->get("typeOptions", "label")); $objTpl->setVariable("TFV_LIST_NOTES", $objLang->get("templateListType", "tip")); $objTpl->setVariable("TFV_FORMAT_NOTES", $objLang->get("templateDateType", "tip")); $objTpl->setVariable("TFV_QUALITY_NOTES", $objLang->get("templateImageType", "tip")); $objTpl->setVariable("TFV_EXTENSION_NOTES", $objLang->get("templateFileType", "tip")); //*** Render image scale pulldown. $arrValues = array(1, 2, 3, 4, 5); $arrLabels = array("Resize exact, crop", "Resize exact, distort", "Resize with boundary, crop", "Resize with boundary, distort", "Resize with boundary, exact"); $strValue = ""; foreach ($arrValues as $key => $value) { $strValue .= "<option value=\"{$arrValues[$key]}\">{$arrLabels[$key]}</option>\n"; } $objTpl->setVariable("TFV_IMAGE_SCALE", $strValue); //*** Insert values if action is edit. if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("FORM_REQUIRED_VALUE", $objField->getRequired() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objField->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objField->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objField->getDescription()); //*** Insert values for the field type. $objFieldValues = $objField->getValues(); if (is_object($objFieldValues)) { foreach ($objFieldValues as $objFieldValue) { if (strtoupper($objFieldValue->getName()) == "TFV_IMAGE_SCALE") { if ($objField->getTypeId() == FIELD_TYPE_IMAGE) { $strValue = ""; foreach ($arrValues as $key => $value) { $selected = $value == $objFieldValue->getValue() ? " selected=\"selected\"" : ""; $strValue .= "<option value=\"{$arrValues[$key]}\"{$selected}>{$arrLabels[$key]}</option>\n"; } $objTpl->setVariable(strtoupper($objFieldValue->getName()), $strValue); } } else { $strValue = $objFieldValue->getValue(); $objTpl->setVariable(strtoupper($objFieldValue->getName()), $strValue); } } } } $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("singleview"); if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getFormId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getFormId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("CID", NAV_PCMS_FORMS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; } return $objTpl->get(); }
function parseSearch($intElmntId, $strCommand) { global $_PATHS, $objLang, $DBAConn; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("search.tpl.htm"); $objTpl->setVariable("TITLE", $objLang->get("pageTitle")); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsSearch", "menu")); $objTpl->setVariable("BUTTON_INDEX_HREF", "?cid=" . NAV_PCMS_SEARCH . "&cmd=" . CMD_BUILD_INDEX); $objTpl->setVariable("BUTTON_INDEX", $objLang->get("searchIndex", "button")); $objTpl->setVariable("SEARCH_BUTTON", $objLang->get("search", "button")); $objTpl->setVariable("SEARCH_ALL", $objLang->get("searchall", "label")); //*** Perform query if submitted. $objSearch = new Search(); $strQuery = request('query'); $strExact = request('search_all'); $strCache = request('cache'); $intPosition = request("pos"); $blnExact = false; $blnCache = false; if ($strExact == 'on') { $blnExact = true; } if ($strCache == 'true') { $blnCache = true; } if ($strCommand == CMD_BUILD_INDEX) { //*** Rebuild search index. set_time_limit(60 * 60); $objSearch->clearIndex(); $objSearch->updateIndex(); $objTpl->setVariable("SEARCH_DESCRIPTION", $objLang->get("searchIndexed", "form")); } if (!empty($strQuery)) { $objResults = $objSearch->find($strQuery, $blnExact); //*** Cache results in the current session. $_SESSION["searchresult"] = serialize($objResults); } else { if ($blnCache && isset($_SESSION["searchresult"]) && is_object(unserialize($_SESSION["searchresult"]))) { $objResults = unserialize($_SESSION["searchresult"]); } } if (isset($objResults) && is_object($objResults)) { $objTpl->setVariable("RESULT_LABEL", $objLang->get("searchresult", "label")); $objTpl->setVariable("SEARCH_STRING", $objResults->getQuery()); if ($objResults->count() > 0) { $listCount = 0; $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objResults->seek($intPosition); //*** Render results. foreach ($objResults as $objResult) { $objElement = Element::selectByPK($objResult->id); if (is_object($objElement)) { $strPath = "<b>" . $objLang->get("path", "label") . "</b>" . Element::recursivePath($objElement->getParentId()); } else { $strPath = ""; } $objTpl->setCurrentBlock("searchresult"); $objTpl->setVariable("EID", $objResult->id); $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS); $objTpl->setVariable("CMD", CMD_EDIT); $objTpl->setVariable("RESULT_NAME", $objResult->name); $objTpl->setVariable("RESULT_RATIO", $objResult->ratio); $strValue = strip_tags($objResult->value); if (!empty($strValue)) { $objTpl->setVariable("RESULT_VALUE", $strValue); } if (!empty($strPath)) { $objTpl->setVariable("RESULT_PATH", $strPath); } $objTpl->parseCurrentBlock(); } //*** Render page navigation. $pageCount = ceil($objResults->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"] < $objResults->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_SEARCH . "&pos={$previousPos}&cache=true"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_SEARCH . "&pos={$nextPos}&cache=true"); //*** Bottom page navigation. for ($intCount = 0; $intCount < $pageCount; $intCount++) { $objTpl->setCurrentBlock("pagenavitem"); $position = $intCount * $_SESSION["listCount"]; if ($intCount != $intPosition / $_SESSION["listCount"]) { $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_SEARCH . "&pos={$position}&cache=true\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } else { $objTpl->setCurrentBlock("searchresult"); $objTpl->setVariable("RESULT_VALUE", $objLang->get("search_noresult", "label")); $objTpl->parseCurrentBlock(); } } $objTpl->setVariable("CID", NAV_PCMS_SEARCH); $strReturn = $objTpl->get(); return $strReturn; }
static function inclusaoDependencias($params, HTML_Template_IT $view, Control $componente) { $nomeComponente = null; //$classe = substr(get_class($componente), 8); $classe = get_class($componente); if (preg_match('/^Controle/', $classe)) { $classe = substr(get_class($componente), 8); } else { if (preg_match('/^Admin/', $classe)) { $classe = substr(get_class($componente), 5); } } if (strpos($classe, "_")) { $nomeComponente = substr($classe, 0, strpos($classe, "_")); } if (in_array("JavaScript", array_keys($view->blocklist))) { $view->setCurrentBlock("JavaScript"); $dependenciasJS = $componente->dependenciasJS(); if ($dependenciasJS) { foreach ($dependenciasJS as $javascript) { /* * Verificamos se existe um JavaScript associado ao * componente e se este ainda não foi incluído. */ if ($javascript && !in_array($javascript, self::$js_inclusos)) { self::$js_inclusos[] = $javascript; /* * Caso a classe esteja no novo formato, verificamos * a possibilidade do roteiro JavaScript residir na * pasta apropriada, dentro da estrutura do componente. */ if (strpos($javascript, "http://") !== false) { $javascript = $javascript; } else { if (!(strpos($classe, "_") === true) && file_exists("Componentes/" . $nomeComponente . "/view/js/" . $javascript . ".js") || file_exists("Componentes/" . $classe . "/view/js/" . $javascript . ".js") || file_exists("Componentes/" . ucfirst($javascript) . "/view/js/" . $javascript . ".js") || file_exists("js/" . $javascript . ".js")) { $javascript = URL . "js.php?src=" . $javascript; } else { if (strpbrk("_", $javascript)) { $pfx = explode("_", $javascript); $prefixo = ucfirst($pfx[0]); if (file_exists("Componentes/" . $prefixo . "/view/js/" . $javascript . ".js")) { $javascript = URL . "js.php?src=" . $javascript; } else { $javascript = "js/" . $javascript; } } else { $javascript = "js/" . $javascript; } } } $view->setVariable("javascript", $javascript); $view->parseCurrentBlock(); } } } } if (in_array("CSS", array_keys($view->blocklist))) { $view->setCurrentBlock("CSS"); $dependenciasCSS = $componente->dependenciasCSS(); if (!$dependenciasCSS) { //$dependenciasCSS = $menu[$classe]["css"]; } if ($dependenciasCSS) { foreach ($dependenciasCSS as $css) { /* * Verificamos se existe uma folha de estilo associada ao * componente e se esta ainda não foi incluído. */ if ($css && !in_array($css, self::$css_inclusos)) { if (file_exists("css/" . $css)) { $arquivo = "css/" . $css; } else { if (file_exists("Componentes/" . $classe . "/view/css/" . $css)) { $arquivo = "Componentes/" . $classe . "/view/css/" . $css; } else { if (file_exists("Componentes/" . $nomeComponente . "/view/css/" . $css)) { $arquivo = "Componentes/" . $nomeComponente . "/view/css/" . $css; } else { if (file_exists($css)) { $arquivo = $css; } } } } $view->setVariable("css", $arquivo); $view->parseCurrentBlock(); self::$css_inclusos[] = $css; } } } } }
<?php require_once "pear/HTML/Template/IT.php"; $tpl = new HTML_Template_IT("./"); $tpl->loadTemplatefile("test.tpl.html", true, true); $tpl->setCurrentBlock("not_logged"); $tpl->touchBlock("not_logged"); $tpl->parseCurrentBlock("not_logged"); $tpl->Show();
function parseSetting($intElmntId, $strCommand) { global $_PATHS, $objLang, $_CLEAN_POST, $_CONF, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("setting.tpl.htm"); //*** Post the profile form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editSettings") { //*** The element form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("ERROR_SETTINGS_MAIN", $objLang->get("main", "formerror")); } else { //*** Remove current settings. Setting::clearFields(); //*** Save the settings. foreach ($_REQUEST as $key => $value) { if ($value != "" && substr($key, 0, 4) == "sfv_") { //*** Get the template Id from the request $intTemplateFieldId = substr($key, 4); //*** Is the Id really an Id? if (is_numeric($intTemplateFieldId)) { //*** Save the setting. if (!empty($value)) { $objField = new Setting(); $objField->setAccountId($_CONF['app']['account']->getId()); $objField->setSettingId($intTemplateFieldId); $objField->setUsername($objLiveUser->getProperty('name')); $objSettingTemplate = SettingTemplate::selectByPk($intTemplateFieldId); switch ($objSettingTemplate->getType()) { case "text": case "number": case "password": $objField->setValue($value); break; case "checkbox": $objField->setValue(1); break; } $objField->save(); } } } } //*** Move imported files to the remote server. ImpEx::moveImportedFiles($_CONF['app']['account']); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"]); exit; } } $objTpl->setVariable("SETTINGS", $objLang->get("settings", "label")); $objSections = SettingTemplate::select("SELECT DISTINCT section FROM pcms_setting_tpl ORDER BY sort"); foreach ($objSections as $objSection) { //*** Fields. $strSql = sprintf("SELECT * FROM pcms_setting_tpl WHERE section = '%s' ORDER BY sort", $objSection->getSection()); $objSettings = SettingTemplate::select($strSql); foreach ($objSettings as $objSetting) { $strValue = Setting::getValueByName($objSetting->getName()); $objTpl->setCurrentBlock("setting.{$objSetting->getType()}"); $objTpl->setVariable("FIELD_ID", "sfv_{$objSetting->getId()}"); $objTpl->setVariable("FIELD_LABEL", $objLang->get($objSetting->getName(), "settingsLabel")); switch ($objSetting->getType()) { case "text": case "password": $objTpl->setVariable("FIELD_VALUE", $strValue); $objTpl->setVariable("FIELD_TYPE", $objSetting->getType()); break; case "number": $objTpl->setVariable("FIELD_VALUE", $strValue); break; case "checkbox": $strValue = $strValue ? "checked=\"checked\"" : ""; $objTpl->setVariable("FIELD_VALUE", $strValue); break; } $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("section"); $objTpl->setVariable("SECTION", $objSetting->getSection()); if ($objSections->key() != 0) { $objTpl->setVariable("CLASS", " class=\"anchor\""); } $objTpl->parseCurrentBlock(); //*** Tabs. $objTpl->setCurrentBlock("section.tab"); $objTpl->setVariable("SECTION", $objSection->getSection()); $objTpl->setVariable("LABEL", $objLang->get("section_{$objSection->getSection()}", "settingsLabel")); if ($objSections->key() == 0) { $objTpl->setVariable("CLASS", " class=\"on\""); } $objTpl->parseCurrentBlock(); } $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_SETTINGS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); $strReturn = $objTpl->get(); return $strReturn; }
//See if we have an authenticated user, if so, setup the appropriate message. if (isset($_SESSION["loggedinUserName"])) { $exerciseDescription; $firstRun = 1; $userID = getUserID($connection); $yearmoday = explode("-", $edit_date); // See if the users is trying to display a month other than the current month. if ($yearmoday != NULL) { $display_mo = new Date(); $display_mo->setDayMonthYear($yearmoday[2], $yearmoday[1], $yearmoday[0]); } else { $display_mo = new Date(); } $template->setCurrentBlock("NAVIGATION"); $template->setVariable("MONTH", $display_mo->format("%A %B %e, %Y")); $template->parseCurrentBlock(); // Load the category select box. $template->setCurrentBlock("CATEGORYSELECT"); $query = "SELECT DISTINCT category FROM flexercise_type WHERE user_id={$userID}"; $result = @mysql_query($query, $connection); while ($row = mysql_fetch_array($result)) { $template->setVariable("CATEGORY", $row["category"]); // Set the category box selection if any. if (setSelectCategoryOption($category, $row["category"], $template)) { $template->setVariable("SELECTED", 'selected="selected"'); } $template->parseCurrentBlock(); } // Load the templates select box. $template->setCurrentBlock("TEMPLATESELECT"); $query = "SELECT DISTINCT description FROM flexercise_templates WHERE user_id={$userID}";
function parseAlias($intAliasId, $strCommand) { global $_PATHS, $_CLEAN_POST, $_CONF, $objLang, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("alias.tpl.htm"); $blnError = false; switch ($strCommand) { case CMD_LIST: case CMD_ADD: case CMD_EDIT: //*** Post the profile form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editAlias") { //*** The element form has been posted. //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_active"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_alias"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_language"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_element"])) { $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_ALIAS_VALUE", $_POST["frm_alias"]); $objTpl->setVariable("ERROR_ALIAS_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the alias. if ($strCommand == CMD_EDIT) { $objAlias = Alias::selectByPK($intAliasId); } else { $objAlias = new Alias(); } $objAlias->setAccountId($_CONF['app']['account']->getId()); $objAlias->setActive($_POST["frm_active"] == "on" ? 1 : 0); $objAlias->setLanguageId(empty($_CLEAN_POST["frm_language"]) ? 0 : $_CLEAN_POST["frm_language"]); $objAlias->setAlias($_CLEAN_POST["frm_alias"]); $objAlias->setUrl($_CLEAN_POST["frm_element"]); $objAlias->save(); header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_ALIASES); exit; } } //*** Initiate child element loop. $objAliases = Alias::selectSorted(); $totalCount = 0; $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; //*** Find total count. foreach ($objAliases as $objAlias) { $strAlias = $objAlias->getAlias(); if (!empty($strAlias)) { $totalCount++; } } $objAliases->seek($intPosition); $objLanguages = ContentLanguage::select(); foreach ($objAliases as $objAlias) { $strAlias = $objAlias->getAlias(); if (!empty($strAlias)) { $strUrl = $objAlias->getUrl(); if (is_numeric($strUrl)) { $objElement = Element::selectByPk($strUrl); if (is_object($objElement)) { $strUrlHref = "?eid={$strUrl}&cmd=" . CMD_EDIT . "&cid=" . NAV_PCMS_ELEMENTS; $strUrl = Element::recursivePath($strUrl); } else { $strUrlHref = "?cid=" . NAV_PCMS_ALIASES; $strUrl = "<b>" . $objLang->get("aliasUnavailable", "label") . "</b>"; } } $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("MULTIITEM_VALUE", $objAlias->getId()); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Alias.remove({$objAlias->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_ALIASES . "&eid={$objAlias->getId()}&cmd=" . CMD_EDIT); $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "alias"); $objTpl->setVariable("MULTIITEM_ALIAS", $objAlias->getAlias()); $objTpl->setVariable("MULTIITEM_POINTS_TO", $objLang->get("pointsTo", "label")); $objTpl->setVariable("MULTIITEM_URL", $strUrl); $objTpl->setVariable("MULTIITEM_URL_HREF", $strUrlHref); if ($objLanguages->count() > 1) { if ($objAlias->getLanguageId() > 0) { $strLanguage = ContentLanguage::selectByPK($objAlias->getLanguageId())->getName(); $objTpl->setVariable("MULTIITEM_LANGUAGE", sprintf($objLang->get("forLanguage", "label"), $strLanguage)); } else { $objTpl->setVariable("MULTIITEM_LANGUAGE", $objLang->get("forAllLanguages", "label")); } } else { $objTpl->setVariable("MULTIITEM_LANGUAGE", ""); } if (!$objAlias->getActive()) { $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\""); } $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } } //*** Render page navigation. $pageCount = ceil($totalCount / $_SESSION["listCount"]); if ($pageCount > 0) { $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]); $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0; $nextPos = $intPosition + $_SESSION["listCount"] < $totalCount ? $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_ALIASES . "&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_ALIASES . "&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_ALIASES . "&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_ALIASES . "&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; foreach ($arrActions as $key => $value) { $objTpl->setCurrentBlock("multiview-listactionitem"); $objTpl->setVariable("LIST_ACTION_TEXT", $key); $objTpl->setVariable("LIST_ACTION_VALUE", $value); $objTpl->parseCurrentBlock(); } $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&cid=" . NAV_PCMS_ALIASES . "\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_ALIASES . "\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_ALIASES . "\""); 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", "&cid=" . NAV_PCMS_ALIASES); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "Alias.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:Alias.multiSelect()"); $objTpl->parseCurrentBlock(); //*** Form variables. $intActiveLanguage = 0; if ($strCommand == CMD_EDIT) { $objAlias = Alias::selectByPK($intAliasId); $intActiveLanguage = $objAlias->getLanguageId(); $objTpl->setVariable("FORM_ACTIVE_VALUE", $objAlias->getActive() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_ALIAS_VALUE", $objAlias->getAlias()); $objTpl->setVariable("FORM_URL_VALUE", $objAlias->getUrl()); $objTpl->setVariable("FRM_HEADER", $objLang->get("editAlias", "form")); $objTpl->setVariable("FRM_STYLE", ""); $objTpl->setVariable("CMD", CMD_EDIT); $objTpl->touchBlock("alias.edit"); } else { $objTpl->setVariable("FORM_ACTIVE_VALUE", "checked=\"checked\""); $objTpl->setVariable("FRM_HEADER", $objLang->get("addAlias", "form")); if (!$blnError) { $objTpl->setVariable("FRM_STYLE", " style=\"display:none\""); } $objTpl->setVariable("CMD", CMD_ADD); $objTpl->touchBlock("alias.add"); } //*** Languages. $objLanguages = ContentLanguage::select(); foreach ($objLanguages as $objLanguage) { $objTpl->setCurrentBlock("language.item"); $objTpl->setVariable("ID", $objLanguage->getId()); $objTpl->setVariable("LABEL", $objLanguage->getName()); $objTpl->setVariable("SELECTED", $intActiveLanguage == $objLanguage->getId() ? " selected=\"selected\"" : ""); $objTpl->parseCurrentBlock(); } $objTpl->setVariable("ALIASES", $objLang->get("aliases", "label")); $objTpl->setVariable("BUTTON_ADD", $objLang->get("aliasAdd", "button")); $objTpl->setVariable("FRM_LABEL_ACTIVE", $objLang->get("active", "form")); $objTpl->setVariable("FRM_LABEL_ALIAS", $objLang->get("alias", "form")); $objTpl->setVariable("FRM_DESCR_ALIAS", $objLang->get("alias", "tip")); $objTpl->setVariable("FRM_LABEL_LANGUAGE", $objLang->get("language", "form")); $objTpl->setVariable("FRM_DESCR_LANGUAGE", $objLang->get("language", "tip")); $objTpl->setVariable("FRM_LABEL_ALL_LANGUAGES", $objLang->get("allLanguages", "form")); $objTpl->setVariable("FRM_LABEL_URL", $objLang->get("element", "form")); $objTpl->setVariable("FRM_LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_ALIASES); $objTpl->setVariable("EID", $intAliasId); $objTpl->parseCurrentBlock(); $strReturn = $objTpl->get(); break; case CMD_REMOVE: if (strpos($intAliasId, ',') !== false) { //*** Multiple elements submitted. $arrAliases = explode(',', $intAliasId); $objAliases = Alias::selectByPK($arrAliases); foreach ($objAliases as $objAlias) { $objAlias->delete(); } } else { //*** Single element submitted. $objAlias = Alias::selectByPK($intAliasId); $objAlias->delete(); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; } return $strReturn; }
function parseLanguage($intLangId, $strCommand) { global $_PATHS, $objLang, $_CLEAN_POST, $_CONF, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("language.tpl.htm"); switch ($strCommand) { case CMD_LIST: case CMD_ADD: case CMD_EDIT: //*** Post the profile form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editLanguage") { //*** The element form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_active"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_name"])) { $blnError = true; } if (is_null($_CLEAN_POST["frm_apiname"])) { $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("ERROR_LANGUAGE_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the language. if ($strCommand == CMD_EDIT) { $objLanguage = ContentLanguage::selectByPK($intLangId); } else { $objLanguage = new ContentLanguage(); } $objLanguage->setAccountId($_CONF['app']['account']->getId()); $objLanguage->setActive($_CLEAN_POST["frm_active"] == "on" ? 1 : 0); $objLanguage->setName($_CLEAN_POST["frm_name"]); $objLanguage->setAbbr($_CLEAN_POST["frm_apiname"]); $objLanguage->save(); header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_LANGUAGES); exit; } } $objLangs = ContentLanguage::select(); foreach ($objLangs as $objLanguage) { $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("MULTIITEM_VALUE", $objLanguage->getId()); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:ContentLanguage.remove({$objLanguage->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_LANGUAGES . "&eid={$objLanguage->getId()}&cmd=" . CMD_EDIT); $strValue = htmlspecialchars($objLanguage->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $objTpl->setVariable("MULTIITEM_ABBR", $objLanguage->getAbbr()); if ($objLanguage->default > 0) { $strValue = $objLang->get("standardLanguage", "label"); } else { $strValue = "<a href=\"javascript:;\" onclick=\"ContentLanguage.setDefault({$objLanguage->getId()})\" rel=\"internal\">" . $objLang->get("standardLanguage", "button") . "</a>"; } $objTpl->setVariable("MULTIITEM_META", $strValue); if (!$objLanguage->getActive()) { $objTpl->setVariable("MULTIITEM_ACTIVE", " class=\"inactive\""); } $objTpl->parseCurrentBlock(); } $objTpl->setVariable("LANGUAGES", $objLang->get("languages", "label")); $objTpl->setVariable("BUTTON_ADD", $objLang->get("languageAdd", "button")); $objTpl->setVariable("BUTTON_ADD_HREF", "ContentLanguage.prepareAdd()"); //*** Form variables. if ($strCommand == CMD_EDIT) { $objLanguage = ContentLanguage::selectByPK($intLangId); $objTpl->setVariable("FORM_ACTIVE_VALUE", $objLanguage->getActive() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objLanguage->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objLanguage->getAbbr()); $objTpl->setVariable("FRM_HEADER", $objLang->get("editLanguage", "form")); $objTpl->setVariable("FRM_STYLE", ""); $objTpl->setVariable("CMD", CMD_EDIT); } else { $objTpl->setVariable("FRM_HEADER", $objLang->get("addLanguage", "form")); $objTpl->setVariable("FRM_STYLE", " style=\"display:none\""); $objTpl->setVariable("CMD", CMD_ADD); } $objTpl->setVariable("FRM_LABEL_ACTIVE", $objLang->get("active", "form")); $objTpl->setVariable("FRM_LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("FRM_LABEL_ABBR", $objLang->get("shortName", "form")); $objTpl->setVariable("FRM_DESCR_ABBR", $objLang->get("shortName", "tip")); $objTpl->setVariable("FRM_LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_PCMS_LANGUAGES); $objTpl->setVariable("EID", $intLangId); $objTpl->parseCurrentBlock(); $strReturn = $objTpl->get(); break; case CMD_REMOVE: if (strpos($intLangId, ',') !== false) { //*** Multiple elements submitted. $arrLanguages = explode(',', $intLangId); $objLanguages = ContentLanguage::selectByPK($arrLanguages); foreach ($objLanguages as $objLanguage) { $objLanguage->delete(); } } else { //*** Single element submitted. $objLanguage = ContentLanguage::selectByPK($intLangId); $objLanguage->delete(); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; case CMD_SET_DEFAULT: if ($intLangId > 0) { ContentLanguage::setDefault($intLangId); } //*** Redirect the page. $strReturnTo = request('returnTo'); if (empty($strReturnTo)) { header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST); exit; } else { header("Location: " . Request::getURI() . $strReturnTo); exit; } break; } return $strReturn; }
function parseProfile($intElmntId, $strCommand) { global $_PATHS, $objLang, $_CLEAN_POST, $_CONF, $objLiveAdmin, $objLiveUser; //*** Retrieve the latest user info from the DB. $objLiveUser->updateProperty(true, false, $_CONF['app']['account']->getId()); $objTpl = new HTML_Template_IT($_PATHS['templates']); $objTpl->loadTemplatefile("profile.tpl.htm"); $objTpl->setVariable("TITLE", $objLang->get("pageTitle")); //*** Render timezones. $objTimeZones = Timezone::select(); //echo $objLiveUser->getProperty("time_zone_id"); foreach ($objTimeZones as $objTimeZone) { $objTpl->setCurrentBlock("timezone-option"); if ($objLiveUser->getProperty("time_zone_id") == $objTimeZone->getId()) { $objTpl->setVariable("TIMEZONE_SELECTED", " selected=\"selected\""); } $objTpl->setVariable("TIMEZONE_VALUE", $objTimeZone->getId()); $objTpl->setVariable("TIMEZONE_TEXT", $objTimeZone->getLongName()); $objTpl->parseCurrentBlock(); } //*** Render languages. $objLanguages = $objLang->getLangs(); foreach ($objLanguages as $objLanguage) { $objTpl->setCurrentBlock("language-option"); if ($objLang->name == $objLanguage->name) { $objTpl->setVariable("LANGUAGE_SELECTED", " selected=\"selected\""); } $objTpl->setVariable("LANGUAGE_VALUE", $objLanguage->name); $objTpl->setVariable("LANGUAGE_TEXT", $objLanguage->language); $objTpl->parseCurrentBlock(); } $objTpl->setCurrentBlock("profile"); //*** Post the profile form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editProfile") { //*** The element form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("profileName", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_email"])) { $objTpl->setVariable("ERROR_EMAIL_ON", " error"); $objTpl->setVariable("ERROR_EMAIL", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_language"])) { $objTpl->setVariable("ERROR_LANGUAGE_ON", " error"); $objTpl->setVariable("ERROR_LANGUAGE", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_timezone"])) { $objTpl->setVariable("ERROR_TIMEZONE_ON", " error"); $objTpl->setVariable("ERROR_TIMEZONE", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_EMAIL_VALUE", $_POST["frm_email"]); $objTpl->setVariable("ERROR_PROFILE_MAIN", $objLang->get("main", "formerror")); } else { //*** Save the user profile. $data = array('name' => $_CLEAN_POST["frm_name"], 'email' => $_CLEAN_POST["frm_email"], 'time_zone_id' => $_CLEAN_POST["frm_timezone"]); $objLiveAdmin->updateUser($data, $objLiveUser->getProperty('perm_user_id')); //*** Save the language setting. $objLang->setLang($_CLEAN_POST["frm_language"]); $_SESSION['objLang'] = NULL; header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"]); exit; } } $objTpl->setVariable("PROFILE", $objLang->get("userprofile", "label")); $objTpl->setVariable("LABEL_USERNAME", $objLang->get("username", "form")); $objTpl->setVariable("FORM_USERNAME_VALUE", $objLiveUser->getProperty('handle')); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("FORM_NAME_VALUE", $objLiveUser->getProperty('name')); $objTpl->setVariable("LABEL_EMAIL", $objLang->get("emailaddress", "form")); $objTpl->setVariable("FORM_EMAIL_VALUE", $objLiveUser->getProperty('email')); $objTpl->setVariable("LABEL_LANGUAGE", $objLang->get("language", "form")); $objTpl->setVariable("LABEL_TIMEZONE", $objLang->get("timezone", "form")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_MYPUNCH_PROFILE); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("password"); //*** Post the password form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editPass") { //*** The element form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_currentpass"])) { $objTpl->setVariable("ERROR_CURRENTPASS_ON", " error"); $objTpl->setVariable("ERROR_CURRENTPASS", $objLang->get("commonTypePassword", "formerror")); $blnError = true; } if (!is_null($_CLEAN_POST["frm_currentpass"])) { if (sha1($_CLEAN_POST["frm_currentpass"]) !== $objLiveUser->getProperty('passwd')) { $objTpl->setVariable("ERROR_CURRENTPASS_ON", " error"); $objTpl->setVariable("ERROR_CURRENTPASS", $objLang->get("wrongPassword", "formerror")); $blnError = true; } } if (is_null($_CLEAN_POST["frm_newpass"])) { $objTpl->setVariable("ERROR_NEWPASS_ON", " error"); $objTpl->setVariable("ERROR_NEWPASS", $objLang->get("commonTypePassword", "formerror")); $blnError = true; } if (!is_null($_CLEAN_POST["frm_newpass"]) && strlen($_CLEAN_POST["frm_newpass"]) < $_CONF['app']['minPassLength']) { $objTpl->setVariable("ERROR_NEWPASS_ON", " error"); $objTpl->setVariable("ERROR_NEWPASS", $objLang->get("shortPassword", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_verifypass"])) { $objTpl->setVariable("ERROR_VERIFYPASS_ON", " error"); $objTpl->setVariable("ERROR_VERIFYPASS", $objLang->get("commonTypePassword", "formerror")); $blnError = true; } if (!is_null($_CLEAN_POST["frm_newpass"]) && !is_null($_CLEAN_POST["frm_verifypass"])) { if ($_CLEAN_POST["frm_newpass"] !== $_CLEAN_POST["frm_verifypass"]) { $objTpl->setVariable("ERROR_VERIFYPASS_ON", " error"); $objTpl->setVariable("ERROR_VERIFYPASS", $objLang->get("passwordNotMatch", "formerror")); $blnError = true; } } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("ERROR_PASSWORD_MAIN", $objLang->get("main", "formerror")); } else { //*** Save the password. $data = array('passwd' => $_CLEAN_POST["frm_newpass"]); $objLiveAdmin->updateUser($data, $objLiveUser->getProperty('perm_user_id')); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"]); exit; } } $objTpl->setVariable("PASSWORD", $objLang->get("password", "label")); $objTpl->setVariable("LABEL_CURRENTPASS", $objLang->get("currentpassword", "form")); $objTpl->setVariable("LABEL_NEWPASS", $objLang->get("newpassword", "form")); $objTpl->setVariable("NEWPASS_NOTE", sprintf($objLang->get("newpasswordNote", "tip"), $_CONF['app']['minPassLength'])); $objTpl->setVariable("LABEL_VERIFYPASS", $objLang->get("verifypassword", "form")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); $objTpl->setVariable("CID", NAV_MYPUNCH_PROFILE); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); $strReturn = $objTpl->get(); return $strReturn; }
." WHERE s.MOVIE_SEQ = m.SEQ " ." AND s.MOVIE_SEQ = $movie_seq " ." AND s.CLASS_ID = '$_SESSION[ss_class_id]' "; $res =& $db->query($sql); if (PEAR::isError($db)) { die($db->getMessage()); } // 편집 $iSeq=0; while ($res->fetchInto($row)) { if (!$tpl->setCurrentBlock("row")) Error("setCurrentBlock"); $tpl->setVariable("TITLE" , $row[1]); $tpl->setVariable("PLAN_ILSI", $row[2]); $tpl->parseCurrentBlock("row"); // parse outter block if (!$tpl->parse("row")) Error("parseCurrentBlock"); // 2007.09.28 : SCS if (strstr($row[3],".swf")) $tpl->setVariable("EMBED_TAG", "<script type='text/javascript'>".chr(13). "//<![CDATA[".chr(13). "swf(800,655,'$row[3]','Player');".chr(13). "//]]>".chr(13). "</script>".chr(13). "<INPUT type='image' src='/images/movie_play.gif' NAME='BtnPlay' VALUE='Play' OnClick='Player.play()'>".chr(13). "<INPUT type='image' src='/images/movie_pause.gif' NAME='BtnPlay' VALUE='Play' OnClick='Player.stop()'>".chr(13). "<INPUT type='image' src='/images/movie_rewind.gif' NAME='BtnStop' VALUE='Play' OnClick='Player.rewind()'>"); else
function parseFiles($intElmntId, $strCommand) { global $objLang, $_CLEAN_POST, $objLiveUser, $_CONF, $_PATHS, $DBAConn, $objMultiUpload; $objTpl = new HTML_Template_IT($_PATHS['templates']); switch ($strCommand) { case CMD_LIST: $objTpl->loadTemplatefile("multiview.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsStorage", "menu")); $objFolder = StorageItem::selectByPK($intElmntId); if (empty($intElmntId)) { $strFolderName = "ROOT"; } else { if (is_object($objFolder)) { $strFolderName = $objFolder->getName(); } else { $strFolderName = ""; } } if (is_object($objFolder) || empty($intElmntId)) { if (empty($intElmntId)) { $objItems = StorageItems::getFromParent(0); } else { $objItems = StorageItems::getFromParent($intElmntId); } if (is_object($objItems) && $objItems->count() > 0) { //*** Initiate child item loop. $blnBreak = false; $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objItems->seek($intPosition); //*** Loop through the items. foreach ($objItems as $objItem) { $strMeta = $objLang->get("editedBy", "label") . " " . $objItem->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objItem->getModified()); $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:StorageItem.remove({$objItem->getId()});"); $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button")); $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:StorageItem.duplicate({$objItem->getId()});"); $objTpl->setVariable("MULTIITEM_VALUE", $objItem->getId()); $objTpl->setVariable("MULTIITEM_HREF", "href=\"?cid=" . NAV_PCMS_STORAGE . "&eid={$objItem->getId()}&cmd=" . CMD_EDIT . "\""); $strValue = htmlspecialchars($objItem->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $objTpl->setVariable("MULTIITEM_META", $strMeta); switch ($objItem->getTypeId()) { case STORAGE_TYPE_FOLDER: $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "folder"); break; case STORAGE_TYPE_FILE: $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "element"); break; } $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } //*** Render page navigation. $pageCount = ceil($objItems->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"] < $objItems->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_STORAGE . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&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_STORAGE . "&eid={$intElmntId}&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_STORAGE . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; $arrActions[$objLang->get("duplicate", "button")] = "duplicate"; 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&cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_STORAGE . "&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", "&cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}"); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "StorageItem.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:StorageItem.multiSelect()"); $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newFile", "button")); $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&cmd=" . CMD_ADD); $objTpl->setVariable("BUTTON_NEWFOLDER", $objLang->get("newFolder", "button")); $objTpl->setVariable("BUTTON_NEWFOLDER_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&cmd=" . CMD_ADD_FOLDER); if ($intElmntId > 0) { $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button")); $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&cmd=" . CMD_EDIT); } $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("mediaIn", "label") . " "); $objTpl->setVariable("SUBJECT_NAME", $strFolderName); $objTpl->parseCurrentBlock(); break; case CMD_REMOVE: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrElements = explode(',', $intElmntId); $objElements = StorageItem::selectByPK($arrElements); $intParent = $objElements->current()->getParentId(); foreach ($objElements as $objElement) { $objElement->delete(); } } else { //*** Single element submitted. $objElement = StorageItem::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 = StorageItem::selectByPK($arrElements); $intParent = $objElements->current()->getParentId(); foreach ($objElements as $objElement) { $objElement->setUsername($objLiveUser->getProperty("name")); $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label")); } } else { //*** Single element submitted. $objElement = StorageItem::selectByPK($intElmntId); $objElement->setUsername($objLiveUser->getProperty("name")); $intParent = $objElement->getParentId(); $objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label")); } //*** 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: $objTpl->loadTemplatefile("storageitems.tpl.htm"); $blnError = false; $blnIsFolder = false; //*** Check the element type (element or folder) if ($strCommand == CMD_EDIT) { $objElement = StorageItem::selectByPK($intElmntId); if (is_object($objElement) && $objElement->getTypeId() == STORAGE_TYPE_FOLDER) { $blnIsFolder = true; } } else { if ($strCommand == CMD_ADD_FOLDER) { $blnIsFolder = 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; } //*** 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 ($strCommand == CMD_EDIT) { $objTpl->setVariable("MAINTITLE", $objLang->get("fileDetailsFor", "label")); $objTpl->setVariable("MAINSUB", $objElement->getName()); } else { $objTpl->setVariable("MAINTITLE", $objLang->get("fileDetails", "label")); } } //*** Post the element form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addStorageItem") { //*** The element form has been posted. //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_name"]) && $strCommand != CMD_ADD) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("elementName", "formerror")); $blnError = true; } if (!$blnIsFolder && empty($_FILES['frm_file_new']['name'][0])) { if (empty($_CLEAN_POST['frm_file'])) { $objTpl->setVariable("ERROR_FILE_ON", " error"); $objTpl->setVariable("ERROR_FILE", $objLang->get("noFile", "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; } //*** TODO: Check element specific fields. if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); //*** TODO: Display element specific errors. } else { //*** Input is valid. Save the element. if ($blnIsFolder || $strCommand == CMD_EDIT && is_array(Request::get('frm_file'))) { if ($strCommand == CMD_EDIT) { $objElement = StorageItem::selectByPK($intElmntId); } else { $objElement = new StorageItem(); $objElement->setParentId($_POST["eid"]); $objElement->setAccountId($_CONF['app']['account']->getId()); } $objElement->setName($_CLEAN_POST["frm_name"]); $objElement->setDescription($_CLEAN_POST["frm_description"]); $objElement->setUsername($objLiveUser->getProperty("name")); if ($blnIsFolder) { $objElement->setTypeId(STORAGE_TYPE_FOLDER); } else { $objElement->setTypeId(STORAGE_TYPE_FILE); } $objElement->save(); } else { //*** 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 ($strCommand == CMD_EDIT) { $objElement = StorageItem::selectByPK($intElmntId); $objElement->setName($_CLEAN_POST["frm_name"]); $objElement->setDescription($_CLEAN_POST["frm_description"]); $objElement->setUsername($objLiveUser->getProperty("name")); $objElement->save(); $objData = $objElement->getData(); $strOldFile = $objData->getLocalName(); } if (isset($_FILES['frm_file_new'])) { $objMultiUpload->setExtensions(explode(" ", Setting::getValueByName('file_upload_extensions') . " " . Setting::getValueByName('image_upload_extensions'))); $objMultiUpload->setTempNames($_FILES['frm_file_new']['tmp_name']); $objMultiUpload->setOriginalNames($_FILES['frm_file_new']['name']); $objMultiUpload->setErrors($_FILES['frm_file_new']['error']); $objMultiUpload->uploadFiles(); if ($objMultiUpload->getTotalFiles() == $objMultiUpload->getSuccessFiles()) { //*** Everything is cool. $localValues = $objMultiUpload->getLocalNames(); $arrCleanup = array(); foreach ($objMultiUpload->getOriginalNames() as $subkey => $subvalue) { $blnSkipData = false; if (!is_null($subvalue)) { if ($strCommand == CMD_ADD) { if (FileIO::extension($subvalue) == "zip") { //*** Zip file. Extract and add. require_once 'dzip/dUnzip2.inc.php'; $blnSkipData = true; $strZip = $_PATHS['upload'] . $localValues[$subkey]; $strTempDir = Account::generateId(); $strTempPath = $_PATHS['upload'] . $strTempDir . "/"; if (is_file($strZip)) { $objZip = new dUnzip2($strZip); if (is_object($objZip)) { array_push($arrCleanup, $localValues[$subkey]); mkdir($strTempPath); $objZip->unzipAll($strTempPath); if ($handle = opendir($strTempPath)) { while (false !== ($file = readdir($handle))) { if (is_file($strTempPath . $file)) { $objElement = new StorageItem(); $objElement->setParentId($_POST["eid"]); $objElement->setAccountId($_CONF['app']['account']->getId()); $objElement->setName($file); $objElement->setDescription($_CLEAN_POST["frm_description"]); $objElement->setUsername($objLiveUser->getProperty("name")); $objElement->setTypeId(STORAGE_TYPE_FILE); $objElement->save(); $objData = $objElement->getData(); $objData->setItemId($objElement->getId()); $objData->setOriginalName($file); $objData->setLocalName($file); $objData->save(); //*** Move file to remote server. $objUpload = new SingleUpload(); if (!$objUpload->moveToFTP($file, $strTempPath, $strServer, $strUsername, $strPassword, $strRemoteFolder)) { Log::handleError("File could not be moved to remote server. " . $objUpload->errorMessage()); } } } closedir($handle); } FileIO::unlinkDir($strTempPath); } } } else { $objElement = new StorageItem(); $objElement->setParentId($_POST["eid"]); $objElement->setAccountId($_CONF['app']['account']->getId()); $objElement->setName(empty($_CLEAN_POST["frm_name"]) ? $subvalue : $_CLEAN_POST["frm_name"]); $objElement->setDescription($_CLEAN_POST["frm_description"]); $objElement->setUsername($objLiveUser->getProperty("name")); $objElement->setTypeId(STORAGE_TYPE_FILE); $objElement->save(); $objData = $objElement->getData(); } } if (!$blnSkipData) { $objData->setItemId($objElement->getId()); $objData->setOriginalName($subvalue); $objData->setLocalName($localValues[$subkey]); $objData->save(); } } } //*** Move file to remote server. if (!$objMultiUpload->moveToFTP($strServer, $strUsername, $strPassword, $strRemoteFolder)) { $strMessage = $objMultiUpload->errorMessage(); } //*** Fix file linkage. if (is_object($objElement)) { $objElement->fixLinkedElements(); } //*** Cleanup zip files. foreach ($arrCleanup as $value) { $objFtp = new FTP($strServer, NULL, NULL, true); $objFtp->login($strUsername, $strPassword); $strFile = $strRemoteFolder . $value; $objFtp->delete($strFile); } } else { $strMessage = $objMultiUpload->errorMessage() . "<br />"; $strMessage .= "Files: " . $objMultiUpload->getTotalFiles() . " and Success: " . $objMultiUpload->getSuccessFiles(); } } //*** Remove deleted files. if ($strCommand == CMD_EDIT && !empty($strOldFile)) { $objFtp = new FTP($strServer, NULL, NULL, true); $objFtp->login($strUsername, $strPassword); $strFile = $strRemoteFolder . $strOldFile; $objFtp->delete($strFile); } } //*** Redirect the page. if (empty($strMessage)) { $intElmntId = $blnIsFolder ? $intElmntId : $objElement->getParentId(); header("Location: " . Request::getUri() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $intElmntId); exit; } else { echo $strMessage; } } } //*** Parse the page. $objElement = StorageItem::selectByPK($intElmntId); //*** Render the details tab. $objTpl->setCurrentBlock("headertitle_simple"); $objTpl->setVariable("HEADER_TITLE", $blnIsFolder ? $objLang->get("newFolder", "label") : $objLang->get("singleFile", "label")); $objTpl->parseCurrentBlock(); //*** Render the element form. $objTpl->setCurrentBlock("description-details"); $objTpl->setVariable("LABEL", $objLang->get("requiredFields", "form")); $objTpl->parseCurrentBlock(); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_SAVE", $objLang->get("save", "button")); if ($blnIsFolder) { $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("folderName", "form")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); } else { $objTpl->setVariable("LABEL_ELEMENTNAME", $objLang->get("fileName", "form")); $objTpl->setVariable("LABEL_ELEMENTNAME_TIP", $objLang->get("storageName", "tip")); $objTpl->setVariable("LABEL_CHOOSER", $objLang->get("browseImage", "label")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("description", "form")); $objTpl->setVariable("FIELD_LABEL_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("FIELD_THUMB_PATH", Setting::getValueByName("web_server") . Setting::getValueByName("file_folder")); } //*** Insert values if action is edit. if ($strCommand == CMD_EDIT) { if ($blnError === false) { $objTpl->setVariable("FORM_NAME_VALUE", $objElement->getName()); $objTpl->setVariable("FORM_NOTES_VALUE", $objElement->getDescription()); if (!$blnIsFolder) { $objData = $objElement->getData(); if (is_object($objData)) { $objTpl->setVariable("FORM_CHOOSER_VALUE", $objData->getOriginalName() . ":" . $objData->getLocalName()); } $objTpl->setVariable("FIELD_CURRENT_FILES", 1); $objTpl->setVariable("FIELD_MAX_FILES", 1); } } $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$objElement->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$objElement->getParentId()}&cmd=" . CMD_LIST); } else { if (!$blnIsFolder) { $objTpl->setVariable("FIELD_CURRENT_FILES", 0); $objTpl->setVariable("FIELD_MAX_FILES", 50); } $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_STORAGE . "&eid={$intElmntId}&cmd=" . CMD_LIST); } //*** 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_STORAGE); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); break; } return $objTpl->get(); }
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 . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&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") . " "] = "delete"; $arrActions[$objLang->get("duplicate", "button") . " "] = "duplicate"; $arrActions[$objLang->get("activate", "button") . " "] = "activate"; $arrActions[$objLang->get("deactivate", "button") . " "] = "deactivate"; if (is_object($objElement)) { $arrActions[$objLang->get("export", "button") . " "] = "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&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_ELEMENTS . "&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", "&cid=" . NAV_PCMS_ELEMENTS . "&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 . "&eid={$intElmntId}&cmd=" . CMD_ADD); } $objTpl->setVariable("BUTTON_NEWFOLDER", $objLang->get("newFolder", "button")); $objTpl->setVariable("BUTTON_NEWFOLDER_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&cmd=" . CMD_EXPORT_ELEMENT); $objTpl->setVariable("BUTTON_IMPORT_ELEMENT", $objLang->get("import", "button")); $objTpl->setVariable("BUTTON_IMPORT_ELEMENT_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&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("\"", """, $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 . "&eid={$objElement->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$objElement->getParentId()}&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) ? " " : $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", " "); } if ($objSchedule->getEndActive()) { $strValue = Date::fromMysql("%d %B %Y", $objSchedule->getEndDate()); $objTpl->setVariable("END_DATE_DISPLAY", empty($strValue) ? " " : $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", " "); } } 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 . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_ELEMENTS . "&eid={$intElmntId}&cmd=" . CMD_LIST); //*** Publish specific values. $objTpl->setVariable("START_DATE_DISPLAY", " "); $objTpl->setVariable("END_DATE_DISPLAY", " "); } //*** 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 . "&eid={$intElmntId}&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 . "&eid={$intElmntId}&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(); }
/** * Returns news list * for a given category * * @param object &$db a reference to a db connection object * @param string $category news category */ function getNewsList(&$db, $category) { $query = " SELECT news_id AS assockey, news_id AS id, DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date, news_title AS title FROM news WHERE news_category = ". $db->quote($category, 'text'); $news = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC, true); if (PEAR::isError($news)) { die($news->getMessage() . ' ' . $news->getUserinfo()); } else { $tpl = new HTML_Template_IT('./'); $tpl->loadTemplatefile('news_list.tpl', false, false); $tpl->setVariable('CATEGORY', ucfirst($category)); foreach ($news as $id => $name) { foreach ($name as $cell) { // Assign data to the inner block $tpl->setCurrentBlock('cell'); $tpl->setVariable("ID", $id); $tpl->setVariable("DATA", nl2br($cell)); $tpl->parseCurrentBlock('cell'); } // Assign data and the inner block to the // outer block $tpl->setCurrentBlock('row'); $tpl->parseCurrentBlock('row'); } return $tpl->get(); } }