$mainframe->close() Joomla 2.5 - joomla

In Joomla 1.5 when I like to call AJAX, I add function in the controller like so
global $mainframe;
$idContact = JRequest::getVar('idContact');
$modelContact = $this->getModel('clientcontact');
if($modelContact->delete($idContact))
echo "1";
else
echo "0";
$mainframe->close();
And the controler return 1 or 0 (I dont need to use the raw or anthing else just tmpl=component in the URL)
In the 2.5 I have an error wiht $mainframe->close();
I dont like to use the raw or modal layout

global $mainframe;
Was deprecated in 1.6 and is not available in Joomla 2.5 you should read the Adapting a Joomla 1.5 extension to Joomla 2.5 article on the Joomla Doc's website.
If you're doing it the lazy way, then you can simply replace:
global $mainframe;
With:
$mainframe = JFactory::getApplication();
throughout your extension.
In addition the $option global is gone.
You may also want to bookmark the Developers portal on Joomla Doc's.

Related

Captcha Custom Form in Joomla 2.5

after many hours of trying and searching to solve an issue with captcha issue and several faild attempts to fix the problem I decide to ask for your help, I have a web site on Joomla 2.5 I have a custom register form for new users and I want to add a captcha mechanism, where here what I made (i found it here in stackoverflow but i have some qusetions).
So far I made the followings:
1)I enabled the capcha-recaptcha plugin and I enter private key and site key from google captcha
2)I set captcha-Recaptcha to Default captcha at global configuration
3)In my file template\mytemplate\html\mod_login\default.php
I enter the following code which I found here in stackoverflow
//php code
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit','dynamic_recaptcha_1');
//html code inside form tag
<div id="dynamic_recaptcha_1"></div>
So far so good it appears the captcha image and entry box but when I press submit button I receive Invalid token
I suspect that it has something to do with the following part of code which it should validate/proccess the form
$post = JRequest::get('post');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
die('Invalid Captcha');
}
in joomla in which file I should insert the validation code? I have tried in submit button at : template\mytemplate\html\mod_login\default.php
but nothing, I have tried also at com_users\controllers\registrattion.php still nothing any ideas where I should insert this part of code? in order to make it work?
Thnks in advance for your time!!
Regards,
Jim
EDITED ANSWER
Try this code below from https://forum.joomla.org/viewtopic.php?t=833213
$app = JFactory::getApplication();
$captchaResponse = JRequest::get('recaptcha_response_field');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$captchaResponse);
if(!$res[0])
{
// Invalid captcha
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
return false;
}
ORIGINAL ANSWER
Make sure you are using newest version of the 2.5 series. The original recaptcha plugin won't work because Google changed their API script location from recaptcha.net to google.com/recaptcha . You can open the recaptcha files to do a quick check.

Joomla 3.0 administration protection remove iframe

I have more joomla pages, and i must work at the same time on more admin. panels, so i have created a page where i load pages in iframe, but joomla admin. area is protected from iframe, know someone how can i deactivate this protection?
If i try to open in iframe:www.mypage.com/administrator then i will be redirected to normal page.
I have tried to create new admin template, without any scripts but protection is yet here, i can't found anything with keyword "iframe" or something...
you are looking for the noframes behavior, the com_login view loads
JHtml::_('behavior.noframes');
which ends up calling the noFrames function in the JHtmlBehavior class (libraries/joomla/html/behavior.php)
which loads
$js = "window.addEvent('domready', function () {
if (top == self) {
document.documentElement.style.display = 'block';
}" .
" else {top.location = self.location; }
});";
basically telling the window to change location, so either change how noFrames works or remvoe the JHtml::_('behavior.noframes') call
But note that you shouldnt mod core files as they will get overwritten on updates that need to update that file.

JParameter showing error

I have used the below code for Joomla 1.5 & 2.5 but it is not supporting joomla 3
$pluginParams = new JParameter( $plugin->params );
Instead of i have used the below code in joomla 3
$params = new JInput();
$pluginParams = $params->get('params');
If i use the joomla 3, it conflicting with article title, content-page navigation and also with K2 component.
Is there any solution to get the plugin params in joomla3.
JParameter was deprecated for the whole lifetime of the 1.6-2.5 series and removed in Joomla 3. You should be using JForm in both.

Place certain article anywhere in joomla template

Is it possible in Joomla to place a certain article in a template, additionally to the normal content? I want the article to show up on every page.
You can simply take it from the databse and print its content. In the template, where you want to show the article, write this:
$id=/*Id of the article to show*/;
$db=&JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id=$id");
$item=$db->loadObject();
echo $item->introtext;
UPDATE: ENABLE PLUGINS
I can't find where i've used that code and i can't copy-paste it, so i try to write it again by looking at the view.html.php of the com_content:
JPluginHelper::importPlugin('content');
$dispatcher =& JDispatcher::getInstance();
$params = &$mainframe->getParams();
$dispatcher->trigger('onPrepareContent', array (&$item, &$params, 0));
//The last line triggers the onPrepareContent event, so if it does not work maybe you need other events, so try with onAfterDisplayTitle, onBeforeDisplayContent or onAfterDisplayContent
Have you seen this? http://extensions.joomla.org/extensions/news-display/content-embed/7528
It allows you to place any article as a module on your Joomla site. And with modules you can have them displayed site wide.

DHTMLX calendar enable / disable in whole website

I am working on website (built using PHP, Mysql, jQuery) which require that admin set a variable in configuration and according to that configuration variable jQuery autocomplete is enabled or disabled to all website. Is there any way to achieve that functionality.
The easiest way to do it is to add a common id, or other attribute to all the parent elements where the schedule shows up. Then include into your main javascript file something of the form
FLAG = 1; //for visibile, or 0 for invisible
$('#calendar').toggle(FLAG); //OR
$('[rel=calendar]').toggle(FLAG);
If you wanted that to come from php, you can always load your javascript within php:
functions.js.php:
FLAG = <?php $CAL_SETTING ?>
//go on with the rest of the javascript
//then include it into your html
<script language="javascript" src="functions.js.php"></script>
Good luck!
create a table setting with these fields [name, value,..] and set the name calendar_status value hide
in your view you can get read of that field from you DB and set the myCalendar.hide(true); or myCalendar.hide(false);
myCalendar = new dhtmlXCalendarObject("DateStart");
myCalendar.hide(); <- you php code like <?php echo calendar_status; ?>

Resources