Your IP : 216.73.216.224


Current Path : /var/www/html/plugins/content/jssupportticketpopulardownload/
Upload File :
Current File : /var/www/html/plugins/content/jssupportticketpopulardownload/jssupportticketpopulardownload.php

<?php

/**
  + Created by:	Ahmad Bilal
 * Company:		Buruj Solutions
  + Contact:		www.burujsolutions.com , info@burujsolutions.com
  www.joomsky.com, ahmad@joomsky.com
 * Created on:	Aug 25, 2010
  ^
  + Project: 		JS Jobs
 * File Name:	Pplugin/jssupportticketdownload.php
  ^
 * Description: Plugin for JS Jobs
  ^
 * History:		NONE
  ^
 */
defined('_JEXEC') or die('Restricted access');

// Import Joomla! Plugin library file
jimport('joomla.plugin.plugin');
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}

//The Content plugin Loadmodule
class plgContentjssupportticketpopulardownload extends JPlugin {

    /**
     * onContentPrepare is for Joomla 1.6
     */
    public function onContentPrepare($context, &$row, &$params, $page = 0) {
        if (JString::strpos($row->text, 'jssupportticketdownload') === false) {
            return true;
        }

        // expression to search for
        $regex = '/{jssupportticketdownload\s*.*?}/i';
        if (!$this->params->get('enabled', 1)) {
            $row->text = preg_replace($regex, '', $row->text);
            return true;
        }
        preg_match_all($regex, $row->text, $matches);
        $count = count($matches[0]);
        if ($count) {
            // Get plugin parameters
            $style = $this->params->def('style', -2);
            $this->_process($row, $matches, $count, $regex, $style);
        }
    }

    protected function _process(&$row, &$matches, $count, $regex, $style) {
        for ($i = 0; $i < $count; $i++) {
            $load = str_replace('jssupportticketdownload', '', $matches[0][$i]);
            $load = str_replace('{', '', $load);
            $load = str_replace('}', '', $load);
            $load = trim($load);

            $modules = $this->_load($load, $style);
            $row->text = preg_replace('{' . $matches[0][$i] . '}', $modules, $row->text);
        }
        $row->text = preg_replace($regex, '', $row->text);
    }

