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


PHP Element::selectByPk方法代码示例

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


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

示例1: getValue

 public function getValue($intLanguageId = 0)
 {
     $strReturn = "";
     if ($intLanguageId == 0) {
         $intLanguageId = ContentLanguage::getDefault()->getId();
     }
     $objValue = $this->getValueObject($intLanguageId);
     if (is_object($objValue)) {
         /* Perform any format conversions before saving the value to
          * the database.
          */
         $objTemplateField = TemplateField::selectByPK($this->templateFieldId);
         switch ($objTemplateField->getTypeId()) {
             case FIELD_TYPE_DATE:
                 //*** Convert the date to the predefined format.
                 $strReturn = Date::fromMysql($objTemplateField->getValueByName("tfv_field_format")->getValue(), $objValue->getValue());
                 break;
             case FIELD_TYPE_LARGETEXT:
                 //*** Correct internal anchors.
                 $intElementId = Element::selectByPk($this->getElementId())->getPageId();
                 $strReturn = str_replace("href=\"#", "href=\"?eid={$intElementId}#", $objValue->getValue());
                 break;
             case FIELD_TYPE_FILE:
             case FIELD_TYPE_IMAGE:
                 //*** Split the current filename from the raw value.
                 $arrReturn = array();
                 $arrFileTemp = explode("\n", $objValue->getValue());
                 foreach ($arrFileTemp as $fileValue) {
                     if (!empty($fileValue)) {
                         $arrTemp = explode(":", $fileValue);
                         $objTemp = array();
                         $objTemp["original"] = $arrTemp[0];
                         $objTemp["src"] = count($arrTemp) > 1 ? $arrTemp[1] : $arrTemp[0];
                         $objTemp["media_id"] = count($arrTemp) > 2 ? $arrTemp[2] : 0;
                         $objTemp["alt"] = count($arrTemp) > 3 ? $arrTemp[3] : "";
                         array_push($arrReturn, $objTemp);
                     }
                 }
                 $strReturn = $arrReturn;
                 break;
             case FIELD_TYPE_BOOLEAN:
                 //*** Make it a true boolean.
                 if ($objValue->getValue() == "true") {
                     $strReturn = true;
                 } else {
                     $strReturn = false;
                 }
                 break;
             default:
                 $strReturn = $objValue->getValue();
                 break;
         }
         $this->rawValue = $objValue->getValue();
     }
     return $strReturn;
 }
开发者ID:laiello,项目名称:punchcms,代码行数:56,代码来源:class.elementfield.php

示例2: find

    public function find($strQuery, $blnExact = false)
    {
        global $_CONF;
        //*** Set query property.
        $objReturn = new SearchResults();
        $objReturn->setQuery($strQuery);
        $strQuery = str_replace("*", "%", $strQuery);
        //*** Convert query to stem.
        $arrWords = array_values($this->stemPhrase($strQuery));
        $intWordCount = count($arrWords);
        //*** Query does not validate.
        if (!$arrWords) {
            return $objReturn;
        }
        //*** Set query property.
        $objReturn->setQuery($strQuery);
        $strSql = sprintf("SELECT DISTINCT pcms_search_index.elementId, COUNT(pcms_search_index.id) as word,\n\t\t\t\t\tSUM(pcms_search_index.count) as count FROM pcms_search_index, pcms_element WHERE\n\t\t\t\t\tpcms_search_index.elementId = pcms_element.id AND\n\t\t\t\t\tpcms_element.accountId = '%s' AND ", quote_smart($_CONF['app']['account']->getId()));
        $strSql .= '(' . implode(' OR ', array_fill(0, $intWordCount, '?')) . ')
					GROUP BY pcms_search_index.elementId';
        //*** AND query?
        if ($blnExact) {
            $strSql .= ' HAVING word = ' . $intWordCount;
        }
        $strSql .= ' ORDER BY word DESC, count DESC';
        //*** Inject the search words into the query.
        $arrSql = explode('?', $strSql);
        $strTempSql = "";
        for ($i = 0; $i < $intWordCount; $i++) {
            $equal = stripos($arrWords[$i], "%") !== false ? "LIKE" : "=";
            $strTempSql .= $arrSql[$i] . "word {$equal} '" . $arrWords[$i] . "'";
        }
        $strTempSql .= $arrSql[$i];
        //*** Query the database.
        $objSearchIndexes = SearchIndex::select($strTempSql);
        foreach ($objSearchIndexes as $objSearchIndex) {
            $objElement = Element::selectByPk($objSearchIndex->getElementId());
            if (!isset($intMaxWeight)) {
                $intMaxWeight = $objSearchIndex->getCount();
            }
            if (!isset($intMaxCount)) {
                $intMaxCount = $objSearchIndex->getWord();
            }
            $intRatio = round(100 / ($intMaxWeight * $intMaxCount) * $objSearchIndex->getCount() * $objSearchIndex->getWord());
            $objSearchResult = new SearchResult();
            $objSearchResult->id = $objSearchIndex->getElementId();
            $objSearchResult->name = $objElement->getName();
            $objSearchResult->value = $objElement->getDescription();
            $objSearchResult->ratio = $intRatio;
            $objReturn->addObject($objSearchResult);
        }
        return $objReturn;
    }
