Beispiel #1
0
/**
* TinyMCE WYSIWYG Editor - javascript initialisation
*/
function botTinymceEditorInit()
{
    global $mosConfig_live_site, $database;
    // load tinymce info
    $query = "SELECT id FROM #__mambots WHERE element = 'tinymce' AND folder = 'editors'";
    $database->setQuery($query);
    $id = $database->loadResult();
    $mambot = new mosMambot($database);
    $mambot->load($id);
    $params =& new mosParameters($mambot->params);
    $theme = $params->get('theme', 'default');
    return <<<EOD
<script type="text/javascript" src="{$mosConfig_live_site}/mambots/editors/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
\ttinyMCE.init({
\t\ttheme : "{$theme}",
\t\tlanguage : "uk",
\t\tmode : "specific_textareas",
\t\tdocument_base_url: "{$mosConfig_live_site}/mambots/editors/tinymce/",
\t\tinvalid_elements: "script,object,applet,iframe",
\t\tdebug : false
\t});
</script>
EOD;
}
Beispiel #2
0
function plugJumi($published, &$row, &$params, $page = 0)
{
    global $mosConfig_absolute_path, $database;
    // expression to search for
    $regex = '/{(jumi)\\s*(.*?)}/i';
    // if not publish then output empty string
    if (!$published) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    // cycle through all bots. Bot text will be in $dummy[2]
    foreach ($matches as $dummy) {
        //read arguments from bot text and put them into the array $jumi
        $mms = array();
        $jumi = "";
        preg_match_all('/\\[.*?\\]/', $dummy[2], $mms);
        if ($mms) {
            //at the least one argument found
            foreach ($mms as $i => $mm) {
                $jumi = preg_replace("/\\[|]/", "", $mm);
            }
        }
        //The first argument must be the file pathname
        $incl_file = array_shift($jumi);
        $output = "You must supply the file pathname into the <b>first Jumi argument at the least!</b>";
        if ($incl_file) {
            //if the string $incl_file is nonempty try to include the file else $output "You must supply ...
            //get plugin parameters
            $query = "SELECT id FROM #__mambots WHERE element = 'plugin_jumi' AND folder = 'content'";
            $database->setQuery($query);
            $id = $database->loadResult();
            $mambot = new mosMambot($database);
            $mambot->load($id);
            $param =& new mosParameters($mambot->params);
            $incl_file = $param->def('default_absolute_path', $mosConfig_absolute_path) . '/' . $incl_file;
            if (is_readable($incl_file)) {
                // if the file is readable then include it else $output "The file ...
                ob_start();
                include $incl_file;
                $output = str_replace('$', '\\$', ob_get_contents());
                //fixed joomla bug
                ob_end_clean();
            } else {
                $output = "The file <b>" . $incl_file . "</b> cannot be included!<br />It does not exist or is not readable.";
            }
        }
        // final replacing of $regex (i.e. jumi) in $row->text by $output
        $row->text = preg_replace($regex, $output, $row->text, 1);
    }
    return true;
}
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     josSpoofCheck();
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'mambot')) {
         return false;
     }
     $xmlDoc = $this->xmlDoc();
     $mosinstall =& $xmlDoc->documentElement;
     // Set some vars
     $e =& $mosinstall->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $folder = $mosinstall->getAttribute('group');
     $this->elementDir(mosPathName($mosConfig_absolute_path . '/mambots/' . $folder));
     if (!file_exists($this->elementDir()) && !mosMakePath($this->elementDir())) {
         $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"');
         return false;
     }
     if ($this->parseFiles('files', 'mambot', 'Não existem arquivos definidos como Plugin') === false) {
         return false;
     }
     // Insert mambot in DB
     $query = "SELECT id" . "\n FROM #__mambots" . "\n WHERE element = " . $database->Quote($this->elementName());
     $database->setQuery($query);
     if (!$database->query()) {
         $this->setError(1, 'Erro SQL: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosMambot($database);
         $row->name = $this->elementName();
         $row->ordering = 0;
         $row->folder = $folder;
         $row->iscore = 0;
         $row->access = 0;
         $row->client_id = 0;
         $row->element = $this->elementSpecial();
         if ($folder == 'editors') {
             $row->published = 1;
         }
         if (!$row->store()) {
             $this->setError(1, 'Erro SQL: ' . $row->getError());
             return false;
         }
     } else {
         $this->setError(1, 'O plugin "' . $this->elementName() . '" já existe!');
         return false;
     }
     if ($e =& $mosinstall->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Beispiel #4
0
 /**
  * Custom install method
  * @param boolean True if installing from directory
  */
 function install($p_fromdir = null)
 {
     global $mosConfig_absolute_path, $database;
     if (!$this->preInstallCheck($p_fromdir, 'mambot')) {
         return false;
     }
     $xml = $this->xmlDoc();
     $mosinstall =& $xml->documentElement;
     // Set some vars
     $e =& $xml->getElementsByPath('name', 1);
     $this->elementName($e->getText());
     $folder = $mosinstall->getAttribute('group');
     $this->elementDir(mosPathName($mosConfig_absolute_path . '/mambots/' . $folder));
     //if(!file_exists($this->elementDir()) && !mkdir($this->elementDir(),0777)) {
     if (!file_exists($this->elementDir()) && !mkdir($this->elementDir(), 0777)) {
         $this->setError(1, 'Failed to create directory "' . $this->elementDir() . '"');
         return false;
     }
     if ($this->parseFiles('files', 'mambot', 'No file is marked as mambot file') === false) {
         return false;
     }
     // Insert in module in DB
     $database->setQuery("SELECT id FROM #__mambots WHERE element = '" . $this->elementName() . "'");
     if (!$database->query()) {
         $this->setError(1, 'SQL error: ' . $database->stderr(true));
         return false;
     }
     $id = $database->loadResult();
     if (!$id) {
         $row = new mosMambot($database);
         $row->name = $this->elementName();
         $row->ordering = 0;
         $row->folder = $folder;
         $row->iscore = 0;
         $row->access = 0;
         $row->client_id = 0;
         $row->element = $this->elementSpecial();
         if (!$row->store()) {
             $this->setError(1, 'SQL error: ' . $row->getError());
             return false;
         }
     } else {
         $this->setError(1, 'Mambot "' . $this->elementName() . '" already exists!');
         return false;
     }
     if ($e =& $xml->getElementsByPath('description', 1)) {
         $this->setError(0, $this->elementName() . '<p>' . $e->getText() . '</p>');
     }
     return $this->copySetupFile('front');
 }
Beispiel #5
0
/**
* changes the access level of a record
* @param integer The increment to reorder by
*/
function accessMenu($uid, $access, $option, $client)
{
    global $database;
    switch ($access) {
        case 'accesspublic':
            $access = 0;
            break;
        case 'accessregistered':
            $access = 1;
            break;
        case 'accessspecial':
            $access = 2;
            break;
    }
    $row = new mosMambot($database);
    $row->load($uid);
    $row->access = $access;
    if (!$row->check()) {
        return $row->getError();
    }
    if (!$row->store()) {
        return $row->getError();
    }
    mosRedirect('index2.php?option=' . $option);
}
Beispiel #6
0
 function view()
 {
     $database = mamboDatabase::getInstance();
     $query = "SELECT a.*, a.id AS value, CONCAT_WS( ' - ', a.name, a.con_position ) AS text" . "\n FROM #__contact_details AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n WHERE a.published = '1'" . "\n AND cc.published = '1'" . "\n AND a.access <=" . $this->user->gid . "\n AND cc.access <=" . $this->user->gid . "\n ORDER BY a.default_con DESC, a.ordering ASC";
     $database->setQuery($query);
     $list = $database->loadObjectList();
     $count = count($list);
     if ($count == 0) {
         $params =& new mosParameters('');
         $params->def('back_button', mamboCore::get('mosConfig_back_button'));
         HTML_contact::nocontact($params);
         return;
     }
     if ($this->contact_id == 0) {
         $this->contact_id = $list[0]->id;
     }
     foreach ($list as $cont) {
         if ($cont->id == $this->contact_id) {
             $contact =& $cont;
             break;
         }
     }
     if (!isset($contact)) {
         echo T_('You are not authorized to view this resource.');
         return;
     }
     // creates dropdown select list
     $contact->select = mosHTML::selectList($list, 'contact_id', 'class="inputbox" onchange="ViewCrossReference(this);"', 'value', 'text', $this->contact_id);
     // Adds parameter handling
     $params =& $this->makeParams($contact->params);
     // load mambot params info
     $query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'";
     $database->setQuery($query);
     $id = $database->loadResult();
     $mambot = new mosMambot($database);
     $mambot->load($id);
     $params2 =& $this->makeParams($mambot->params);
     if ($contact->email_to and $params->get('email')) {
         // email cloacking
         $contact->email = mosHTML::emailCloaking($contact->email_to, $params2->get('mode'));
     }
     // loads current template for the pop-up window
     $pop = mosGetParam($_REQUEST, 'pop', 0);
     if ($pop) {
         $params->set('popup', 1);
         $params->set('back_button', 0);
     }
     if ($params->get('email_description')) {
         $params->set('email_description', $params->get('email_description_text'));
     } else {
         $params->set('email_description', '');
     }
     // needed to control the display of the Address marker
     $temp = $params->get('street_address') . $params->get('suburb') . $params->get('state') . $params->get('country') . $params->get('postcode');
     $params->set('address_check', $temp);
     // determines whether to use Text, Images or nothing to highlight the different info groups
     $this->groupMarking($params);
     // params from menu item
     $menuhandler = mosMenuHandler::getInstance();
     $menu =& $menuhandler->getMenuByID($this->Itemid);
     $menu_params =& new mosParameters($menu->params);
     $menu_params->def('page_title', 1);
     $menu_params->def('header', $menu->name);
     $menu_params->def('pageclass_sfx', '');
     HTML_contact::viewcontact($contact, $params, $count, $list, $menu_params);
 }
Beispiel #7
0
function installBots_11x()
{
    global $database;
    $error = '';
    $return = '<b>' . _ACA_INSTALL_BOT . '</b> : ';
    if (!is_dir(ACA_JPATH_ROOT . '/mambots/acajoom')) {
        if (!@mkdir(ACA_JPATH_ROOT . '/mambots/acajoom', 0755)) {
            $return .= '<br /> Error adding bot directory.';
        } else {
            @chmod(ACA_JPATH_ROOT . '/mambots/acajoom', 0755);
        }
    }
    $bot_files = array('acajoombot.php', 'acajoombot.xml', 'index.html');
    foreach ($bot_files as $bot_file) {
        if (is_file(ACA_JPATH_ROOT . '/mambots/acajoom/' . $bot_file)) {
            @unlink(WPATH_ADMIN . 'bots/' . $bot_file);
        } else {
            if (!@rename(WPATH_ADMIN . 'bots/' . $bot_file, ACA_JPATH_ROOT . '/mambots/acajoom/' . $bot_file)) {
                $error .= '<br />Error copying bot file ' . $bot_file . ' to bot directory.';
            }
        }
    }
    @chmod(ACA_JPATH_ROOT . '/mambots/acajoom', 0755);
    if (!@rmdir(WPATH_ADMIN . 'bots/')) {
        $error .= '<br /> Error deleting the temporary bot directory.';
    }
    ### Acajoom bot
    $bot_infos = array('Acajoom Content Bot', 'acajoombot');
    foreach ($bot_infos as $bot_info) {
        $query = "SELECT `id` FROM `#__mambots` WHERE `element` = 'acajoombot'";
        $database->setQuery($query);
        $database->query();
        $error .= $database->getErrorMsg();
        if (!empty($error)) {
            $error .= '<br /> Error getting bot information from bot table for "' . $bot_info[0] . '". Database error: <br />' . $error . '<br />';
        } else {
            $id = $database->loadResult();
            if (!$id) {
                $row = new mosMambot($database);
                $row->name = $bot_infos[0];
                $row->ordering = 0;
                $row->folder = 'acajoom';
                $row->iscore = 0;
                $row->access = 0;
                $row->client_id = 0;
                $row->element = $bot_infos[1];
                $row->published = 1;
                if (!$row->store()) {
                    $error .= '<br />Error adding bot information to bot table for "' . $bot_info[0] . '".';
                }
            }
        }
    }
    if (empty($error)) {
        $return .= acajoom::printM('green', _ACA_INSTALL_SUCCESS) . '<br />';
    } else {
        $return .= $error . acajoom::printM('red', _ACA_INSTALL_ERROR) . '<br />';
    }
    return $return;
}
function botEditorArea($name, $content, $hiddenField, $width, $height, $col, $row)
{
    global $my, $mosConfig_live_site, $database, $option, $_MAMBOTS, $mosConfig_absolute_path, $isInline, $bodyStyles, $template, $path_root;
    $gid = 20;
    $isInline = 0;
    $bodyStyles = "";
    $template = "";
    $content = str_replace("&lt;", "<", $content);
    $content = str_replace("&gt;", ">", $content);
    $content = str_replace("&amp;", "&", $content);
    $content = str_replace("&nbsp;", " ", $content);
    $content = str_replace("&quot;", "\"", $content);
    $mainframe = new mosMainFrame($database, $option, '.');
    $query = "SELECT id FROM #__mambots WHERE element = 'legacy.fckeditor' AND folder = 'editors'";
    $database->setQuery($query);
    $id = $database->loadResult();
    $mambot = new mosMambot($database);
    $mambot->load($id);
    $params =& new mosParameters($mambot->params);
    $toolbar = $params->get('toolbar', 'Advanced');
    $toolbar_ft = $params->get('toolbar_ft', 'Advanced');
    $content_css = $params->get('content_css', '1');
    $editor_css = $params->get('editor_css', '0');
    $content_css_custom = $params->get('content_css_custom', '');
    $text_direction = $params->get('text_direction', 'ltr');
    $newlines = $params->get('newlines', 'false');
    $skin = $params->get('skin', 'office2007');
    $image_path = $params->get('imagePath', '/images/stories/');
    $wwidth = $params->get('wwidth', '100%');
    $hheight = $params->get('hheight', '480');
    $formatSource = $params->get('FormatSource', 1);
    $add_stylesheet_path = $params->get('add_stylesheet_path', '');
    $add_stylesheet = $params->get('add_stylesheet', '');
    $bgcolor = $params->get('bgcolor', '#FFFFFF');
    $fontcolor = $params->def('fontcolor', '');
    $entermode = $params->def('entermode', 0);
    $shiftentermode = $params->def('shiftentermode', 1);
    $htmlentities = $params->def('htmlentities', 0);
    $crtlshiftentermode = $params->def('ctrlshiftentermode', 2);
    $includelatinentities = $params->def('includelatinentities', 0);
    $includegreekentities = $params->def('includegreekentities', 0);
    $numericentities = $params->def('numericentities', 0);
    $useRelativeURLPath = $params->def('UserRelativeFilePath', 1);
    $textAlign = $params->def('TextAlign', '');
    $showerrors = $params->def('showerrors', 1);
    $ForceSpellCheck = $params->def('ForceSpellCheck', 0);
    //set default view for toolabar
    $toolbar = $toolbar == 'Default' ? 'Advanced' : $toolbar;
    $toolbar_ft = $toolbar_ft == 'Default' ? 'Advanced' : $toolbar_ft;
    //set flag to see if Pspell should be enabled
    $enablePspell = function_exists("pspell_check") ? 1 : 0;
    //define path_root for relative path
    $path_root = '../';
    if (strpos($_SERVER['REQUEST_URI'], 'administrator')) {
        $logintime = mosGetParam($_SESSION, 'session_logintime', '');
        $session_id = md5($my->id . $my->username . $my->usertype . $logintime);
    } else {
        $query = 'select s.session_id from #__session s' . ' join #__users u on u.id = s.userid ' . ' where u.id =' . $my->id . ' and s.guest = 0 and u.gid > 18 ';
        $database->setQuery($query);
        $session_id = $database->loadResult();
        //set toolbar to compact mode
        $toolbar = $toolbar_ft;
        $path_root = '';
    }
    //check to see if we have to change the install chmod settings
    changeFCKChmod($path_root);
    /* Need to check to see  session recorded already created */
    $ip = md5($_SERVER['REMOTE_ADDR']);
    $query = 'select session_id from #__session where session_id =\'' . $ip . '\'';
    $database->setQuery($query);
    $ip_recorded = $database->loadResult();
    if (!isset($ip_recorded)) {
        $query = 'insert into #__session(username,time,session_id,gid) values(\'' . $session_id . '\',\'' . (time() + 7200) . '\',\'' . $ip . '\',0)';
    } else {
        $query = 'update #__session set time = \'' . (time() + 7200) . '\',username = \'' . $session_id . '\' ' . 'where session_id =\'' . $ip . '\'';
    }
    $database->setQuery($query);
    $database->query();
    $errors = '';
    //Sanitize image path
    $image_path = preg_replace('/(^\\s*\\/|\\/\\s*$)/', '', $image_path);
    $xml_path = "{$mosConfig_absolute_path}/mambots/editors/fckeditor/fckstyles_template.xml";
    $template = $mainframe->getTemplate();
    if ($content_css || $editor_css) {
        if ($editor_css !== 0 & $content_css == 0) {
            if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/editor_css.css')) {
                $content_css = 'templates/' . $template . '/css/editor_css.css';
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . 'templates/' . $template . '/css/editor_css.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                }
                //end if gid > 29
            }
            //end if valid file
        } else {
            if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/template_css.css')) {
                $content_css = 'templates/' . $template . '/css/template_css.css';
            } else {
                if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/template.css.php')) {
                    $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                    if (!is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime($mosConfig_absolute_path . '/templates/' . $template . '/css/template.css.php') > filemtime($mosConfig_absolute_path . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                        $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                        $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                        $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                        $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                        $fout = fopen($path_root . $content_css, "w");
                        fwrite($fout, $file_content);
                        fclose($fout);
                    }
                    include $path_root . $content_css;
                    $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                    ob_start();
                    getYooThemeCSS();
                    $file_content = ob_get_contents();
                    ob_end_clean();
                    $fout = fopen($path_root . $content_css, "w");
                    fwrite($fout, $file_content);
                    fclose($fout);
                } else {
                    if ($my->gid > $gid) {
                        $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . 'templates/' . $template . '/css/template_css.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                    }
                    //end if gid > 29
                }
            }
            //end if valid file
        }
        //end if  $editor_css !== 0 & $content_css == 0
        /* Is the content_css == 0 or 1 then use FCK's default */
        if ($errors != "") {
            $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
            $style_css = "fckstyles.xml";
        }
        //end if
        /*write to xml file and read from css asnd store this file under editors*/
        xml_writer($path_root . $content_css, $xml_path);
        $style_css = "fckstyles_template.xml";
    } else {
        if ($content_css_custom) {
            $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower($mosConfig_absolute_path));
            $file_path = ($hasRoot ? '' : $mosConfig_absolute_path) . ($hasRoot || substr($content_css_custom, 0, 1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR) . $content_css_custom;
            if (is_file($file_path)) {
                $content_css = $file_path;
                $content_css = str_replace(strtolower($mosConfig_absolute_path) . DS, '', strtolower($content_css_custom));
                xml_writer($path_root . $content_css, $xml_path);
                $style_css = "fckstyles_template.xml";
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . '/' . $content_css_custom . ' does not appear to be a valid file.</span><br/>';
                }
                //end if gid > $gid
                $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
                $style_css = "fckstyles.xml";
            }
            //end if valid file
        } else {
            $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
            $style_css = "fckstyles.xml";
        }
        //end if $content_css_custom
    }
    //end if $content_css || $editor_css
    if (strpos($width, '%') === false) {
        $WidthCSS = $width . 'px';
    } else {
        $WidthCSS = $width;
    }
    if (strpos($height, '%') === false) {
        $HeightCSS = $height . 'px';
    } else {
        $HeightCSS = $height;
    }
    //if additional stylesheets specified
    $stylesheet_name = '';
    if ($add_stylesheet_path) {
        $hasRoot = strpos(' ' . strtolower($add_stylesheet_path), strtolower($mosConfig_absolute_path));
        $add_stylesheet_path = str_replace(strtolower($mosConfig_absolute_path) . DIRECTORY_SEPARATOR, '', strtolower($add_stylesheet_path));
    } else {
        $add_stylesheet_path = '/templates/' . $template . '/css/';
    }
    $BaseAddCSSPath = (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : '/') . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : '/');
    $BaseAddCSSPath = str_replace('\\', '/', $BaseAddCSSPath);
    //echo $add_stylesheet_path;
    if ($add_stylesheet_path && $add_stylesheet) {
        if (strpos($add_stylesheet, ';')) {
            $stylesheets = explode(';', $add_stylesheet);
        } else {
            $stylesheets[] = $add_stylesheet;
        }
        $count = 0;
        foreach ($stylesheets as $stylesheet) {
            if (!preg_match('/\\.\\w{3}$/', $stylesheet)) {
                $stylesheet .= '.css';
            }
            $fin = $path_root . substr($BaseAddCSSPath, 1, strlen($BaseAddCSSPath)) . $stylesheet;
            $file = $mosConfig_absolute_path . (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : DIRECTORY_SEPARATOR) . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : DIRECTORY_SEPARATOR) . $stylesheet;
            $fout = $path_root . 'mambots/editors/fckeditor/' . str_replace('.css', '.xml', $stylesheet);
            if (is_file($file)) {
                xml_writer($fin, $fout);
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $file . ' does not appear to be a valid file.</span><br/>';
                }
                //end if gid > $gid
                array_splice($stylesheets, $count, 1);
            }
            //end if valid file
            $count++;
        }
        $stylesheet_name = str_replace('.css', '', implode(';', $stylesheets));
    }
    $results = $_MAMBOTS->trigger('onCustomEditorButton');
    $buttons = array();
    foreach ($results as $result) {
        if ($result[0]) {
            $buttons[] = '<img src="' . $mosConfig_live_site . '/mambots/editors-xtd/' . $result[0] . '" onclick="InsertHTML(\'' . $hiddenField . '\',\'' . $result[1] . '\')" />';
        }
    }
    $buttons = implode("", $buttons);
    /* Lets sort out the directory issue */
    $urlDetails = parse_url($mosConfig_live_site);
    $directory = str_replace(array($urlDetails['scheme'], $urlDetails['host'], '://'), '', $mosConfig_live_site);
    if ($showerrors && $my->gid > $gid) {
        //Version Checker
        if (function_exists("curl_init")) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'http://www.joomlafckeditor.com/version.txt');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $version = curl_exec($ch);
            curl_close($ch);
            if ($version != '2.6.4.1' && $version) {
                $errors .= 'Please be aware there is a newer version of the JoomlaFCK Editor which can be downloaded from <a href="http://www.joomlafckeditor.com" target="_blank">http://www.joomlafckeditor.com</a>.<br/>';
            }
            //end if
        }
        //end if
        /* Check to see if the path exists. */
        if (!is_dir($mosConfig_absolute_path . '/' . $image_path)) {
            $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . $imagePath . ' does not appear to be a valid directory!</span><br/>';
        }
        //end if
        if ($errors !== "") {
            echo $errors . '<span style="color:blue">Please note the above message will only displayed to Managers and above.</span>';
        }
        //end if
    }
    $content_css = $mosConfig_live_site . '/' . $content_css;
    $content_css = str_replace('\\', '/', $content_css);
    // Define Enter & Shift Enter Mode
    $enterbehavior = array();
    $enterbehavior[0] = 'br';
    $enterbehavior[1] = 'p';
    $enterbehavior[2] = 'div';
    // Define Entities
    $htmlentities = $htmlentities ? 'true' : 'false';
    $includelatinentities = $includelatinentities ? 'true' : 'false';
    $includegreekentities = $includegreekentities ? 'true' : 'false';
    $numericentities = $numericentities ? 'true' : 'false';
    return <<<EOD