    protected function _load($position, $style = -2) {
        $inline_params = array();
        if(strpos($position,'=')){
            $posstart = 0;
            $posend = 0;
            $notfound = 0;
            do{
                $lastpoststart = $posstart;
                $lastposend = $posend;
                $posstart = strpos($position, '="', $posstart);
                if (is_numeric($posstart)){
                    $posend = strpos($position, '"', $posstart+2);
                    $stringFound = substr($position, ($posstart+2), ($posend-$posstart)-2);
                    if($lastpoststart == 0){
                        $lastpoststart = $posstart;
                    }else{
                        $lastpoststart = strpos($position, '="', $lastpoststart);
                        $lastposend += 1;
                        $lastpoststart = $lastpoststart - $lastposend;
                    }
                    $stringFoundTitle = substr($position, $lastposend, $lastpoststart);
                    $stringFoundTitle = trim($stringFoundTitle);
                    $inline_params[$stringFoundTitle] = $stringFound;
                    $posstart = $posend;
                }else{
                    $notfound = 1;
                }
            }while($notfound != 1);
        }
        
        $document = JFactory::getDocument();
        $version = new JVersion;
        $joomla = $version->getShortVersion();
        $jversion = substr($joomla,0,3);
        if($jversion < 3){
            $document->addScript('components/com_jssupportticket/js/jquery.js');
            JHtml::_('behavior.mootools');
        }else{
            JHtml::_('bootstrap.framework');
            JHtml::_('jquery.framework');
        }

        $document->addStyleSheet('components/com_jssupportticket/include/css/jssupportticketdefault.css');
        $document->addStyleSheet('administrator/components/com_jssupportticket/include/css/bootstrap.min.css');
        if(isset($inline_params['title'])){
            $title = $inline_params['title'];
        }else{
            $title = $this->params->get('title');
        }
        if(isset($inline_params['showtitle'])){
            switch ($inline_params['showtitle']) {
                case 'show':
                case 'yes':
                    $showtitle = 1;
                break;
                default:
                    $showtitle = 0;
                break;
            }
        }else{
            $showtitle = $this->params->get('showtitle', 1);    
        }
        if(isset($inline_params['titlebackgroundcolor'])){
            $titlebackgroundcolor = $inline_params['titlebackgroundcolor'];
        }else{
            $titlebackgroundcolor = $this->params->get('titlebackgroundcolor');
        }
        if(isset($inline_params['titletextcolor'])){
            $titlecolor = $inline_params['titletextcolor'];
        }else{
            $titlecolor = $this->params->get('titlecolor');
        }
        if(isset($inline_params['viewall'])){
            switch ($inline_params['viewall']) {
                case 'show':
                case 'yes':
                    $viewall = 1;
                break;
                default:
                    $viewall = 0;
                break;
            }
        }else{
            $viewall = $this->params->get('viewall', 1);
        }
        if(isset($inline_params['maxrecord'])){
            $maxrecord = $inline_params['maxrecord'];
        }else{
            $maxrecord = $this->params->get('maxrecord', 10);    
        }
        if(isset($inline_params['recordperrow'])){
            $recordperrow = $inline_params['recordperrow'];
        }else{
            $recordperrow = $this->params->get('recordperrow', 1);    
        }
        if(isset($inline_params['textoverflow'])){
            switch ($inline_params['textoverflow']) {
                case 'ellipsis':
                    $textoverflow = 2;
                    break;
                default:
                    $textoverflow = 1;
                    break;
            }
        }else{
            $textoverflow = $this->params->get('textoverflow', 2);
        }
        if(isset($inline_params['Itemid'])){
            $itemid = $inline_params['Itemid'];
        }else{
            if($this->params->get('Itemid')) $itemid = $this->params->get('Itemid');            
            else $itemid = JFactory::getApplication()->input->get('Itemid');
        }
        $lang = JFactory::getLanguage();
        $lang->load('com_jssupportticket', JPATH_ADMINISTRATOR, null, true);
        $moduleclass_sfx = $this->params->get('moduleclass_sfx');
        $componentPath =  JPATH_ADMINISTRATOR.'/components/com_jssupportticket/';
        require_once $componentPath.'JSApplication.php';
        require_once 'components/com_jssupportticket/include/css/color.php';
        $content = JSSupportTicketModel::getJSModelForMP('moduleplugin')->getContentForMP($title,$showtitle,$titlebackgroundcolor,$titlecolor,2,$viewall,$maxrecord,$recordperrow,$textoverflow,$itemid,'download',null);
        $content .= '
                    <script type="text/javascript">
                        jQuery(document).ready(function ($) {
                            jQuery("a[href=\"#\"]").click(function(e){
                                e.preventDefault();
                            });
                            jQuery("div#js-ticket-main-black-background,span#js-ticket-popup-close-button").click(function () {
                                jQuery("div#js-ticket-main-popup").slideUp();
                                setTimeout(function () {
                                    jQuery("div#js-ticket-main-black-background").hide();
                                }, 600);

                            });
                        });
                        function getDownloadById(value) {
                            link = "index.php?option=com_jssupportticket&c=downloads&task=getUserDownloadsById";
                            jQuery.post(link, {downloadid: value}, function (data) {
                                if (data) {
                                    var obj = jQuery.parseJSON(data);
                                    jQuery("div#js-ticket-main-content").html(obj.data);
                                    jQuery("span#js-ticket-popup-title").html(obj.title);
                                    jQuery("div#js-ticket-main-downloadallbtn").html(obj.downloadallbtn);
                                    jQuery("div#js-ticket-main-black-background").show();
                                    jQuery("div#js-ticket-main-popup").slideDown("slow");
                                }
                            });
                        }
                        function getAllDownloads(value) {
                            link = "index.php?option=com_jssupportticket&c=downloads&task=getUserAllDownloads";
                            jQuery.post(link, {downloadid:value}, function (data) {
                                console.log(data);
                                /*          
                                 if(data){
                                 var obj = jQuery.parseJSON(data);
                                 alert(obj.helloworld);
                                 }
                                 */     
                             });
                        }
                    </script>
                    <div id="js-ticket-main-black-background" style="display:none;">
                    </div>
                    <div id="js-ticket-main-popup" style="display:none;">
                        <span id="js-ticket-popup-title">abc title</span>
                        <span id="js-ticket-popup-close-button"><img src="components/com_jssupportticket/include/images/close.png" /></span>
                        <div id="js-ticket-main-content">
                        </div>
                        <div id="js-ticket-main-downloadallbtn">
                        </div>

                    </div>
                ';
        return $content;
    }

}

?>