开发者ID:laiello,项目名称:punchcms,代码行数:52,代码来源:class.search.php

示例3: prepareValue

 private function prepareValue()
 {
     if (empty($this->rawvalue) && !is_array($this->rawvalue) && !empty($this->value)) {
         $this->rawvalue = $this->value;
         switch ($this->typeid) {
             case FIELD_TYPE_DATE:
                 //*** Convert the date to the predefined format.
                 $objTemplateField = TemplateField::selectByPK($this->templatefieldid);
                 $this->value = Date::fromMysql($objTemplateField->getValueByName("tfv_field_format")->getValue(), $this->value);
                 break;
             case FIELD_TYPE_LARGETEXT:
                 //*** Correct internal anchors.
                 $intElementId = Element::selectByPk($this->elementid)->getPageId();
                 $this->value = str_replace("href=\"#", "href=\"?eid={$intElementId}#", $this->value);
                 break;
             case FIELD_TYPE_FILE:
             case FIELD_TYPE_IMAGE:
                 //*** Split the current filename from the raw value.
                 $arrReturn = array();
                 $arrFileTemp = explode("\n", $this->value);
                 foreach ($arrFileTemp as $fileValue) {
                     if (!empty($fileValue)) {
                         $arrTemp = explode(":", $fileValue);
                         $objTemp = array();
                         $objTemp["original"] = $arrTemp[0];
                         $objTemp["src"] = count($arrTemp) > 1 ? $arrTemp[1] : $arrTemp[0];
                         $objTemp["media_id"] = count($arrTemp) > 2 ? $arrTemp[2] : 0;
                         $objTemp["alt"] = count($arrTemp) > 3 ? $arrTemp[3] : "";
                         array_push($arrReturn, $objTemp);
                     }
                 }
                 $this->value = $arrReturn;
                 break;
             case FIELD_TYPE_BOOLEAN:
                 //*** Make it a true boolean.
                 if ($this->value == "true") {
                     $this->value = TRUE;
                 } else {
                     $this->value = FALSE;
                 }
                 break;
             case FIELD_TYPE_SIMPLETEXT:
                 $this->value = nl2br($this->value);
                 break;
         }
     }
     if (empty($this->value)) {
         switch ($this->typeid) {
             case FIELD_TYPE_FILE:
             case FIELD_TYPE_IMAGE:
                 $this->value = array();
                 break;
         }
     }
 }
开发者ID:laiello,项目名称:punchcms,代码行数:55,代码来源:lib.pcms_client.php

