本文整理汇总了PHP中Element::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::getId方法的具体用法?PHP Element::getId怎么用?PHP Element::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::getId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Find list item by search
* @param \Jazzee\Entity\Element $element
* @param array $searchTerms
* @param array $variables
* @return array
*/
public function search(Element $element, $searchTerms, $variables = array())
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->add('select', 'item')->from('Jazzee\\Entity\\ElementListItem', 'item')->leftJoin('item.variables', 'variable');
$queryBuilder->where('item.element = :elementId');
$queryBuilder->setParameter('elementId', $element->getId());
$expression = $queryBuilder->expr()->orX();
$expression2 = $queryBuilder->expr()->andX();
foreach ($searchTerms as $key => $term) {
$expression2->add($queryBuilder->expr()->like("item.value", ":term{$key}"));
$queryBuilder->setParameter("term{$key}", '%' . $term . '%');
}
$expression->add($expression2);
$expression2 = $queryBuilder->expr()->andX();
foreach ($searchTerms as $key => $term) {
$expression3 = $queryBuilder->expr()->andX();
foreach ($variables as $key2 => $name) {
$expression3->add($queryBuilder->expr()->eq("variable.name", ":v{$key2}"));
$expression3->add($queryBuilder->expr()->like("variable.value", ":term{$key}"));
$queryBuilder->setParameter('v' . $key2, $name);
}
$expression2->add($expression3);
$queryBuilder->setParameter("term{$key}", '%' . $term . '%');
}
$expression->add($expression2);
$queryBuilder->andWhere($expression);
return $queryBuilder->getQuery()->getResult();
}
示例2: getId
public function getId()
{
$id = parent::getId();
if ($id == "" && $this->ajax) {
$id = str_replace(".", "_", $this->getName());
}
return $id;
}
示例3: encode
private function encode(Element $element)
{
$chromosomeLength = count($element->getProperties());
$this->elementId = $element->getId();
$this->elementName = $element->getCssTag();
$newChromosome = new SplFixedArray($chromosomeLength);
$chromosomeIndex = 0;
foreach ($element->getProperties() as $property) {
$newChromosome[$chromosomeIndex] = $property->getRandomValue();
$chromosomeIndex++;
}
return $newChromosome;
}
示例4: 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.
//.........这里部分代码省略.........
示例5: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param Element $value A Element object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Element $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
// if key === null
self::$instances[$key] = $obj;
}
}
示例6: 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.");
}
//.........这里部分代码省略.........
示例7: setElement
/**
* Declares an association between this object and a Element object.
*
* @param Element $v
* @return ElementFile The current object (for fluent API support)
* @throws PropelException
*/
public function setElement(Element $v = null)
{
if ($v === null) {
$this->setElementId(NULL);
} else {
$this->setElementId($v->getId());
}
$this->aElement = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Element object, it will not be re-added.
if ($v !== null) {
$v->addElementFile($this);
}
return $this;
}
示例8: save
public function save()
{
if (is_object($this->__template)) {
$objCms = PCMS_Client::getInstance();
//*** Element.
$objElement = new Element();
$objElement->setParentId($this->__parent->getId());
$objElement->setAccountId($objCms->getAccount()->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_ELEMENT);
$objElement->setTemplateId($this->__template->getId());
$objElement->save();
//*** Activate default schedule.
$objSchedule = new ElementSchedule();
$objSchedule->setStartActive(0);
$objSchedule->setStartDate(PCMS_DEFAULT_STARTDATE);
$objSchedule->setEndActive(0);
$objSchedule->setEndDate(PCMS_DEFAULT_ENDDATE);
$objElement->setSchedule($objSchedule);
foreach ($this->__fields as $apiName => $arrField) {
$objTemplateField = $this->__template->getFieldByName($apiName);
$objField = new ElementField();
$objField->setElementId($objElement->getId());
$objField->setTemplateFieldId($objTemplateField->getId());
$objField->save();
foreach ($arrField as $intLanguage => $arrValue) {
$objValue = $objField->getNewValueObject();
$objValue->setValue($arrValue['value']);
$objValue->setLanguageId($intLanguage);
$objValue->setCascade($arrValue['cascade']);
$objField->setValueObject($objValue);
//*** Activate the language.
$objElement->setLanguageActive($intLanguage, TRUE);
}
}
if (count($this->__fields) == 0) {
//*** Set all languages active if there are no fields.
$objLangs = $objCms->getLanguages();
foreach ($objLangs as $objLang) {
$objElement->setLanguageActive($objLang->getId(), TRUE);
}
}
return new __Element($objElement);
}
}
示例9: importElements
public static function importElements($objElements, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, &$arrElementIds, &$arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $intParentId = 0)
{
global $intDefaultLanguage;
$strElmntPattern = "/(\\?eid=)([0-9]+)/ie";
$strStoragePattern = "/(\\?mid=)([0-9]+)/ie";
foreach ($objElements->childNodes as $elementNode) {
if (!is_null($arrTemplateIds[$elementNode->getAttribute("templateId")])) {
$objElement = new Element();
$objElement->setAccountId($intAccountId);
$objElement->setParentId($intParentId);
$objElement->setActive($elementNode->getAttribute("active"));
$objElement->setIsPage($elementNode->getAttribute("isPage"));
$objElement->setName($elementNode->getAttribute("name"));
$objElement->setApiName($elementNode->getAttribute("apiName"));
$objElement->setDescription($elementNode->getAttribute("description"));
$objElement->setUsername($elementNode->getAttribute("username"));
$objElement->setTypeId($elementNode->getAttribute("typeId"));
$objElement->setTemplateId($arrTemplateIds[$elementNode->getAttribute("templateId")]);
$objElement->setSort($elementNode->getAttribute("sort"));
$objElement->save(false, false);
if ($elementNode->getAttribute("typeId") == 1) {
$objElement->setLanguageActive($intDefaultLanguage, 1);
}
$arrElementIds[$elementNode->getAttribute("id")] = $objElement->getId();
//*** Schedule.
$objSchedule = new ElementSchedule();
$objSchedule->setStartActive($elementNode->getAttribute("scheduleStartActive"));
$objSchedule->setStartDate($elementNode->getAttribute("scheduleStartDate"));
$objSchedule->setEndActive($elementNode->getAttribute("scheduleEndActive"));
$objSchedule->setEndDate($elementNode->getAttribute("scheduleEndDate"));
$objElement->setSchedule($objSchedule);
//*** Add fields to the element.
foreach ($elementNode->childNodes as $subNode) {
switch ($subNode->nodeName) {
case "fields":
$arrActiveLangs = array();
foreach ($subNode->childNodes as $fieldNode) {
switch ($fieldNode->nodeName) {
case "field":
$objField = new ElementField();
$objField->setElementId($objElement->getId());
$objField->setTemplateFieldId($arrTemplateFieldIds[$fieldNode->getAttribute("templateFieldId")]);
$objField->setSort($fieldNode->getAttribute("sort"));
$objField->save();
foreach ($fieldNode->childNodes as $languageNode) {
$objValue = $objField->getNewValueObject();
$objValue->setValue($languageNode->nodeValue);
$objValue->setLanguageId($arrLanguageIds[$languageNode->getAttribute("id")]);
$objValue->setCascade($languageNode->getAttribute("cascade"));
$objField->setValueObject($objValue);
$arrActiveLangs[$languageNode->getAttribute("id")] = $languageNode->getAttribute("active");
if (preg_match($strElmntPattern, $languageNode->nodeValue) > 0) {
array_push($arrElementFieldIds["largeText"], $objField->getId());
}
if (preg_match($strStoragePattern, $languageNode->nodeValue) > 0) {
array_push($arrElementFieldIds["largeText"], $objField->getId());
}
}
if (in_array($fieldNode->getAttribute("templateFieldId"), $arrLinkFieldIds)) {
array_push($arrElementFieldIds["link"], $objField->getId());
}
break;
}
}
foreach ($arrActiveLangs as $key => $value) {
$objElement->setLanguageActive($arrLanguageIds[$key], $value);
}
break;
case "feed":
foreach ($subNode->childNodes as $feedFieldNode) {
if ($feedFieldNode->nodeName == "feedfield") {
$objFeedField = new ElementFieldFeed();
$objFeedField->setElementId($objElement->getId());
$objFeedField->setTemplateFieldId($arrTemplateFieldIds[$feedFieldNode->getAttribute("templateFieldId")]);
$objFeedField->setFeedPath($feedFieldNode->getAttribute("feedPath"));
$objFeedField->setXpath($feedFieldNode->getAttribute("xpath"));
$objFeedField->setLanguageId($arrLanguageIds[$feedFieldNode->getAttribute("languageId")]);
$objFeedField->setCascade($feedFieldNode->getAttribute("cascade"));
$objFeedField->setSort($feedFieldNode->getAttribute("sort"));
$objFeedField->save();
}
}
$objFeed = new ElementFeed();
$objFeed->setElementId($objElement->getId());
$objFeed->setFeedId($arrFeedIds[$subNode->getAttribute("feedId")]);
$objFeed->setFeedPath($subNode->getAttribute("feedPath"));
$objFeed->setMaxItems($subNode->getAttribute("maxItems"));
$objFeed->setSortBy($subNode->getAttribute("sortBy"));
$objFeed->setAliasField($subNode->getAttribute("aliasField"));
$objFeed->save();
break;
case "meta":
$arrMetaFields = array("title", "keywords", "description");
foreach ($subNode->childNodes as $metaFieldNode) {
if ($metaFieldNode->nodeName == "language") {
$intLanguageId = $arrLanguageIds[$metaFieldNode->getAttribute("id")];
foreach ($arrMetaFields as $value) {
$objMeta = new ElementMeta();
$objMeta->setName($value);
$objMeta->setValue($metaFieldNode->getAttribute($value));
//.........这里部分代码省略.........
示例10: radio
/**
* Radio element type
* @param Element $element
* @param $fieldHtml
* @throws \Exception
*/
protected static function radio(Element &$element, &$fieldHtml)
{
$name = $element->getName();
$id = $element->getId();
$value = $element->getValue();
if ($element->getType() == self::TYPE_MULTICHECKBOX && !is_array($value)) {
$value = array();
}
$options = $element->getProperties('options');
if (!is_array($options)) {
throw new \Exception("Options for field type '{$element->getType()}' must be given as array.");
}
//classes
$class = $element->getProperties('class');
if (!is_array($class)) {
$class = array();
}
$attributes = $element->getProperties('attributes');
$extraAttributes = '';
if (is_array($attributes)) {
foreach ($attributes as $attr => $val) {
if (is_string($attr)) {
$extraAttributes .= sprintf('%s="%s" ', $attr, $val);
} else {
$extraAttributes .= sprintf('%s ', $val);
}
}
}
foreach ($options as $option => $lbl) {
$optionAttributes = $extraAttributes;
//does this option have its own settings?
if (is_array($lbl)) {
$optionSettings = $lbl;
if (!isset($optionSettings['label'])) {
throw new \Exception("A label has not been set for one of the arrayed options for field - " . $element->getName(true));
}
$lbl = $optionSettings['label'];
if (isset($optionSettings['attributes']) && is_array($optionSettings['attributes'])) {
foreach ($optionSettings['attributes'] as $attr => $val) {
if (is_string($attr)) {
$optionAttributes .= sprintf('%s="%s" ', $attr, $val);
} else {
$optionAttributes .= sprintf('%s ', $val);
}
}
}
}
$labelHtml = self::$templates['label'];
$labelHtml = str_replace('{{id}}', "{$id}_{$option}", $labelHtml);
$labelHtml = str_replace('{{text}}', $lbl, $labelHtml);
if ($element->getType() == self::TYPE_RADIO) {
$field = self::$templates[self::TYPE_RADIO];
$field = str_replace('{{name}}', $name, $field);
$field = str_replace('{{value}}', 'value="' . $option . '" ' . ($option == $value ? ' checked="checked"' : ''), $field);
} else {
if ($element->getType() == self::TYPE_MULTICHECKBOX) {
$field = self::$templates[self::TYPE_CHECKBOX];
$field = str_replace('{{name}}', "{$name}[]", $field);
$field = str_replace('{{value}}', 'value="' . $option . '" ' . (in_array($option, $value) ? ' checked="checked"' : ''), $field);
}
}
$field = str_replace('{{id}}', "{$id}_{$option}", $field);
$field = str_replace('{{class}}', implode(' ', $class), $field);
$field = str_replace('{{attributes}}', $optionAttributes, $field);
$field .= ' ' . $labelHtml;
$options[$option] = "<div>{$field}</div>";
}
$fieldHtml = '<div>' . implode('', $options) . '</div>';
}
示例11: displayElement
public function displayElement(Element $element)
{
$elementIds = $this->getElementIds();
return in_array($element->getId(), $elementIds);
}