本文整理汇总了PHP中plgFabrik_Element::copyRow方法的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element::copyRow方法的具体用法?PHP plgFabrik_Element::copyRow怎么用?PHP plgFabrik_Element::copyRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plgFabrik_Element
的用法示例。
在下文中一共展示了plgFabrik_Element::copyRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createLinkedElements
/**
* When saving a table that links to a database for the first time we
* need to create all the elements based on the database table fields and their
* column type
*
* @param int $groupId group id
*
* @return void
*/
private function createLinkedElements($groupId)
{
$db = FabrikWorker::getDbo(true);
$user = JFactory::getUser();
$config = JFactory::getConfig();
$createdate = JFactory::getDate();
$createdate = $createdate->toSql();
$post = JRequest::get('post');
$tableName = $post['jform']['db_table_name'];
$formModel = $this->getFormModel();
$pluginManager = FabrikWorker::getPluginManager();
$ordering = 0;
$fabrikDb = $this->getFEModel()->getDb();
$groupTable = FabTable::getInstance('Group', 'FabrikTable');
$groupTable->load($groupId);
// Here we're importing directly from the database schema
$query = $db->getQuery(true);
$query->select('id')->from('#__{package}_lists')->where('db_table_name = ' . $db->quote($tableName));
$db->setQuery($query);
$id = $db->loadResult();
$dispatcher = JDispatcher::getInstance();
$elementModel = new plgFabrik_Element($dispatcher);
if ($id) {
// A fabrik table already exists - so we can copy the formatting of its elements
$groupListModel = JModel::getInstance('list', 'FabrikFEModel');
$groupListModel->setId($id);
$groupListModel->getTable();
$groups = $groupListModel->getFormGroupElementData();
$newElements = array();
$ecount = 0;
foreach ($groups as $groupModel) {
/**
* If we are saving a new table and the previously found tables group is a join
* then don't add its elements to the table as they don't exist in the database table
* we are linking to
* $$$ hugh - why the test for task and new table? When creating elements for a copy of a table,
* surely we NEVER want to include elements which were joined to the original,
* regardless of whether this is a new List? Bearing in mind that this routine gets called from
* the makeNewJoin() method, when adding a join to an existing list, to build the "Foo - [bar]" join
* group, as well as from save() when creating a new List.
*
* if ($groupModel->isJoin() && JRequest::getCmd('task') == 'save' && JRequest::getInt('id') == 0)
*/
if ($groupModel->isJoin()) {
continue;
}
$elementModels =& $groupModel->getMyElements();
foreach ($elementModels as $elementModel) {
$ecount++;
$element = $elementModel->getElement();
$copy = $elementModel->copyRow($element->id, $element->label, $groupId);
if (!Jerror::isError($copy)) {
$newElements[$element->id] = $copy->id;
}
}
}
foreach ($newElements as $origId => $newId) {
$plugin = $pluginManager->getElementPlugin($newId);
$plugin->finalCopyCheck($newElements);
}
// Hmm table with no elements - lets create them from the structure anyway
if ($ecount == 0) {
$this->makeElementsFromFields($groupId, $tableName);
}
} else {
// No previously found fabrik list
$this->makeElementsFromFields($groupId, $tableName);
}
}
示例2: createLinkedElements
/**
* when saving a table that links to a database for the first time we
* need to create all the elements based on the database table fields and their
* column type
*
* @access private
* @param int group id
* @param (deprecicated can't see that we use this) array of element objects - if this is not empty then we've come from the csv import and the elements
* have already been defined, use this instead of the field analysis to create correctly typed elements
*/
private function createLinkedElements($groupId, $aSpecificElements = array())
{
$db = FabrikWorker::getDbo(true);
$user = JFactory::getUser();
$config = JFactory::getConfig();
$createdate = JFactory::getDate();
$createdate = $createdate->toMySQL();
$post = JRequest::get('post');
$tableName = $post['jform']['db_table_name'];
$formModel = $this->getFormModel();
$pluginManager = $formModel->getPluginManager();
$ordering = 0;
$fabrikDb =& $this->getFEModel()->getDb();
$groupTable = FabTable::getInstance('Group', 'FabrikTable');
$groupTable->load($groupId);
/*if (!empty($aSpecificElements)) {
//we're asking the method to create predefined elements - e.g. when installing sample data.
foreach ($aSpecificElements as $elementModel) {
$element =& $elementModel->getElement();
if ($element->label == 'id') {
$element->hidden = 1;
$element->primary_key = 1;
$element->auto_increment = 1;
} else {
$element->hidden = 0;
}
$element->name = strtolower(str_replace(' ', '', $element->name));
$element->group_id = $groupId;
$element->created = $createdate;
$element->created_by = $user->get('id');
$element->created_by_alias = $user->get('username');
$element->published = 1;
$element->show_in_list_summary = 1;
$element->width = 30;
$element->height = 6;
$element->ordering = 99999;
$element->params = $elementModel->getDefaultAttribs();
$element->store();
$where = " group_id = '" . $element->group_id . "'";
$element->reorder($where);
}
} else {*/
//here we're importing directly from the database schema
$query = $db->getQuery(true);
$query->select('id')->from('#__{package}_lists')->where('db_table_name = ' . $db->Quote($tableName));
$db->setQuery($query);
$id = $db->loadResult();
$dispatcher = JDispatcher::getInstance();
$elementModel = new plgFabrik_Element($dispatcher);
if ($id) {
//a fabrik table already exists - so we can copy the formatting of its elements
$groupTableModel = JModel::getInstance('list', 'FabrikFEModel');
$groupTableModel->setId($id);
$table = $groupTableModel->getTable();
//$this->formModel = null; //reset form so that it loads new table form
$groups = $groupTableModel->getFormGroupElementData();
$newElements = array();
$ecount = 0;
foreach ($groups as $groupModel) {
// if we are saving a new table and the previously found tables group is a join
// then don't add its elements to the table as they don't exist in the database table
// we are linking to
if ($groupModel->isJoin() && JRequest::getCmd('task') == 'save' && JRequest::getInt('id') == 0) {
continue;
}
$elementModels =& $groupModel->getMyElements();
foreach ($elementModels as $elementModel) {
$ecount++;
$element = $elementModel->getElement();
$copy = $elementModel->copyRow($element->id, '', $groupId);
$newElements[$element->id] = $copy->id;
}
}
foreach ($newElements as $origId => $newId) {
$plugin = $pluginManager->getElementPlugin($newId);
$plugin->finalCopyCheck($newElements);
}
// hmm table with no elements - lets create them from the structure anyway
if ($ecount == 0) {
$this->makeElementsFromFields($groupId, $tableName);
}
} else {
//no previously found fabrik list
$this->makeElementsFromFields($groupId, $tableName);
}
// }
}
示例3: createLinkedElements
/**
* when saving a table that links to a database for the first time we
* need to create all the elements based on the database table fields and their
* column type
*
* @access private
* @param int group id
*/
private function createLinkedElements($groupId)
{
$db = FabrikWorker::getDbo(true);
$user = JFactory::getUser();
$config = JFactory::getConfig();
$createdate = JFactory::getDate();
$createdate = $createdate->toMySQL();
$post = JRequest::get('post');
$tableName = $post['jform']['db_table_name'];
$formModel = $this->getFormModel();
$pluginManager = FabrikWorker::getPluginManager();
$ordering = 0;
$fabrikDb = $this->getFEModel()->getDb();
$groupTable = FabTable::getInstance('Group', 'FabrikTable');
$groupTable->load($groupId);
//here we're importing directly from the database schema
$query = $db->getQuery(true);
$query->select('id')->from('#__{package}_lists')->where('db_table_name = ' . $db->Quote($tableName));
$db->setQuery($query);
$id = $db->loadResult();
$dispatcher = JDispatcher::getInstance();
$elementModel = new plgFabrik_Element($dispatcher);
if ($id) {
//a fabrik table already exists - so we can copy the formatting of its elements
$groupListModel = JModel::getInstance('list', 'FabrikFEModel');
$groupListModel->setId($id);
$groupListModel->getTable();
//$this->formModel = null; //reset form so that it loads new table form
$groups = $groupListModel->getFormGroupElementData();
$newElements = array();
$ecount = 0;
foreach ($groups as $groupModel) {
// if we are saving a new table and the previously found tables group is a join
// then don't add its elements to the table as they don't exist in the database table
// we are linking to
if ($groupModel->isJoin() && JRequest::getCmd('task') == 'save' && JRequest::getInt('id') == 0) {
continue;
}
$elementModels =& $groupModel->getMyElements();
foreach ($elementModels as $elementModel) {
$ecount++;
$element = $elementModel->getElement();
$copy = $elementModel->copyRow($element->id, $element->label, $groupId);
if (!Jerror::isError($copy)) {
$newElements[$element->id] = $copy->id;
}
}
}
foreach ($newElements as $origId => $newId) {
$plugin = $pluginManager->getElementPlugin($newId);
$plugin->finalCopyCheck($newElements);
}
// hmm table with no elements - lets create them from the structure anyway
if ($ecount == 0) {
$this->makeElementsFromFields($groupId, $tableName);
}
} else {
//no previously found fabrik list
$this->makeElementsFromFields($groupId, $tableName);
}
}