本文整理汇总了PHP中ca_sets::removeItem方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::removeItem方法的具体用法?PHP ca_sets::removeItem怎么用?PHP ca_sets::removeItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::removeItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _processRelatedSets
/**
* @param RequestHTTP $po_request
* @param string $ps_form_prefix
* @param string $ps_placement_code
*/
public function _processRelatedSets($po_request, $ps_form_prefix, $ps_placement_code)
{
require_once __CA_MODELS_DIR__ . '/ca_sets.php';
foreach ($_REQUEST as $vs_key => $vs_value) {
// check for new relationships to add
if (preg_match("/^{$ps_placement_code}{$ps_form_prefix}_idnew_([\\d]+)/", $vs_key, $va_matches)) {
$vn_c = intval($va_matches[1]);
if ($vn_new_id = $po_request->getParameter("{$ps_placement_code}{$ps_form_prefix}_idnew_{$vn_c}", pString)) {
$t_set = new ca_sets($vn_new_id);
$t_set->addItem($this->getPrimaryKey(), null, $po_request->getUserID());
}
}
// check for delete keys
if (preg_match("/^{$ps_placement_code}{$ps_form_prefix}_([\\d]+)_delete/", $vs_key, $va_matches)) {
$vn_c = intval($va_matches[1]);
$t_set = new ca_sets($vn_c);
$t_set->removeItem($this->getPrimaryKey());
}
}
}
示例2: saveBundlesForScreen
//.........这里部分代码省略.........
// This bundle is only available when editing objects of type ca_representation_annotations
case 'ca_representation_annotation_properties':
if ($vb_batch) {
break;
}
// not supported in batch mode
if (!$this->useInEditor()) {
break;
}
foreach ($this->getPropertyList() as $vs_property) {
$this->setPropertyValue($vs_property, $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}{$vs_property}", pString));
}
if (!$this->validatePropertyValues()) {
$po_request->addActionErrors($this->errors(), 'ca_representation_annotation_properties', 'general');
}
$this->update();
break;
# -------------------------------------
// This bundle is only available for types which support set membership
# -------------------------------------
// This bundle is only available for types which support set membership
case 'ca_sets':
// check for existing labels to delete (no updating supported)
require_once __CA_MODELS_DIR__ . '/ca_sets.php';
require_once __CA_MODELS_DIR__ . '/ca_set_items.php';
$t_set = new ca_sets();
if (!$vb_batch) {
$va_sets = caExtractValuesByUserLocale($t_set->getSetsForItem($this->tableNum(), $this->getPrimaryKey(), array('user_id' => $po_request->getUserID())));
foreach ($va_sets as $vn_set_id => $va_set_info) {
$vn_item_id = $va_set_info['item_id'];
if ($po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_set_id_{$vn_item_id}_delete", pString)) {
// delete
$t_set->load($va_set_info['set_id']);
$t_set->removeItem($this->getPrimaryKey(), $po_request->getUserID());
// remove *all* instances of the item in the set, not just the specified id
if ($t_set->numErrors()) {
$po_request->addActionErrors($t_set->errors(), $vs_f);
}
}
}
}
if ($vb_batch) {
$vs_batch_mode = $_REQUEST["{$vs_placement_code}{$vs_form_prefix}_batch_mode"];
if ($vs_batch_mode == '_disabled_') {
break;
}
if ($vs_batch_mode == '_replace_') {
$t_set->removeItemFromAllSets($this->tableNum(), $this->getPrimaryKey());
}
if ($vs_batch_mode == '_delete_') {
$t_set->removeItemFromAllSets($this->tableNum(), $this->getPrimaryKey());
break;
}
}
foreach ($_REQUEST as $vs_key => $vs_value) {
if (!preg_match("/{$vs_placement_code}{$vs_form_prefix}_set_id_new_([\\d]+)/", $vs_key, $va_matches)) {
continue;
}
$vn_c = intval($va_matches[1]);
if ($vn_new_set_id = $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_set_id_new_{$vn_c}", pString)) {
$t_set->load($vn_new_set_id);
$t_set->addItem($this->getPrimaryKey(), null, $po_request->getUserID());
if ($t_set->numErrors()) {
$po_request->addActionErrors($t_set->errors(), $vs_f);
}
}
示例3: testAddAndGetSetItem
/**
* @link http://clangers.collectiveaccess.org/jira/browse/PROV-434
*/
public function testAddAndGetSetItem()
{
$t_set = new ca_sets($this->opn_set_id);
$t_set->setMode(ACCESS_WRITE);
// "quick" add object (this method uses direct INSERT queries)
$t_set->addItems(array($this->opn_object_id));
$va_set_items = $t_set->getItems();
// get rid of unneeded nesting in array. we should only have one label in one locale.
$this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale');
$va_set_items = array_shift($va_set_items);
$this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale');
$va_set_items = array_shift($va_set_items);
// basic checks
$this->assertArrayHasKey('caption', $va_set_items, 'Set item must have empty/blank label');
$this->assertEquals('[BLANK]', $va_set_items['caption'], 'Set item must have empty/blank label');
$this->assertArrayHasKey('row_id', $va_set_items, 'Set item must be related to object');
$this->assertEquals($this->opn_object_id, $va_set_items['row_id'], 'Set item must be related to object');
//
// this is (hopefully was?) the actual PROV-434 bug
// @see http://clangers.collectiveaccess.org/jira/browse/PROV-434
//
$va_items = $t_set->get('ca_set_items', array('returnWithStructure' => true));
$this->assertEquals(1, sizeof($va_items));
$va_item = array_shift($va_items);
$this->assertArrayHasKey('caption', $va_item, 'Set item must have empty/blank label');
$this->assertEquals('[BLANK]', $va_item['caption'], 'Set item must have empty/blank label');
$this->assertArrayHasKey('record_id', $va_item, 'Set item must be related to object');
$this->assertEquals($this->opn_object_id, $va_item['record_id'], 'Set item must be related to object');
// try text (no return as array)
$vs_ret = $t_set->get('ca_set_items.item_id');
// what comes out is a string with the primary key
$this->assertRegExp("/^[0-9]+\$/", $vs_ret);
$vs_ret = $t_set->get('ca_set_items.preferred_labels');
$this->assertEquals("[BLANK]", $vs_ret);
$vs_ret = $t_set->get('ca_set_items.row_id');
$this->assertEquals((string) $this->opn_object_id, $vs_ret);
// remove item
$t_set->removeItem($this->opn_object_id);
$this->assertEmpty($t_set->getItems());
// re-add object using model method (as opposed to direct insert addItems() above)
$t_set->addItem($this->opn_object_id);
// basic checks (again)
$va_set_items = $t_set->getItems();
// get rid of unneeded nesting in array. we should only have one label in one locale.
$this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale');
$va_set_items = array_shift($va_set_items);
$this->assertEquals(1, sizeof($va_set_items), 'Set should only have one item in one locale');
$va_set_items = array_shift($va_set_items);
$this->assertArrayHasKey('caption', $va_set_items, 'Set item must have empty/blank label');
$this->assertEquals('[BLANK]', $va_set_items['caption'], 'Set item must have empty/blank label');
$this->assertArrayHasKey('row_id', $va_set_items, 'Set item must be related to object');
$this->assertEquals($this->opn_object_id, $va_set_items['row_id'], 'Set item must be related to object');
//
// this is (hopefully was?) the actual PROV-434 bug
// @see http://clangers.collectiveaccess.org/jira/browse/PROV-434
//
$va_items = $t_set->get('ca_set_items', array('returnWithStructure' => true));
$this->assertEquals(1, sizeof($va_items));
$va_item = array_shift($va_items);
$this->assertArrayHasKey('caption', $va_item, 'Set item must have empty/blank label');
$this->assertEquals('[BLANK]', $va_item['caption'], 'Set item must have empty/blank label');
$this->assertArrayHasKey('record_id', $va_item, 'Set item must be related to object');
$this->assertEquals($this->opn_object_id, $va_item['record_id'], 'Set item must be related to object');
}