<textarea name="{$hiddenField}" id="{$hiddenField}" cols="{$col}" rows="{$row}" style="width:{$WidthCSS}; height:{$HeightCSS};">{$content}</textarea>
<script type="text/javascript">

\tvar oFCKeditor{$hiddenField} = new FCKeditor('{$hiddenField}');
\toFCKeditor{$hiddenField}.BasePath = "{$directory}/mambots/editors/fckeditor/" ;
\toFCKeditor{$hiddenField}.Config["SitePath"] =  "{$mosConfig_live_site}";
\toFCKeditor{$hiddenField}.Config["ImagePath"] =  "{$image_path}"; 
\toFCKeditor{$hiddenField}.Config["UseRelativeURLPath"] =  {$useRelativeURLPath}; 
\toFCKeditor{$hiddenField}.Config["CustomConfigurationsPath"] = "{$mosConfig_live_site}/mambots/editors/fckconfigjoomla.js";
\toFCKeditor{$hiddenField}.ToolbarSet = "{$toolbar}" ;
\toFCKeditor{$hiddenField}.Config['BaseAddCSSPath'] = "{$BaseAddCSSPath}";
\toFCKeditor{$hiddenField}.Config['EditorAreaCSS'] = "{$content_css}";
\toFCKeditor{$hiddenField}.Config['ContentLangDirection'] = "{$text_direction}" ;
\toFCKeditor{$hiddenField}.Config['SkinPath'] = oFCKeditor{$hiddenField}.BasePath + 'editor/skins/' + '{$skin}' + '/' ;
\toFCKeditor{$hiddenField}.Config['StylesXmlPath']= oFCKeditor{$hiddenField}.BasePath +'{$style_css}';
\toFCKeditor{$hiddenField}.Config['FormatSource'] = {$formatSource};\t
\toFCKeditor{$hiddenField}.Config['AddStylesheets'] = "{$stylesheet_name}";
\toFCKeditor{$hiddenField}.Config['BackgroundColor'] = "{$bgcolor}";
\toFCKeditor{$hiddenField}.Config['FontColor'] = "'.{$fontcolor}.'";\t
\toFCKeditor{$hiddenField}.Config['EnterMode'] = "{$enterbehavior[$entermode]}";
\toFCKeditor{$hiddenField}.Config['ShiftEnterMode'] = "{$enterbehavior[$shiftentermode]}";
\toFCKeditor{$hiddenField}.Config['CrtlShiftEnterMode'] = "{$enterbehavior[$crtlshiftentermode]}";
\toFCKeditor{$hiddenField}.Config['ProcessHTMLEntities'] = {$htmlentities} ;
\toFCKeditor{$hiddenField}.Config['IncludeLatinEntities'] = {$includelatinentities} ;
\toFCKeditor{$hiddenField}.Config['IncludeGreekEntities'] = {$includegreekentities} ;
\toFCKeditor{$hiddenField}.Config['ProcessNumericEntities'] = {$numericentities} ;
\toFCKeditor{$hiddenField}.Config['Pspell'] = "{$enablePspell}";
\toFCKeditor{$hiddenField}.Config['ForceInlineStyles'] = {$isInline};
\toFCKeditor{$hiddenField}.Config['JTemplate'] = "{$template}";
\toFCKeditor{$hiddenField}.Config['BodyStyles'] = "{$bodyStyles}";
\toFCKeditor{$hiddenField}.Config['TextAlign'] = "{$textAlign}";
\toFCKeditor{$hiddenField}.Config['UseAspell'] = "{$enablePspell}";
\toFCKeditor{$hiddenField}.Width = "{$wwidth}" ;
\toFCKeditor{$hiddenField}.Style_css = "{$style_css}" ;
\toFCKeditor{$hiddenField}.Height = "{$hheight}" ;
\t//oFCKeditor{$hiddenField}.ReplaceTextarea() ;
\t
\t
\t
\tvar forceSpellonSave = {$ForceSpellCheck}; 
\t
\tif(forceSpellonSave) {
\t
\t
\t\tif (!window.addEventListener) {
  \t\t\t  window.addEventListener = function (type, listener, useCapture) {
        \t\t\twindow.attachEvent('on' + type, function() { listener(event) });
    \t\t}
\t\t}
\t
\t\twindow.addEventListener("load", function() {
\t\t
\t\tif(typeof FCKIndexOf != "function")
\t\t{\t\t
\t\t\t\tvar FCKIndexOf = ( Array.prototype.indexOf ) ?
\t\t\t\t\t\tfunction( array, entry )
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\treturn array.indexOf( entry );
\t\t\t\t\t\t\t}
\t\t\t\t\t:
\t\t\t\t\t\tfunction( array, entry )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tfor ( var i = 0, len = array.length ; i < len ; i++ )
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tif ( array[ i ] === entry )
\t\t\t\t\t\t\t\t\treturn i;
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\treturn -1;
\t\t\t\t\t\t};\t
\t\t\t
\t\t\t\t\t\t
\t\t\t\tfunction getElementByTitle( titles, obj ) {
\t\t\t\t
\t\t\t\t\tif (obj.title && FCKIndexOf(titles,obj.title) != -1 ) {
\t\t\t\t\t\t return obj;
\t\t\t\t\t}
\t\t\t\t\tfor ( var i = 0; i < obj.childNodes.length; i++ )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tvar child = getElementByTitle( titles, obj.childNodes[i] );
\t\t\t\t\t\t\tif(child)
\t\t\t\t\t\t\t\treturn child;
\t\t\t\t\t\t}
\t\t\t\t\t
\t\t\t\t}\t
\t\t
\t\t\t\tvar submitbuttonOrig = submitbutton; // save fuction defintion defined by component
\t\t\t\t\t
\t\t\t\tif(typeof submitbutton == "function")
\t\t\t\t{
\t\t\t\t\t\t
\t\t\t\t\tfunction submitbuttonNew(pressbutton) //overide function defintion to call spellcheck on save
\t\t\t\t\t{
\t\t\t\t\t\t\t
\t\t\t\t\t\tif(pressbutton == "cancel" || pressbutton == "close" || pressbutton =="cpanel" )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tsubmitbuttonOrig(pressbutton);
\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\t\t\t
\t\t\t\t\t\tvar titles = ["Close","Cancel"];
\t\t\t\t\t\t
\t\t\t\t\t\tvar obj = getElementByTitle(titles,document); 
\t\t\t\t\t\t
\t\t\t\t\t\tvar exp = RegExp(pressbutton,"i");
\t\t\t\t\t\t
\t\t\t\t\t\tif(obj && obj.parentNode && exp.test(obj.parentNode.getAttribute("href")) )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tsubmitbuttonOrig(pressbutton);
\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\tvar FCK = FCKeditorAPI.GetInstance("{$hiddenField}");
\t\t\t\t\t\tFCK.submitform = submitbuttonOrig;
\t\t\t\t\t\tFCK.Config["saveAction"] = pressbutton;
\t\t\t\t\t\tFCK.ToolbarSet.CurrentInstance.Commands.GetCommand( "SpellCheck" ).Execute() ;
\t\t\t\t\t}
\t\t\t\t\t
\t\t\t\t\tsubmitbutton = submitbuttonNew; ' : "") . ' \t\t
\t\t\t\t}
\t\t\t}\t
\t\t},false);\t
\t}
\t
\t
\tfunction ReplaceText{$hiddenField}()
\t{
   \t\toFCKeditor{$hiddenField}.ReplaceTextarea();
   \t}
   
   \tif(window.addEvent)
