本文整理汇总了PHP中JPath::find方法的典型用法代码示例。如果您正苦于以下问题:PHP JPath::find方法的具体用法?PHP JPath::find怎么用?PHP JPath::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPath
的用法示例。
在下文中一共展示了JPath::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Returns a reference to the a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string A prefix for the table class name
* @return database A database object
* @since 1.5
*/
function &getInstanceAutofields($type, $prefix, $table, $key = 'id', $defaults = array())
{
$type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
$tableClass = $prefix . ucfirst($type);
if (!class_exists($tableClass)) {
jimport('joomla.filesystem.path');
if ($path = JPath::find(RdbsTable::addIncludePath(), strtolower($type) . '.php')) {
require_once $path;
if (!class_exists($tableClass)) {
$tableClass = 'RdbsTable';
}
} else {
$tableClass = 'RdbsTable';
}
}
$db =& RdbsFactory::getDBO();
$instance = new $tableClass($table, $key, $db);
$instance->setDBO($db);
// get the table properties
$result = $db->getTableFields(array($table));
$fields = $result[$table];
foreach ($fields as $key => $val) {
if (count($defaults) != 0 and array_key_exists($key, $defaults)) {
$instance->set($key, $defaults[$key]);
} else {
if (strpos($val, 'int') === false and strpos($val, 'float') === false) {
$instance->set($key, '');
} else {
$instance->set($key, 0);
}
}
}
return $instance;
}
示例2: onContentPrepareForm
/**
*
* Enter description here ...
* @param JForm $form
* @param unknown $data
*/
function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->template = $this->getTemplateName();
if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) {
jimport('joomla.filesystem.path');
//JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params');
$plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml');
$tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml');
if (!$plg_file) {
return false;
}
if ($tpl_file) {
$form->loadFile($plg_file, false, '//form');
$form->loadFile($tpl_file, false, '//config');
} else {
$form->loadFile($plg_file, false, '//form');
}
if ($app->isSite()) {
$jmstorage_fields = $form->getFieldset('jmstorage');
foreach ($jmstorage_fields as $name => $field) {
$form->removeField($name, 'params');
}
$form->removeField('config', 'params');
}
if ($app->isAdmin()) {
$doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}');
}
}
}
示例3: createView
/**
* Overrides method to first lookup into potential extension for the view.
*/
protected function createView($name, $prefix = '', $type = '', $config = array())
{
$extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
foreach ($extensions as $e => $extension) {
$result = null;
// Clean the view name
$viewName = preg_replace('/[^A-Z0-9_]/i', '', $name);
$classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
$viewType = preg_replace('/[^A-Z0-9_]/i', '', $type);
// Build the view class name
$viewClassExtension = $classPrefix . $viewName . ucfirst($extension);
if (!class_exists($viewClassExtension)) {
jimport('joomla.filesystem.path');
$path = JPath::find($this->paths['view'], $this->createFileName('view', array('name' => $viewName, 'type' => $viewType)));
if ($path) {
require_once $path;
if (class_exists($viewClassExtension)) {
$result = new $viewClassExtension($config);
return $result;
}
}
} else {
$result = new $viewClassExtension($config);
return $result;
}
}
// Still here ? Then the extension doesn't override this, use regular view
return parent::createView($name, $prefix, $type, $config);
}
示例4: loadTemplate
/**
* Load a template file -- first look in the templates folder for an override
*
* @param string The name of the template source file ...
* automatically searches the template paths and compiles as needed.
* @param string The name of the layout...
* null or absent - use current layout (don't change behavior),
* '' - no layout prefix in the name of file
* not empty string - uses specified layout.
*
* @return string The output of the the template script.
* @since 1.0
*/
public function loadTemplate($tpl = null, $layout = null)
{
if (!is_string($layout)) {
return parent::loadTemplate($tpl);
}
// clear prior output
$this->_output = null;
$template = JFactory::getApplication()->getTemplate();
$layoutTemplate = $this->getLayoutTemplate();
if ($layout == '') {
if (empty($tpl)) {
return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file));
} else {
$file = $tpl;
}
} else {
//create the template file name based on the layout
$file = isset($tpl) ? $layout . '_' . $tpl : $layout;
}
// clean the file name
$file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file);
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl;
// Load the language file for the template
$lang = JFactory::getLanguage();
$lang->load('tpl_' . $template, JPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, false) || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", $lang->getDefault(), false, false);
// change the template folder if alternative layout is in different template
if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) {
$this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']);
}
// load the template script
jimport('joomla.filesystem.path');
$filetofind = $this->_createFileName('template', array('name' => $file));
$this->_template = JPath::find($this->_path['template'], $filetofind);
// If alternate layout can't be found, fall back to default layout
if ($this->_template == false) {
$filetofind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl)));
$this->_template = JPath::find($this->_path['template'], $filetofind);
}
if ($this->_template != false) {
// 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 $this->_template;
// done with the requested template; get the buffer and
// clear it.
$this->_output = ob_get_contents();
ob_end_clean();
return $this->_output;
} else {
return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file));
}
}
示例5: getPath
/**
* Method to finds the full real file path, checking possible overrides
*
* @return string The full path to the layout file
*
* @since 3.0
*/
protected function getPath()
{
JLoader::import('joomla.filesystem.path');
if (is_null($this->fullPath) && !empty($this->layoutId)) {
$this->addDebugMessage('<strong>Layout:</strong> ' . $this->layoutId);
/*
* Refresh paths - override is due to this line
* -commenting out to stop default paths being re-instated in render()
*
* $this->refreshIncludePaths(false);
*/
$this->addDebugMessage('<strong>Include Paths:</strong> ' . print_r($this->includePaths, true));
$suffixes = $this->options->get('suffixes', array());
// Search for suffixed versions. Example: tags.j31.php
if (!empty($suffixes)) {
$this->addDebugMessage('<strong>Suffixes:</strong> ' . print_r($suffixes, true));
foreach ($suffixes as $suffix) {
$rawPath = str_replace('.', '/', $this->layoutId) . '.' . $suffix . '.php';
$this->addDebugMessage('<strong>Searching layout for:</strong> ' . $rawPath);
if ($this->fullPath = JPath::find($this->includePaths, $rawPath)) {
$this->addDebugMessage('<strong>Found layout:</strong> ' . $this->fullPath);
return $this->fullPath;
}
}
}
// Standard version
$rawPath = str_replace('.', '/', $this->layoutId) . '.php';
$this->addDebugMessage('<strong>Searching layout for:</strong> ' . $rawPath);
$this->fullPath = JPath::find($this->includePaths, $rawPath);
if ($this->fullPath = JPath::find($this->includePaths, $rawPath)) {
$this->addDebugMessage('<strong>Found layout:</strong> ' . $this->fullPath);
}
}
return $this->fullPath;
}
示例6: 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;
}
示例7: getInstance
/**
* Returns a reference to the a Helper object, only creating it if it doesn't already exist
*
* @param type $type The helper type to instantiate
* @param string $prefix A prefix for the helper class name. Optional.
* @return helper The Helper Object
*/
public static function getInstance($type = 'Base', $prefix = 'TiendaHelper')
{
//parent::getInstance( $type , $prefix );
static $instances;
if (!isset($instances)) {
$instances = array();
}
$type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
// The Base helper is in _base.php, but it's named TiendaHelperBase
if (strtolower($type) == 'Base') {
$helperClass = $prefix . ucfirst($type);
$type = '_Base';
}
$helperClass = $prefix . ucfirst($type);
if (empty($instances[$helperClass])) {
if (!class_exists($helperClass)) {
jimport('joomla.filesystem.path');
if ($path = JPath::find(TiendaHelperBase::addIncludePath(), strtolower($type) . '.php')) {
require_once $path;
if (!class_exists($helperClass)) {
JError::raiseWarning(0, 'Helper class ' . $helperClass . ' not found in file.');
return false;
}
} else {
JError::raiseWarning(0, 'Helper ' . $type . ' not supported. File not found.');
return false;
}
}
$instance = new $helperClass();
$instances[$helperClass] =& $instance;
}
return $instances[$helperClass];
}
示例8: getInstance
/**
* Overrides method to try to load model from extension if it exists
*/
public static function getInstance($type, $prefix = '', $config = array())
{
$extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
foreach ($extensions as $e => $extension) {
$modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
$modelClass = $prefix . ucfirst($modelType) . ucfirst($extension);
$result = false;
if (!class_exists($modelClass)) {
jimport('joomla.filesystem.path');
$path = JPath::find(parent::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type)));
if (!$path) {
$path = JPath::find(parent::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type)));
}
if ($path) {
require_once $path;
if (class_exists($modelClass)) {
$result = new $modelClass($config);
return $result;
}
}
} else {
$result = new $modelClass($config);
return $result;
}
}
// Still here ? Then the extension doesn't override this, use regular way
return parent::getInstance($type, $prefix, $config);
}
示例9: array
/**
* Overrides method to try to load model from extension if it exists
*/
public static function &getInstance($type, $prefix = '', $config = array())
{
$extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p'));
foreach ($extensions as $e => $extension) {
$modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
$modelClass = $prefix . ucfirst($modelType) . ucfirst($extension);
$result = false;
if (!class_exists($modelClass)) {
jimport('joomla.filesystem.path');
$path = JPath::find(JModel::addIncludePath(), JModel::_createFileName('model', array('name' => $modelType)));
if ($path) {
require_once $path;
if (class_exists($modelClass)) {
$result = new $modelClass($config);
return $result;
}
}
} else {
$result = new $modelClass($config);
return $result;
}
}
$instance = parent::getInstance($type, $prefix, $config);
return $instance;
}
示例10: setupTheme
public function setupTheme()
{
// Load our CSS and Javascript files
if (!$this->isJFBConnectInstalled) {
$this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/sc_bootstrap.css');
}
$this->doc->addStyleSheet(JURI::base(true) . '/media/sourcecoast/css/common.css');
$paths = array();
$paths[] = JPATH_ROOT . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/mod_sclogin/themes/';
$paths[] = JPATH_ROOT . '/media/sourcecoast/themes/sclogin/';
$theme = $this->params->get('theme', 'default.css');
$file = JPath::find($paths, $theme);
$file = str_replace(JPATH_SITE, '', $file);
$file = str_replace('\\', "/", $file);
//Windows support for file separators
$this->doc->addStyleSheet(JURI::base(true) . $file);
// Add placeholder Javascript for old browsers that don't support the placeholder field
if ($this->user->guest) {
jimport('joomla.environment.browser');
$browser = JBrowser::getInstance();
$browserType = $browser->getBrowser();
$browserVersion = $browser->getMajor();
if ($browserType == 'msie' && $browserVersion <= 9) {
// Using addCustomTag to ensure this is the last section added to the head, which ensures that jfbcJQuery has been defined
$this->doc->addCustomTag('<script src="' . JURI::base(true) . '/media/sourcecoast/js/jquery.placeholder.js" type="text/javascript"> </script>');
$this->doc->addCustomTag("<script>jfbcJQuery(document).ready(function() { jfbcJQuery('input').placeholder(); });</script>");
}
}
}
示例11: _
/**
* Class loader method
*
* Additional arguments may be supplied and are passed to the sub-class.
* Additional include paths are also able to be specified for third-party use
*
* @param string $key The name of helper method to load, (prefix).(class).function
* prefix and class are optional and can be used to load custom
* html helpers.
*
* @return mixed JHtml::call($function, $args) or False on error
*
* @since 1.0
* @throws InvalidArgumentException
*/
public static function _($key)
{
list($key, $prefix, $file, $func) = static::extract($key);
if (array_key_exists($key, static::$registry)) {
$function = static::$registry[$key];
$args = func_get_args();
// Remove function name from arguments
array_shift($args);
return static::call($function, $args);
}
$className = $prefix . ucfirst($file);
if (!class_exists($className)) {
$path = JPath::find(static::$includePaths, strtolower($file) . '.php');
if ($path) {
require_once $path;
if (!class_exists($className)) {
throw new InvalidArgumentException(sprintf('%s not found.', $className), 500);
}
} else {
throw new InvalidArgumentException(sprintf('%s %s not found.', $prefix, $file), 500);
}
}
$toCall = array($className, $func);
if (is_callable($toCall)) {
static::register($key, $toCall);
$args = func_get_args();
// Remove function name from arguments
array_shift($args);
return static::call($toCall, $args);
} else {
throw new InvalidArgumentException(sprintf('%s::%s not found.', $className, $func), 500);
}
}
示例12: getInstance
/**
* Returns a Controller object, always creating it
*
* @param string $type The contlorer type to instantiate
* @param string $prefix Prefix for the controller class name. Optional.
* @param array $config Configuration array for controller. Optional.
*
* @return mixed A model object or false on failure
*
* @since 1.1.0
*/
public static function getInstance($type, $prefix = '', $config = array())
{
// Check for array format.
$filter = JFilterInput::getInstance();
$type = $filter->clean($type, 'cmd');
$prefix = $filter->clean($prefix, 'cmd');
$controllerClass = $prefix . ucfirst($type);
if (!class_exists($controllerClass)) {
if (!isset(self::$paths[$controllerClass])) {
// Get the environment configuration.
$basePath = JArrayHelper::getValue($config, 'base_path', JPATH_COMPONENT);
$nameConfig = empty($type) ? array('name' => 'controller') : array('name' => $type, 'format' => JFactory::getApplication()->input->get('format', '', 'word'));
// Define the controller path.
$paths[] = $basePath . '/controllers';
$paths[] = $basePath;
$path = JPath::find($paths, self::createFileName($nameConfig));
self::$paths[$controllerClass] = $path;
// If the controller file path exists, include it.
if ($path) {
require_once $path;
}
}
if (!class_exists($controllerClass)) {
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $controllerClass), JLog::WARNING, 'kextensions');
return false;
}
}
return new $controllerClass($config);
}
示例13: loadTemplate
public function loadTemplate($tpl = null)
{
$this->_output = null;
$template = JFactory::getApplication()->getTemplate();
$layout = $this->getLayout();
$layoutTemplate = $this->getLayoutTemplate();
$file = isset($tpl) ? $layout . '_' . $tpl : $layout;
$file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file);
$tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl;
$lang = JFactory::getLanguage();
$lang->load('tpl_' . $template, JPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, true);
if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) {
$this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']);
}
jimport('joomla.filesystem.path');
$jversion_arr = explode(".", JVERSION);
$priVersion = $jversion_arr[0];
$subVersion = $jversion_arr[1];
$fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . $subVersion));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
if ($this->_template == false) {
$fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . 'x'));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
}
if ($this->_template == false) {
$fileToFind = $this->_createFileName('template', array('name' => $file));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
}
if ($this->_template == false) {
$fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . $subVersion . (isset($tpl) ? '_' . $tpl : $tpl)));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
if ($this->_template == false) {
$fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . 'x' . (isset($tpl) ? '_' . $tpl : $tpl)));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
}
if ($this->_template == false) {
$fileToFind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl)));
$this->_template = JPath::find($this->_path['template'], $fileToFind);
}
}
if ($this->_template != false) {
unset($tpl);
unset($file);
if (isset($this->this)) {
unset($this->this);
}
ob_start();
include $this->_template;
$this->_output = ob_get_contents();
ob_end_clean();
return $this->_output;
} else {
throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
}
}
示例14: getForm
public function getForm($data = array(), $loadData = true)
{
if ($data) {
$data = (object) $data;
} else {
$data = $this->getItem();
}
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
$style_xml_path = JPath::find(JForm::addFormPath(), strtolower('style') . '.xml');
$style_xml = JFactory::getXML($style_xml_path, true);
if (isset($data->template_id) && $data->template_id) {
$styleObject = JUDownloadFrontHelperTemplate::getTemplateStyleObject($data->id);
$folder = $styleObject->folder;
$folder = strtolower(str_replace(' ', '', $folder));
if ($folder) {
$xml_file = JPath::clean(JPATH_SITE . "/components/com_judownload/templates/" . $folder . "/" . $folder . '.xml');
if (JFile::exists($xml_file)) {
$xml = JFactory::getXML($xml_file);
if ($xml->config) {
foreach ($xml->config->children() as $child) {
$style_params_xpath = $style_xml->xpath('//fieldset[@name="params"]');
JUDownloadHelper::appendXML($style_params_xpath[0], $child);
}
if ($xml->languages->count()) {
foreach ($xml->languages->children() as $language) {
$languageFile = (string) $language;
$first_pos = strpos($languageFile, '.');
$last_pos = strrpos($languageFile, '.');
$languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
$client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
$path = isset($client->path) ? $client->path : JPATH_BASE;
JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
}
}
}
}
}
}
$form = $this->loadForm('com_judownload.style', $style_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
$app = JFactory::getApplication();
$id = $app->input->get('id', 0);
if ($id) {
$form->setFieldAttribute('template_id', 'disabled', 'true');
$form->setFieldAttribute('template_id', 'filter', 'unset');
if (isset($data->home) && $data->home == 1) {
$form->setFieldAttribute('home', 'disabled', 'true');
}
}
return $form;
}
示例15: _getDefaultTemplate
/**
* Gets the default template, searching for it in the
* html/com_jsolrsearch/browse/ first, then loading the default.php
* template from the extension's views/browse/tmpl folder.
*
* To override the default browse page, place a file called
* <override>_<extension>.php in the html/com_jsolrsearch/browse/ directory,
* where <override> is the name of the base layout you are overriding (in
* most cases this will be "default"), and <extension> is the name of the
* component whose data you are trying to browse.
*
* E.g.
*
* default_content.php
*/
private function _getDefaultTemplate()
{
$o = JFactory::getApplication()->input->get('o');
$extension = str_replace("com_", "", $o);
$override = $this->getLayout() . '_' . $extension . '.php';
$themeOverridePath = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_jsolrsearch/browse';
if (JPath::find($themeOverridePath, $override)) {
return $extension;
} else {
return null;
}
}