本文整理汇总了PHP中JFactory::getDbo方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getDbo方法的具体用法?PHP JFactory::getDbo怎么用?PHP JFactory::getDbo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::getDbo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
protected function getInput()
{
$html = '';
$db = JFactory::getDbo();
$options = JUDownloadHelper::getFieldGroupOptions();
if ($this->element['usenone'] == 'true') {
array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
}
if ($this->element['useinherit'] == 'true') {
$appendInherit = "";
if ($this->form->getValue("id")) {
$appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
if ($this->form->getValue("id") > 0) {
$catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
if ($catObj->fieldgroup_id > 1) {
$query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
$db->setQuery($query);
$fieldgroup = $db->loadObject();
$groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
$appendInherit = "( " . $groupName . " )";
}
}
}
array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
} else {
array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
}
$required_class = $this->element['required'] == 'true' ? 'required' : '';
$attributes = "class=\"inputbox {$required_class}\"";
$html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
return $html;
}
示例2: display
/**
* sauto view display method.
*
* @param string $tpl The name of the template file to parse;
*
* @return void
*/
public function display($tpl = null)
{
$app =& JFactory::getApplication();
$link_redirect = JRoute::_('index.php?option=com_sauto');
$user =& JFactory::getUser();
$uid = $user->id;
if ($uid == 0) {
//vizitator
$app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
} else {
$db = JFactory::getDbo();
$query = "SELECT `tip_cont` FROM #__sa_profiles WHERE `uid` = '" . $uid . "'";
$db->setQuery($query);
$type = $db->loadResult();
if ($type == 0) {
//cont customer
$tpl = '0';
} elseif ($type == 1) {
//cont dealer
$tpl = '1';
} else {
$app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
}
parent::display($tpl);
}
}
示例3: display
function display($tpl = null)
{
JToolBarHelper::title(JText::_('COM_REDSOCIALSTREAM_CONFIGURE'), 'configure.png');
JToolBarHelper::apply();
JToolBarHelper::cancel('cancel', 'COM_REDSOCIALSTREAM_CLOSE');
//DEVNOTE: set document title
$document = JFactory::getDocument();
$document->setTitle(JText::_('COM_REDSOCIALSTREAM_REDSOCIALSTREAMS'));
$mainframe = JFactory::getApplication();
$context = "config";
$model = $this->getModel('configure');
$db = JFactory::getDbo();
$q = "SELECT * FROM #__redsocialstream_settings";
$db->setQuery($q);
$this->settingsrows = $db->loadObjectList();
$typelist = $this->get('type_list_sorted');
$pagination = $this->get('Pagination');
//DEVNOTE:give me ordering from request
$filter_order = $mainframe->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'ordering');
$filter_order_Dir = $mainframe->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '');
$this->assignRef('lists', $lists);
$this->assignRef("typelist", $typelist);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
示例4: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->state != -2) {
return false;
}
$user = JFactory::getUser();
$permissions = SibdietHelper::getUserPermissions();
// Check that user have access permission to data banks and can delete
if (in_array('contags', $permissions)) {
// Check that tag not used in diets controller
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_setdiets AS s')->where("FIND_IN_SET('" . $record->id . "', s.tags)");
$db->setQuery($query);
try {
$used = $db->loadColumn();
} catch (Exception $e) {
// catch any database errors.
}
if (count($used)) {
// echo that item is used
$this->setError(JText::sprintf('COM_SIBDIET_ERR_CONTAG_USED', $record->title . ' (' . implode(' - ', $used) . ')'));
return;
}
return $user->authorise('core.delete', 'com_sibdiet');
}
}
return false;
}
示例5: getExtensionId
/**
* Get current plugin id in the #__extensions table
*
* @return integer The plugin / extension id
*/
protected function getExtensionId()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('folder') . ' = ' . $db->q($this->_type))->where($db->qn('element') . ' = ' . $db->q($this->_name));
$db->setQuery($query);
return $db->loadResult();
}
示例6: load
/**
* Loads the entire menu table into memory.
*
* @return boolean True on success, false on failure
*
* @since 1.5
*/
public function load()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')->select('e.element as component')->from('#__menu AS m')->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')->where('m.published = 1')->where('m.parent_id > 0')->where('m.client_id = 0')->order('m.lft');
// Set the query
$db->setQuery($query);
try {
$this->_items = $db->loadObjectList('id');
} catch (RuntimeException $e) {
JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage()));
return false;
}
foreach ($this->_items as &$item) {
// Get parent information.
$parent_tree = array();
if (isset($this->_items[$item->parent_id])) {
$parent_tree = $this->_items[$item->parent_id]->tree;
}
// Create tree.
$parent_tree[] = $item->id;
$item->tree = $parent_tree;
// Create the query array.
$url = str_replace('index.php?', '', $item->link);
$url = str_replace('&', '&', $url);
parse_str($url, $item->query);
}
return true;
}
示例7: getObjectOwner
function getObjectOwner($id)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT dmsubmitedby FROM #__docman WHERE id = ' . $id);
$userid = $db->loadResult();
return $userid;
}
示例8: display
public function display($tpl = null)
{
// Initialise variables
$this->state = $this->get("State");
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Get params
$this->params = $this->state->get("params");
/** @var $this->params Joomla\Registry\Registry */
$this->numberInRow = $this->params->get("items_row", 3);
$this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow);
// Get the folder with images
$this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
$this->displayCreator = $this->params->get("integration_display_creator", true);
// Prepare social integration.
if (!empty($this->displayCreator)) {
$socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "users_ids" => CrowdfundingHelper::fetchUserIds($this->items)));
$socialProfilesBuilder->build();
$this->socialProfiles = $socialProfilesBuilder->getProfiles();
}
$this->layoutData = array("items" => $this->items, "params" => $this->params, "amount" => $this->amount, "socialProfiles" => $this->socialProfiles, "imageFolder" => $this->imageFolder, "titleLength" => $this->params->get("discover_title_length", 0), "descriptionLength" => $this->params->get("discover_description_length", 0), "span" => !empty($this->numberInRow) ? round(12 / $this->numberInRow) : 4);
$this->prepareDocument();
parent::display($tpl);
}
示例9: display
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $this->state->get("params");
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->state->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
// Get rewards number
$usersIds = array();
foreach ($this->items as $item) {
$usersIds[] = $item->id;
}
// Get number of rewards.
$statistics = new Crowdfunding\Statistics\Users(JFactory::getDbo(), $usersIds);
$this->projects = $statistics->getProjectsNumber();
$this->amounts = $statistics->getAmounts();
// Add submenu
CrowdfundingHelper::addSubmenu($this->getName());
// Prepare sorting data
$this->prepareSorting();
// Prepare actions
$this->addToolbar();
$this->addSidebar();
$this->setDocument();
parent::display($tpl);
}
示例10: getOptions
/**
* Method to get a list of content types
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$lang = JFactory::getLanguage();
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('a.type_id AS value, a.type_title AS text, a.type_alias AS alias')->from('#__content_types AS a')->order('a.type_title ASC');
// Get the options.
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
return false;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
foreach ($options as $option) {
// Make up the string from the component sys.ini file
$parts = explode('.', $option->alias);
$comp = array_shift($parts);
// Make sure the component sys.ini is loaded
$lang->load($comp . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($comp . '.sys', JPATH_ADMINISTRATOR . '/components/' . $comp, null, false, true);
$option->string = implode('_', $parts);
$option->string = $comp . '_CONTENT_TYPE_' . $option->string;
if ($lang->hasKey($option->string)) {
$option->text = JText::_($option->string);
}
}
return $options;
}
示例11: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->state != -2) {
return;
}
$user = JFactory::getUser();
// Check that user have access permission to data banks and can delete
if ($user->authorise('core.delete', $this->option)) {
// Check that desease not used in these tables
$tables = array('defaults', 'setdiets');
$db = JFactory::getDbo();
foreach ($tables as $table) {
$query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_' . $table . ' AS s')->where("FIND_IN_SET('" . $record->id . "', s.goals)");
$db->setQuery($query);
try {
$used = $db->loadColumn();
} catch (Exception $e) {
// catch any database errors.
}
if (count($used)) {
// echo that item is used
$this->setError(JText::sprintf('COM_SIBDIET_ERR_GOAL_USED', $record->title . ' (' . JText::_('COM_SIBDIET_SUBMENU_' . $table) . ': ' . implode(' - ', $used) . ')'));
return;
}
}
return true;
}
return;
}
}
示例12: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
public function getOptions()
{
// Initialize variables.
$options = array();
/*
* SQL query:
*
* SELECT DISTINCT (school) AS value, school AS text
* FROM #__osbitusers
* ORDER BY school
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('DISTINCT (school) AS value, school AS text');
$query->from('#__osbitusers');
$query->order('school');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
return $options;
}
示例13: loadPluginLanguage
/**
* Method to load Smart Search plug-in language files.
*
* @return void
*
* @since 2.5
*/
public static function loadPluginLanguage()
{
static $loaded = false;
// If already loaded, don't load again.
if ($loaded) {
return;
}
$loaded = true;
// Get array of all the enabled Smart Search plug-in names.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('name');
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$query->where($db->quoteName('folder') . ' = ' . $db->quote('finder'));
$query->where($db->quoteName('enabled') . ' = 1');
$db->setQuery($query);
$plugins = $db->loadObjectList();
if (empty($plugins)) {
return;
}
// Load generic language strings.
$lang = JFactory::getLanguage();
$lang->load('plg_content_finder', JPATH_ADMINISTRATOR);
// Load language file for each plug-in.
foreach ($plugins as $plugin) {
$lang->load($plugin->name, JPATH_ADMINISTRATOR);
}
}
示例14: onContentSearch
/**
* Search content (articles).
* The SQL must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav.
*
* @param string $text Target search string.
* @param string $phrase Matching option (possible values: exact|any|all). Default is "any".
* @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest".
* @param mixed $areas An array if the search it to be restricted to areas or null to search all areas.
*
* @return array Search results.
*
* @since 1.6
*/
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db = JFactory::getDbo();
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$limit = $this->params->def('search_limit', 50);
$text = trim($text);
if ($text == '') {
return array();
}
$rows = array();
//Search Contents.
if ($limit > 0) {
switch ($phrase) {
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.vocabulary LIKE ' . $text;
$wheres2[] = 'vocab_subject.subject LIKE ' . $text;
$wheres2[] = 'vocab_category.category LIKE ' . $text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.vocabulary LIKE ' . $word;
$wheres2[] = 'vocab_subject.subject LIKE ' . $word;
$wheres2[] = 'vocab_category.category LIKE ' . $word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
break;
}
switch ($ordering) {
default:
$order = 'a.id DESC';
break;
}
$query = $db->getQuery(true);
$query->clear()->select(array('a.id', 'a.vocabulary AS title', '"" AS created', 'a.vocabulary AS text', '"Content" AS section', '1 AS browsernav'))->from('#__vocab_content AS a')->innerJoin('`#__vocab_subject` AS vocab_subject ON vocab_subject.id = a.subject')->innerJoin('`#__vocab_category` AS vocab_category ON vocab_category.id = a.category')->where('(' . $where . ')')->group('a.id')->order($order);
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list)) {
foreach ($list as $key => $item) {
$list[$key]->href = JRoute::_('index.php?option=com_vocab&view=content&id=' . $item->id, false, 2);
}
}
$rows = array_merge($list, $rows);
}
return $rows;
}
示例15: getList
/**
* Get a list of logged users.
*
* @param JObject The module parameters.
* @return mixed An array of articles, or false on error.
*/
public static function getList($params)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true);
$query->select('s.time, s.client_id, u.id, u.name, u.username');
$query->from('#__session AS s');
$query->leftJoin('#__users AS u ON s.userid = u.id');
$query->where('s.guest = 0');
$db->setQuery($query, 0, $params->get('count', 5));
try {
$results = $db->loadObjectList();
} catch (RuntimeException $e) {
JError::raiseError(500, $e->getMessage());
return false;
}
foreach ($results as $k => $result) {
$results[$k]->logoutLink = '';
if ($user->authorise('core.manage', 'com_users')) {
$results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
$results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JSession::getFormToken() . '=1');
}
if ($params->get('name', 1) == 0) {
$results[$k]->name = $results[$k]->username;
}
}
return $results;
}