本文整理汇总了PHP中JPath类的典型用法代码示例。如果您正苦于以下问题:PHP JPath类的具体用法?PHP JPath怎么用?PHP JPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* Upload files and attach them to an issue or a comment.
*
* @param array $files Array containing the uploaded files.
* @param int $issueId ID of the issue/comment where to attach the files.
* @param int $commentId One of 'issue' or 'comment', indicating if the files should be attached to an issue or a comment.
*
* @return boolean True on success, false otherwise.
*/
public function upload($files, $issueId, $commentId = null)
{
if (!$issueId || !is_array($files)) {
return false;
}
jimport('joomla.filesystem.file');
if ($commentId) {
$type = 'comment';
$id = $commentId;
} else {
$type = 'issue';
$id = $issueId;
}
foreach ($files as $file) {
$rand = MonitorHelper::genRandHash();
$pathParts = array($type, $id, $rand . '-' . $file[0]['name']);
$path = JPath::clean(implode(DIRECTORY_SEPARATOR, $pathParts));
$values = array('issue_id' => $issueId, 'comment_id' => $commentId, 'path' => $path, 'name' => $file[0]['name']);
if (!JFile::upload($file[0]['tmp_name'], $this->pathPrefix . $path)) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MONITOR_ATTACHMENT_UPLOAD_FAILED', $file[0]['name']));
return false;
}
$query = $this->db->getQuery(true);
$query->insert('#__monitor_attachments')->set(MonitorHelper::sqlValues($values, $query));
$this->db->setQuery($query);
if ($this->db->execute() === false) {
return false;
}
}
return true;
}
示例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: admin_postinstall_eaccelerator_action
/**
* Disables the unsupported eAccelerator caching method, replacing it with the
* "file" caching method.
*
* @return void
*
* @since 3.2
*/
function admin_postinstall_eaccelerator_action()
{
$prev = new JConfig();
$prev = JArrayHelper::fromObject($prev);
$data = array('cacheHandler' => 'file');
$data = array_merge($prev, $data);
$config = new Registry('config');
$config->loadArray($data);
jimport('joomla.filesystem.path');
jimport('joomla.filesystem.file');
// Set the configuration file path.
$file = JPATH_CONFIGURATION . '/configuration.php';
// Get the new FTP credentials.
$ftp = JClientHelper::getCredentials('ftp', true);
// Attempt to make the file writeable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
}
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
if (!JFile::write($file, $configuration)) {
JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
return;
}
// Attempt to make the file unwriteable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
}
}
示例4: getFilePath
/**
* Retrieve path to file in hard disk based from file URL
*
* @param string $file URL to the file
* @return string
*/
public static function getFilePath($file)
{
// Located file from root
if (strpos($file, '/') === 0) {
if (file_exists($tmp = realpath(str_replace(JUri::root(true), JPATH_ROOT, $file)))) {
return $tmp;
} elseif (file_exists($tmp = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $file))) {
return $tmp;
} elseif (file_exists($tmp = realpath(JPATH_ROOT . '/' . $file))) {
return $tmp;
}
}
if (strpos($file, '://') !== false && JURI::isInternal($file)) {
$path = parse_url($file, PHP_URL_PATH);
if (file_exists($tmp = realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $path))) {
return $tmp;
} elseif (file_exists($tmp = realpath(JPATH_ROOT . '/' . $path))) {
return $tmp;
}
}
$rootURL = JUri::root();
$currentURL = JUri::current();
$currentPath = JPATH_ROOT . '/' . substr($currentURL, strlen($rootURL));
$currentPath = str_replace(DIRECTORY_SEPARATOR, '/', $currentPath);
$currentPath = dirname($currentPath);
return JPath::clean($currentPath . '/' . $file);
}
示例5: extract
/**
* Extract a ZIP compressed file to a given path
*
* @access public
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
function extract($archive, $destination, $options = array())
{
// Initialize variables
$this->_data = null;
$this->_metadata = null;
if (!($this->_data = JFile::read($archive))) {
$this->set('error.message', 'Unable to read archive');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (!$this->_getTarInfo($this->_data)) {
return JError::raiseWarning(100, $this->get('error.message'));
}
for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) {
$type = strtolower($this->_metadata[$i]['type']);
if ($type == 'file' || $type == 'unix file') {
$buffer = $this->_metadata[$i]['data'];
$path = JPath::clean($destination . DS . $this->_metadata[$i]['name']);
// Make sure the destination folder exists
if (!JFolder::create(dirname($path))) {
$this->set('error.message', 'Unable to create destination');
return JError::raiseWarning(100, $this->get('error.message'));
}
if (JFile::write($path, $buffer) === false) {
$this->set('error.message', 'Unable to write entry');
return JError::raiseWarning(100, $this->get('error.message'));
}
}
}
return true;
}
示例6: 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;
}
示例7: 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>");
}
}
}
示例8: getInput
function getInput()
{
$lang = JFactory::getLanguage();
$extension = "com_joomleague";
$source = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension);
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension, $source, null, false, false) || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension, $source, $lang->getDefault(), false, false);
$mitems = array();
$mitems[] = JHtml::_('select.option', 0, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NICK_LAST'));
$mitems[] = JHtml::_('select.option', 1, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_NICK_FIRST'));
$mitems[] = JHtml::_('select.option', 2, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST_NICK'));
$mitems[] = JHtml::_('select.option', 3, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST'));
$mitems[] = JHtml::_('select.option', 4, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST'));
$mitems[] = JHtml::_('select.option', 5, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK_FIRST_LAST'));
$mitems[] = JHtml::_('select.option', 6, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK_LAST_FIRST'));
$mitems[] = JHtml::_('select.option', 7, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST_NICK'));
$mitems[] = JHtml::_('select.option', 8, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST2'));
$mitems[] = JHtml::_('select.option', 9, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST2'));
$mitems[] = JHtml::_('select.option', 10, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST'));
$mitems[] = JHtml::_('select.option', 11, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NICK_LAST2'));
$mitems[] = JHtml::_('select.option', 12, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_NICK'));
$mitems[] = JHtml::_('select.option', 13, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_LAST3'));
$mitems[] = JHtml::_('select.option', 14, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST2_FIRST'));
$mitems[] = JHtml::_('select.option', 15, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_NEWLINE_FIRST'));
$mitems[] = JHtml::_('select.option', 16, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_FIRST_NEWLINE_LAST'));
$mitems[] = JHtml::_('select.option', 17, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRST_NICK'));
$mitems[] = JHtml::_('select.option', 18, JText::_('COM_JOOMLEAGUE_GLOBAL_NAME_FORMAT_LAST_FIRSTNAME_FIRST_CHAR_DOT'));
$output = JHtml::_('select.genericlist', $mitems, $this->name, 'class="inputbox" size="1"', 'value', 'text', $this->value, $this->id);
return $output;
}
示例9: onAfterDelete
/**
* Pre-processor for $table->delete($pk)
*
* @param mixed $pk An optional primary key value to delete. If not set the instance property value is used.
*
* @return void
*
* @since 3.1.2
* @throws UnexpectedValueException
*/
public function onAfterDelete($pk)
{
$params = JComponentHelper::getParams('com_gamification');
/** @var $params Joomla\Registry\Registry */
$filesystemHelper = new Prism\Filesystem\Helper($params);
$mediaFolder = $filesystemHelper->getMediaFolder();
if ($this->table->get('image') !== null and $this->table->get('image') !== '') {
$file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image'));
if (JFile::exists($file)) {
JFile::delete($file);
}
}
if ($this->table->get('image_small') !== null and $this->table->get('image_small') !== '') {
$file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image_small'));
if (JFile::exists($file)) {
JFile::delete($file);
}
}
if ($this->table->get('image_square') !== null and $this->table->get('image_square') !== '') {
$file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $mediaFolder . DIRECTORY_SEPARATOR . $this->table->get('image_square'));
if (JFile::exists($file)) {
JFile::delete($file);
}
}
}
示例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: downloadLangInstaller
public function downloadLangInstaller($resources, $language)
{
// check tmp
if ($warning = $this->app->zlfw->path->checkSystemPaths()) {
$response['success'] = false;
$response['errors'][] = $warning;
echo json_encode($response);
jexit();
}
$this->_initCheck();
// set default file name
$filename = $language . '.' . (count($resources) > 1 ? 'language_pack' : $resources[0]) . '.zip';
// set url
$url = self::$apiUrl . 'getLangInstaller&resources=' . implode(',', $resources) . '&language=' . $language;
// attempt to override file name with one from header response
$headers = get_headers($url, 1);
if (isset($headers['Content-Disposition'])) {
if (preg_match('/name="(?P<filename>.+?)"/', $headers['Content-Disposition'], $matches)) {
$filename = $matches['filename'];
}
}
// set file destination
$file = JPath::clean(JPATH_SITE . '/tmp/' . $filename);
// download
$result = $this->app->zl->extensions->download($url, $file);
return $file;
}
示例12: connector
function connector()
{
$mainframe = JFactory::getApplication();
$params = JComponentHelper::getParams('com_digicom');
$root = $params->get('ftp_source_path', 'digicom');
$folder = JRequest::getVar('folder', $root, 'default', 'path');
if (JString::trim($folder) == "") {
$folder = $root;
} else {
// Ensure that we are always below the root directory
if (strpos($folder, $root) !== 0) {
$folder = $root;
}
}
// Disable debug
JRequest::setVar('debug', false);
$url = JURI::root(true) . '/' . $folder;
$path = JPATH_SITE . '/' . JPath::clean($folder);
JPath::check($path);
include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderConnector.class.php';
include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinder.class.php';
include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderVolumeDriver.class.php';
include_once JPATH_COMPONENT_ADMINISTRATOR . '/libs/elfinder/elFinderVolumeLocalFileSystem.class.php';
function access($attr, $path, $data, $volume)
{
$mainframe = JFactory::getApplication();
// Hide PHP files.
$ext = strtolower(JFile::getExt(basename($path)));
if ($ext == 'php') {
return true;
}
// Hide files and folders starting with .
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
return true;
}
// Read only access for front-end. Full access for administration section.
switch ($attr) {
case 'read':
return true;
break;
case 'write':
return $mainframe->isSite() ? false : true;
break;
case 'locked':
return $mainframe->isSite() ? true : false;
break;
case 'hidden':
return false;
break;
}
}
if ($mainframe->isAdmin()) {
$permissions = array('read' => true, 'write' => true);
} else {
$permissions = array('read' => true, 'write' => false);
}
$options = array('debug' => false, 'roots' => array(array('driver' => 'LocalFileSystem', 'path' => $path, 'URL' => $url, 'accessControl' => 'access', 'defaults' => $permissions)));
$connector = new elFinderConnector(new elFinder($options));
$connector->run();
}
示例13: remove
/**
* Remove an extra image from database and file system.
*
* <code>
* $imageId = 1;
* $imagesFolder = "/.../folder";
*
* $image = new CrowdFundingImageRemoverExtra(JFactory::getDbo(), $image, $imagesFolder);
* $image->remove();
* </code>
*/
public function remove()
{
// Get the image
$query = $this->db->getQuery(true);
$query->select("a.image, a.thumb")->from($this->db->quoteName("#__crowdf_images", "a"))->where("a.id = " . (int) $this->imageId);
$this->db->setQuery($query);
$row = $this->db->loadObject();
if (!empty($row)) {
// Remove the image from the filesystem
$file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->image);
if (JFile::exists($file)) {
JFile::delete($file);
}
// Remove the thumbnail from the filesystem
$file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->thumb);
if (JFile::exists($file)) {
JFile::delete($file);
}
// Delete the record
$query = $this->db->getQuery(true);
$query->delete($this->db->quoteName("#__crowdf_images"))->where($this->db->quoteName("id") . " = " . (int) $this->imageId);
$this->db->setQuery($query);
$this->db->execute();
}
}
示例14: 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);
}
示例15: cssPath
/**
*
* Check and convert to css real path
* @var url
*/
public static function cssPath($url = '')
{
$url = preg_replace('#[?\\#]+.*$#', '', $url);
$base = JURI::base();
$root = JURI::root(true);
$path = false;
$ret = false;
if (substr($url, 0, 2) === '//') {
//check and append if url is omit http
$url = JURI::getInstance()->getScheme() . ':' . $url;
}
//check for css file extensions
foreach (self::$cssexts as $ext) {
if (substr_compare($url, $ext, -strlen($ext), strlen($ext)) === 0) {
$ret = true;
break;
}
}
if ($ret) {
if (preg_match('/^https?\\:/', $url)) {
//is full link
if (strpos($url, $base) === false) {
// external css
return false;
}
$path = JPath::clean(JPATH_ROOT . '/' . substr($url, strlen($base)));
} else {
$path = JPath::clean(JPATH_ROOT . '/' . ($root && strpos($url, $root) === 0 ? substr($url, strlen($root)) : $url));
}
return is_file($path) ? $path : false;
}
return false;
}