本文整理汇总了PHP中JTable::addIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::addIncludePath方法的具体用法?PHP JTable::addIncludePath怎么用?PHP JTable::addIncludePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::addIncludePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTheme
public function setTheme($theme, $style)
{
if ($style) {
\JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables');
$table = \JTable::getInstance('Style', 'TemplatesTable');
$table->load(['id' => $style, 'client_id' => 0]);
$theme = $table->template;
}
if (!$theme) {
$theme = StyleHelper::getDefaultStyle()->template;
}
$path = JPATH_SITE . '/templates/' . $theme;
if (!is_file("{$path}/gantry/theme.yaml")) {
$theme = null;
$this->container['streams']->register();
/** @var UniformResourceLocator $locator */
$locator = $this->container['locator'];
$this->container['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true);
}
$this->container['base_url'] = \JUri::base(true) . '/index.php?option=com_gantry5';
$this->container['ajax_suffix'] = '&format=json';
$token = \JSession::getFormToken();
$this->container['routes'] = ['1' => "&view=%s&theme={$theme}&{$token}=1", 'themes' => '&view=themes', 'picker/layouts' => "&view=layouts&theme={$theme}&{$token}=1"];
if (!$theme) {
return $this;
}
$this->container['theme.path'] = $path;
$this->container['theme.name'] = $theme;
// Load language file for the template.
$languageFile = 'tpl_' . $theme;
$lang = \JFactory::getLanguage();
$lang->load($languageFile, JPATH_SITE) || $lang->load($languageFile, $path) || $lang->load($languageFile, $path, 'en-GB');
return $this;
}
示例2: createCustomField
function createCustomField($what)
{
// Load the JTable Object.
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'tables');
$row = JTable::getInstance('profiles', 'CommunityTable');
$row->load(0);
switch ($what) {
case PROFILETYPE_CUSTOM_FIELD_CODE:
$data['type'] = PROFILETYPE_FIELD_TYPE_NAME;
$data['name'] = 'Profiletype';
$data['tips'] = 'Profiletype Of User';
break;
case TEMPLATE_CUSTOM_FIELD_CODE:
$data['type'] = TEMPLATE_FIELD_TYPE_NAME;
$data['name'] = 'Template';
$data['tips'] = 'Template Of User';
break;
default:
XiptError::assert(0);
break;
}
$data['published'] = 1;
$data['fieldcode'] = $what;
return $row->bind($data) && $row->store();
}
示例3: ThemeFlow
function ThemeFlow()
{
$pathModelShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'models';
$pathTableShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'tables';
JModelLegacy::addIncludePath($pathModelShowcaseTheme);
JTable::addIncludePath($pathTableShowcaseTheme);
}
示例4: getAutoInstance
/**
* Get a model instance.
*
* @param string $name Model name
* @param mixed $client Client. null = auto, 1 = admin, 0 = frontend
* @param array $config An optional array of configuration
* @param string $option Component name, use for call model from modules
*
* @return RModelAdmin The model
*
* @throws InvalidArgumentException
*/
public static function getAutoInstance($name, $client = null, array $config = array(), $option = 'auto')
{
if ($option === 'auto') {
$option = JFactory::getApplication()->input->getString('option', '');
}
$componentName = ucfirst(strtolower(substr($option, 4)));
$prefix = $componentName . 'Model';
if (is_null($client)) {
$client = (int) JFactory::getApplication()->isAdmin();
}
// Admin
if ($client === 1) {
self::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/models', $prefix);
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/tables');
} elseif ($client === 0) {
self::addIncludePath(JPATH_SITE . '/components/' . $option . '/models', $prefix);
JTable::addIncludePath(JPATH_SITE . '/components/' . $option . '/tables');
} else {
throw new InvalidArgumentException(sprintf('Cannot instantiate the model %s. Invalid client %s.', $name, $client));
}
$model = self::getInstance($name, $prefix, $config);
if (!$model instanceof JModelAdmin && !$model instanceof JModelLegacy) {
throw new InvalidArgumentException(sprintf('Cannot instantiate the model %s from client %s.', $name, $client));
}
return $model;
}
示例5: copy
public function copy()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$cid = $this->input->post->get('cid', array(), 'array');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tagmeta/tables');
$table =& JTable::getInstance('Rule', 'TagMetaTable');
$n = count($cid);
if ($n > 0) {
$i = 0;
foreach ($cid as $id) {
if ($table->load((int) $id)) {
$table->id = 0;
$table->url = JText::_('COM_TAGMETA_COPY_OF') . $table->url;
$table->ordering = 0;
$table->published = false;
$table->checked_out = false;
if ($table->store()) {
$i++;
} else {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_SAVING', $id, $table->getError()), 'error');
}
} else {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_LOADING', $id, $table->getError()), 'error');
}
}
} else {
return JError::raiseWarning(500, JText::_('COM_TAGMETA_COPY_ERROR_NO_SELECTION'));
}
$this->setMessage(JText::sprintf('COM_TAGMETA_COPY_OK', $i));
$this->setRedirect('index.php?option=com_tagmeta&view=rules');
}
示例6: vm_require
protected function vm_require()
{
if (!class_exists('VmConfig')) {
if (file_exists(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php')) {
require JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
} else {
$this->error = 'Could not find VmConfig helper';
return false;
}
}
VmConfig::loadConfig();
VmConfig::loadJLang('com_virtuemart', true);
if (!class_exists('VmModel')) {
if (defined('JPATH_VM_ADMINISTRATOR') && file_exists(JPATH_VM_ADMINISTRATOR . '/helpers/vmmodel.php')) {
require JPATH_VM_ADMINISTRATOR . '/helpers/vmmodel.php';
} else {
$this->error = 'Could not find VmModel helper';
return false;
}
}
if (defined('JPATH_VM_ADMINISTRATOR')) {
JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . '/tables');
}
if (!class_exists('VirtueMartModelCustom')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'custom.php';
}
if (!class_exists('VirtueMartModelCustomfields')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
}
return true;
}
示例7: __construct
public function __construct()
{
parent::__construct();
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
$document = JFactory::getDocument();
$config = RSMembershipConfig::getInstance();
$version = (string) new RSMembershipVersion();
// Load our CSS
$document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/rsmembership.css?v=' . $version);
// Load our JS
$document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/rsmembership.js?v=' . $version);
if (!RSMembershipHelper::isJ3()) {
// Load 2.5 CSS
$document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/j2.css?v=' . $version);
// Load Bootstrap on 2.5.x
if ($config->get('load_bootstrap')) {
$document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/bootstrap.min.css?v=' . $version);
$document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/jquery.min.js?v=' . $version);
$document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/jquery.noconflict.js?v=' . $version);
$document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/bootstrap.min.js?v=' . $version);
}
} else {
// Load 3.x CSS
$document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/j3.css?v=' . $version);
// Load Bootstrap on 3.x
if ($config->get('load_bootstrap')) {
JHtml::_('bootstrap.framework');
}
}
}
示例8: display
/**
* Generates a random captcha image
*
**/
function display($cachable = false, $urlparams = false)
{
// @TODO: Run some cleaning query here to clear the database.
JTable::addIncludePath(DISCUSS_TABLES);
$id = JRequest::getInt('captcha-id', '');
$captcha = DiscussHelper::getTable('Captcha');
// clearing the oudated keys.
$captcha->clear();
// load the captcha records.
$captcha->load($id);
if (!$captcha->id) {
return false;
}
// @task: Generate a very random integer and take only 5 chars max.
$hash = JString::substr(md5(rand(0, 9999)), 0, 5);
$captcha->response = $hash;
$captcha->store();
// Captcha width and height
$width = 100;
$height = 20;
$image = ImageCreate($width, $height);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$gray = ImageColorAllocate($image, 204, 204, 204);
ImageFill($image, 0, 0, $white);
ImageString($image, 5, 30, 3, $hash, $black);
ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
imageline($image, 0, $height / 2, $width, $height / 2, $gray);
imageline($image, $width / 2, 0, $width / 2, $height, $gray);
header('Content-type: image/jpeg');
ImageJpeg($image);
ImageDestroy($image);
exit;
}
示例9: changeBlock
/**
* Method to change the block status on a record.
*
* @return void
*
* @since 0.3.0
*/
public function changeBlock()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$ids = $this->input->get('cid', array(), 'array');
$values = array('block' => 1, 'unblock' => 0);
$task = $this->getTask();
$value = JArrayHelper::getValue($values, $task, 0, 'int');
// Convert from customer ID to Joomla user ID
$joomlaUserIds = array();
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/tables', 'SolidresTable');
$customerTable = JTable::getInstance('Customer', 'SolidresTable');
foreach ($ids as $id) {
$customerTable->load($id);
$joomlaUserIds[] = $customerTable->user_id;
}
if (empty($joomlaUserIds)) {
JError::raiseWarning(500, JText::_('SR_CUSTOMERS_NO_ITEM_SELECTED'));
} else {
// Get the model.
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
$model = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
// Change the state of the records.
if (!$model->block($joomlaUserIds, $value)) {
JError::raiseWarning(500, $model->getError());
} else {
if ($value == 1) {
$this->setMessage(JText::plural('SR_N_CUSTOMERS_BLOCKED', count($joomlaUserIds)));
} elseif ($value == 0) {
$this->setMessage(JText::plural('SR_N_CUSTOMERS_UNBLOCKED', count($joomlaUserIds)));
}
}
}
$this->setRedirect('index.php?option=com_solidres&view=customers');
}
示例10: array
/**
* Returns a reference to the a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $options Configuration array for model. Optional.
* @return database A database object
* @since 1.5
*/
function &getInstance($type, $prefix = 'JTable', $config = array())
{
$false = false;
$type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
$tableClass = $prefix . ucfirst($type);
if (!class_exists($tableClass)) {
jimport('joomla.filesystem.path');
if ($path = JPath::find(JTable::addIncludePath(), strtolower($type) . '.php')) {
require_once $path;
if (!class_exists($tableClass)) {
JError::raiseWarning(0, 'Table class ' . $tableClass . ' not found in file.');
return $false;
}
} else {
JError::raiseWarning(0, 'Table ' . $type . ' not supported. File not found.');
return $false;
}
}
//Make sure we are returning a DBO object
if (array_key_exists('dbo', $config)) {
$db =& $config['dbo'];
} else {
$db =& JFactory::getDBO();
}
$instance = new $tableClass($db);
//$instance->setDBO($db);
return $instance;
}
示例11: getInput
public function getInput()
{
$mainframe =& JFactory::getApplication();
$doc =& JFactory::getDocument();
$fieldName = $this->element['name'];
$value = $this->value;
$name = $this->name;
$e_folder = basename(dirname(dirname(__FILE__)));
JTable::addIncludePath(JPATH_ROOT . '/modules/' . $e_folder . '/elements');
$item =& JTable::getInstance('YjContent', 'Table');
$title = $item->title;
if ($value) {
$item->load($value);
} else {
$title = JText::_('Select specific items...');
}
$document =& JFactory::getDocument();
$js = "\r\n\t\tfunction jSelectArticle(id, title, object) {\r\n\t\t\tdocument.getElementById(object + '_id').value = id;\r\n\t\t\tdocument.getElementById(object + '_name').value = title;\r\n\t\t\tdocument.getElementById('sbox-window').close();\r\n\t\t}\r\n\t\t";
$doc->addScriptDeclaration($js);
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&object=' . $name;
JHTML::_('behavior.modal', 'a.modal');
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="' . $name . '_name" value="' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal" title="' . JText::_('Select specific items') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('Select') . '</a>
</div>
</div>
<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />
';
return $html;
}
示例12: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
$mainframe =& JFactory::getApplication();
$db =& JFactory::getDBO();
$doc =& JFactory::getDocument();
$fieldName = K2_JVERSION == '16' ? $name : $control_name . '[' . $name . ']';
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
$item =& JTable::getInstance('K2Item', 'Table');
if ($value) {
$item->load($value);
} else {
$item->title = JText::_('K2_SELECT_AN_ITEM');
}
$doc->addScriptDeclaration($js);
$link = 'index.php?option=com_k2&view=items&task=element&tmpl=component&object=' . $name;
JHTML::_('behavior.modal', 'a.modal');
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="' . $name . '_name" value="' . htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal" title="' . JText::_('K2_SELECT_AN_ITEM') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('K2_SELECT') . '</a>
</div>
</div>
<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />
';
return $html;
}
示例13: getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
//$this->getAttribute('teste');
$input = JFactory::getApplication()->input;
$id = $input->get('id', 0);
$options = array();
if ($id == 0) {
$options[] = JHtml::_('select.option', 'NULL', JText::_('COM_AGENDADIRIGENTES_SALVE_PRIMEIRO'));
return $options;
}
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_agendadirigentes' . DS . 'tables');
$table = JTable::getInstance('dirigente', 'AgendaDirigentesTable');
$table->load($id);
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('dir.ordering, dir.name')->from($db->quoteName('#__agendadirigentes_dirigentes', 'dir'))->join('INNER', $db->quoteName('#__categories', 'cat') . ' ON (' . $db->quoteName('dir.catid') . ' = ' . $db->quoteName('cat.id') . ')')->where('dir.catid = ' . intval($table->catid))->where('dir.id <> ' . intval($id));
$query->order('dir.ordering ASC, dir.name ASC');
$db->setQuery((string) $query);
$dirigentes = $db->loadObjectList();
$options = array();
if ($dirigentes) {
$options[] = JHtml::_('select.option', 0, ' - Primeiro - ');
foreach ($dirigentes as $dirigente) {
$options[] = JHtml::_('select.option', $dirigente->ordering, $dirigente->name);
}
} else {
$options[] = JHtml::_('select.option', 0, JText::_('COM_AGENDADIRIGENTES_ORDERING_SOMENTE_UM'));
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例14: post
/**
* This is not the best example to follow
* Please see the category plugin for a better example
*/
public function post()
{
// Set variables to be used
APIHelper::setSessionUser();
// Include dependencies
jimport('joomla.database.table');
$language = JFactory::getLanguage();
$language->load('joomla', JPATH_ADMINISTRATOR);
$language->load('com_k2', JPATH_ADMINISTRATOR);
require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/item.php';
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
// Fake parameters
$_REQUEST[JUtility::getToken()] = 1;
$_POST[JUtility::getToken()] = 1;
// Clear userstate just in case
$row = $this->save();
if ($this->getError()) {
$response = $this->getErrorResponse(400, $this->getError());
} elseif (!$row->id) {
$response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
} else {
$response = $this->getSuccessResponse(201, JText::_('COM_API_SUCCESS'));
// Get the ID of the category that was modified or inserted
$response->id = $row->id;
}
$this->plugin->setResponse($response);
}
示例15: __construct
/**
* Base Controller Constructor
*
* @param array $config Controller initialization configuration parameters
* @return void
* @since 0.1
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->set('option', JRequest::getCmd('option'));
JModel::addIncludePath(JPATH_SITE . '/components/com_api/models');
JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables');
}