Welcome Guest, Not a member yet? Register   Sign In
NBBC Callback Tags + CI
#5

[eluser]nagata[/eluser]
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once 'bb/nbbc_main.php';

function MyBorderFunction($bbcode, $action, $name,    $default, $params, $content) {
    if ($action == BBCODE_CHECK) {
        if (isset($params['color'])
            && !preg_match('/^#[0-9a-fA-F]+|[a-zA-Z]+$/', $params['color']))
            return false;
        if (isset($params['size'])
            && !preg_match('/^[1-9][0-9]*$/', $params['size']))
            return false;
        return true;
    }

    $color = isset($params['color']) ? $params['color'] : "blue";
    $size = isset($params['size']) ? $params['size'] : 1;
    return "<div {$size}px solid $color\">$content</div>";
}

function MyMCFunction($bbcode, $action, $name,    $default, $params, $content) {
    if ($action == BBCODE_CHECK) {
        if (isset($params['name'])
            && !preg_match('/^[a-zA-Z0-9]+$/', $params['name']))
            return false;
        return true;
    }

   // $name = isset($params['name']) ? $params['name'] : "char";
   // $name = isset($default) ? $default : $params['name'];
   $this_test = $this->CI->access->hashPass("lol");
$site = site_url('mc/'.$content);
    return "<img >";
}

class Mybbcode
{
var $CI;

function Mybbcode()
{
  $this->CI =& get_instance();
  $this->CI->load->model('users_model');
}

function dowork($content = "NoBBCodeContent",$type = "basic")
{

$user = $this->CI->access->get_user();
$bbcode = new BBCode;
$bbcode->SetSmileyURL(base_url("smileys/"));
$bbcode->AddRule('viewer_name',  Array(
        'simple_start' => "{$user->screen_name}",
        'simple_end' => '',
        'class' => 'inline',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
    ));
$bbcode->AddRule('border',  Array(
        'mode' => BBCODE_MODE_CALLBACK,
        'method' => 'MyBorderFunction',
        'class' => 'block',
        'allow_in' => Array('listitem', 'block', 'columns'),
    ));
$bbcode->AddRule('mc',  Array(
        'mode' => BBCODE_MODE_CALLBACK,
        'method' => 'MyMCFunction',
        'class' => 'block',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
    ));
$bbcode->AddRule('viewer_id',  Array(
        'simple_start' => "{$user->id}",
        'simple_end' => '',
        'class' => 'inline',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
    ));
    return $bbcode->Parse($content);
}



}
Ok here is the code of what I got so far,
there is a test variable in MC function, its just there to see if It would work or not,
what I basicly need is ability to interct with the rest of the CI outside from a function like that MC func...
any help?
ps. going sleep now, hope for some help tomorow...


Messages In This Thread
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 04:14 AM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 04:54 AM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 06:01 AM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 11:29 AM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 02:08 PM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 11:03 PM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 11:23 PM
NBBC Callback Tags + CI - by El Forum - 07-05-2012, 11:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB