本文整理汇总了PHP中JPath::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP JPath::clean方法的具体用法?PHP JPath::clean怎么用?PHP JPath::clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JPath
的用法示例。
在下文中一共展示了JPath::clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __getList
/**
* get the list of k2 items
*
* @param JParameter $params;
* @return Array
*/
public function __getList($params)
{
$mainframe =& JFactory::getApplication();
$maxTitle = $params->get('max_title', '100');
$maxDesciption = $params->get('max_description', 100);
$openTarget = $params->get('open_target', 'parent');
$formatter = $params->get('style_displaying', 'title');
$titleMaxChars = $params->get('title_max_chars', '100');
$descriptionMaxChars = $params->get('description_max_chars', 100);
$condition = $this->buildConditionQuery($params);
$ordering = $params->get('k2_ordering', 'created_asc');
$limit = $params->get('limit_items', 5);
$ordering = str_replace('_', ' ', $ordering);
$my =& JFactory::getUser();
$aid = $my->get('aid', 0);
$thumbWidth = (int) $params->get('thumbnail_width', 35);
$thumbHeight = (int) $params->get('thumbnail_height', 60);
$imageHeight = (int) $params->get('main_height', 300);
$imageWidth = (int) $params->get('main_width', 660);
$isThumb = $params->get('auto_renderthumb', 1);
$isStripedTags = $params->get('auto_strip_tags', 0);
$extraURL = $params->get('open_target') != 'modalbox' ? '' : '&tmpl=component';
$db =& JFactory::getDBO();
$date =& JFactory::getDate();
$now = $date->toMySQL();
require_once JPath::clean(JPATH_SITE . '/components/com_k2/helpers/route.php');
$query = "SELECT a.*, cr.rating_sum/cr.rating_count as rating, c.name as categoryname,\n c.id as categoryid, c.alias as categoryalias, c.params as categoryparams, cc.commentcount as commentcount" . " FROM #__k2_items as a" . " LEFT JOIN #__k2_categories c ON c.id = a.catid" . " LEFT JOIN #__k2_rating as cr ON a.id = cr.itemid" . " LEFT JOIN (select cm.itemid as id, count(cm.id) as commentcount from #__k2_comments as cm\n where cm.published=1 group by cm.itemid) as cc on a.id = cc.id";
$query .= " WHERE a.published = 1" . " AND a.access <= {$aid}" . " AND a.trash = 0" . " AND c.published = 1" . " AND c.access <= {$aid}" . " AND c.trash = 0 ";
if ($params->get('featured_items_show', '0') == 0) {
$query .= " AND a.featured != 1";
} elseif ($params->get('featured_items_show', '0') == 2) {
$query .= " AND a.featured = 1";
}
$query .= $condition . ' ORDER BY ' . $ordering;
$query .= $limit ? ' LIMIT ' . $limit : '';
$db->setQuery($query);
$data = $db->loadObjectlist();
if (empty($data)) {
return array();
}
foreach ($data as $key => &$item) {
if ($item->access <= $aid) {
$item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . $item->categoryalias) . $extraURL);
} else {
$item->link = JRoute::_('index.php?option=com_user&view=login');
}
$item->date = JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
$item->subtitle = self::substring($item->title, $titleMaxChars);
$item->description = self::substring($item->introtext, $descriptionMaxChars, true);
$item = self::parseImages($item);
if ($item->mainImage && ($image = $this->renderThumb($item->mainImage, $imageWidth, $imageHeight, $item->title, $isThumb))) {
$item->mainImage = $image;
}
$item->rating = is_numeric($item->rating) ? floatval($item->rating / 5 * 100) : null;
if ($item->thumbnail && ($image = $this->renderThumb($item->thumbnail, $thumbWidth, $thumbHeight, $item->title, $isThumb))) {
$item->thumbnail = $image;
}
}
return $data;
}
示例2: 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;
}
示例3: addSubmenu
/**
* Configure the Submenu links.
*
* @param string The extension being used for the categories.
*
* @return void
* @since 1.6
*/
public static function addSubmenu($extension)
{
// Avoid nonsense situation.
if ($extension == 'com_categories') {
return;
}
$parts = explode('.', $extension);
$component = $parts[0];
if (count($parts) > 1) {
$section = $parts[1];
}
// Try to find the component helper.
$eName = str_replace('com_', '', $component);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');
if (file_exists($file)) {
require_once $file;
$prefix = ucfirst(str_replace('com_', '', $component));
$cName = $prefix . 'Helper';
if (class_exists($cName)) {
if (is_callable(array($cName, 'addSubmenu'))) {
$lang = JFactory::getLanguage();
// loading language file from the administrator/language directory then
// loading language file from the administrator/components/*extension*/language directory
$lang->load($component, JPATH_BASE, null, false, false) || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false) || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);
call_user_func(array($cName, 'addSubmenu'), 'categories' . (isset($section) ? '.' . $section : ''));
}
}
}
}
示例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: 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);
}
示例6: getVarsToPush
public function getVarsToPush()
{
$black_list = array('spacer');
$data = array();
if (JVM_VERSION === 2) {
$filename = JPATH_SITE . '/plugins/' . $this->_type . '/' . $this->_name . '/' . $this->_name . '.xml';
} else {
$filename = JPATH_SITE . '/plugins/' . $this->_type . '/' . $this->_name . '.xml';
}
// Check of the xml file exists
$filePath = JPath::clean($filename);
if (is_file($filePath)) {
$xml = JFactory::getXMLParser('simple');
$result = $xml->loadFile($filename);
if ($result) {
if ($params = $xml->document->params) {
foreach ($params as $param) {
if ($param->_name = "params") {
if ($children = $param->_children) {
foreach ($children as $child) {
if (isset($child->_attributes['name'])) {
$data[$child->_attributes['name']] = array('', 'char');
$result = TRUE;
}
}
}
}
}
}
}
}
return $data;
}
示例7: 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;
}
示例8: 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();
}
}
示例9: 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();
}
示例10: _displayPopulate
function _displayPopulate($tpl)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$document = JFactory::getDocument();
$uri = JFactory::getURI();
$url = $uri->toString();
$model = $this->getModel();
$projectws = $this->get('Data', 'project');
$document->setTitle(JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TITLE'));
$lists = array();
$iScheduleType = 0;
$options = array();
$options[] = JHtml::_('select.option', $iScheduleType++, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_SINGLE_ROUND_ROBIN'));
$options[] = JHtml::_('select.option', $iScheduleType++, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_DOUBLE_ROUND_ROBIN'));
$path = JPath::clean(JPATH_ROOT . '/images/com_joomleague/database/round_populate_templates');
$files = JFolder::files($path, '.', false);
foreach ($files as $file) {
$filename = strtoupper(JFile::stripExt($file));
$options[] = JHtml::_('select.option', $file, JText::_('COM_JOOMLEAGUE_ADMIN_ROUNDS_POPULATE_TYPE_' . $filename));
}
// $lists['scheduling'] = JHtml::_('select.genericlist', $options, 'scheduling', 'onchange="handleOnChange_scheduling(this)"', 'value', 'text');
$lists['scheduling'] = JHtml::_('select.genericlist', $options, 'scheduling', '', 'value', 'text');
// $teams = $this->get('projectteams');
// $options = array();
// foreach ($teams as $t) {
// $options[] = JHtml::_('select.option', $t->projectteam_id, $t->text);
// }
// $lists['teamsorder'] = JHtml::_('select.genericlist', $options, 'teamsorder[]', 'multiple="multiple" size="20"');
$this->projectws = $projectws;
$this->request_url = $url;
$this->lists = $lists;
$this->addToolbar_Populate();
parent::display($tpl);
}
示例11: 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;
}
示例12: download
public function download()
{
$file = $this->input->get->get('file', null, 'raw');
if (!$file) {
JFactory::getApplication()->close(404);
}
$model = $this->getModel();
/** @var $model CrowdfundingModelLog */
try {
$fileSource = $model->prepareFile(JPath::clean($file));
$fileName = basename($fileSource);
$fileSize = filesize($fileSource);
$doc = JFactory::getDocument();
if (strcmp('error_log', $fileName) == 0) {
JResponse::setHeader('Content-Type', 'text/plain', true);
$doc->setMimeEncoding('text/plain');
} else {
JResponse::setHeader('Content-Type', 'application/octet-stream', true);
JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
$doc->setMimeEncoding('application/octet-stream');
}
JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
JResponse::setHeader('Pragma', 'no-cache', true);
JResponse::setHeader('Expires', '0', true);
JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $fileName, true);
JResponse::setHeader('Content-Length', $fileSize, true);
} catch (Exception $e) {
JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
}
echo file_get_contents($fileSource);
JFactory::getApplication()->close();
}
示例13: addSubmenu
/**
* Configure the Submenu links.
*
* @param string The extension being used for the categories.
*/
public function addSubmenu($extension)
{
// Avoid nonsense situation.
if ($extension == 'com_categories') {
return;
}
// Try to find the component helper.
$eName = str_replace('com_', '', $extension);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension . '/helpers/' . $eName . '.php');
if (file_exists($file)) {
require_once $file;
$prefix = ucfirst(str_replace('com_', '', $extension));
$cName = $prefix . 'Helper';
if (class_exists($cName)) {
if (is_callable(array($cName, 'addSubmenu'))) {
$lang =& JFactory::getLanguage();
// loading language file from the administrator/components/*extension*/language directory
$lang->load($extension, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $extension));
// loading language file from the administrator/language directory
$lang->load($extension);
call_user_func(array($cName, 'addSubmenu'), 'categories');
}
}
}
}
示例14: getInput
protected function getInput()
{
// Initialize variables.
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
// To avoid user's confusion, readonly="true" should imply disabled="true".
if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
$attr .= ' disabled="disabled"';
}
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
$attr .= $this->multiple ? ' multiple="multiple"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
// Get the field options.
$path = JPath::clean(JPATH_BASE . DS . 'components' . DS . 'com_k2');
if (file_exists($path)) {
$options = (array) $this->getOptions();
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true') {
$html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
} else {
if ($options[0] != '') {
$html[] = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
} else {
return '<select id="jform_params_k2_tags" style="display:none"></select><strong style="line-height: 2.6em">K2 is not installed or any K2 tags are available.</strong>';
}
}
} else {
return '<select id="jform_params_k2_tags" style="display:none"></select><strong style="line-height: 2.6em">K2 is not installed or any K2 tags are available.</strong>';
}
return implode($html);
}
示例15: getItem
function getItem()
{
global $mainframe;
jimport('joomla.filesystem.path');
if (!$this->template) {
return JError::raiseWarning(500, 'Template not specified');
}
$tBaseDir = JPath::clean(JPATH_RSGALLERY2_SITE . '/templates');
if (!is_dir($tBaseDir . '/' . $this->template)) {
return JError::raiseWarning(500, 'Template not found');
}
$lang =& JFactory::getLanguage();
$lang->load('tpl_' . $this->template, JPATH_RSGALLERY2_SITE);
$ini = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/params.ini';
$xml = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/templateDetails.xml';
$row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $this->template);
jimport('joomla.filesystem.file');
// Read the ini file
if (JFile::exists($ini)) {
$content = JFile::read($ini);
} else {
$content = null;
}
$params = new JParameter($content, $xml, 'template');
// Set FTP credentials, if given
jimport('joomla.client.helper');
$ftp =& JClientHelper::setCredentialsFromRequest('ftp');
$item = new stdClass();
$item->params = $params;
$item->row = $row;
$item->type = $this->_type;
$item->template = $this->template;
return $item;
}