本文整理汇总了PHP中JFile::stripext方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::stripext方法的具体用法?PHP JFile::stripext怎么用?PHP JFile::stripext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::stripext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJoomlaTemplate
public static function getJoomlaTemplate($view = 'category')
{
$clientId = 0;
$client = JApplicationHelper::getClientInfo($clientId);
$extn = 'com_judirectory';
$lang = JFactory::getLanguage();
$items = array();
if ($extn && $view && $client) {
$lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false);
$component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
$groups = array();
$groups['inherit'] = array();
$groups['inherit']['id'] = 'layout_inherit';
$groups['inherit']['text'] = '---' . JText::_('COM_JUDIRECTORY_INHERIT') . '---';
$groups['inherit']['items'] = array();
if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.xml$', false, true))) {
$groups['_'] = array();
$groups['_']['id'] = 'layout__';
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT');
$groups['_']['items'] = array();
foreach ($component_layouts as $i => $file) {
if (!($xml = simplexml_load_file($file))) {
unset($component_layouts[$i]);
continue;
}
if (!($menu = $xml->xpath('layout[1]'))) {
unset($component_layouts[$i]);
continue;
}
$menu = $menu[0];
$value = JFile::stripext(JFile::getName($file));
$component_layouts[$i] = $value;
$text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value);
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
$items['_'][$value] = $text;
}
}
}
return $items;
}
示例2: getInput
protected function getInput()
{
$clientId = $this->element['client_id'];
if (is_null($clientId) && $this->form instanceof JForm) {
$clientId = $this->form->getValue('client_id');
}
$clientId = (int) $clientId;
$client = JApplicationHelper::getClientInfo($clientId);
$extn = (string) $this->element['extension'];
if (empty($extn) && $this->form instanceof JForm) {
$extn = $this->form->getValue('extension');
}
$extn = preg_replace('#\\W#', '', $extn);
$template = (string) $this->element['template'];
$template = preg_replace('#\\W#', '', $template);
if ($this->form instanceof JForm) {
$template_style_id = $this->form->getValue('template_style_id');
}
$template_style_id = preg_replace('#\\W#', '', $template_style_id);
$view = (string) $this->element['view'];
$view = preg_replace('#\\W#', '', $view);
if ($extn && $view && $client) {
$lang = JFactory::getLanguage();
$lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('e.element, e.name');
$query->from('#__extensions AS e');
$query->where('e.client_id = ' . (int) $clientId);
$query->where('e.type = ' . $db->quote('template'));
$query->where('e.enabled = 1');
if ($template) {
$query->where('e.element = ' . $db->quote($template));
}
if ($template_style_id) {
$query->join('LEFT', '#__template_styles AS s on s.template=e.element');
$query->where('s.id=' . (int) $template_style_id);
}
$db->setQuery($query);
$templates = $db->loadObjectList('element');
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
$component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
$component_layouts = array();
$groups = array();
$items = array();
if ($this->element['useinherit']) {
$groups['inherit'] = array();
$groups['inherit']['id'] = $this->id . '_inherit';
$groups['inherit']['text'] = '---' . JText::_('COM_JUDOWNLOAD_INHERIT') . '---';
$groups['inherit']['items'] = array();
}
if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.xml$', false, true))) {
$groups['_'] = array();
$groups['_']['id'] = $this->id . '__';
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT');
$groups['_']['items'] = array();
foreach ($component_layouts as $i => $file) {
if (!($xml = simplexml_load_file($file))) {
unset($component_layouts[$i]);
continue;
}
if (!($menu = $xml->xpath('layout[1]'))) {
unset($component_layouts[$i]);
continue;
}
$menu = $menu[0];
$value = JFile::stripext(JFile::getName($file));
$component_layouts[$i] = $value;
$text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value);
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
$items['_'][$value] = $text;
}
}
if ($this->element['useinherit']) {
$appendinherit = "";
if ($this->form->getValue("parent_id")) {
$appendinherit = $this->calculatorInheritLayout($items, $this->form->getValue("parent_id"));
}
$appendGlobal = $this->getLayout($items);
$groups['inherit']['items'][] = JHtml::_('select.option', '-2', JText::_('COM_JUDOWNLOAD_GLOBAL') . $appendGlobal);
$groups['inherit']['items'][] = JHtml::_('select.option', '-1', JText::_('COM_JUDOWNLOAD_INHERIT') . $appendinherit);
}
$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
$selected = array($this->value);
return JHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected));
} else {
return '';
}
}
示例3: _getTypeOptionsFromLayouts
protected function _getTypeOptionsFromLayouts($component, $view)
{
// Initialise variables.
$options = array();
$layouts = array();
$layoutNames = array();
$templateLayouts = array();
// Get the layouts from the view folder.
$path = JPATH_SITE . '/components/' . $component . '/views/' . $view . '/tmpl';
if (JFolder::exists($path)) {
$layouts = array_merge($layouts, JFolder::files($path, '.xml$', false, true));
} else {
return $options;
}
// build list of standard layout names
foreach ($layouts as $layout) {
// Ignore private layouts.
if (strpos(JFile::getName($layout), '_') === false) {
$file = $layout;
// Get the layout name.
$layoutNames[] = JFile::stripext(JFile::getName($layout));
}
}
// get the template layouts
// TODO: This should only search one template -- the current template for this item (default of specified)
$folders = JFolder::folders(JPATH_SITE . DS . 'templates', '', false, true);
foreach ($folders as $folder) {
if (JFolder::exists($folder . DS . 'html' . DS . $component . DS . $view)) {
$templateLayouts = JFolder::files($folder . DS . 'html' . DS . $component . DS . $view, '.xml$', false, true);
foreach ($templateLayouts as $layout) {
$file = $layout;
// Get the layout name.
$templateLayoutName = JFile::stripext(JFile::getName($layout));
// add to the list only if it is not a standard layout
if (array_search($templateLayoutName, $layoutNames) === false) {
$layouts[] = $layout;
}
}
}
}
// Process the found layouts.
foreach ($layouts as $layout) {
// Ignore private layouts.
if (strpos(JFile::getName($layout), '_') === false) {
$file = $layout;
// Get the layout name.
$layout = JFile::stripext(JFile::getName($layout));
// Create the menu option for the layout.
$o = new JObject();
$o->title = ucfirst($layout);
$o->description = '';
$o->request = array('option' => $component, 'view' => $view);
// Only add the layout request argument if not the default layout.
if ($layout != 'default') {
$o->request['layout'] = $layout;
}
// Load layout metadata if it exists.
if (is_file($file)) {
// Attempt to load the xml file.
if ($xml = simplexml_load_file($file)) {
// Look for the first view node off of the root node.
if ($menu = $xml->xpath('layout[1]')) {
$menu = $menu[0];
// If the view is hidden from the menu, discard it and move on to the next view.
if (!empty($menu['hidden']) && $menu['hidden'] == 'true') {
unset($xml);
unset($o);
continue;
}
// Populate the title and description if they exist.
if (!empty($menu['title'])) {
$o->title = trim((string) $menu['title']);
}
if (!empty($menu->message[0])) {
$o->description = trim((string) $menu->message[0]);
}
}
}
}
// Add the layout to the options array.
$options[] = $o;
}
}
return $options;
}
示例4: _getLayouts
/**
* @access private
*/
function _getLayouts($path, &$node)
{
$return = false;
$folder = $path . DS . 'tmpl';
if (is_dir($folder)) {
$files = JFolder::files($folder, '.php$');
if (count($files)) {
foreach ($files as $file) {
if (strpos($file, '_') === false) {
// Load view metadata if it exists
$layout = JFile::stripext($file);
$xmlpath = $path . DS . 'tmpl' . DS . $layout . '.xml';
if (JFile::exists($xmlpath)) {
$data = $this->_getXML($xmlpath, 'layout');
} else {
$data = null;
}
if ($layout != 'default') {
$url = 'url[option]=com_' . $this->_com . '&url[view]=' . basename($path) . '&url[layout]=' . $layout;
} else {
$url = 'url[option]=com_' . $this->_com . '&url[view]=' . basename($path);
}
if ($data) {
if ($data->attributes('hidden') != 'true') {
$m = $data->getElementByPath('message');
if ($m) {
$message = $m->data();
}
$child =& new iLinkNode($data->attributes('title'), $url, $message);
$node->addChild($child);
}
} else {
// Add default info for the layout
$child =& new iLinkNode(ucfirst($layout) . ' ' . JText::_('Layout'), $url);
$node->addChild($child);
}
}
}
}
}
return $return;
}
示例5: getInput
/**
* Method to get the field input.
*
* @return string The field input.
* @since 11.1
*/
protected function getInput()
{
// Initialize variables.
// Get the client id.
$clientId = $this->element['client_id'];
if (is_null($clientId) && $this->form instanceof JForm) {
$clientId = $this->form->getValue('client_id');
}
$clientId = (int) $clientId;
$client = JApplicationHelper::getClientInfo($clientId);
// Get the extension.
$extn = (string) $this->element['extension'];
if (empty($extn) && $this->form instanceof JForm) {
$extn = $this->form->getValue('extension');
}
$extn = preg_replace('#\\W#', '', $extn);
// Get the template.
$template = (string) $this->element['template'];
$template = preg_replace('#\\W#', '', $template);
// Get the style.
if ($this->form instanceof JForm) {
$template_style_id = $this->form->getValue('template_style_id');
}
$template_style_id = preg_replace('#\\W#', '', $template_style_id);
// Get the view.
$view = (string) $this->element['view'];
$view = preg_replace('#\\W#', '', $view);
// If a template, extension and view are present build the options.
if ($extn && $view && $client) {
// Load language file
$lang = JFactory::getLanguage();
$lang->load($extn . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extn . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false);
// Get the database object and a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Build the query.
$query->select('e.element, e.name');
$query->from('#__extensions as e');
$query->where('e.client_id = ' . (int) $clientId);
$query->where('e.type = ' . $db->quote('template'));
$query->where('e.enabled = 1');
if ($template) {
$query->where('e.element = ' . $db->quote($template));
}
if ($template_style_id) {
$query->join('LEFT', '#__template_styles as s on s.template=e.element');
$query->where('s.id=' . (int) $template_style_id);
}
// Set the query and load the templates.
$db->setQuery($query);
$templates = $db->loadObjectList('element');
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
// Build the search paths for component layouts.
$component_path = JPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl');
// Prepare array of component layouts
$component_layouts = array();
// Prepare the grouped list
$groups = array();
// Add a Use Global option if useglobal="true" in XML file
if ($this->element['useglobal'] == 'true') {
$groups[JText::_('JOPTION_FROM_STANDARD')]['items'][] = JHtml::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL'));
}
// Add the layout options from the component path.
if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\\.xml$', false, true))) {
// Create the group for the component
$groups['_'] = array();
$groups['_']['id'] = $this->id . '__';
$groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT');
$groups['_']['items'] = array();
foreach ($component_layouts as $i => $file) {
// Attempt to load the XML file.
if (!($xml = simplexml_load_file($file))) {
unset($component_layouts[$i]);
continue;
}
// Get the help data from the XML file if present.
if (!($menu = $xml->xpath('layout[1]'))) {
unset($component_layouts[$i]);
continue;
}
$menu = $menu[0];
// Add an option to the component group
$value = JFile::stripext(JFile::getName($file));
$component_layouts[$i] = $value;
$text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value);
$groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text);
}
}
// Loop on all templates
if ($templates) {
foreach ($templates as $template) {
//.........这里部分代码省略.........
示例6: download
public function download()
{
$session = JFactory::getSession();
$input = JFactory::getApplication()->input;
$download_url = trim(base64_decode($input->getBase64('download_url', $session->get('marketplace.download_url'))));
$tmp_file = $input->getCmd('tmp_file');
if (substr($download_url, 0, 4) == 'http') {
$http_response_header = array_change_key_case(get_headers($download_url, 1), CASE_LOWER);
if (!empty($http_response_header['content-disposition'])) {
preg_match('/filename=([^ ]+)/', $http_response_header['content-disposition'], $matches);
$matches[1] = str_replace('"', '', $matches[1]);
$matches[1] = str_replace(';', '', $matches[1]);
$tmp_file = $matches[1];
} else {
$tmp_file = basename($download_url);
}
}
$config = JFactory::getConfig();
$tempdir = $config->get('tmp_path');
$file_path = $tempdir . DIRECTORY_SEPARATOR . $tmp_file;
file_put_contents($file_path, file_get_contents($download_url));
$total_size = filesize($file_path);
$response = array('total_size' => $total_size, 'read' => $total_size, 'download_url' => base64_encode($download_url), 'tmp_file' => $tmp_file, 'file_path' => $tempdir . DIRECTORY_SEPARATOR . JFile::stripext($tmp_file));
return $response;
}
示例7: loadComponentFiles
/**
* Load component files that can be overrided
*
* Controllers, Models and Views
* We have an exeption for MenuModelMenutypes because we've add a new feature to read our codepools and override views and create new views.
*
* @access private
* @param mixed $option
* @return void
*/
private function loadComponentFiles($option)
{
$JPATH_COMPONENT = JPATH_BASE . '/components/' . $option;
$files = array();
//check if default controller exists
if (JFile::exists($JPATH_COMPONENT . '/controller.php')) {
$files[] = $JPATH_COMPONENT . '/controller.php';
}
//check if controllers folder exists
if (JFolder::exists($JPATH_COMPONENT . '/controllers')) {
$exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX');
//check if has controllers exceptions
if (self::hasException($option, 'controllers')) {
//add source controllers files to exception list
foreach (self::$_exception[$option][JFactory::getApplication()->getName()]['controllers'] as $controllerData) {
$exclude[] = JFile::stripext($controllerData['source']);
}
}
$controllers = JFolder::files($JPATH_COMPONENT . '/controllers', '.php', false, true, $exclude);
$files = array_merge($files, $controllers);
}
//check if models folder exists
if (JFolder::exists($JPATH_COMPONENT . '/models')) {
$exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX');
//check if have some models exception
if (self::hasException($option, 'models')) {
//add source model files to exception list
foreach (self::$_exception[$option][JFactory::getApplication()->getName()]['models'] as $modelData) {
$exclude[] = JFile::stripext($modelData['source']);
}
}
$models = JFolder::files($JPATH_COMPONENT . '/models', '.php', false, true, $exclude);
$files = array_merge($files, $models);
}
//check if views folder exists
if (JFolder::exists($JPATH_COMPONENT . '/views')) {
//reading view folders
$views = JFolder::folders($JPATH_COMPONENT . '/views');
foreach ($views as $view) {
$exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX');
//check if have some views exception
if (self::hasException($option, 'views')) {
//add source views files to exception list
foreach (self::$_exception[$option][JFactory::getApplication()->getName()]['views'] as $viewData) {
$exclude[] = JFile::stripext($viewData['source']);
}
}
//get view formats files
$viewsFiles = JFolder::files($JPATH_COMPONENT . '/views/' . $view, '.php', false, true, $exclude);
$files = array_merge($files, $viewsFiles);
}
}
//now we check all types of exception and load custom classes
if (self::hasException($option)) {
foreach (self::$_exception[$option][JFactory::getApplication()->getName()] as $type => $exceptionDatas) {
foreach ($exceptionDatas as $exceptionData) {
$modelContent = JFile::read($JPATH_COMPONENT . $exceptionData['source']);
$modelContent = str_replace($exceptionData['class'], $exceptionData['class'] . 'Default', $modelContent);
// Finally we can load the base class
eval('?>' . $modelContent . PHP_EOL . '?>');
require_once dirname(__DIR__) . '/core/' . $exceptionData['destiny'];
}
}
}
$return = array();
//cleaning files
foreach ($files as $file) {
$file = JPath::clean($file);
$file = substr($file, strlen(JPATH_BASE . '/components/'));
$return[] = $file;
}
return $return;
}
示例8: getTypeOptionsFromLayouts
/**
* Sync with codepools
*
* @param string $component
* @param string $view
*/
protected function getTypeOptionsFromLayouts($component, $view)
{
// Initialise variables.
$options = array();
$layouts = array();
$layoutNames = array();
$templateLayouts = array();
$lang = JFactory::getLanguage();
// Get the views for this component.
$paths = array(JPATH_SITE . '/components/' . $component . '/views/' . $view . '/tmpl', JPATH_SITE . '/code/' . $component . '/views/' . $view . '/tmpl');
if (JFolder::exists($paths[0])) {
$layouts = JFolder::files($paths[0], '.xml$', false, true);
}
if (JFolder::exists($paths[1])) {
$layouts = array_merge($layouts, JFolder::files($paths[1], '.xml$', false, true));
}
if (is_null($layouts) || empty($layouts)) {
return $options;
}
// build list of standard layout names
foreach ($layouts as $layout) {
// Ignore private layouts.
if (strpos(JFile::getName($layout), '_') === false) {
$file = $layout;
// Get the layout name.
$layoutNames[] = JFile::stripext(JFile::getName($layout));
}
}
// get the template layouts
// TODO: This should only search one template -- the current template for this item (default of specified)
$folders = JFolder::folders(JPATH_SITE . '/templates', '', false, true);
// Array to hold association between template file names and templates
$templateName = array();
foreach ($folders as $folder) {
if (JFolder::exists($folder . '/html/' . $component . '/' . $view)) {
$template = JFile::getName($folder);
$lang->load('tpl_' . $template . '.sys', JPATH_SITE, null, false, false) || $lang->load('tpl_' . $template . '.sys', JPATH_SITE . '/templates/' . $template, null, false, false) || $lang->load('tpl_' . $template . '.sys', JPATH_SITE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template . '.sys', JPATH_SITE . '/templates/' . $template, $lang->getDefault(), false, false);
$templateLayouts = JFolder::files($folder . '/html/' . $component . '/' . $view, '.xml$', false, true);
foreach ($templateLayouts as $layout) {
$file = $layout;
// Get the layout name.
$templateLayoutName = JFile::stripext(JFile::getName($layout));
// add to the list only if it is not a standard layout
if (array_search($templateLayoutName, $layoutNames) === false) {
$layouts[] = $layout;
// Set template name array so we can get the right template for the layout
$templateName[$layout] = JFile::getName($folder);
}
}
}
}
// Process the found layouts.
foreach ($layouts as $layout) {
// Ignore private layouts.
if (strpos(JFile::getName($layout), '_') === false) {
$file = $layout;
// Get the layout name.
$layout = JFile::stripext(JFile::getName($layout));
// Create the menu option for the layout.
$o = new JObject();
$o->title = ucfirst($layout);
$o->description = '';
$o->request = array('option' => $component, 'view' => $view);
// Only add the layout request argument if not the default layout.
if ($layout != 'default') {
// If the template is set, add in format template:layout so we save the template name
$o->request['layout'] = isset($templateName[$file]) ? $templateName[$file] . ':' . $layout : $layout;
}
// Load layout metadata if it exists.
if (is_file($file)) {
// Attempt to load the xml file.
if ($xml = simplexml_load_file($file)) {
// Look for the first view node off of the root node.
if ($menu = $xml->xpath('layout[1]')) {
$menu = $menu[0];
// If the view is hidden from the menu, discard it and move on to the next view.
if (!empty($menu['hidden']) && $menu['hidden'] == 'true') {
unset($xml);
unset($o);
continue;
}
// Populate the title and description if they exist.
if (!empty($menu['title'])) {
$o->title = trim((string) $menu['title']);
}
if (!empty($menu->message[0])) {
$o->description = trim((string) $menu->message[0]);
}
}
}
}
// Add the layout to the options array.
$options[] = $o;
}
//.........这里部分代码省略.........