本文整理汇总了PHP中Alias::setAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Alias::setAlias方法的具体用法?PHP Alias::setAlias怎么用?PHP Alias::setAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alias
的用法示例。
在下文中一共展示了Alias::setAlias方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parsePages
//.........这里部分代码省略.........
$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"];
示例2: addById
public static function addById($intId, $intParentId = 0)
{
global $_CONF;
$objDoc = Structure::getXmlDoc($intId);
$arrUserIds = array();
$arrGroupIds = array();
$arrStorageIds = array();
$arrFeedIds = array();
$arrLanguageIds[0] = 0;
$arrTemplateIds[0] = 0;
$arrTemplateFieldIds[0] = 0;
$arrLinkFieldIds = array();
$arrElementIds[0] = 0;
$arrElementFieldIds = array();
$arrElementFieldIds["link"][0] = 0;
$arrElementFieldIds["largeText"][0] = 0;
$intTemplateParentId = 0;
$intElementParentId = 0;
//*** Get structure fields from selects.
if (Structure::hasSelect($intId)) {
$objSelects = Structure::getSelectsById($intId);
foreach ($objSelects as $objSelect) {
switch ($objSelect->getType()) {
case "language":
$intId = Request::get("frm_select_{$objSelect->getId()}");
$arrLanguageIds[$objSelect->getLogicId()] = $intId;
break;
case "element":
$intId = Request::get("frm_select_{$objSelect->getId()}");
if ($objSelect->getLogicId() == "PARENT") {
$intElementParentId = $intId;
} else {
$arrElementIds[$objSelect->getLogicId()] = $intId;
}
break;
}
}
}
foreach ($objDoc->childNodes as $rootNode) {
if ($rootNode->nodeName == "structure") {
//*** Valid structure XML.
switch ($rootNode->getAttribute("type")) {
case "template":
$intTemplateParentId = $intParentId;
break;
case "element":
$intElementParentId = $intParentId;
break;
}
foreach ($rootNode->childNodes as $logicNode) {
if ($logicNode->nodeName == "logic") {
foreach ($logicNode->childNodes as $childNode) {
switch ($childNode->nodeName) {
case "languages":
//*** Add languages to the account.
foreach ($childNode->childNodes as $languageNode) {
$objLanguage = new ContentLanguage();
$objLanguage->setAccountId($_CONF['app']['account']->getId());
$objLanguage->setName($languageNode->getAttribute("name"));
$objLanguage->setAbbr($languageNode->getAttribute("abbr"));
$objLanguage->default = $languageNode->getAttribute("default");
$objLanguage->setActive($languageNode->getAttribute("active"));
$objLanguage->setSort($languageNode->getAttribute("sort"));
$objLanguage->setUsername($languageNode->getAttribute("username"));
$objLanguage->save();
$arrLanguageIds[$languageNode->getAttribute("id")] = $objLanguage->getId();
if ($languageNode->getAttribute("default") == 1) {
$intDefaultLanguage = $objLanguage->getId();
}
}
break;
case "templates":
//*** Add templates to the account.
ImpEx::importTemplates($childNode, $_CONF['app']['account']->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrLinkFieldIds, $intTemplateParentId);
break;
case "elements":
//*** Add elements to the account.
ImpEx::importElements($childNode, $_CONF['app']['account']->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $intElementParentId);
break;
case "aliases":
//*** Add aliases to the account.
foreach ($childNode->childNodes as $aliasNode) {
$objAlias = new Alias();
$objAlias->setAccountId($_CONF['app']['account']->getId());
$objAlias->setAlias($aliasNode->getAttribute("alias"));
if (array_key_exists($aliasNode->getAttribute("url"), $arrElementIds)) {
$objAlias->setUrl($arrElementIds[$aliasNode->getAttribute("url")]);
} else {
$objAlias->setUrl(0);
}
if (array_key_exists($aliasNode->getAttribute("language"), $arrLanguageIds)) {
$objAlias->setLanguageId($arrLanguageIds[$aliasNode->getAttribute("language")]);
} else {
$objAlias->setLanguageId(0);
}
$objAlias->setCascade($aliasNode->getAttribute("cascade"));
$objAlias->setActive($aliasNode->getAttribute("active"));
$objAlias->setSort($aliasNode->getAttribute("sort"));
$objAlias->setCreated($aliasNode->getAttribute("created"));
$objAlias->setModified($aliasNode->getAttribute("modified"));
//.........这里部分代码省略.........
示例3: getConnection
include "config.inc.php";
//include "uploadedFile.php";
include "alias.php";
adminPage();
$conn = getConnection();
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
$aliasText = issetOrBlank($_POST['alias']);
$pointer = issetOrBlank($_POST['pointer']);
//echo "Alias: ".$alias.", pointer: ".$pointer;
if ($aliasText != "" && $pointer != "") {
//we can add them if the alias doesn't already exist.
if (!startsWith($aliasText, "/")) {
$aliasText = "/" . $aliasText;
}
$alias = new Alias($conn);
$alias->setAlias($aliasText);
//must start with '/'
$numAliases = sizeof($alias->getObjectsLikeThis());
$alias->setType("url");
$alias->setPointer($pointer);
if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) {
echo '<h1>Alias created OK!</h1>';
echo $alias->getAlias() . " will now point to: " . $pointer;
} else {
if ($numAliases > 0) {
echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>';
} else {
if ($alias->getAlias() == "/") {
echo '<p>Alias cannot be saved as /</p>';
//shouldnt occur
} else {
示例4: save
public function save()
{
global $_CONF, $_PATHS;
if (is_object($this->__template)) {
$strServer = Setting::getValueByName('ftp_server');
$strUsername = Setting::getValueByName('ftp_username');
$strPassword = Setting::getValueByName('ftp_password');
$strRemoteFolder = Setting::getValueByName('ftp_remote_folder');
//*** Element.
$objElement = new Element();
$objElement->setParentId($this->__parent->getId());
$objElement->setAccountId($_CONF['app']['account']->getId());
$objElement->setPermissions($this->__permissions);
$objElement->setActive($this->active);
$objElement->setName($this->name);
$objElement->setUsername($this->username);
$objElement->setSort($this->sort);
$objElement->setTypeId(ELM_TYPE_LOCKED);
$objElement->setTemplateId($this->__template->getId());
$objElement->save(true, false);
//*** Activate default schedule.
$objSchedule = new ElementSchedule();
$objSchedule->setStartActive(0);
$objSchedule->setStartDate(APP_DEFAULT_STARTDATE);
$objSchedule->setEndActive(0);
$objSchedule->setEndDate(APP_DEFAULT_ENDDATE);
$objElement->setSchedule($objSchedule);
//*** Alias.
if ($objElement->isPage()) {
$objAlias = new Alias();
$objAlias->setAlias($this->alias);
$objElement->setAlias($objAlias);
}
foreach ($this->__fields as $intTemplateFieldId => $arrField) {
$objTemplateField = TemplateField::selectByPK($intTemplateFieldId);
$objField = new ElementField();
$objField->setElementId($objElement->getId());
$objField->setTemplateFieldId($objTemplateField->getId());
$objField->save();
foreach ($arrField as $intLanguage => $arrValue) {
$objValue = $objField->getNewValueObject();
switch ($objField->getTypeId()) {
case FIELD_TYPE_FILE:
case FIELD_TYPE_IMAGE:
//*** Upload file.
$arrPath = parse_url($arrValue['value']);
if ($arrPath !== false) {
$strFile = @file_get_contents(str_replace(" ", "%20", $arrValue['value']));
if ($strFile !== false) {
$strOriginalName = array_pop(explode("/", $arrPath['path']));
$strLocalValue = ImageField::filename2LocalName($strOriginalName);
$objImageField = new ImageField($intTemplateFieldId);
$arrSettings = $objImageField->getSettings();
if (file_put_contents($_PATHS['upload'] . $strOriginalName, $strFile) !== false) {
if (count($arrSettings) > 1) {
foreach ($arrSettings as $key => $arrSetting) {
$strFileName = FileIO::add2Base($strLocalValue, $arrSetting['key']);
if (copy($_PATHS['upload'] . $strOriginalName, $_PATHS['upload'] . $strFileName)) {
if ($objTemplateField->getTypeId() == FIELD_TYPE_IMAGE && (!empty($arrSetting['width']) || !empty($arrSetting['height']))) {
//*** Resize the image.
$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 {$strFileName} could not be moved to remote server. " . $objUpload->errorMessage());
}
}
}
//*** Move original file.
if (rename($_PATHS['upload'] . $strOriginalName, $_PATHS['upload'] . $strLocalValue)) {
$objUpload = new SingleUpload();
if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
Log::handleError("File {$strLocalValue} could not be moved to remote server. " . $objUpload->errorMessage());
}
}
//*** Unlink original file.
@unlink($_PATHS['upload'] . $strOriginalName);
} 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'] . $strOriginalName, $_PATHS['upload'] . $strFileName)) {
$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 {$strFileName} could not be moved to remote server.");
}
}
}
//*** Move original file.
if (file_exists($_PATHS['upload'] . $strOriginalName) && rename($_PATHS['upload'] . $strOriginalName, $_PATHS['upload'] . $strLocalValue)) {
//*** Move file to remote server.
$objUpload = new SingleUpload();
if (!$objUpload->moveToFTP($strLocalValue, $_PATHS['upload'], $strServer, $strUsername, $strPassword, $strRemoteFolder)) {
Log::handleError("File {$strLocalValue} could not be moved to remote server.");
}
//.........这里部分代码省略.........
示例5: Alias
//echo 'Alias ID: '.$file->getAliasID().' needs to point to: '.$fileAlias;
if ($fileAlias == "/") {
//remove the alias
echo "Delete alias" . $file->getAliasID();
$fileUpdate->setAliasID(0);
$aliasUpdate = "DELETE FROM `alias` where `id` = :ALIASID";
$aliasUpdate = $conn->prepare($aliasUpdate);
$aliasUpdate->bindParam(':ALIASID', $file->getAliasID());
if ($aliasUpdate->execute()) {
echo "Alias deleted Successfully.";
}
} else {
//new or Update
//ensure it is available!
$alias = new Alias($conn);
$alias->setAlias($fileAlias);
$numAliases = sizeof($alias->getObjectsLikeThis());
if ($numAliases == 0) {
if ($file->getAliasID() == 0) {
$alias->setPointer($file->getId());
$alias->setType('file');
if ($alias->save() > 0) {
//echo "Alias Saved";
$fileUpdate->setAliasID($alias->getId());
}
} else {
$aliasUpdate = "UPDATE `alias` set `alias` = :NEWALIAS where `id` = :ALIASID";
$aliasUpdate = $conn->prepare($aliasUpdate);
$aliasUpdate->bindParam(':NEWALIAS', $fileAlias);
$aliasUpdate->bindParam(':ALIASID', $file->getAliasID());
$fileUpdate->setAliasID($file->getAliasID());
示例6: importIn
//.........这里部分代码省略.........
}
}
}
}
if ($validTemplateStructure || !$validate) {
//*** Import elements
foreach ($objDoc->childNodes as $rootNode) {
foreach ($rootNode->childNodes as $logicNode) {
if ($logicNode->nodeName == "logic") {
foreach ($logicNode->childNodes as $childNode) {
switch ($childNode->nodeName) {
case "languages":
// Get all languages
$arrCurrentLangs = array();
$objContentLangs = ContentLanguage::select();
$objDefaultLang = NULL;
foreach ($objContentLangs as $objContentLang) {
$arrCurrentLangs[$objContentLang->getAbbr()] = $objContentLang->getId();
if ($objContentLang->default == 1) {
$objDefaultLang = $objContentLang;
}
}
$arrLanguageIds[0] = 0;
// loop trough languages from export
foreach ($childNode->childNodes as $languageNode) {
// if abbreviations match, use that language ID
if (array_key_exists($languageNode->getAttribute('abbr'), $arrCurrentLangs)) {
$arrLanguageIds[$languageNode->getAttribute("id")] = $arrCurrentLangs[$languageNode->getAttribute('abbr')];
} else {
// if no match, use default current language
$arrLanguageIds[$languageNode->getAttribute("id")] = $arrCurrentLangs[$objDefaultLang->getAbbr()];
}
}
break;
case "templates":
if ($importTemplates) {
//*** Add templates to the account.
self::importTemplates($childNode, $_CONF['app']['account']->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrLinkFieldIds, $intTemplateId);
}
break;
case "elements":
if ($importElements) {
if ($intElementId == NULL) {
$strSql = sprintf("SELECT * FROM pcms_element WHERE templateId = '%s' AND accountId = '%s' ORDER BY sort LIMIT 1", $intTemplateId, $intAccountId);
$objElements = Element::select($strSql);
foreach ($objElements as $objElement) {
self::importElements($childNode, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $objElement->getId());
}
} else {
self::importElements($childNode, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $intElementId);
}
}
break;
case "aliases":
if ($importElements) {
//*** Add aliases to the account.
foreach ($childNode->childNodes as $aliasNode) {
if (in_array($aliasNode->getAttribute("url"), $arrElementIds)) {
$objAlias = new Alias();
$objAlias->setAccountId($_CONF['app']['account']->getId());
$objAlias->setAlias($aliasNode->getAttribute("alias"));
$objAlias->setUrl($arrElementIds[$aliasNode->getAttribute("url")]);
$objAlias->setLanguageId($arrLanguageIds[$aliasNode->getAttribute("language")]);
// check for existence of alias
$objTmpAliases = Alias::selectByAlias($aliasNode->getAttribute("alias"));
$objTmpAlias = $objTmpAliases->current();
if (!is_object($objTmpAlias)) {
$objAlias->setCascade($aliasNode->getAttribute("cascade"));
$objAlias->setActive($aliasNode->getAttribute("active"));
$objAlias->setSort($aliasNode->getAttribute("sort"));
$objAlias->setCreated($aliasNode->getAttribute("created"));
$objAlias->setModified($aliasNode->getAttribute("modified"));
$objAlias->save();
}
}
}
}
break;
}
if ($importElements) {
//*** Adjust the links for deeplink fields.
self::adjustDeeplinks($arrElementFieldIds["link"], $arrElementIds, $arrLanguageIds);
//*** Adjust the links in large text fields.
self::adjustTextlinks($arrElementFieldIds["largeText"], $arrElementIds, $arrLanguageIds, array(0));
}
}
}
}
}
//*** Import files
$objAccount = Account::selectByPK($_CONF['app']['account']->getId());
if ($blnZip && is_object($objAccount) && $importElements) {
self::importFiles($objZip, $objAccount);
//*** Move files to remote server.
self::moveImportedFiles($objAccount);
}
return true;
}
return false;
}
示例7: recursiveFeedInsert
private function recursiveFeedInsert($objElement, $objParent, $objNode, $objLangs)
{
global $objLiveUser;
$objElementFeed = $objElement->getFeed();
$objTemplate = Template::selectByPK($objElement->getTemplateId());
if (is_null($objNode)) {
$objNodes = $objElementFeed->getBody();
} else {
$strFeedPath = $objElementFeed->getFeedPath();
if (empty($strFeedPath)) {
$objNodes = array($objNode);
} else {
$objNodes = $objNode->xpath($objElementFeed->getFeedPath());
}
}
$intMaxItems = $objElementFeed->getMaxItems();
if (empty($intMaxItems)) {
$intMaxItems = 0;
}
$intCount = 1;
foreach ($objNodes as $objNode) {
//*** Create elements.
$strName = "";
$objInsertElement = new InsertFeedElement($objParent);
$objInsertElement->setTemplate($objElement->getTemplateId());
foreach ($objLangs as $objLang) {
$objFeedFields = ElementFieldFeed::selectByElement($objElement->getId(), $objLang->getId());
foreach ($objFeedFields as $objFeedField) {
$strPath = $objFeedField->getXPath();
if (stripos($strPath, "user->") !== false) {
$strValue = str_replace("user->", "", $strPath);
$objInsertElement->addField($objFeedField->getTemplateFieldId(), $strValue, $objLang->getId(), $objFeedField->getCascade());
} else {
$strValue = $this->valueByPath($objNode, $strPath);
if (!empty($strValue)) {
$objInsertElement->addField($objFeedField->getTemplateFieldId(), $strValue, $objLang->getId(), $objFeedField->getCascade());
if (!is_numeric($strValue) && empty($strName)) {
$strName = getShortValue(strip_tags($strValue), 40, true, "");
}
}
}
}
}
$strName = empty($strName) ? "Dynamic" : $strName;
$objInsertElement->setName($strName);
$objInsertElement->setUsername("PunchCMS");
$objInsertElement->setActive(true);
$objInsertedElement = $objInsertElement->save();
//*** Add the alias.
$strAlias = "";
$strAliasField = $objElementFeed->getAliasField();
if (!empty($strAliasField)) {
//*** Get the alias field value.
$strValue = $this->valueByPath($objNode, $objElementFeed->getAliasField());
$strAlias = $objElement->getAlias();
if (!empty($strAlias) && stripos($strAlias, "%s") !== false) {
//*** Merge value with the flat alias.
$strAlias = sprintf($strAlias, $strValue);
} else {
//*** Use just the value.
$strAlias = $strValue;
}
} else {
//*** Use the flat alias.
$strAlias = $objElement->getAlias();
}
if (!empty($strAlias)) {
$objAlias = new Alias();
$objAlias->setAlias($strAlias);
$objInsertedElement->setAlias($objAlias);
}
//*** Sub elements.
$objSubElements = $objElement->getElements(false, ELM_TYPE_DYNAMIC, $this->getAccountId());
foreach ($objSubElements as $objSubElement) {
$this->recursiveFeedInsert($objSubElement, $objInsertedElement, $objNode, $objLangs);
}
if ($intMaxItems > 0 && $intCount >= $intMaxItems) {
break;
}
$intCount++;
}
}
示例8: parseAlias
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", "");
//.........这里部分代码省略.........