本文整理汇总了PHP中Element::selectByPK方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::selectByPK方法的具体用法?PHP Element::selectByPK怎么用?PHP Element::selectByPK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::selectByPK方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parsePages
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.
//.........这里部分代码省略.........
示例2: sortChildren
public static function sortChildren($intElementId)
{
$lastSort = 0;
$arrItemlist = request("itemlist");
$lastPosition = request("pos", 0);
if (is_array($arrItemlist) && count($arrItemlist) > 0) {
//*** Find last sort position.
if ($lastPosition > 0) {
$objElements = Elements::getFromParent($intElementId);
$objElements->seek($lastPosition);
$lastSort = $objElements->current()->getSort();
}
//*** Loop through the items and manipulate the sort order.
foreach ($arrItemlist as $value) {
$lastSort++;
$objElement = Element::selectByPK($value);
$objElement->setSort($lastSort);
$objElement->save(FALSE);
}
}
}
示例3: parseSearch
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();
}
}
//.........这里部分代码省略.........
示例4: exportElement
public static function exportElement($objDoc, $intAccountId, $intId, &$arrFiles, $arrTemplateFilters = NULL, $arrElementFilters = NULL, $includeSelf = false)
{
global $_CONF;
$objElements = $objDoc->createElement('elements');
if ($includeSelf) {
$objElement = Element::selectByPK($intId);
$objDbElements = new DBA__Collection();
$objDbElements->addObject($objElement);
} else {
//$objDbTemplates = Templates::getFromParent($intId, false, $intAccountId);
$objDbElements = Elements::getFromParent($intId, false, "'1', '2', '3', '4', '5'", $intAccountId);
}
if ($objDbElements->count() > 0) {
foreach ($objDbElements as $objDbElement) {
if (($arrTemplateFilters == NULL || in_array($objDbElement->getTemplateId(), $arrTemplateFilters)) && ($arrElementFilters == NULL || in_array($objDbElement->getId(), $arrElementFilters))) {
$objElement = $objDoc->createElement('element');
$objElement->setAttribute("id", $objDbElement->getId());
$objElement->setAttribute("name", $objDbElement->getName());
$objElement->setAttribute("nameCount", $objDbElement->getNameCount());
$objElement->setAttribute("apiName", $objDbElement->getApiName());
$objElement->setAttribute("description", $objDbElement->getDescription());
$objElement->setAttribute("typeId", $objDbElement->getTypeId());
$objElement->setAttribute("templateId", $objDbElement->getTemplateId());
$objElement->setAttribute("isPage", $objDbElement->getIsPage());
$objElement->setAttribute("userId", $objDbElement->getUserId());
$objElement->setAttribute("groupId", $objDbElement->getGroupId());
$objElement->setAttribute("sort", $objDbElement->getSort());
$objElement->setAttribute("active", $objDbElement->getActive());
$objElement->setAttribute("username", $objDbElement->getUsername());
$objElement->setAttribute("created", $objDbElement->getCreated());
$objElement->setAttribute("modified", $objDbElement->getModified());
//*** Schedule.
$objSchedule = $objDbElement->getSchedule();
$objElement->setAttribute("scheduleStartActive", $objSchedule->getStartActive());
$objElement->setAttribute("scheduleStartDate", $objSchedule->getStartDate());
$objElement->setAttribute("scheduleEndActive", $objSchedule->getEndActive());
$objElement->setAttribute("scheduleEndDate", $objSchedule->getEndDate());
//*** Fields.
$arrActiveLangs = $objDbElement->getLanguageActives();
$objContentLangs = ContentLanguage::select();
$objFields = $objDoc->createElement('fields');
$objDbFields = $objDbElement->getFields();
foreach ($objDbFields as $objDbField) {
$objField = $objDoc->createElement('field');
$objField->setAttribute("templateFieldId", $objDbField->getTemplateFieldId());
$objField->setAttribute("sort", $objDbField->getSort());
foreach ($objContentLangs as $objContentLanguage) {
$objValue = $objDbField->getValueObject($objContentLanguage->getId());
if (is_object($objValue)) {
$strValue = str_replace("&", "&", $objValue->getValue());
$objLanguage = $objDoc->createElement('language', $strValue);
$objLanguage->setAttribute("id", $objContentLanguage->getId());
$objLanguage->setAttribute("active", in_array($objContentLanguage->getId(), $arrActiveLangs) ? 1 : 0);
$objLanguage->setAttribute("cascade", $objValue->getCascade());
$objField->appendChild($objLanguage);
switch ($objDbField->getTypeId()) {
case FIELD_TYPE_FILE:
$arrFileTemp = explode("\n", $strValue);
foreach ($arrFileTemp as $fileValue) {
if (!empty($fileValue)) {
$arrTemp = explode(":", $fileValue);
$strSrc = count($arrTemp) > 1 ? $arrTemp[1] : $arrTemp[0];
array_push($arrFiles, $strSrc);
}
}
break;
case FIELD_TYPE_IMAGE:
$arrFileTemp = explode("\n", $strValue);
foreach ($arrFileTemp as $fileValue) {
if (!empty($fileValue)) {
$arrTemp = explode(":", $fileValue);
$strSrc = count($arrTemp) > 1 ? $arrTemp[1] : $arrTemp[0];
$objImageField = new ImageField($objDbField->getTemplateFieldId());
$arrSettings = $objImageField->getSettings();
foreach ($arrSettings as $key => $arrSetting) {
if (!empty($arrSetting['width']) || !empty($arrSetting['height'])) {
//*** Add file.
array_push($arrFiles, FileIO::add2Base($strSrc, $arrSetting['key']));
}
}
array_push($arrFiles, $strSrc);
}
}
break;
}
}
}
$objFields->appendChild($objField);
}
if ($objDbFields->count() > 0) {
$objElement->appendChild($objFields);
} else {
$objDbLanguages = ElementLanguage::selectByElement($objDbElement->getId());
$objLanguages = $objDoc->createElement('languages');
foreach ($objDbLanguages as $objDbLanguage) {
if ($objDbLanguage->getActive()) {
$objLanguage = $objDoc->createElement('language');
$objLanguage->setAttribute("id", $objDbLanguage->getLanguageId());
$objLanguage->setAttribute("active", $objDbLanguage->getActive());
$objLanguage->setAttribute("cascade", $objDbLanguage->getCascade());
//.........这里部分代码省略.........
示例5: setParent
public static function setParent()
{
$intElementId = request('eid', 0);
$intParentId = request('parentId', -1);
$strReturn = "<fields>";
$strReturn .= "<field name=\"elementId\">";
if ($intElementId > 0 && $intParentId > -1) {
$objElement = Element::selectByPK($intElementId);
if (is_object($objElement)) {
$objElement->setParentId($intParentId);
$objElement->save();
}
$strReturn .= "<value>{$intElementId}</value>";
} else {
$strReturn .= "<value>-1</value>";
}
$strReturn .= "</field>";
$strReturn .= "</fields>";
return $strReturn;
}
示例6: updateElements
public function updateElements()
{
$this->cache();
$objLangs = ContentLanguage::select();
$objElementFeeds = ElementFeed::selectByFeed($this->getId());
foreach ($objElementFeeds as $objElementFeed) {
$objElement = Element::selectByPK($objElementFeed->getElementId());
$objParent = Element::selectByPK($objElement->getParentId());
if (is_object($objElement) && is_object($objParent) && $objParent->getTypeId() != ELM_TYPE_DYNAMIC) {
//*** Remove old elements.
$objOldElements = $objParent->getElements(false, ELM_TYPE_LOCKED, $this->getAccountId());
foreach ($objOldElements as $objOldElement) {
$objOldElement->delete();
}
$this->recursiveFeedInsert($objElement, $objParent, NULL, $objLangs);
}
}
}