当前位置: 首页>>代码示例>>PHP>>正文


PHP Element::setLanguageActive方法代码示例

本文整理汇总了PHP中Element::setLanguageActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setLanguageActive方法的具体用法?PHP Element::setLanguageActive怎么用?PHP Element::setLanguageActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element::setLanguageActive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parsePages


//.........这里部分代码省略.........
                        $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);
开发者ID:laiello,项目名称:punchcms,代码行数:67,代码来源:inc.tplparse_element.php

示例2: save


//.........这里部分代码省略.........
         $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.");
                                             }
                                         }
                                         //*** Unlink original file.
                                         @unlink($_PATHS['upload'] . $strOriginalName);
                                     }
                                     $objValue->setValue($strOriginalName . ":" . $strLocalValue . "\n");
                                 }
                             }
                         }
                         break;
                     default:
                         $objValue->setValue($arrValue['value']);
                 }
                 $objValue->setLanguageId($intLanguage);
                 $objValue->setCascade($arrValue['cascade']);
                 $objField->setValueObject($objValue);
                 //*** Activate the language.
                 $objElement->setLanguageActive($intLanguage, true);
             }
         }
         return $objElement;
     }
 }
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:class.insertfeedelement.php

示例3: 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));
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:class.impex.php

示例4: 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);
     }
 }
开发者ID:laiello,项目名称:punchcms,代码行数:49,代码来源:lib.pcms_client.php

示例5: createForcedElements

 private function createForcedElements()
 {
     global $_CONF;
     $objTemplates = $this->getSubTemplates();
     foreach ($objTemplates as $objTemplate) {
         if ($objTemplate->getForceCreation()) {
             //*** Create a child element based on this template.
             $objPermissions = new ElementPermission();
             $objPermissions->setUserId($this->getPermissions()->getUserId());
             $objPermissions->setGroupId($this->getPermissions()->getGroupId());
             $objElement = new Element();
             $objElement->setParentId($this->getId());
             $objElement->setAccountId($_CONF['app']['account']->getId());
             $objElement->setPermissions($objPermissions);
             $objElement->setActive($this->getActive());
             $objElement->setIsPage(0);
             $objElement->setName($objTemplate->getName());
             $objElement->setUsername($this->getUsername());
             $objElement->setTypeId(ELM_TYPE_ELEMENT);
             $objElement->setTemplateId($objTemplate->getId());
             $objElement->save();
             $objSchedule = new ElementSchedule();
             $objSchedule->setStartActive(0);
             $objSchedule->setStartDate(APP_DEFAULT_STARTDATE);
             $objSchedule->setEndActive(0);
             $objSchedule->setEndDate(APP_DEFAULT_ENDDATE);
             $objElement->setSchedule($objSchedule);
             $objElement->setLanguageActive(ContentLanguage::getDefault()->getId(), TRUE);
         }
     }
 }
开发者ID:laiello,项目名称:punchcms,代码行数:31,代码来源:class.element.php


注:本文中的Element::setLanguageActive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。