\t{
\t\twindow.addEvent("domready",ReplaceText{$hiddenField})
\t}
\telse if(window.addEventListener)
\t{
\t\twindow.addEventListener("DOMContentLoaded", ReplaceText{$hiddenField}, null);
\t}
\telse
\t{
\t\twindow.attachEvent("onload",ReplaceText{$hiddenField})
\t
\t}\t
   
   
\tfunction InsertHTML(field, value) {
\t\t// Get the editor instance that we want to interact with.
\t\tvar oEditor = FCKeditorAPI.GetInstance(field) ;
\t
\t\t// Check the active editing mode.
\t\tif ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )\t{
\t\t\t// Insert the desired HTML.
\t\t\toEditor.InsertHtml( value ) ;
\t\t} else {
\t\t\talert( 'Please switch to WYSIWYG mode.' ) ;
\t\t}//end if
\t}//end function

</script>
<br />
<p>{$buttons}</p>
EOD;
}
Beispiel #9
0
function plugJumi($published, &$row, &$params, $page = 0)
{
    global $mainframe, $mosConfig_absolute_path, $database;
    //get plugin parameters
    $query = "SELECT id FROM #__mambots WHERE element = 'plugin_jumi' AND folder = 'content'";
    $database->setQuery($query);
    $id = $database->loadResult();
    $mambot = new mosMambot($database);
    $mambot->load($id);
    $pluginParams =& new mosParameters($mambot->params);
    // expression to search for
    $regex = '/{(jumi)\\s*(.*?)}/i';
    // if clear_code then replace jumi syntax codes with an empty string
    if ($pluginParams->get('clear_code') == 1) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    $continuesearching = true;
    while ($continuesearching) {
        //Nesting loop
        // find all instances of $regex (i.e. jumi) in an article and put them in $matches
        $matches = array();
        $matches_found = preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
        if ($matches_found) {
            // cycle through all jumi instancies. Put text into $dummy[2]
            foreach ($matches as $dummy) {
                //read arguments contained in [] from $dummy[2] and put them into the array $jumi
                $mms = array();
                $jumi = "";
                preg_match_all('/\\[.*?\\]/', $dummy[2], $mms);
                if ($mms) {
                    //at the least one argument found
                    foreach ($mms as $i => $mm) {
                        $jumi = preg_replace("/\\[|]/", "", $mm);
                    }
                }
                //Following syntax {jumi [storage_source][arg1]...[argN]}
                $storage_source = trim(array_shift($jumi));
                //filepathname or record id or ""
                if ($storage_source != "") {
                    if ($id = substr(strchr($storage_source, "*"), 1)) {
                        //if record id return it
                        $storage_source = (int) $id;
                    } else {
                        // else return filepathname
                        $storage_source = $pluginParams->def('default_absolute_path', $mosConfig_absolute_path) . '/' . $storage_source;
                    }
                }
                $output = '';
                // Jumi output
                $debug = $pluginParams->def('debug_mode', '0');
                if ($storage_source == '') {
                    //if nothing to show
                    $output = $debug == 0 ? 'dbgerr' : '<div style="color:#FF0000;background:#FFFF00;">Jumi is working but there is <b>nothing to be shown</b>.<br />Specify the source of the code (first square brackets)</div>';
                } else {
                    // buffer output
                    ob_start();
                    if (is_int($storage_source)) {
                        //it is record id
                        $user = $mainframe->getUser();
                        $database->setQuery("select custom_script from #__jumi where id = '{$storage_source}' and access <= {$user->gid} and published = 1");
                        $code_stored = $database->loadResult();
                        //returns code stored in the database or null.
                        if ($code_stored != null) {
                            //include custom script written
                            eval('?>' . $code_stored);
                        } else {
                            $output = $debug == 0 ? 'dbgerr' : '<div style="color:#FF0000;background:#FFFF00;">ERR: Record ID:<b>' . $storage_source . '</b> does not exist, or is not published, or you have got insufficient rights to read it!</div>';
                        }
                    } else {
                        //it is file
                        if (is_readable($storage_source)) {
                            include $storage_source;
                            //include file
                        } else {
                            $output = $debug == 0 ? 'dbgerr' : '<div style="color:#FF0000;background:#FFFF00;">ERR: The file<br /><b>' . $storage_source . '</b><br />does not exist or is not readable!</div>';
                        }
                    }
                    if ($output == '') {
                        //if there are no errors
                        $output = str_replace('$', '\\$', ob_get_contents());
                        //fixed joomla bug
                        $output = ob_get_contents();
                    } elseif ($output == 'dbgerr') {
                        $output = '';
                    }
                    ob_end_clean();
                }
                // final replacement of $regex (i.e. {jumi [][]}) in $row->text by $output
                $row->text = preg_replace($regex, $output, $row->text, 1);
            }
            if ($pluginParams->get('nested_replace') == 0) {
                $continuesearching = false;
            }
        } else {
            $continuesearching = false;
        }
    }
    return true;
}
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosMambot($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "folder = " . $database->Quote($row->folder) . " AND ordering > -10000 AND ordering < 10000 AND client_id = " . (int) $row->client_id;
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    $msg = 'Nova ordenação salva';
    mosRedirect('index2.php?option=com_mambots', $msg);
}
 $query = "SELECT catdir FROM #__zoom WHERE catid=" . $row1->catid;
 $database->setQuery($query);
 $result = $database->query();
 $row2 = mysql_fetch_object($result);
 //display info
 echo '<div align="left" style="clear: both;">';
 echo '<p><a href="' . ($zoom->_isBackend ? 'index2.php?option=com_zoom&Itemid=' . $Itemid . '&page=zoomthumb&task=step1' : sefReltoAbs('index.php?option=com_zoom&Itemid=' . $Itemid . '&page=zoomthumb&task=step1')) . '">(back to step 1:: select gallery)</a></p>';
 echo '<p><a href="' . ($zoom->_isBackend ? 'index2.php?option=com_zoom&Itemid=' . $Itemid . '&page=zoomthumb&task=step2&catid=' . $row1->catid : sefReltoAbs('index.php?option=com_zoom&Itemid=' . $Itemid . '&page=zoomthumb&task=step2&catid=' . $row1->catid)) . '">(back to step 2:: select image)</a></p>';
 echo '<p id="step"><strong>Step 3 :: choose styling</strong></p>';
 // display image
 echo '<div style="clear: both;"><img style="margin: 2px; float: left" src="' . $mosConfig_live_site . '/' . $zoom->_CONFIG['imagepath'] . '/' . $row2->catdir . '/thumbs/' . $row1->imgfilename . '"></a>Title: ' . $row1->imgname . '<br />Descr: ' . $row1->imgdescr . '<br />' . ($row1->published == 0 ? 'Warning NOT published' : 'Published') . '<br />File: ' . $row1->imgfilename . '</div>';
 //get some Caption configuration settings defined in the ZoomThumb-Joomla!t-settings
 $query = "SELECT id FROM #__mambots WHERE element = 'moszoomthumb' AND folder = 'content'";
 $database->setQuery($query);
 $id = $database->loadResult();
 $mambot = new mosMambot($database);
 $mambot->load($id);
 $param =& new mosParameters($mambot->params);
 $showZoomcaption = $param->get('caption_show', '1');
 //is mambot configured to show caption by default?
 $captionlength = $param->get('caption_length', '0');
 //max length of caption
 $defaultcaption = $captionlength != '0' ? substr($row1->imgdescr, 0, intval($captionlength)) : $row1->imgdescr;
 //// compute default value
 if ($showZoomcaption == '1') {
     $defaultcaptionlabel = 'Default, use Zoom Gallery caption : ' . $defaultcaption;
 } else {
     $defaultcaptionlabel = 'Default, no caption used';
 }
 $captionwarning = $captionlength != '0' ? ':: caption length is limited to ' . $captionlength . ' characters' : '';
 // create form code for selection of specific mambot codes