示例4: buildXmlNodes

 private static function buildXmlNodes($intElmntId = 0, $strType = "elements", $strAction = "list", $childId = 0, $strChildren = "")
 {
     global $objLang, $objLiveUser;
     $strReturn = "";
     switch ($strType) {
         case "elements-ckeditor":
         case "elements":
             $objElements = Elements::getFromParent($intElmntId);
             foreach ($objElements as $objElement) {
                 if ($objLiveUser->checkRightLevel(PUNCHCMS_ELEMENTS_VIEW, $objElement->getPermissions()->getUserId(), $objElement->getPermissions()->getGroupId())) {
                     $objChildren = $objElement->getElements();
                     $isPage = $objElement->isPage() ? 'font-weight:bold;' : '';
                     if (is_object($objChildren) && $objChildren->count() > 0 && $objElement->getTypeId() != ELM_TYPE_FOLDER) {
                         if (!$objElement->getActive()) {
                             $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"elementClosedInactive.gif\" im1=\"elementOpenInactive.gif\" im2=\"elementClosedInactive.gif\" child=\"1\">";
                         } else {
                             $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" im0=\"elementClosed.gif\" im1=\"elementOpen.gif\" im2=\"elementClosed.gif\" child=\"1\">";
                         }
                         if ($childId == $objElement->getId()) {
                             $strReturn .= $strChildren;
                         }
                         $strReturn .= "</item>";
                     } else {
                         if ($objElement->getTypeId() == ELM_TYPE_FOLDER) {
                             $intChild = is_object($objChildren) && $objChildren->count() > 0 ? 1 : 0;
                             if (!$objElement->getActive()) {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"folderClosedInactive.gif\" im1=\"folderOpenInactive.gif\" im2=\"folderClosedInactive.gif\" child=\"{$intChild}\">";
                             } else {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" im0=\"folderClosed.gif\" im1=\"folderOpen.gif\" im2=\"folderClosed.gif\" child=\"{$intChild}\">";
                             }
                             if ($childId == $objElement->getId()) {
                                 $strReturn .= $strChildren;
                             }
                             $strReturn .= "</item>";
                         } else {
                             if (!$objElement->getActive()) {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}color:#999\" im0=\"leafInactive.gif\" im1=\"leafInactive.gif\" im2=\"leafInactive.gif\" child=\"0\" />";
                             } else {
                                 $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" style=\"{$isPage}\" child=\"0\" />";
                             }
                         }
                     }
                 }
             }
             if ($strAction == "init") {
                 $objParent = Element::selectByPk($intElmntId);
                 if (is_object($objParent)) {
                     $intParent = $objParent->getParentId();
                     $strReturn = self::buildXmlNodes($intParent, $strType, $strAction, $intElmntId, $strReturn);
                 }
             }
             break;
         case "templates":
             $objTemplates = Templates::getFromParent($intElmntId);
             foreach ($objTemplates as $objTemplate) {
                 $objChildren = $objTemplate->getTemplates();
                 if (is_object($objChildren) && $objChildren->count() > 0) {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objTemplate->getName()) . "\" id=\"{$objTemplate->getId()}\" im0=\"templateClosed.gif\" im1=\"templateOpen.gif\" im2=\"templateClosed.gif\" child=\"1\">";
                     if ($childId == $objTemplate->getId()) {
                         $strReturn .= $strChildren;
                     }
                     $strReturn .= "</item>";
                 } else {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objTemplate->getName()) . "\" id=\"{$objTemplate->getId()}\" im0=\"template.gif\" im1=\"template.gif\" im2=\"template.gif\" child=\"0\" />";
                 }
             }
             if ($strAction == "init") {
                 $objParent = Template::selectByPk($intElmntId);
                 if (is_object($objParent)) {
                     $intParent = $objParent->getParentId();
                     $strReturn = self::buildXmlNodes($intParent, $strType, $strAction, $intElmntId, $strReturn);
                 }
             }
             break;
         case "users":
             $strReturn = "<item text=\"" . self::escapeForXml($objLang->get("users", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_USER . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("groups", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_GROUP . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("applications", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_APPLICATION . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("areas", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_AREA . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             $strReturn .= "<item text=\"" . self::escapeForXml($objLang->get("rights", "usersLabel")) . "\" id=\"" . NAV_MYPUNCH_USERS_RIGHT . "\" im0=\"misc.gif\" im1=\"misc.gif\" im2=\"misc.gif\" child=\"0\" />";
             break;
         case "forms":
             $objForms = Form::selectByAccountId();
             foreach ($objForms as $objForm) {
                 $strReturn .= "<item text=\"" . self::escapeForXml($objForm->getName()) . "\" id=\"{$objForm->getId()}\" im0=\"template.gif\" im1=\"template.gif\" im2=\"template.gif\" child=\"0\" />";
             }
             break;
         case "media-ckeditor":
         case "storage":
             $objFolders = StorageItems::getFromParent($intElmntId, STORAGE_TYPE_ALL);
             foreach ($objFolders as $objElement) {
                 $objChildren = $objElement->getItems(STORAGE_TYPE_ALL);
                 if ($objElement->getTypeId() != STORAGE_TYPE_FOLDER) {
                     $strReturn .= "<item text=\"" . self::escapeForXml($objElement->getName()) . "\" id=\"{$objElement->getId()}\" child=\"0\">";
                     if ($childId == $objElement->getId()) {
                         $strReturn .= $strChildren;
                     }
                     $strReturn .= "</item>";
                 } else {
                     if ($objElement->getTypeId() == STORAGE_TYPE_FOLDER) {
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:class.tree.php

示例5: clearCache

 public function clearCache($objFtp = NULL)
 {
     if (Setting::getValueByName('caching_enable')) {
         if (!is_object($objFtp)) {
             $objFtp = new FTP(Setting::getValueByName('ftp_server'));
             $objFtp->login(Setting::getValueByName('ftp_username'), Setting::getValueByName('ftp_password'));
             $objFtp->pasv(TRUE);
         }
         $objFtp->delete(Setting::getValueByName('caching_ftp_folder') . "/*_{$this->id}_*");
         $objParent = Element::selectByPk($this->getParentId());
         if (is_object($objParent)) {
             $objParent->clearCache($objFtp);
         }
     }
 }
开发者ID:laiello,项目名称:punchcms,代码行数:15,代码来源:class.element.php

示例6: 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}&amp;cmd=" . CMD_EDIT . "&amp;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 . "&amp;eid={$objAlias->getId()}&amp;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", "");
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:inc.tplparse_alias.php


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