當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ca_metadata_elements::setMode方法代碼示例

本文整理匯總了PHP中ca_metadata_elements::setMode方法的典型用法代碼示例。如果您正苦於以下問題:PHP ca_metadata_elements::setMode方法的具體用法?PHP ca_metadata_elements::setMode怎麽用?PHP ca_metadata_elements::setMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ca_metadata_elements的用法示例。


在下文中一共展示了ca_metadata_elements::setMode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processMetadataElement

 private function processMetadataElement($po_element, $pn_parent_id)
 {
     require_once __CA_MODELS_DIR__ . "/ca_metadata_elements.php";
     require_once __CA_MODELS_DIR__ . "/ca_lists.php";
     if (($vn_datatype = ca_metadata_elements::getAttributeTypeCode(self::getAttribute($po_element, "datatype"))) === false) {
         return false;
         // should not happen due to XSD restrictions, but just in case
     }
     $vs_element_code = self::getAttribute($po_element, "code");
     $t_lists = new ca_lists();
     if ($this->opb_updating) {
         $t_md_element = ca_metadata_elements::getInstance($vs_element_code) ? ca_metadata_elements::getInstance($vs_element_code) : new ca_metadata_elements();
     } else {
         $t_md_element = new ca_metadata_elements();
     }
     $t_md_element->setMode(ACCESS_WRITE);
     $t_md_element->set('element_code', $vs_element_code);
     $t_md_element->set('parent_id', $pn_parent_id);
     $t_md_element->set('documentation_url', (string) $po_element->documentationUrl);
     $t_md_element->set('datatype', $vn_datatype);
     $vs_list = self::getAttribute($po_element, "list");
     if (isset($vs_list) && $vs_list && $t_lists->load(array('list_code' => $vs_list))) {
         $vn_list_id = $t_lists->getPrimaryKey();
     } else {
         $vn_list_id = null;
     }
     $t_md_element->set('list_id', $vn_list_id);
     $this->_processSettings($t_md_element, $po_element->settings);
     if ($t_md_element->getPrimaryKey()) {
         $t_md_element->update();
     } else {
         $t_md_element->insert();
     }
     if ($t_md_element->numErrors()) {
         $this->addError("There was an error while inserting metadata element {$vs_element_code}: " . join(" ", $t_md_element->getErrors()));
         return false;
     }
     $vn_element_id = $t_md_element->getPrimaryKey();
     // add element labels
     self::addLabelsFromXMLElement($t_md_element, $po_element->labels, $this->opa_locales);
     if ($po_element->elements) {
         foreach ($po_element->elements->children() as $vo_child) {
             $this->processMetadataElement($vo_child, $vn_element_id);
         }
     }
     return $vn_element_id;
 }
開發者ID:idiscussforum,項目名稱:providence,代碼行數:47,代碼來源:Installer.php

示例2: stabilizeElementRanks

 private function stabilizeElementRanks($pn_parent_id, $pa_ranks)
 {
     $vo_db = new Db();
     $t_element = new ca_metadata_elements();
     do {
         $va_ranks = array_keys($pa_ranks);
         $vn_rank = $va_ranks[0];
         $qr_res = $vo_db->query("\n\t\t\t\tSELECT * FROM\n\t\t\t\t\tca_metadata_elements\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(parent_id=?)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(rank>?)\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\trank\n\t\t\t", $pn_parent_id, $vn_rank);
         while ($qr_res->nextRow()) {
             $t_element->load($qr_res->get('element_id'));
             $t_element->set('rank', intval($t_element->get('rank')) + $pa_ranks[0]);
             $t_element->setMode(ACCESS_WRITE);
             $t_element->update();
         }
         $qr_res = $vo_db->query("\n\t\t\t\tSELECT * FROM\n\t\t\t\t\tca_metadata_elements\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(parent_id=?)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(rank=?)\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\trank\n\t\t\t", $pn_parent_id, $vn_rank);
         $i = 0;
         while ($qr_res->nextRow()) {
             $i++;
             $t_element->load($qr_res->get('element_id'));
             $t_element->set('rank', intval($t_element->get('rank')) + $i);
             $t_element->setMode(ACCESS_WRITE);
             $t_element->update();
         }
         $pa_ranks = $this->elementRankStabilizationNeeded($pn_parent_id);
     } while (is_array($pa_ranks));
 }
開發者ID:samrahman,項目名稱:providence,代碼行數:26,代碼來源:ElementsController.php


注:本文中的ca_metadata_elements::setMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。