Greetings All,
I’m trying to write my first extension which I need for a plugin I’ve just created to work properly. I’m trying to edit the “action=” and “ret=” in the comments form. This is the code I have so far which shouldn’t do anything really, just not give out errors. The error I’m getting is:
Notice: Undefined property: Ajax_comments::$version in /home/cody/public_html/system/core/core.extensions.php on line 235
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Ajax_comments::change_return' was given in /home/cody/public_html/system/core/core.extensions.php on line 262
Notice: Undefined property: Ajax_comments::$version in /home/cody/public_html/system/core/core.extensions.php on line 235
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Ajax_comments::change_action' was given in /home/cody/public_html/system/core/core.extensions.php on line 262
My code is in the second post.
Again, this shouldn’t do anything. I took the format from the ext.cp_jquery.php extension and barely changed anything…
<?php if ( ! defined('EXT')) exit('No direct script access allowed');
/**
* AJAX Comments
*
* Needed for the AJAX Comments Plugin to work
*
* @author Cody Lundquist
* @license http://creativecommons.org/licenses/by-sa/3.0/
* @link http://www.codysplace.com
* @since Version 1.0
* @filesource
*
* This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
* or send a letter to Creative Commons, 171 Second Street, Suite 300,
* San Francisco, California, 94105, USA.
*
*/
class Ajax_comments {
var $settings = array();
var $name = 'AJAX Comments';
var $version = '1.0';
var $description = 'Needed for AJAX Comments Plugin to work.';
var $settings_exist = 'y';
var $docs_url = '';
/**
* Constructor
*/
function Ajax_comments($settings = '')
{
$this->settings = $settings;
}
// --------------------------------------------------------------------
/**
* Register hooks by adding them to the database
*/
function activate_extension()
{
global $DB;
// default settings
$settings = array();
$settings['comment_url'] = 'http://example.com/blog/comment_container/';
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => __CLASS__,
'method' => "change_return",
'hook' => "comment_form_hidden_fields",
'settings' => serialize($settings),
'priority' => 10,
'version' => $this->version,
'enabled' => "y"
)
)
);
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => __CLASS__,
'method' => "change_action",
'hook' => "comment_form_action",
'settings' => "",
'priority' => 10,
'version' => $this->version,
'enabled' => "y"
)
)
);
}
// --------------------------------------------------------------------
/**
* No updates yet.
* Manual says this function is required.
* @param string $current currently installed version
*/
function update_extension($current = '')
{
global $DB, $EXT;
if ($current < '1.0')
{
$query = $DB->query("SELECT settings FROM exp_extensions WHERE class = '".$DB->escape_str(__CLASS__)."'");
$this->settings = unserialize($query->row['settings']);
unset($this->settings['comment_url']);
$DB->query($DB->update_string('exp_extensions', array('settings' => serialize($this->settings), 'version' => $this->version), array('class' => __CLASS__)));
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Uninstalls extension
*/
function disable_extension()
{
global $DB;
$DB->query("DELETE FROM exp_extensions WHERE class = '".__CLASS__."'");
}
// --------------------------------------------------------------------
/**
* EE extension settings
* @return array
*/
function settings()
{
$settings = array();
$settings['comment_url'] = '';
return $settings;
}
// --------------------------------------------------------------------
/**
* Adds script tags to the head of CP pages
*
* We add the jQuery libraries to the top of the head tag to ensure that they
* are before any other javascript that could use the libraries.
*
* @param string $html Final html of the control panel before display
* @return string Modified HTML
*/
function change_return($return)
{
global $EXT;
$EXT->end_script = TRUE;
$return = ($EXT->last_call !== FALSE) ? $EXT->last_call : $return;
return $return;
}
function change_action($action)
{
global $EXT;
$EXT->end_script = TRUE;
$action = ($EXT->last_call !== FALSE) ? $EXT->last_call : $action;
return $action;
}
// --------------------------------------------------------------------
}
// END CLASS Cp_jquery
/* End of file ext.ajax_comments.php */
/* Location: ./system/extensions/ext.ajax_comments.php */
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.