本文整理汇总了PHP中JApplicationHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationHelper类的具体用法?PHP JApplicationHelper怎么用?PHP JApplicationHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JApplicationHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setPath
/**
* Sets an entire array of search paths for templates or resources.
*
* @access protected
* @param string $type The type of path to set, typically 'template'.
* @param string|array $path The new set of search paths. If null or
* false, resets to the current directory only.
*/
function _setPath($type, $path)
{
$option = JApplicationHelper::getComponentName();
$app = JFactory::getApplication();
$extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
if (!count($extensions)) {
return parent::_setPath($type, $path);
}
// clear out the prior search dirs
$this->_path[$type] = array();
// actually add the user-specified directories
$this->_addPath($type, $path);
// add extensions paths
if (strtolower($type) == 'template') {
foreach ($extensions as $e => $extension) {
$JLGPATH_EXTENSION = JPATH_COMPONENT_SITE . '/extensions/' . $extension;
// set the alternative template search dir
if (isset($app)) {
if ($app->isAdmin()) {
$this->_addPath('template', $JLGPATH_EXTENSION . '/admin/views/' . $this->getName() . '/tmpl');
} else {
$this->_addPath('template', $JLGPATH_EXTENSION . '/views/' . $this->getName() . '/tmpl');
}
// always add the fallback directories as last resort
$option = preg_replace('/[^A-Z0-9_\\.-]/i', '', $option);
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $option . '/' . $extension . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
}
}
}
示例2: getInstance
/**
* Returns a JPathway object
*
* @param string $client The name of the client
* @param array $options An associative array of options
*
* @return JPathway A JPathway object.
*
* @since 1.5
* @throws RuntimeException
*/
public static function getInstance($client, $options = array())
{
if (empty(self::$instances[$client])) {
// Create a JPathway object
$classname = 'JPathway' . ucfirst($client);
if (!class_exists($classname)) {
// @deprecated 4.0 Everything in this block is deprecated but the warning is only logged after the file_exists
// Load the pathway object
$info = JApplicationHelper::getClientInfo($client, true);
if (is_object($info)) {
$path = $info->path . '/includes/pathway.php';
if (file_exists($path)) {
JLog::add('Non-autoloadable JPathway subclasses are deprecated, support will be removed in 4.0.', JLog::WARNING, 'deprecated');
include_once $path;
}
}
}
if (class_exists($classname)) {
self::$instances[$client] = new $classname($options);
} else {
throw new RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_PATHWAY_LOAD', $client), 500);
}
}
return self::$instances[$client];
}
示例3: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$language = JFactory::getLanguage();
// create a unique id
$id = preg_replace('#([^a-z0-9_-]+)#i', '', $control_name . 'filesystem' . $name);
// add javascript if element has parameters
if ($node->attributes('parameters')) {
$document = JFactory::getDocument();
$document->addScriptDeclaration('$jce.Parameter.add("#' . $id . '", "filesystem");');
}
// path to directory
$path = WF_EDITOR_EXTENSIONS . DS . 'filesystem';
$filter = '\\.xml$';
$files = JFolder::files($path, $filter, false, true);
$options = array();
if (!$node->attributes('exclude_default')) {
$options[] = JHTML::_('select.option', '', WFText::_('WF_OPTION_NOT_SET'));
}
if (is_array($files)) {
foreach ($files as $file) {
// load language file
$language->load('com_jce_filesystem_' . basename($file, '.xml'), JPATH_SITE);
$xml = JApplicationHelper::parseXMLInstallFile($file);
$options[] = JHTML::_('select.option', basename($file, '.xml'), WFText::_($xml['name']));
}
}
return JHTML::_('select.genericlist', $options, '' . $control_name . '[filesystem][' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $id);
}
示例4: getFiles
/**
* Method to get a list of all the files to edit in a template.
*
* @return array A nested array of relevant files.
* @since 1.6
*/
public function getFiles()
{
// Initialise variables.
$result = array();
if ($template = $this->getTemplate()) {
jimport('joomla.filesystem.folder');
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' . $template->element . '/');
$lang = JFactory::getLanguage();
// Load the core and/or local language file(s).
$lang->load('tpl_' . $template->element, $client->path, null, false, false) || $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, null, false, false) || $lang->load('tpl_' . $template->element, $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template->element, $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false);
// Check if the template path exists.
if (is_dir($path)) {
$result['main'] = array();
$result['css'] = array();
$result['clo'] = array();
$result['mlo'] = array();
$result['html'] = array();
// Handle the main PHP files.
$result['main']['index'] = $this->getFile($path, 'index.php');
$result['main']['error'] = $this->getFile($path, 'error.php');
$result['main']['print'] = $this->getFile($path, 'component.php');
$result['main']['offline'] = $this->getFile($path, 'offline.php');
// Handle the CSS files.
$files = JFolder::files($path . '/css', '\\.css$', false, false);
foreach ($files as $file) {
$result['css'][] = $this->getFile($path . '/css/', 'css/' . $file);
}
} else {
$this->setError(JText::_('COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND'));
return false;
}
}
return $result;
}
示例5: initialise
/**
* Initialise the application.
*
* @param array $options An optional associative array of configuration settings.
*
* @return void
* @since 1.5
*/
public function initialise($options = array())
{
$config = JFactory::getConfig();
// if a language was specified it has priority
// otherwise use user or default language settings
if (empty($options['language'])) {
$user = JFactory::getUser();
$lang = $user->getParam('admin_language');
// Make sure that the user's language exists
if ($lang && JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$params = JComponentHelper::getParams('com_languages');
$client = JApplicationHelper::getClientInfo($this->getClientId());
$options['language'] = $params->get($client->name, $config->get('language', 'es-LA'));
}
}
// One last check to make sure we have something
if (!JLanguage::exists($options['language'])) {
$lang = $config->get('language', 'es-LA');
if (JLanguage::exists($lang)) {
$options['language'] = $lang;
} else {
$options['language'] = 'es-LA';
// as a last ditch fail to english
}
}
// Execute the parent initialise method.
parent::initialise($options);
// Load Library language
$lang = JFactory::getLanguage();
$lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, false, true);
}
示例6: _loadItems
/**
* Current discovered extension list
*/
function _loadItems()
{
jimport('joomla.filesystem.folder');
/* Get a database connector */
$db =& JFactory::getDBO();
$query = 'SELECT *' . ' FROM #__extensions' . ' WHERE state = -1' . ' ORDER BY type, client_id, folder, name';
$db->setQuery($query);
$rows = $db->loadObjectList();
$apps =& JApplicationHelper::getClientInfo();
$numRows = count($rows);
for ($i = 0; $i < $numRows; $i++) {
$row =& $rows[$i];
if (strlen($row->manifest_cache)) {
$data = unserialize($row->manifest_cache);
if ($data) {
foreach ($data as $key => $value) {
$row->{$key} = $value;
}
}
}
$row->jname = JString::strtolower(str_replace(" ", "_", $row->name));
if (isset($apps[$row->client_id])) {
$row->client = ucfirst($apps[$row->client_id]->name);
} else {
$row->client = $row->client_id;
}
}
$this->setState('pagination.total', $numRows);
if ($this->_state->get('pagination.limit') > 0) {
$this->_items = array_slice($rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit'));
} else {
$this->_items = $rows;
}
}
示例7: array
/**
* Returns a reference to the global JRouter object, only creating it if it
* doesn't already exist.
*
* This method must be invoked as:
* <pre> $menu = &JRouter::getInstance();</pre>
*
* @access public
* @param string $client The name of the client
* @param array $options An associative array of options
* @return JRouter A router object.
*/
function &getInstance($client, $options = array())
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
if (empty($instances[$client])) {
//Load the router object
$info =& JApplicationHelper::getClientInfo($client, true);
$classname = 'JRouter' . ucfirst($client);
if (!class_exists($classname)) {
$path = $info->path . DS . 'includes' . DS . 'router.php';
if (file_exists($path)) {
require_once $path;
}
}
if (!class_exists($classname)) {
$error = JError::raiseError(500, 'Unable to load router: ' . $client);
return $error;
}
$instance = new $classname($options);
$instances[$client] =& $instance;
}
return $instances[$client];
}
示例8: getLabel
/**
* Method to get the field label.
*
* @return string A message containing the installed version and,
* if necessary, information on a new version.
*
* @since 2.1
*/
protected function getLabel()
{
// Check if cURL is loaded; if not, proceed no further
if (!extension_loaded('curl')) {
return JText::_('TPL_CONSTRUCT5_ERROR_NOCURL');
} else {
// Get the module's XML
$xmlfile = JPATH_SITE . '/templates/construct5/templateDetails.xml';
$data = JApplicationHelper::parseXMLInstallFile($xmlfile);
// The module's version
$version = $data['version'];
$name = str_replace(array('construct', 'bootstruct'), array('Construct', 'Bootstruct'), $data['name']);
// The target to check against
$target = 'http://construct-framework.com/upgradecheck/' . $data['name'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $target);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$update = curl_exec($curl);
curl_close($curl);
// Message containing the version
$message = '<label style="max-width:100%">' . JText::sprintf('TPL_CONSTRUCT5_VERSION_INSTALLED', $name, $version);
// If an update is available, and compatible with the current Joomla! version, notify the user
if (version_compare($version, $update, 'lt')) {
$message .= ' <a href="http://construct-framework.com" target="_blank">' . JText::sprintf('TPL_CONSTRUCT5_VERSION_UPDATE', $update) . '</a></label>';
} else {
$message .= ' ' . JText::_('TPL_CONSTRUCT5_VERSION_CURRENT') . '</label>';
}
return $message;
}
}
示例9: _loadItems
function _loadItems()
{
global $mainframe, $option;
// Get a database connector
$db =& JFactory::getDBO();
$query = 'SELECT e.id as id, e.name as name, e.extension as extension, e.folder as folder, p.name as file, p.title as plugin' . ' FROM #__jce_extensions AS e' . ' INNER JOIN #__jce_plugins as p ON e.pid = p.id' . ' ORDER BY e.name';
$db->setQuery($query);
$rows = $db->loadObjectList();
$numRows = count($rows);
for ($i = 0; $i < $numRows; $i++) {
$row =& $rows[$i];
$plugin = $row->plugin;
$name = $row->name;
$folder = $row->folder;
// Get the plugin base path
$baseDir = JPATH_PLUGINS . DS . 'editors' . DS . 'jce' . DS . 'tiny_mce' . DS . 'plugins';
// Get the plugin xml file
$xmlfile = $baseDir . DS . $row->file . DS . 'extensions' . DS . $row->folder . DS . $row->extension . ".xml";
if (file_exists($xmlfile)) {
if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) {
foreach ($data as $key => $value) {
$row->{$key} = $value;
}
}
}
$row->name = $name;
$row->plugin = $plugin;
}
$this->setState('pagination.total', $numRows);
if ($this->_state->get('pagination.limit') > 0) {
$this->_items = array_slice($rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit'));
} else {
$this->_items = $rows;
}
}
示例10: display
function display($tpl = null)
{
global $option;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$client = JRequest::getWord('client', 'site');
$id = JRequest::getVar('id', '', '', 'int');
$lists = array();
$query = 'SELECT * FROM #__jomtube_plugins WHERE id = ' . $id;
$db->setQuery($query);
$row = $db->loadObject();
if ($id) {
$data = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . $row->folder . DS . $row->element . '.xml');
} else {
$row->folder = '';
$row->ordering = 999;
$row->published = 1;
$row->description = '';
}
$lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
// get params definitions
$params = new JParameter($row->params, JPATH_SITE . DS . $row->folder . DS . $row->element . '.xml', 'plugin');
$this->assignRef('lists', $lists);
$this->assignRef('plugin', $row);
$this->assignRef('params', $params);
parent::display($tpl);
}
示例11: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
// Get the client id.
$clientId = $this->element['client_id'];
if (!isset($clientId)) {
$clientName = $this->element['client'];
if (isset($clientName)) {
$client = JApplicationHelper::getClientInfo($clientName, true);
$clientId = $client->id;
}
}
if (!isset($clientId) && $this->form instanceof JForm) {
$clientId = $this->form->getValue('client_id');
}
$clientId = (int) $clientId;
// Load the modal behavior script.
JHtml::_('behavior.modal', 'a.modal');
// Build the script.
$script = array();
$script[] = ' function jSelectPosition_' . $this->id . '(name) {';
$script[] = ' document.id("' . $this->id . '").value = name;';
$script[] = ' SqueezeBox.close();';
$script[] = ' }';
// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_modules&view=positions&layout=modal&tmpl=component&function=jSelectPosition_' . $this->id . '&client_id=' . $clientId;
// The current user display field.
$html[] = '<div class="input-append">';
$html[] = parent::getInput() . '<a class="btn modal" title="' . JText::_('COM_MODULES_CHANGE_POSITION_TITLE') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . '<i class="icon-screenshot"></i> ' . JText::_('COM_MODULES_CHANGE_POSITION_BUTTON') . '</a>';
$html[] = '</div>';
return implode("\n", $html);
}
示例12: display
function display($tpl = null)
{
/*Ověření, jestli jde o přístup z administrace nebo front-endu*/
$doc =& JFactory::getDocument();
if (JPATH_BASE == JPATH_ADMINISTRATOR) {
require_once JApplicationHelper::getPath('toolbar_html');
TOOLBAR_mapping::_DEFAULT();
} else {
echo '<div class="componentheading">' . JText::_('COM_MAPPING') . '</div>';
$doc->addStyleSheet('components/com_mapping/css/general.css');
$doc->addStyleSheet('components/com_mapping/css/component.css');
}
/**/
echo '<h1>' . JText::_('MAPPING_FINALIZATION') . '</h1>';
echo '<p>' . JText::_('MAPPING_SAVED_INFO') . '</p>';
if ($this->redirectUrl) {
echo '<p>' . JText::_('REDIRECT_INFO') . '</p>';
echo '<script type="text/javascript">
function redirectToUrl(){
location.href="' . $this->redirectUrl . '";
}
var t=setTimeout("redirectToUrl();",5000);
</script>';
}
}
示例13: getUnidades
function getUnidades()
{
$joopoa_helper = JApplicationHelper::getPath('helper', 'com_joopoa');
require $joopoa_helper;
$unidades =& JoopoaHelper::getUnidades();
return $unidades;
}
示例14: disableInfoMode
/**
*
* Disable JT3 infomode
*
* @return: Save setting to file params.ini
*/
public function disableInfoMode()
{
JSNFactory::localimport('libraries.joomlashine.database');
$template = JSNDatabase::getDefaultTemplate();
$client = JApplicationHelper::getClientInfo($template->client_id);
$file = $client->path . '/templates/' . $template->element . '/params.ini';
$data = JFile::read($file);
$data = explode("\n", $data);
$params = array();
$needChange = false;
foreach ($data as $val) {
$spos = strpos($val, "=");
$key = substr($val, 0, $spos);
$value = substr($val, $spos + 1, strlen($val) - $spos);
if ($key == 'infomode') {
if ($value == '"1"') {
$value = '"0"';
$needChange = true;
}
}
$params[$key] = $value;
}
if ($needChange) {
$data = array();
foreach ($params as $key => $val) {
$data[] = $key . '=' . $val;
}
$data = implode("\n", $data);
if (JFile::exists($file)) {
@chmod($file, 0777);
}
JFile::write($file, $data);
}
}
示例15: __construct
function __construct(JXMLElement $element = null)
{
if ($element && is_a($element, 'JXMLElement')) {
$this->type = (string) $element->attributes()->type;
$this->id = (string) $element->attributes()->id;
switch ($this->type) {
case 'component':
// by default a component doesn't have anything
break;
case 'module':
case 'template':
case 'language':
$this->client = (string) $element->attributes()->client;
$this->client_id = JApplicationHelper::getClientInfo($this->client, 1);
$this->client_id = $this->client_id->id;
break;
case 'plugin':
$this->group = (string) $element->attributes()->group;
break;
default:
// catch all
// get and set client and group if we don't recognise the extension
if ($client = (string) $element->attributes()->client) {
$this->client_id = JApplicationHelper::getClientInfo($this->client, 1);
$this->client_id = $this->client_id->id;
}
if ($group = (string) $element->attributes()->group) {
$this->group = (string) $element->attributes()->group;
}
break;
}
$this->filename = (string) $element;
}
}