Your IP : 216.73.216.209


Current Path : /home/musicpassiondjs40/djandreidis/plugins/jce/links-k2/
Upload File :
Current File : /home/musicpassiondjs40/djandreidis/plugins/jce/links-k2/links-k2.php

<?php
/**
 * @version     2.6.2
 * @package     K2 Links for JCE
 * @author      JoomlaWorks http://www.joomlaworks.net
 * @copyright   Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved.
 * @license     GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

defined('_WF_EXT') or die('RESTRICTED');

class WFLinkBrowser_K2 extends JObject
{
    public $_option = array();
    public $_adapters = array();

    public function __construct($options = array())
    {
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');

        $path = dirname(__FILE__).'/k2links';

        // Get all files
        $files = JFolder::files($path, '\.(php)$');

        if (!empty($files)) {
            foreach ($files as $file) {
                require_once($path.'/'.$file);
                $classname = 'K2links'.ucfirst(basename($file, '.php'));
                $this->_adapters[] = new $classname;
            }
        }
    }

    public function getInstance()
    {
        static $instance;

        if (!is_object($instance)) {
            $instance = new WFLinkBrowser_K2();
        }
        return $instance;
    }

    public function display()
    {
    }

    public function isEnabled()
    {
        $wf = WFEditorPlugin::getInstance();
        return $wf->checkAccess($wf->getName().'.links.k2links', 1);
    }

    public function getOption()
    {
        foreach ($this->_adapters as $adapter) {
            $this->_option[] = $adapter->getOption();
        }
        return $this->_option;
    }

    public function getList()
    {
        $list = '';

        foreach ($this->_adapters as $adapter) {
            $list .= $adapter->getList();
        }
        return $list;
    }

    public function getLinks($args)
    {
        foreach ($this->_adapters as $adapter) {
            if ($adapter->getOption() == $args->option) {
                if (property_exists($args, 'task')) {
                    $task = $args->task;
                } else {
                    $task = 'category';
                }
                if ($adapter->getTask() == $task) {
                    return $adapter->getLinks($args);
                }
            }
        }
    }
}