本文整理汇总了PHP中FabrikWorker::getDbo方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::getDbo方法的具体用法?PHP FabrikWorker::getDbo怎么用?PHP FabrikWorker::getDbo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::getDbo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* validate the elements data against the rule
* @param string data to check
* @param object element
* @param int plugin sequence ref
* @return bol true if validation passes, false if fails
*/
function validate($data, &$element, $c)
{
if (empty($data)) {
return false;
}
$params = $this->getParams();
//as ornot is a radio button it gets json encoded/decoded as an object
$ornot = (object) $params->get('emailexists_or_not');
$ornot = isset($ornot->{$c}) ? $ornot->{$c} : 'fail_if_exists';
jimport('joomla.user.helper');
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('id')->from('#__users')->where('email = ' . $db->quote($data));
$db->setQuery($query);
$result = $db->loadResult();
if (!$result) {
if ($ornot == 'fail_if_exists') {
return true;
}
} else {
if ($ornot == 'fail_if_not_exists') {
return true;
}
}
return false;
}
示例2: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*/
protected function getOptions()
{
$connectionDd = $this->element['observe'];
$connectionName = 'connection_id';
$connId = (int) $this->form->getValue($connectionName);
$options = array();
$db = FabrikWorker::getDbo(true);
// DB join element observes 'params___join_conn_id'
if (strstr($connectionDd, 'params_') && $connId === 0) {
$connectionName = str_replace('params_', 'params.', $connectionDd);
$connId = (int) $this->form->getValue($connectionName);
}
if ($connectionDd == '') {
// We are not monitoring a connection drop down so load in all tables
$query = "SHOW TABLES";
$db->setQuery($query);
$items = $db->loadColumn();
$options[] = JHTML::_('select.option', null, null);
foreach ($items as $l) {
$options[] = JHTML::_('select.option', $l, $l);
}
} else {
// Delay for the connection to trigger an update via js.
}
return $options;
}
示例3: display
/**
* Display the view
*/
function display()
{
$document = JFactory::getDocument();
$viewName = JRequest::getVar('view', 'package', 'default', 'cmd');
$viewType = $document->getType();
// Set the default view name from the Request
$view = $this->getView($viewName, $viewType);
//if the view is a package create and assign the table and form views
$tableView = $this->getView('list', $viewType);
$listModel = $this->getModel('list', 'FabrikFEModel');
$tableView->setModel($listModel, true);
$view->_tableView = $tableView;
$view->_formView =& $this->getView('Form', $viewType);
$formModel = $this->getModel('Form', 'FabrikFEModel');
$formModel->setDbo(FabrikWorker::getDbo());
$view->_formView->setModel($formModel, true);
// Push a model into the view
$model = $this->getModel($viewName, 'FabrikFEModel');
$model->setDbo(FabrikWorker::getDbo());
if (!JError::isError($model)) {
$view->setModel($model, true);
}
// Display the view
$view->assign('error', $this->getError());
$view->display();
}
示例4: doCron
function doCron(&$pluginManager)
{
$db = FabrikWorker::getDbo();
$cid = JRequest::getVar('element_id', array(), 'method', 'array');
$query = $db->getQuery();
$query->select('id, plugin')->from('#__{package}_cron');
if (!empty($cid)) {
$query->where(" id IN (" . implode(',', $cid).")");
}
$db->setQuery($query);
$rows = $db->loadObjectList();
$viewModel = JModel::getInstance('view', 'FabrikFEModel');
$c = 0;
foreach ($rows as $row) {
//load in the plugin
$plugin = $pluginManager->getPlugIn($row->plugin, 'cron');
$plugin->setId($row->id);
$params = $plugin->getParams();
$thisViewModel = clone($viewModel);
$thisViewModel->setId($params->get('table'));
$table = $viewModel->getTable();
$total = $thisViewModel->getTotalRecords();
$nav = $thisViewModel->getPagination($total, 0, $total);
$data = $thisViewModel->getData();
// $$$ hugh - added table model param, in case plugin wants to do further table processing
$c = $c + $plugin->process($data, $thisViewModel);
}
$query = $db->getQuery();
$query->update('#__{package}_cron')->set('lastrun=NOW()')->where("id IN (".implode(',', $cid).")");
$db->setQuery($query);
$db->query();
}
示例5: getGroups
/**
* Method to get the list of groups and elements
* grouped by group and element.
*
* @return array The field option objects as a nested array in groups.
*/
protected function getGroups()
{
$app = JFactory::getApplication();
$input = $app->input;
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('form_id')->from($db->quoteName('#__{package}_formgroup') . ' AS fg')->join('LEFT', '#__{package}_elements AS e ON e.group_id = fg.group_id')->where('e.id = ' . $input->getInt('elementid'));
$db->setQuery($query);
$formId = $db->loadResult();
$formModel = JModelLegacy::getInstance('Form', 'FabrikFEModel');
$formModel->setId($formId);
$rows = array();
$rows[FText::_('COM_FABRIK_GROUPS')] = array();
$rows[FText::_('COM_FABRIK_ELEMENTS')] = array();
// Get available element types
$groups = $formModel->getGroupsHiarachy();
foreach ($groups as $groupModel) {
$group = $groupModel->getGroup();
$label = $group->name;
$value = 'fabrik_trigger_group_group' . $group->id;
$rows[FText::_('COM_FABRIK_GROUPS')][] = JHTML::_('select.option', $value, $label);
$elementModels = $groupModel->getMyElements();
foreach ($elementModels as $elementModel) {
$label = $elementModel->getFullName(false, false);
$value = 'fabrik_trigger_element_' . $elementModel->getFullName(true, false);
$rows[FText::_('COM_FABRIK_ELEMENTS')][] = JHTML::_('select.option', $value, $label);
}
}
reset($rows);
asort($rows[FText::_('COM_FABRIK_ELEMENTS')]);
return $rows;
}
示例6: validate
/**
* validate the elements data against the rule
* @param string data to check
* @param object element
* @param int plugin sequence ref
* @return bol true if validation passes, false if fails
*/
function validate($data, &$element, $c)
{
if (empty($data)) {
return false;
}
$params =& $this->getParams();
$ornot = $params->get('emailexists_or_not');
$ornot = $ornot[$c];
$condition = $params->get('emailexists-validation_condition');
$condition = $condition[$c];
if ($condition !== '') {
if (@eval($condition)) {
return true;
}
}
jimport('joomla.user.helper');
$db = FabrikWorker::getDbo();
$db->setQuery("SELECT id FROM #__users WHERE email = '{$data}'");
$result = $db->loadResult();
if (!$result) {
if ($ornot == 'fail_if_exists') {
return true;
}
} else {
if ($ornot == 'fail_if_not_exists') {
return true;
}
}
return false;
}
示例7: getOptions
function getOptions()
{
// Initialize variables.
$options = array();
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('f.id AS value, f.label AS text, l.id AS listid');
$query->from('#__fabrik_forms AS f');
$query->join('LEFT', '#__fabrik_lists As l ON f.id = l.form_id');
$query->where('f.published = 1 AND l.db_table_name =' . $db->Quote($this->form->getValue('params.join_db_name')));
$query->order('f.label');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList('value');
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
if (empty($options)) {
$options[] = JHTML::_('select.option', '', JText::_('COM_FABRIK_NO_POPUP_FORMS_AVAILABLE'));
} else {
array_unshift($options, JHtml::_('select.option', '', JText::_('COM_FABRIK_PLEASE_SELECT')));
}
return $options;
}
示例8: dolist
/**
* list of items
*
* @return null
*/
public function dolist()
{
$app = JFactory::getApplication();
$input = $app->input;
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$list = $input->get('list', 'form');
$selected = $input->get('selected');
$query->select('id, label')->from('#__fabrik_' . $list . 's');
if ($selected != '') {
// $query->where('id NOT IN ('.$selected.')');
}
$db->setQuery($query);
$rows = $db->loadObjectList();
echo "<ul id=\"{$list}-additems\">";
if (empty($rows)) {
echo "<li>" . JText::sprintf('COM_FABRIK_NO_FREE_ITEMS_FOUND') . "</li>";
} else {
foreach ($rows as $row) {
echo "<li><a href=\"#\" id=\"{$row->id}\">{$row->label}</a>";
}
}
echo "</ul>";
$script = "\$('{$list}-additems').getElements('a').addEvent('click', function(e){\n\t\t\tFabrik.fireEvent('fabrik.package.item.selected', [e]);\n\t\t});";
FabrikHelperHTML::addScriptDeclaration($script);
}
示例9: display
/**
* Display the package view
*
* @param boolean $cachable If true, the view output will be cached - NOTE not actually used to control caching!!!
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController A JController object to support chaining.
*/
public function display($cachable = false, $urlparams = false)
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$input = $app->input;
$viewName = $input->get('view', 'package');
$viewType = $document->getType();
// Set the default view name from the Request
$view = $this->getView($viewName, $viewType);
// If the view is a package create and assign the table and form views
$tableView = $this->getView('list', $viewType);
$listModel = $this->getModel('list', 'FabrikFEModel');
$tableView->setModel($listModel, true);
$view->tableView = $tableView;
$view->formView = $this->getView('Form', $viewType);
$formModel = $this->getModel('Form', 'FabrikFEModel');
$formModel->setDbo(FabrikWorker::getDbo());
$view->formView->setModel($formModel, true);
// Push a model into the view
if ($model = $this->getModel($viewName, 'FabrikFEModel')) {
$model->setDbo(FabrikWorker::getDbo());
$view->setModel($model, true);
}
// Display the view
$view->error = $this->getError();
$view->display();
return $this;
}
示例10: getOptions
function getOptions()
{
$connectionDd = $this->element['observe'];
$options = array();
$db = FabrikWorker::getDbo(true);
if ($connectionDd == '') {
//we are not monitoring a connection drop down so load in all tables
$query = "SHOW TABLES";
$db->setQuery($query);
$items = $db->loadResultArray();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
foreach ($items as $l) {
$options[] = JHTML::_('select.option', $l, $l);
}
} else {
$connId = $this->form->getValue('connection_id');
$query = $db->getQuery(true);
$query->select('id AS value, db_table_name AS ' . $db->Quote('text'))->from('#__{package}_lists')->where('connection_id = ' . (int) $connId);
$db->setQuery($query);
$items = $db->loadObjectList();
foreach ($items as $item) {
$options[] = JHTML::_('select.option', $item->value, $item->text);
}
}
return $options;
}
示例11: getOptions
function getOptions()
{
$db = FabrikWorker::getDbo();
$check = $this->element['checkexists'] ? (bool) $this->element['checkexists'] : false;
if ($check) {
$q = explode(" ", $this->element['query']);
$i = array_search('FROM', $q);
if (!$i) {
$i = array_search('from', $q);
}
$i++;
$tbl = $db->replacePrefix($q[$i]);
$db->setQuery("SHOW TABLES");
$rows = $db->loadResultArray();
$found = in_array($tbl, $rows) ? true : false;
if (!$found) {
return array(JHTML::_('select.option', $tbl . ' not found', ''));
}
}
$db->setQuery($this->element['query']);
$key = $this->element['key_field'] ? $this->element['key_field'] : 'value';
$val = $this->element['value_field'] ? $this->element['value_field'] : $this->name;
if ($this->element['add_select']) {
$rows = array(JHTML::_('select.option', ''));
$rows = array_merge($rows, (array) $db->loadObjectList());
} else {
$rows = $db->loadObjectList();
}
return $rows;
}
示例12: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
$app = JFactory::getApplication();
$input = $app->input;
$option = $input->get('option');
if (!in_array($option, array('com_modules', 'com_menus', 'com_advancedmodules'))) {
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('form_id')->from('#__{package}_formgroup')->where('group_id = ' . (int) $this->form->getValue('id'));
$db->setQuery($query);
$this->value = $db->loadResult();
$this->form->setValue('form', null, $this->value);
}
if ((int) $this->form->getValue('id') == 0 || !$this->element['readonlyonedit']) {
return parent::getInput();
} else {
$options = (array) $this->getOptions();
$v = '';
foreach ($options as $opt) {
if ($opt->value == $this->value) {
$v = $opt->text;
}
}
}
return '<input type="hidden" value="' . $this->value . '" name="' . $this->name . '" />' . '<input type="text" value="' . $v . '" name="form_justalabel" class="readonly" readonly="true" />';
}
示例13: onBeforeStore
/**
* process the plugin, called when form is submitted
*
* @param object $params
* @param object form
*/
function onBeforeStore( &$params, &$formModel )
{
global $vbulletin;
define(VB_AREA, 'fabrik');
define(THIS_SCRIPT, 'fabrik');
// Initialize some variables
$db = FabrikWorker::getDbo();
$data = $formModel->_formData;
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$elementModel = $formModel->getPluginManager()->getElementPlugin($params->get('vb_forum_field'));
$element = $elementModel->getElement(true);
$this->map_forum_field = $elementModel->getFullName();
$this->vb_parent_forum = $params->get('vb_parent', '');
$method = "POST";
$url = JURI::base(). "forum/mkforum.php";
$vars = array();
$vars['forum_name'] = $data[$this->map_forum_field];
$vars['forum_parent'] = $this->vb_parent_forum;
$res = $this->doRequest($method, $url, $vars);
}
示例14: setFieldSets
/**
* Set which fieldsets should be used
*
* @since 3.0.7
*
* @return array fieldset names
*/
private function setFieldSets()
{
$input = $this->app->input;
// From list data view in admin
$id = $input->getInt('listid', 0);
// From list of lists checkbox selection
$cid = $input->get('cid', array(0), 'array');
$cid = ArrayHelper::toInteger($cid);
if ($id === 0) {
$id = $cid[0];
}
if ($id !== 0) {
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('label')->from('#__{package}_lists')->where('id = ' . $id);
$db->setQuery($query);
$this->listName = $db->loadResult();
}
$fieldsets = array('details');
if ($this->model->canEmpty()) {
$fieldsets[] = 'drop';
}
$fieldsets[] = $id === 0 ? 'creation' : 'append';
$fieldsets[] = 'format';
return $fieldsets;
}
示例15: createList
protected function createList($listModel, $adminListModel)
{
$params = $this->getParams();
$table = $params->get('create_list');
if ($table == '') {
return;
}
$db = FabrikWorker::getDbo();
//see if we have a list that already points to the table
$query = $db->getQuery(true);
$query->select('id')->from('jos_{package}_lists')->where('db_table_name = ' . $db->nameQuote($table));
$db->setQuery($query);
$res = (int) $db->loadResult();
$now = JFactory::getDate()->toMySQL();
$user = JFactory::getUser();
$data = array();
//fill in some default data
$data['filter_action'] = 'onchange';
$data['access'] = 1;
$data['id'] = $res;
$data['label'] = $table;
$data['connection_id'] = 1;
$data['db_table_name'] = $table;
$data['published'] = 1;
$data['created'] = $now;
$data['created_by'] = $user->get('id');
JRequest::setVar('jform', $data);
$adminListModel->save($data);
}