I'm trying to find a way to initialize the Joomla 2.5.2 jce editor via javascript with a specific profile.
Right now I've got the following code which is called via an ajax-request:
$wysiwyg =& JFactory::getEditor();
echo $wysiwyg->display(
"editor",
JRequest::getString("value"),
JRequest::getInt("width"),
JRequest::getInt("height"),
40,
6,
array(
)
);
$document =& JFactory::getDocument();
echo "<script type='text/javascript'>";
echo $document->_script["text/javascript"];
echo "</script>";
This initializes the jce editor with the default profile, but I want to init a custom profile I added. Is this something I can configure?
By the way, is there a better way to initialize the editor via javascript?
Related
I have a module with simple pop-up that asks for authorization.
Also I have a authorization module called slogin that was included via <jdoc:include .. in the header of the website in the template.
So in my module that requires slogin system, I'm unable to do it via jdoc.
I tried also to import this module
jimport('joomla.application.module.helper');
$module = JModuleHelper::getModule('mod_slogin');
$attribs['style'] = 'xhtml';
echo JModuleHelper::renderModule($module, $attribs);
But I only got an ajax-loader. Any suggestions?
I need to add fields to the joomla 3.x com_contact component. I have found some instructions via google search but they are all for earlier versions (i.e. 2.5) of Joomla.
I know there are other components on the extensions.joomla.org site, but they are not what I want. And I am not looking for contact form components. I don't need to create forms.
I tried adapting the 2.5 modifications I found for 3.x but they don't work. At least I could not get them to work.
Here's the closest I found to doing this. But it is for joomla 2.5 and the steps appear to be different for 3.x based on my attempts to do this.
How to do it but apparently not for Joomla 3.x
Does anyone have step-by-step directions on how to do this?
Thanks!
If you want add fields to Joomla 2.5.x/3.x ‘Contact Form’ do these steps:
(I want to add ‘telephone’ field)
1- Go to *Joomla Directory > components > com_contact > models > forms*
Open ‘contact.xml’ file.
2- Add this code to the file between ‘fieldset’ element:
<field name="contact_telephone"
type="text"
id="contact-telephone"
size="30"
description="Your Number for Contact"
label="Phone"
filter="string"
required="true"/>
3- Go to *Joomla Directory > components > com_contact > views > contact > tmpl*
Open ‘default_form.php’ file.
4- Find this code in the file:
<legend><?php echo JText::_('COM_CONTACT_FORM_LABEL'); ?></legend>
and add this code between element:
<dt><?php echo $this->form->getLabel('contact_telephone'); ?></dt>
<dd><?php echo $this->form->getInput('contact_telephone'); ?></dd>
5- Go to *Joomla Directory > components > com_contact > controllers*
Open ‘contact.php’ file.
6- Find ‘_sendEmail’ function
[find this code: private function _sendEmail($data, $contact) ]
and add this code in the function:
$telephone = $data['contact_telephone'];
and then change this code
$body = $prefix."\n".$name.' <'.$email.'> '."\r\n\r\n".stripslashes($body);
to
$body = $prefix."\n".$name.' ('.$email.', '.$telephone.') '."\r\n\r\n".stripslashes($body);
I added the variable $telephone in that line.
Now, emails contain the telephone-number from the sender.
This worked perfectly for me!
On Step number 4 IF YOU`RE USING A TEMPLATE, then you go to:
*Joomla Directory > templates > your_template_folder_name > html > com_contact > contact > and ppen ‘default_form.php’ file.
I'm using Kint via Composer in Laravel 4 by loading kint first in composer.json so that dd() is defined by kint, not laravel (suggested here).
I want to leave debug calls in my app, and disable Kint if not in the local environment. I'm successfully using config overrides for Anvard using the following structure:
/app/config/local/packages/provider/package_name/overridefile.php
Unfortunately, this is not working for Kint with the following structure:
/app/config/packages/raveren/kint/local/config.php or
/app/config/packages/raveren/kint/local/config.default.php
The Kint documentation states:
You can optionally copy the included config.default.php and rename to config.php to override default values…
…which works for me (/vendor/raveren/kint/config.php)
How do I achieve this:
without editing a file in the /vendor/ directory that will get overwritten by composer
so that kint is only enabled in the local envirnoment
I've also tried adding the following to a helpers.php file which is called before composer in /bootstrap/autoload.php as suggested here:
<?php
isset( $GLOBALS['_kint_settings'] ) or $GLOBALS['_kint_settings'] = array();
$_kintSettings = &$GLOBALS['_kint_settings'];
/** #var bool if set to false, kint will become silent, same as Kint::enabled(false) or Kint::$enabled = false */
$_kintSettings['enabled'] = false;
unset( $_kintSettings );
(but no dice :)
Any suggestions? TIA!
I'm not familiar with kint but checked the documentation and found that, to disable kint output, you may use (in runtime)
// to disable all output
Kint::enabled(false);
In Laravel you can check the environment using
$env = App::environment();
if($env == 'your_predefined_environment') {
Kint::enabled(false);
}
To configure your environment, you may check the documentation.
Update : I've setup my local environment as givel below (in bootstrap/start.php)
$env = $app->detectEnvironment(array(
'local' => array('*.dev'),
));
And in my local machine, I've setup a virtual mashine which has laravel4.dev as it's base url, so if I visit the app using laravel4.dev or laravel4.dev/logon then I can check the environment in my BaseController.php and it detects the local environment because of .dev
public function __construct()
{
if(App::environment() == 'local') {
// do something
}
}
In your case, I don't know where is the first debug/trace you used to print the output, so you should keep the environment checking and disabling the Kint code before you use any debug/trace but you may try this (if it works for you) but you can check the environment in your filter/routes files too.
Hmm.. I'm not sure if this is the ideal way to do it, but this works, and seems Laravel'ish:
// top of app/start/global.php
Kint::enabled(false);
and
// app/start/local.php
Kint::enabled(true);
(assuming you've got a local environment defined: see #TheAlpha's answer for more info)
http://laravel.com/docs/lifecycle#start-files
gmagick is newer version of imagemagick with more set of features it is less resource intensive and fast but the problem is there is very few discussion about this wonderful tool on web i recently came across this on
http://devzone.zend.com/1559/manipulating-images-with-php-and-graphicsmagick/
but i could not install it on windows machines cos phpize did not work so i tried some other way and some how managed to get on phpinfo page but i could not make it work further i colud not even open a single image with gmagick
this is code i used
<?php
$path="gallery/img1.jpg";
// initialize object
$image = new Gmagick($path);
echo $image;
// read image file
$file = 'gallery/img1.jpg';
$image->readImage($file);
echo '<img src="' . $file . '" width="200" height="150" /> <br/>';
?>
i used this code to instanstiate gmagick class and open image but i am geeting very big error as follows
Fatal error: Uncaught exception 'GmagickException' with message 'Unable to open file (gallery/img1.jpg)' in C:\xampp\htdocs\junk\imgproc\imgproc1.php:4 Stack trace: #0 C:\xampp\htdocs\junk\imgproc\imgproc1.php(4): Gmagick->__construct('gallery/img1.jp...') #1 {main} thrown in C:\xampp\htdocs\junk\imgproc\imgproc1.php on line 4
A) To answer the question in your headline (that might lead other readers here):
Windows builds of the GraphicsMagick extension for PHP can be obtained here:
http://valokuva.org/builds/
Check whether you need the thread-safe version or not by looking at a phpinfo(); output of your webserver. Look for the entry Thread Safety. In the entry PHP Extension Build you should also find the VC version that you need, e.g. API20090626,TS,VC9 for VC9.
Download the latest build that matches your conditions, put it into your PHP/ext directory and add it to your php.ini like this:
extension=php_gmagick_ts.dll
Remember to correct the name of the dll if you use the non-TS version.
Restart Apache and check phpinfo();. There should be a gmagick block now..
B) To correct the problem with your code:
The Gmagick constructor does not expect a path as a parameter, but a full image filename (may include a path). Most often it is better to leave it empty and provide the file in the readImage() call.
Try a full $path (starting at root) and use it in readImage() and writeImage():
Here is an example of a working piece of code:
<?php
// assuming this is the path to your code and to your image files
$path = 'C:\xampp\htdocs\junk\imgproc\';
$image = new Gmagick();
$file = 'img1.jpg';
$image->readImage($path.$file);
// The rest of your code does not make any use of the GM instance,
// so I add something functional here: create a grayscale version and show it
$fileOut= 'img1_GRAY.jpg';
$image->setImageType(Gmagick::IMGTYPE_GRAYSCALE);
$image->writeImage($path.$fileOut);
$image->destroy();
echo "<img src='$fileOut' >";
?>
It should show a grayscale version of your image file.
I have created a new CakePHP 2.0 app and want to run a plugin's shell.
<?php
// app\Plugin\Tmaker\Vendors\Shells\TmakerShell.php
class TmakerShell extends Shell {
}
However, I can't see it when running Console/cake from the command-line.
Please advise my what I have missed?
According to the latest documentation, the path for shells has changed to app/Console/Command/.
Move your shell to the following location: app/Plugin/Tmaker/Console/Command/TmakerShell.php (not sure if plugin directory names are camel-cased in CakePHP 2.0, but it seems to work either way.)
<?php
class TmakerShell extends Shell {
public function main() {
$this->out('It works!');
}
}
As CakePHP 2.0 requires you to load plugins manually, you also need to update app/Config/bootstrap.php by adding CakePlugin::loadAll(); or CakePlugin::load('Tmaker'); to the last line.
You should then be able to access your shell from the command-line. It looks like this in Windows:
C:\xampplite\htdocs\cake2\app>..\lib\Cake\Console\cake Tmaker.tmaker
Welcome to CakePHP v2.0.0-beta Console
---------------------------------------------------------------
App : app
Path: C:\xampplite\htdocs\cake2\app\
---------------------------------------------------------------
It works!