本文整理汇总了PHP中flexicontent_db::saveAssociations方法的典型用法代码示例。如果您正苦于以下问题:PHP flexicontent_db::saveAssociations方法的具体用法?PHP flexicontent_db::saveAssociations怎么用?PHP flexicontent_db::saveAssociations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexicontent_db
的用法示例。
在下文中一共展示了flexicontent_db::saveAssociations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAssociations
/**
* Method to save language associations
*
* @return boolean True if successful
*/
function saveAssociations(&$item, &$data)
{
$item = $item ? $item : $this->_category;
$context = 'com_categories';
return flexicontent_db::saveAssociations($item, $data, $context);
}
示例2: copyitems
//.........这里部分代码省略.........
//print_r($row->fulltext); exit;
// Create a new item in the content fc_items_ext table
$row->store();
// Not doing a translation, we start a new language group for the new item
if ($translate_method == 0) {
$row->lang_parent_id = 0;
//$row->id;
$row->store();
}
// ***********************************************************
// Copy custom fields, translating the fields if so configured
// ***********************************************************
$doTranslation = $translate_method == 3 || $translate_method == 4;
$query = 'SELECT fir.*, f.* ' . ' FROM #__flexicontent_fields_item_relations as fir' . ' LEFT JOIN #__flexicontent_fields as f ON f.id=fir.field_id' . ' WHERE item_id = ' . $sourceid;
$this->_db->setQuery($query);
$fields = $this->_db->loadObjectList();
//echo "<pre>"; print_r($fields); exit;
if ($doTranslation) {
$this->translateFieldValues($fields, $row, $lang_from, $lang_to);
}
//foreach ($fields as $field) if ($field->field_type!='text' && $field->field_type!='textarea') { print_r($field->value); echo "<br><br>"; }
foreach ($fields as $field) {
if (strlen($field->value)) {
$query = 'INSERT INTO #__flexicontent_fields_item_relations (`field_id`, `item_id`, `valueorder`, `suborder`, `value`)' . ' VALUES(' . $field->field_id . ', ' . $row->id . ', ' . $field->valueorder . ', ' . $field->suborder . ', ' . $this->_db->Quote($field->value) . ')';
$this->_db->setQuery($query);
$this->_db->execute();
}
}
if ($use_versioning) {
$v = new stdClass();
$v->item_id = (int) $item->id;
$v->version_id = 1;
$v->created = $item->created;
$v->created_by = $item->created_by;
//$v->comment = 'copy version.';
$this->_db->insertObject('#__flexicontent_versions', $v);
}
// get the items versions
$query = 'SELECT *' . ' FROM #__flexicontent_items_versions' . ' WHERE item_id = ' . $sourceid . ' AND version = ' . $curversion;
$this->_db->setQuery($query);
$curversions = $this->_db->loadObjectList();
foreach ($curversions as $cv) {
$query = 'INSERT INTO #__flexicontent_items_versions (`version`, `field_id`, `item_id`, `valueorder`, `suborder`, `value`)' . ' VALUES(1 ,' . $cv->field_id . ', ' . $row->id . ', ' . $cv->valueorder . ', ' . $cv->suborder . ', ' . $this->_db->Quote($cv->value) . ')';
$this->_db->setQuery($query);
$this->_db->execute();
}
// get the item categories
$query = 'SELECT catid' . ' FROM #__flexicontent_cats_item_relations' . ' WHERE itemid = ' . $sourceid;
$this->_db->setQuery($query);
$cats = $this->_db->loadColumn();
foreach ($cats as $cat) {
$query = 'INSERT INTO #__flexicontent_cats_item_relations (`catid`, `itemid`)' . ' VALUES(' . $cat . ',' . $row->id . ')';
$this->_db->setQuery($query);
$this->_db->execute();
}
if ($keeptags) {
// get the item tags
$query = 'SELECT tid' . ' FROM #__flexicontent_tags_item_relations' . ' WHERE itemid = ' . $sourceid;
$this->_db->setQuery($query);
$tags = $this->_db->loadColumn();
foreach ($tags as $tag) {
$query = 'INSERT INTO #__flexicontent_tags_item_relations (`tid`, `itemid`)' . ' VALUES(' . $tag . ',' . $row->id . ')';
$this->_db->setQuery($query);
$this->_db->execute();
}
}
if ($method == 3) {
$this->moveitem($row->id, $maincat, $seccats);
} else {
if ($method == 99 && ($maincat || $seccats)) {
$row->catid = $maincat ? $maincat : $row->catid;
$this->moveitem($row->id, $row->catid, $seccats);
}
}
// Load item model and save it once, e.g. updating Joomla featured FLAG data
//$itemmodel = new FlexicontentModelItem();
//$itemmodel->getItem($row->id);
//$itemmodel->store((array)$row);
// If new item is a tranlation, load the language associations of item
// that was copied, and save the associations, adding the new item to them
if ($method == 99 && $item->language != '*' && $row->language != '*' && flexicontent_db::useAssociations()) {
$associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $item->id);
// associations of item that was copied
$_data = array();
foreach ($associations as $tag => $association) {
$_data['associations'][$tag] = (int) $association->id;
}
$_data['associations'][$row->language] = $row->id;
// Add new item itself
$_data['associations'][$item->language] = $item->id;
// unneeded, done by saving ...
$context = 'com_content';
flexicontent_db::saveAssociations($row, $_data, $context);
// Save associations, adding the new item
//$app->enqueueMessage( print_r($_data, true), 'message' );
}
}
}
return true;
}