本文整理汇总了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;
}
示例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));
}