本文整理汇总了PHP中JApplicationHelper::getComponentName方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationHelper::getComponentName方法的具体用法?PHP JApplicationHelper::getComponentName怎么用?PHP JApplicationHelper::getComponentName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationHelper
的用法示例。
在下文中一共展示了JApplicationHelper::getComponentName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDbPaths
public static function getDbPaths($which, $dbname, $full = false, $cmp = '')
{
$paths = array();
if (!$cmp) {
$cmp = JApplicationHelper::getComponentName();
}
switch ($which) {
case 'u':
$char1 = '@';
break;
case 'g':
$char1 = '_';
break;
default:
$char1 = '';
break;
}
$dpath = JPATH_SITE . '/' . self::getStorageBase() . '/';
if (is_dir($dpath) && ($dh = opendir($dpath))) {
while (($file = readdir($dh)) !== false) {
if ($file[0] == $char1) {
$ptf = $dpath . $file . '/' . $cmp . '/' . $dbname . '.sql3';
if (file_exists($ptf)) {
$paths[] = $full ? $ptf : $file;
}
$ptf = $dpath . $file . '/' . $cmp . '/' . $dbname . '.db3';
if (file_exists($ptf)) {
$paths[] = $full ? $ptf : $file;
}
}
}
closedir($dh);
}
return $paths;
}
示例2: _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);
}
}
}
}
示例3: __construct
/**
* Method to instantiate the view.
*
* @param JModel $model The model object.
* @param SplPriorityQueue $paths The paths queue.
*
* @since 3.2
*/
public function __construct(JModel $model, SplPriorityQueue $paths = null)
{
$app = JFactory::getApplication();
$component = JApplicationHelper::getComponentName();
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
if (isset($paths)) {
$paths->insert(JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName(), 2);
}
parent::__construct($model, $paths);
}
示例4: createURL
/**
* Create an URL for a giving help file reference
*
* @param string The name of the popup file (excluding the file extension for an xml file)
* @param boolean Use the help file in the component directory
*/
static function createURL($ref, $useComponent = false)
{
$component = JApplicationHelper::getComponentName();
$app =& JFactory::getApplication();
$user =& JFactory::getUser();
$userHelpUrl = $user->getParam('helpsite');
$globalHelpUrl = $app->getCfg('helpurl');
$lang =& JFactory::getLanguage();
if ($useComponent) {
if (!preg_match('#\\.html$#i', $ref)) {
$ref = $ref . '.html';
}
$url = 'components/' . $component . '/help';
$tag = $lang->getTag();
// Check if the file exists within a different language!
if ($lang->getTag() != 'en-GB') {
$localeURL = JPATH_BASE . DS . $url . DS . $tag . DS . $ref;
jimport('joomla.filesystem.file');
if (!JFile::exists($localeURL)) {
$tag = 'en-GB';
}
}
return $url . '/' . $tag . '/' . $ref;
}
if ($userHelpUrl) {
// Online help site as defined in GC
$version = new JVersion();
$ref .= $version->getHelpVersion();
$url = $userHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component&keyref=' . urlencode($ref);
} else {
if ($globalHelpUrl) {
// Online help site as defined in GC
$version = new JVersion();
$ref .= $version->getHelpVersion();
$url = $globalHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component;1&keyref=' . urlencode($ref);
} else {
// Included html help files
$helpURL = 'help/' . $lang->getTag() . '/';
if (!eregi('\\.html$', $ref)) {
$ref = $ref . '.html';
}
// Check if the file exists within a different language!
if ($lang->getTag() != 'en-GB') {
$localeURL = JPATH_BASE . $helpURL . $ref;
jimport('joomla.filesystem.file');
if (!JFile::exists($localeURL)) {
$helpURL = 'help/en-GB/';
}
}
$url = $helpURL . $ref;
}
}
return $url;
}
示例5: convertDb
public function convertDb()
{
$sdp = UserNotesHelper::getStorageBase();
$cids = $this->input->get('cid', array(), 'array');
$view = $this->input->get('view');
$tc = $view == 'usernotes' ? '@' : '_';
foreach ($cids as $cid) {
UserNotesHelperDb::convertDb(JPATH_ROOT . '/' . $sdp . '/' . $tc . $cid . '/' . JApplicationHelper::getComponentName());
}
$this->setRedirect('index.php?option=com_usernotes&view=' . $view, JText::_('COM_USERSCHED_MSG_COMPLETE'));
}
示例6: loadSnippet
/**
* Loads a snippet from the snippets folder. Name can contain a slash:
* foo/bar will load component/views/snippets/tmpl/foo/bar.php
*
* @param string $tpl
*
* @return string the output of the template
* @throws Exception
*/
public function loadSnippet($tpl)
{
// Clear prior output
$this->_output = null;
// create a hash of the template to avoid conflicts with the array key in the cache
$cacheKey = md5($tpl);
// if the cache is not filled for the current template try to get it.
if (!isset(self::$templateCache[$cacheKey])) {
$baseDir = $this->_basePath . '/views/snippets/tmpl';
$component = JApplicationHelper::getComponentName();
$app = JFactory::getApplication();
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
if ($this->_site_template != null) {
$fallback = JPATH_SITE . '/templates/' . $this->_site_template . '/html/' . $component . '/' . 'snippets';
} else {
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'snippets';
}
$path = array($fallback, $baseDir);
// Clean the file name
$file = preg_replace('/[^A-Z0-9_\\.-\\/]/i', '', $tpl);
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl;
// Load the template script
jimport('joomla.filesystem.path');
$filetofind = $this->_createFileName('template', array('name' => $file));
self::$templateCache[$cacheKey] = JPath::find($path, $filetofind);
}
// get the template from the cache
$template = self::$templateCache[$cacheKey];
// If alternate layout can't be found, fall back to default layout
if ($template == false) {
throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
}
// Unset so as not to introduce into template scope
unset($tpl);
unset($file);
// Never allow a 'this' property
if (isset($this->this)) {
unset($this->this);
}
// Start capturing output into a buffer
ob_start();
// Include the requested template filename in the local scope
// (this will execute the view logic).
include $template;
// Done with the requested template; get the buffer and
// clear it.
$this->_output = ob_get_contents();
ob_end_clean();
return $this->_output;
}
示例7: getCategories
function getCategories($name, $active = NULL, $javascript = NULL, $order = 'lft', $size = 1, $sel_cat = 1)
{
$db = JFactory::getDBO();
$extension = JApplicationHelper::getComponentName();
$query = 'SELECT id AS value, title AS text' . ' FROM #__categories' . ' WHERE extension = ' . $db->Quote($extension) . ' AND published = 1' . ' ORDER BY ' . $order;
$db->setQuery($query);
if ($sel_cat and $name != 'catid') {
$categories[] = JHtml::_('select.option', '0', '- ' . JText::_('Select a Category') . ' -');
$categories[] = JHtml::_('select.option', '-1', 'Template Overrides');
$categories = array_merge($categories, $db->loadObjectList());
} else {
$categories = $db->loadObjectList();
}
$category = JHtml::_('select.genericlist', $categories, $name, 'class="inputbox" size="' . $size . '" ' . $javascript, 'value', 'text', $active);
return $category;
}
示例8: _displayForm
function _displayForm($tpl)
{
$user =& JFactory::getUser();
$option = JApplicationHelper::getComponentName();
$model =& $this->getModel();
$document =& JFactory::getDocument();
$document->addStyleSheet('components/' . $option . '/assets/rokcandy.css');
$lists = array();
//get the rokcandymacro
$rokcandymacro =& $this->get('data');
$isNew = $rokcandymacro->id < 1;
// fail if checked out not by 'me'
if ($model->isCheckedOut($user->get('id'))) {
$msg = JText::sprintf('DESCBEINGEDITTED', JText::_('ROKCANDY_MACRO'), $rokcandymacro->macro);
$app = JFactory::getApplication();
$app->redirect('index.php?option=' . $option, $msg);
}
// Edit or Create?
if (!$isNew) {
$model->checkout($user->get('id'));
} else {
// initialise new record
$rokcandymacro->published = 1;
$rokcandymacro->order = 0;
$rokcandymacro->catid = JRequest::getVar('catid', 0, 'post', 'int');
}
// build the html select list for ordering
$query = 'SELECT ordering AS value, macro AS text' . ' FROM #__rokcandy' . ' WHERE catid = ' . (int) $rokcandymacro->catid . ' ORDER BY ordering';
$lists['ordering'] = JHTML::_('list.specificordering', $rokcandymacro, $rokcandymacro->id, $query);
// build list of categories
//$lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $rokcandymacro->catid ) );
$lists['catid'] = JElementRokCandyList::getCategories('catid', intval($rokcandymacro->catid));
// build the html select list
$publishList[] = JHTML::_('select.option', '1', JText::_('Published'));
$publishList[] = JHTML::_('select.option', '0', JText::_('Unpublished'));
$lists['published'] = JHTML::_('select.genericlist', $publishList, 'published', 'class="inputbox" size="1"', 'value', 'text', $rokcandymacro->published);
//clean rokcandymacro data
JFilterOutput::objectHTMLSafe($rokcandymacro, ENT_QUOTES, 'html');
$file = JPATH_COMPONENT . DS . 'models' . DS . 'candymacro.xml';
$params = new JParameter($rokcandymacro->params, $file);
$this->assignRef('lists', $lists);
$this->assignRef('rokcandymacro', $rokcandymacro);
$this->assignRef('params', $params);
parent::display($tpl);
}
示例9: display
function display($tpl = null)
{
$app = JFactory::getApplication();
$option = JApplicationHelper::getComponentName();
$document =& JFactory::getDocument();
$document->addStyleSheet('components/' . $option . '/assets/rokcandy.css');
$filter_state = $app->getUserStateFromRequest($option . 'filter_state', 'filter_state', '', 'word');
$filter_catid = $app->getUserStateFromRequest($option . 'filter_catid', 'filter_catid', 0, 'int');
$filter_catid = $app->getUserStateFromRequest($option . 'filter_catid', 'filter_catid', 0, 'int');
$filter_order = $app->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'a.ordering', 'cmd');
$filter_order_Dir = $app->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
$search = $app->getUserStateFromRequest($option . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
// Get data from the model
if ($filter_catid != -1) {
$items =& $this->get('Data');
} else {
$items = array();
}
$total =& $this->get('Total');
$pagination =& $this->get('Pagination');
if ($filter_catid == -1 or $filter_catid == 0) {
$overrides =& $this->get('TemplateOverrides');
} else {
$overrides = array();
}
// build list of categories
$javascript = 'onchange="document.adminForm.submit();"';
$lists['catid'] = JElementRokCandyList::getCategories('filter_catid', intval($filter_catid), $javascript);
// state filter
$lists['state'] = JHTML::_('grid.state', $filter_state);
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// search filter
$lists['search'] = $search;
$this->assignRef('user', JFactory::getUser());
$this->assignRef('lists', $lists);
$this->assignRef('items', $items);
$this->assignRef('pagination', $pagination);
$this->assignRef('overrides', $overrides);
parent::display($tpl);
}
示例10: __construct
/**
* Method to instantiate the view.
*
* @param JModel $model The model object.
* @param SplPriorityQueue $paths The paths queue.
*
* @since 12.1
*/
public function __construct(JModel $model, SplPriorityQueue $paths = null)
{
parent::__construct($model);
// Setup dependencies.
$this->paths = isset($paths) ? $paths : $this->loadPaths();
/* T3: Add T3 html path to the priority paths of component view */
// T3 html path
$component = JApplicationHelper::getComponentName();
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
$t3Path = T3_PATH . '/html/' . $component . '/' . $this->getName();
// Setup the template path
$this->paths->top();
$defaultPath = $this->paths->current();
$this->paths->next();
$templatePath = $this->paths->current();
// add t3 path
$this->paths->insert($t3Path, 3);
$this->_path['template'] = array($defaultPath, $t3Path, $templatePath);
/* //T3 */
}
示例11: execute
/**
* Execute the controller.
*
* @return boolean True on success
*
* @since 2.0
* @throws \RuntimeException
*/
public function execute()
{
// Set up variables to build our classes
$view = $this->getInput()->getCmd('view', $this->defaultView);
$format = $this->getInput()->getCmd('format', 'html');
// Register the layout paths for the view
$paths = new \SplPriorityQueue();
// Add the path for template overrides
$paths->insert(JPATH_THEMES . '/' . $this->getApplication()->getTemplate() . '/html/' . \JApplicationHelper::getComponentName() . '/' . $view, 2);
// Add the path for the default layouts
$paths->insert(JPATH_BASE . '/components/' . \JApplicationHelper::getComponentName() . '/PatchTester/View/' . ucfirst($view) . '/tmpl', 1);
// Build the class names for the model and view
$viewClass = '\\PatchTester\\View\\' . ucfirst($view) . '\\' . ucfirst($view) . ucfirst($format) . 'View';
$modelClass = '\\PatchTester\\Model\\' . ucfirst($view) . 'Model';
// Sanity check - Ensure our classes exist
if (!class_exists($viewClass)) {
// Try to use a default view
$viewClass = '\\PatchTester\\View\\Default' . ucfirst($format) . 'View';
if (!class_exists($viewClass)) {
throw new \RuntimeException(sprintf('The view class for the %1$s view in the %2$s format was not found.', $view, $format), 500);
}
}
if (!class_exists($modelClass)) {
throw new \RuntimeException(sprintf('The model class for the %s view was not found.', $view), 500);
}
// Initialize the model class now; need to do it before setting the state to get required data from it
$model = new $modelClass($this->context, null, \JFactory::getDbo());
// Initialize the state for the model
$model->setState($this->initializeState($model));
// Initialize the view class now
$view = new $viewClass($model, $paths);
// Echo the rendered view for the application
echo $view->render();
// Finished!
return true;
}
示例12: _setPath
/**
* Sets an entire array of search paths for templates or resources.
*
* @param string The type of path to set, typically 'template'.
* @param string|array The new set of search paths. If null or false, resets to the current directory only.
*/
protected function _setPath($type, $path)
{
jimport('joomla.application.helper');
$component = JApplicationHelper::getComponentName();
$app = JFactory::getApplication();
// Clear out the prior search dirs
$this->_path[$type] = array();
// Actually add the user-specified directories
$this->_addPath($type, $path);
// Always add the fallback directories as last resort
switch (strtolower($type)) {
case 'template':
// Set the alternative template search dir
if (isset($app)) {
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName();
//if it is T3 template, update search path for template
if (T3Common::detect()) {
if (is_array($fallback1 = T3Path::getPath('html' . DS . $component . DS . $this->getName(), true))) {
$fallback = array_reverse($fallback1);
}
}
$this->_addPath('template', $fallback);
}
break;
}
}
示例13: createURL
/**
* Create a URL for a given help key reference
*
* @param string $ref The name of the help screen (its key reference)
* @param boolean $useComponent Use the help file in the component directory
* @param string $override Use this URL instead of any other
* @param string $component Name of component (or null for current component)
*
* @return string
*
* @since 11.1
*/
public static function createURL($ref, $useComponent = false, $override = null, $component = null)
{
$local = false;
$app = JFactory::getApplication();
if (is_null($component)) {
$component = JApplicationHelper::getComponentName();
}
// Determine the location of the help file. At this stage the URL
// can contain substitution codes that will be replaced later.
if ($override) {
$url = $override;
} else {
// Get the user help URL.
$user = JFactory::getUser();
$url = $user->getParam('helpsite');
// If user hasn't specified a help URL, then get the global one.
if ($url == '') {
$url = $app->getCfg('helpurl');
}
// Component help URL overrides user and global.
if ($useComponent) {
// Look for help URL in component parameters.
$params = JComponentHelper::getParams($component);
$url = $params->get('helpURL');
if ($url == '') {
$local = true;
$url = 'components/{component}/help/{language}/{keyref}';
}
}
// Set up a local help URL.
if (!$url) {
$local = true;
$url = 'help/{language}/{keyref}';
}
}
// If the URL is local then make sure we have a valid file extension on the URL.
if ($local) {
if (!preg_match('#\\.html$|\\.xml$#i', $ref)) {
$url .= '.html';
}
}
/*
* Replace substitution codes in the URL.
*/
$lang = JFactory::getLanguage();
$version = new JVersion();
$jver = explode('.', $version->getShortVersion());
$jlang = explode('-', $lang->getTag());
$debug = $lang->setDebug(false);
$keyref = JText::_($ref);
$lang->setDebug($debug);
// Replace substitution codes in help URL.
$search = array('{app}', '{component}', '{keyref}', '{language}', '{langcode}', '{langregion}', '{major}', '{minor}', '{maintenance}');
$replace = array($app->getName(), $component, $keyref, $lang->getTag(), $jlang[0], $jlang[1], $jver[0], $jver[1], $jver[2]);
// If the help file is local then check it exists.
// If it doesn't then fallback to English.
if ($local) {
$try = str_replace($search, $replace, $url);
jimport('joomla.filesystem.file');
if (!JFile::exists(JPATH_BASE . '/' . $try)) {
$replace[3] = 'en-GB';
$replace[4] = 'en';
$replace[5] = 'GB';
}
}
$url = str_replace($search, $replace, $url);
return $url;
}
示例14: getAdminComponentPath
public function getAdminComponentPath()
{
return JURI::base() . 'component' . DS . JApplicationHelper::getComponentName() . DS;
}
示例15: _setPath
/**
* Sets an entire array of search paths for templates or resources.
*
* @param string $type The type of path to set, typically 'template'.
* @param mixed $path The new search path, or an array of search paths. If null or false, resets to the current directory only.
*
* @return void
*
* @since 12.2
*/
protected function _setPath($type, $path)
{
$component = JApplicationHelper::getComponentName();
$app = JFactory::getApplication();
// Clear out the prior search dirs
$this->_path[$type] = array();
// Actually add the user-specified directories
$this->_addPath($type, $path);
// Always add the fallback directories as last resort
switch (strtolower($type)) {
case 'template':
// Set the alternative template search dir
if (isset($app)) {
$component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
$fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName();
$this->_addPath('template', $fallback);
}
break;
}
}