Exemple #1
0
 public function getOnClick()
 {
     $id = KRequest::get('get.id', 'int');
     $token = JUtility::getToken();
     $json = "{method:'post', url:'index.php?option=com_create&view=component&id={$id}', formelem:'adminForm', params:{action:'generate', _token:'{$token}'}}";
     return 'new KForm(' . $json . ').submit();';
 }
Exemple #2
0
 /**
  * Method for logging out with Magento (Single Sign On)
  * 
  * @param string $username
  * @return bool|exit
  */
 public static function doSSOLogout($username = null)
 {
     // Abort if the input is not valid
     if (empty($username)) {
         return false;
     }
     // Get system variables
     $application = JFactory::getApplication();
     $session = JFactory::getSession();
     // Determine the application
     $application_name = $application->isAdmin() ? 'admin' : 'frontend';
     // Get the security token
     $token = method_exists('JSession', 'getFormToken') ? JSession::getFormToken() : JUtility::getToken();
     // Set the redirection URL
     if ($application_name == 'admin') {
         $redirect = JURI::current();
     } else {
         $redirect = MageBridgeUrlHelper::current();
     }
     // Construct the URL
     $arguments = array('sso=logout', 'app=' . $application_name, 'redirect=' . base64_encode($redirect), 'userhash=' . MageBridgeEncryptionHelper::encrypt($username), 'token=' . $token);
     $url = MageBridgeModelBridge::getInstance()->getMagentoBridgeUrl() . '?' . implode('&', $arguments);
     // Redirect the browser to Magento
     MageBridgeModelDebug::getInstance()->notice("SSO: Logout of '{$username}' from " . $application_name);
     $application->redirect($url);
     return true;
 }
Exemple #3
0
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_categories', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
     // Fake parameters
     $_POST['task'] = 'apply';
     $_REQUEST['task'] = 'apply';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $context = 'category';
     // Clear userstate just in case
     $model = APIodel::getInstance('Category', 'CategoriesModel');
     $success = $model->save($data);
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (!$success) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_CATEGORIES_SAVE_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $model->get('state')->get($context . '.id');
         // Checkin category
         $model->checkin($response->id);
     }
     $this->plugin->setResponse($response);
 }
Exemple #4
0
 /**
  * Show the form in the admin
  *
  * @return null
  */
 public function view()
 {
     $document = JFactory::getDocument();
     $model = JModel::getInstance('Form', 'FabrikFEModel');
     $viewType = $document->getType();
     $this->setPath('view', COM_FABRIK_FRONTEND . '/views');
     $viewLayout = JRequest::getCmd('layout', 'default');
     $view = $this->getView('form', $viewType, '');
     $view->setModel($model, true);
     $view->isMambot = $this->isMambot;
     // Set the layout
     $view->setLayout($viewLayout);
     // @TODO check for cached version
     JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_FORMS'), 'forms.png');
     if (in_array(JRequest::getCmd('format'), array('raw', 'csv', 'pdf'))) {
         $view->display();
     } else {
         $user = JFactory::getUser();
         $post = JRequest::get('post');
         $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
         $cache = JFactory::getCache('com_fabrik', 'view');
         ob_start();
         $cache->get($view, 'display', $cacheid);
         $contents = ob_get_contents();
         ob_end_clean();
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         echo preg_replace($search, $replacement, $contents);
     }
     FabrikAdminHelper::addSubmenu(JRequest::getWord('view', 'lists'));
 }
Exemple #5
0
	public function display()
	{
		$state = $this->getModel()->getState();

		$folders = KFactory::get('com://admin/files.controller.folder')
			->container($state->container)
			->tree(true)
			->browse();

		$this->assign('folders', $folders);

		$config = KFactory::get('com://admin/files.model.configs')->getItem();

		// prepare an extensions array for fancyupload
		$extensions = $config->upload_extensions;

		$this->assign('allowed_extensions', $extensions);
		$this->assign('maxsize'           , $config->upload_maxsize);
		$this->assign('path'              , $state->container->relative_path);
		$this->assign('sitebase'          , ltrim(JURI::root(true), '/'));
		$this->assign('token'             , JUtility::getToken());
		$this->assign('session'           , JFactory::getSession());

		if (!$this->editor) {
			$this->assign('editor', '');
		}

		return parent::display();
	}
Exemple #6
0
	function display($tpl=null)
	{
		$r = new JObject();
		$r->token = JUtility::getToken(true);
		
		echo json_encode($r);
	}
Exemple #7
0
 /**
  * Get a list of logged users.
  *
  * @param	JObject	The module parameters.
  * @return	mixed	An array of articles, or false on error.
  */
 public static function getList($params)
 {
     // Initialise variables
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $query = $db->getQuery(true);
     $query->select('s.time, s.client_id, u.id, u.name, u.username');
     $query->from('#__session AS s');
     $query->leftJoin('#__users AS u ON s.userid = u.id');
     $query->where('s.guest = 0');
     $db->setQuery($query, 0, $params->get('count', 5));
     $results = $db->loadObjectList();
     // Check for database errors
     if ($error = $db->getErrorMsg()) {
         JError::raiseError(500, $error);
         return false;
     }
     foreach ($results as $k => $result) {
         $results[$k]->logoutLink = '';
         if ($user->authorise('core.manage', 'com_users')) {
             $results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
             $results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JUtility::getToken() . '=1');
         }
         if ($params->get('name', 1) == 0) {
             $results[$k]->name = $results[$k]->username;
         }
     }
     return $results;
 }
Exemple #8
0
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_k2', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/item.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     // Fake parameters
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     // Clear userstate just in case
     $row = $this->save();
     if ($this->getError()) {
         $response = $this->getErrorResponse(400, $this->getError());
     } elseif (!$row->id) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_API_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $row->id;
     }
     $this->plugin->setResponse($response);
 }
 public function delete($id = null)
 {
     // Include dependencies
     jimport('joomla.application.component.controller');
     jimport('joomla.form.form');
     jimport('joomla.database.table');
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/controllers/categories.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_categories/models/forms/');
     // Fake parameters
     $_POST['task'] = 'trash';
     $_REQUEST['task'] = 'trash';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);
     $controller = new CategoriesControllerCategories();
     try {
         $controller->execute('trash');
     } catch (JException $e) {
         $success = false;
         $controller->set('messageType', 'error');
         $controller->set('message', $e->getMessage());
     }
     if ($controller->getError()) {
         $response = $this->getErrorResponse(400, $controller->getError());
     } elseif ('error' == $controller->get('messageType')) {
         $response = $this->getErrorResponse(400, $controller->get('message'));
     } else {
         $response = $this->getSuccessResponse(200, $controller->get('message'));
     }
     $this->plugin->setResponse($response);
 }
Exemple #10
0
	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
		$this->enabled		= $this->state->params->get('enabled');

		// Check for errors. @todo this has to be queed up and converted to JSON
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		$r = new JObject;
		$r->token = JUtility::getToken(true);
		$r->items = array();
		foreach ($this->items as $i => $item) {
			$rItem = new JObject;
			$rItem->index = $i + 1 + $this->pagination->limitstart;
			$rItem->search_term = $item->search_term;
			if ($this->state->get('filter.results')) {
				$rItem->results = (int) $item->returns;
			} else {
				$rItem->results = JText::_('COM_SEARCH_NO_RESULTS');
			}
			$r->items[$i] = $rItem;
		}
		
		echo json_encode($r);
	}
Exemple #11
0
    public function onAfterRoute()
    {
        $application = JFactory::getApplication();

        if($application->isSite())
        {
            switch(JRequest::getVar('option', null, 'method', 'cmd'))
            {
                case 'com_user':
                    JRequest::setVar('option', 'com_users', 'get');

                    switch(JRequest::getVar('view', null, 'method', 'cmd'))
                    {
                        case 'login':
                            if(!JFactory::getUser()->guest) {
                                JRequest::setVar('view', 'logout', 'get');
                            }

                            break;

                        case 'remind':
                            JRequest::setVar('view', 'remind', 'get');

                            break;

                        case 'register':
                            JRequest::setVar('view', 'user', 'get');
                            JRequest::setVar('layout', 'register', 'get');

                            break;

                        case 'user':
                            if(JRequest::getVar('task', null, 'get', 'cmd') == 'edit') {
                                JRequest::setVar('layout', 'form', 'get');
                            }
                    }

                    switch(JRequest::getVar('task', null, 'method', 'cmd'))
                    {
                        case 'login':
                            JRequest::setVar('view', 'login', 'get');
                            JRequest::setVar('action', 'login', 'post');
                            JRequest::setVar('password', JRequest::getVar('passwd', null, 'method', 'none'), 'post');

                            break;
                    }

                    break;
            }

            if(JRequest::getMethod() == 'POST')
            {
                $token = JUtility::getToken();

                if(JRequest::getVar($token, null, 'post', 'alnum') == 1) {
                    JRequest::setVar('_token', $token, 'post');
                }
            }
        }
    }
Exemple #12
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
Exemple #13
0
 function cria_html()
 {
     // adiciona a biblioteca juri
     jimport('joomla.environment.uri');
     // verifica se a urlbase foi adicionada
     if (!is_null($this->url_base)) {
         $u =& JURI::getInstance($this->url_base);
     } else {
         $u =& JURI::getInstance();
     }
     $links = '';
     $paginas_adm_select = '';
     $select = '';
     // loop nas páginas
     for ($i = 1; $i <= $this->total_paginas; $i++) {
         // adiciona a var na url
         $u->setVar($this->get_var_pagina, $i);
         // retorna o html tag a
         $class = $i == $this->pagina_atual ? ' class="atual"' : '';
         $links .= sprintf('<a href="%s"%s>%d</a> ', JRoute::_($u->toString()), $class, $i);
         // retorna o html select
         $selected = $i == $this->pagina_atual ? ' selected="selected"' : '';
         // cria o select para o site
         $select .= sprintf('<option value="%s" %s>Página %d</option> ', JRoute::_($u->toString()), $selected, $i);
         // cria o select para o adm
         $paginas_adm_select .= sprintf('<option value="%s" %s>Página %d</option> ', $i, $selected, $i);
     }
     // paginas para o adm
     $query = JRequest::get('post');
     unset($query[JUtility::getToken()], $query['funcao'], $query['method'], $query['class'], $query['pagina'], $query['programa'], $query['template'], $query['processID']);
     $u->setQuery($query);
     $u->setVar($this->get_var_pagina, '');
     $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){ eDesktop.dialog.load({programa: "%s", processID: "%s", pagina: "%s", query: "%s"+ $(this).val() }); });});</script>', $this->get_var_pagina, JRequest::getvar('programa'), JRequest::getvar('processID'), JRequest::getvar('pagina'), $u->getQuery());
     $paginas_adm_select = sprintf('<select name="%s" id="%s">%s</select>%s ', $this->get_var_pagina, $this->get_var_pagina, $paginas_adm_select, $js);
     $this->html['paginas.adm.select'] = $paginas_adm_select;
     // páginas para o site
     $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_pagina);
     $select = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_pagina, $this->get_var_pagina, $select, $js);
     $this->html['paginas.links'] = $links;
     $this->html['paginas.select'] = $select;
     // ordem para site
     $order = '';
     $this->order_atual = JRequest::getVar($this->get_var_order);
     if (count($this->orders)) {
         foreach ($this->orders as $k => $v) {
             $u->setVar($this->get_var_pagina, 1);
             $u->setVar($this->get_var_order, $k);
             $selected = $k == $this->order_atual ? ' selected="selected"' : '';
             $order .= sprintf('<option value="%s" %s>%s</option> ', JRoute::_($u->toString()), $selected, $v['label']);
         }
         $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_order);
         $order = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_order, $this->get_var_order, $order, $js);
         //
         $this->html['order.select'] = $order;
     }
     foreach ($this->html as $k => $v) {
         $key = str_replace('.', '_', $k);
         $this->html[$key] = $v;
     }
 }
Exemple #14
0
 function display($tpl = null)
 {
     // Frontpage hack
     $this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'link' . DS . 'tmpl');
     // Only allow "component" template
     JRequest::setVar('tmpl', 'component');
     // JFactory
     $user =& JFactory::getUser();
     $config =& JFactory::getConfig();
     $doc =& JFactory::getDocument();
     $lingo =& JFactory::getLanguage();
     // Include styles
     $doc->addStyleSheet(LINKR_ASSETS . 'css/modal.css?' . LINKR_VERSION_INC);
     // Template override
     global $mainframe;
     $tmpl = $mainframe->getTemplate();
     if (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'linkr.css')) {
         $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/linkr.css');
     } elseif (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'css' . DS . 'linkr.css')) {
         $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/css/linkr.css');
     }
     // Editor name, request endpoint, document base
     $editor = JRequest::getString('e_name', 'text');
     $rUrl = JURI::base() . 'index.php?option=com_linkr&view=request&' . JUtility::getToken() . '=1';
     // Include scripts
     JHTML::_('behavior.mootools');
     $unc = LinkrHelper::getParam('compress', 1) ? '.js' : '-UCP.js';
     $doc->addScript(LINKR_ASSETS . 'js/helper' . $unc . '?' . LINKR_VERSION_INC);
     $doc->addScriptDeclaration('var Linkr=new LinkrAPI(' . '[' . implode(',', explode('.', LINKR_VERSION_READ)) . '],' . '"' . $rUrl . '",' . '"' . $editor . '",' . '"' . JURI::root() . '",' . '[' . '"' . JRequest::getWord('mode', 'squeezebox') . '",' . '"' . $lingo->getTag() . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('MISSING_TEXT', true)) . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('IMG_ANCHOR', true)) . '",' . '"' . LINKR_ASSETS . 'img/",' . $user->get('aid') . ']' . ');' . 'var LinkrHelper=Linkr;');
     // Frontend fix
     if (LinkrHelper::isSite()) {
         //$doc->setBase(LinkrHelper::getLinkrUrl($editor));
     }
     // References
     $this->assign('links', $this->get('Links'));
     $this->assign('tools', $this->get('ToolLinks'));
     // Localize text
     if ($text = $this->get('L18N')) {
         $l18n = array();
         foreach ($text as $k => $v) {
             $l18n[] = '["' . $k . '","' . $v . '"]';
         }
         $doc->addScriptDeclaration('Linkr.setL18N([' . implode(',', $l18n) . ']);');
     }
     // 3rd party javascript
     if ($js = $this->get('Scripts')) {
         $doc->addScriptDeclaration($js);
     }
     // Load single link
     $load = '';
     $inc = $this->get('IncludedLinks');
     if (!$this->tools['count'] && $this->links['count'] == 1) {
         $load = 'Linkr.__fr=function(){' . $inc[$this->links['name'][0]] . '};';
     } elseif (!$this->links['count'] && $this->tools['count'] == 1) {
         $load = 'Linkr.__fr=function(){' . $inc[$this->tools['name'][0]] . '};';
     }
     // Fire "onLoad" event
     $doc->addScriptDeclaration('window.addEvent("domready",function(){' . $load . 'Linkr.fireEvent("onLoad");' . '});');
     parent::display($tpl);
 }
 public function display()
 {
     $this->assign('sitebase', trim(JURI::root(), '/'));
     $this->assign('token', JUtility::getToken());
     $this->assign('container', $this->getModel()->getState()->container);
     return parent::display();
 }
Exemple #16
0
 protected function _tokenValue($force = false)
 {
     if (empty($this->_token_value) || $force) {
         $this->_token_value = JUtility::getToken($force);
     }
     return parent::_tokenValue($force);
 }
Exemple #17
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.basetemplate');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     t3import('core.joomla.view');
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     T3Cache::getInstance($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $data = null;
     $user =& JFactory::getUser();
     if (!$devmode && JRequest::getCmd('cache') != 'no') {
         T3Cache::setCaching(true);
         JResponse::allowCache(true);
     }
     $data = T3Cache::get($key);
     if ($data) {
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $mainframe = JFactory::getApplication();
             $token = JUtility::getToken();
             $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
             $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
             $data = preg_replace($search, $replacement, $data);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     $doc =& JFactory::getDocument();
     $t3 = T3Template::getInstance($doc);
     $t3->_html = $data;
 }
Exemple #18
0
	/**
     * Initializes the options for the object
     *
     * Called from {@link __construct()} as a first step of object instantiation.
     *
     * @param   object  An optional KConfig object with configuration options
     * @return void
     */
    protected function _initialize(KConfig $config)
    {
        $config->append(array(
            'token_value'   => JUtility::getToken(),
        ));

        parent::_initialize($config);
    }
Exemple #19
0
 /**
  * Creates a new registry object.
  */
 public function get($contents = '')
 {
     $version = EasyBlogHelper::getJoomlaVersion();
     if ($version >= '1.6') {
         return JFactory::getSession()->getFormToken();
     }
     return JUtility::getToken();
 }
Exemple #20
0
 public function getOnClick()
 {
     $option = KRequest::get('get.option', 'cmd');
     $view = KRequest::get('get.view', 'cmd');
     $token = JUtility::getToken();
     $json = "{method:'post', url:'index.php?option={$option}&view={$view}&'+id, params:{action:'edit', enabled:0, _token:'{$token}'}}";
     $msg = JText::_('Please select an item from the list');
     return 'var id = Koowa.Grid.getIdQuery();' . 'if(id){new Koowa.Form(' . $json . ').submit();} ' . 'else { alert(\'' . $msg . '\'); return false; }';
 }
Exemple #21
0
 public function display()
 {
     $this->assign('sitebase', trim(JURI::root(), '/'));
     $this->assign('token', JUtility::getToken());
     if (!$this->editor) {
         $this->assign('editor', '');
     }
     return parent::display();
 }
Exemple #22
0
 public function getOnClick()
 {
     $option = KRequest::get('get.option', 'cmd');
     $view = KRequest::get('get.view', 'cmd');
     $id = KRequest::get('get.id', 'int');
     $token = JUtility::getToken();
     $json = "{method:'post', url:'index.php?option={$option}&view={$view}&id={$id}', element:'adminForm', params:{action:'save', _token:'{$token}'}}";
     return 'new Koowa.Form(' . $json . ').submit();';
 }
Exemple #23
0
 /**
  * Display the view
  */
 function display()
 {
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'category', 'default', 'cmd');
     $viewType = $document->getType();
     // interceptors to support legacy urls
     switch ($this->getTask()) {
         //index.php?option=com_contact&task=category&id=0&Itemid=4
         case 'category':
             $viewName = 'category';
             $layout = 'default';
             break;
         case 'view':
             $viewName = 'contact';
             $layout = 'default';
             break;
     }
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     // Push a model into the view
     $model =& $this->getModel($viewName);
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     // Workaround for the item view
     if ($viewName == 'contact') {
         $modelCat =& $this->getModel('category');
         $view->setModel($modelCat);
     }
     // Display the view
     $view->assign('error', $this->getError());
     // View caching logic -- simple... are we logged in?
     $user =& JFactory::getUser();
     $viewnow = JRequest::getVar('view');
     $viewcache = JRequest::getVar('viewcache', '1', 'POST', 'INT');
     if ($user->get('id') || $viewnow == 'category' && $viewcache == 0) {
         $view->display();
     } else {
         // Workaround for token caching
         if ($viewName == 'contact') {
             ob_start();
         }
         $option = JRequest::getCmd('option');
         $cache =& JFactory::getCache($option, 'view');
         $cache->get($view, 'display');
         // Workaround for token caching
         if ($viewName == 'contact') {
             $contents = ob_get_contents();
             ob_end_clean();
             $token = JUtility::getToken();
             $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
             $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
             echo preg_replace($search, $replacement, $contents);
         }
     }
 }
Exemple #24
0
 public static function getToken($contents = '')
 {
     $version = DiscussHelper::getJoomlaVersion();
     if ($version >= '1.6') {
         $token = JFactory::getSession()->getFormToken();
     } else {
         $token = JUtility::getToken();
     }
     return $token;
 }
Exemple #25
0
 /**
  * 
  * @return void
  **/
 function _default($tpl = null)
 {
     Tienda::load('TiendaSelect', 'library.select');
     Tienda::load('TiendaGrid', 'library.grid');
     Tienda::load('TiendaTools', 'library.tools');
     // check config
     $row = Tienda::getInstance();
     $this->assign('row', $row);
     // add toolbar buttons
     JToolBarHelper::apply('save');
     JToolBarHelper::cancel('close', 'COM_TIENDA_CLOSE');
     // plugins
     $filtered = array();
     $items = TiendaTools::getPlugins();
     for ($i = 0; $i < count($items); $i++) {
         $item =& $items[$i];
         // Check if they have an event
         if ($hasEvent = TiendaTools::hasEvent($item, 'onListConfigTienda')) {
             // add item to filtered array
             $filtered[] = $item;
         }
     }
     $items = $filtered;
     $this->assign('items_sliders', $items);
     // Add pane
     jimport('joomla.html.pane');
     $sliders = JPane::getInstance('sliders');
     $this->assign('sliders', $sliders);
     // form
     $validate = JUtility::getToken();
     $form = array();
     $view = strtolower(JRequest::getVar('view'));
     $form['action'] = "index.php?option=com_tienda&controller={$view}&view={$view}";
     $form['validate'] = "<input type='hidden' name='{$validate}' value='1' />";
     $this->assign('form', $form);
     // set the required image
     // TODO Fix this to use defines
     $required = new stdClass();
     $required->text = JText::_('COM_TIENDA_REQUIRED');
     $required->image = "<img src='" . JURI::root() . "/media/com_tienda/images/required_16.png' alt='{$required->text}'>";
     $this->assign('required', $required);
     // Elements
     $elementArticleModel = JModel::getInstance('ElementArticle', 'TiendaModel');
     $this->assign('elementArticleModel', $elementArticleModel);
     // terms
     $elementArticle_terms = $elementArticleModel->fetchElement('article_terms', @$row->get('article_terms'));
     $resetArticle_terms = $elementArticleModel->clearElement('article_terms', '0');
     $this->assign('elementArticle_terms', $elementArticle_terms);
     $this->assign('resetArticle_terms', $resetArticle_terms);
     // shipping
     $elementArticle_shipping = $elementArticleModel->fetchElement('article_shipping', @$row->get('article_shipping'));
     $resetArticle_shipping = $elementArticleModel->clearElement('article_shipping', '0');
     $this->assign('elementArticle_shipping', $elementArticle_shipping);
     $this->assign('resetArticle_shipping', $resetArticle_shipping);
 }
 public function display()
 {
     $state = $this->getModel()->getState();
     if (empty($state->limit)) {
         $state->limit = JFactory::getApplication()->getCfg('list_limit');
     }
     $this->assign('sitebase', trim(JURI::root(), '/'));
     $this->assign('token', version_compare(JVERSION, '3.0', 'ge') ? JSession::getFormToken() : JUtility::getToken());
     $this->assign('container', $this->getModel()->getState()->container);
     return parent::display();
 }
Exemple #27
0
 /**
  * Display the view
  */
 function display()
 {
     //menu links use fabriklayout parameters rather than layout
     $flayout = JRequest::getVar('fabriklayout');
     if ($flayout != '') {
         JRequest::setVar('layout', $flayout);
     }
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'form', 'default', 'cmd');
     $modelName = $viewName;
     if ($viewName == 'emailform') {
         $modelName = 'form';
     }
     if ($viewName == 'details') {
         //huh why was this here? - stopped detailed view from ever ever being loaded
         //JRequest::setVar('view', 'form');
         $viewName = 'form';
         $modelName = 'form';
     }
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     // Push a model into the view
     $model =& $this->getModel($modelName);
     if (!JError::isError($model) && is_object($model)) {
         $view->setModel($model, true);
     }
     // Display the view
     $view->assign('error', $this->getError());
     $cachable = false;
     if ($viewName = 'form' || ($viewName = 'details')) {
         $cachable = true;
     }
     $user =& JFactory::getUser();
     if ($viewType != 'feed' && !$this->_isMambot && $user->get('id') == 0) {
         //$cache =& JFactory::getCache('com_fabrik', 'view');
         //$cache->get($view, 'display');
         // Workaround for token caching
         ob_start();
         $option = JRequest::getCmd('option');
         $cache =& JFactory::getCache('com_fabrik', 'view');
         $cache->get($view, 'display');
         // Workaround for token caching
         $contents = ob_get_contents();
         ob_end_clean();
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $contents = preg_replace($search, $replacement, $contents);
         echo $contents;
     } else {
         return $view->display();
     }
 }
 function display($steps, $workflow, $data)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $response = $pManager->invokeMethod('acl', 'getMyGroupId', array($workflow->acl), null);
     $myGroups = $response[$workflow->acl];
     $user =& JFactory::getUser();
     JHTML::_('script', 'comments.js', 'media/com_jwf/plugins/field_handlers/comments/');
     JHTML::_('stylesheet', 'comments.css', 'media/com_jwf/plugins/field_handlers/comments/');
     $currentStep = null;
     foreach ($steps as $step) {
         if ($step->current == 1) {
             $currentStep = $step;
             break;
         }
     }
     $output = JHTML::_('jwf.startJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "var workflowID = {$currentStep->wid};", 3);
     $output .= JHTML::_('jwf.indentedLine', "var stationID  = {$currentStep->sid};", 3);
     $output .= JHTML::_('jwf.indentedLine', "var itemID     = {$currentStep->iid};", 3);
     $output .= JHTML::_('jwf.indentedLine', "var stepID     = {$currentStep->id};", 3);
     $output .= JHTML::_('jwf.indentedLine', "var jtoken     = '" . JUtility::getToken() . "';", 3);
     $output .= JHTML::_('jwf.endJSBlock', 2);
     $output .= JHTML::_('jwf.indentedLine', "<div id='field-comments'>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<div id='jwf_comment_overlay'></div><img id='jwf_comment_loading' src='administrator/components/com_jwf/plugins/field_handlers/comments/loading.gif' alt='loading' />", 2);
     if ($data) {
         $k = false;
         foreach ($data as $comment) {
             $k = !$k;
             $class = $k ? 'odd' : 'even';
             $output .= JHTML::_('jwf.indentedLine', "<div class='comment {$class}'>", 2);
             if (in_array($workflow->admin_gid, array_keys($myGroups)) || canManageWorkflows() || $user->get('id') == $comment->created_by) {
                 $output .= JHTML::_('jwf.indentedLine', "<a class='edit' href='javascript:onEdit({$comment->id})'>" . JText::_('Edit') . "</a>", 2);
                 $output .= JHTML::_('jwf.indentedLine', "<a class='edit' href='javascript:deleteComment({$comment->id})'>" . JText::_('Delete') . "</a>", 2);
             }
             $output .= JHTML::_('jwf.indentedLine', "<div class='created'>" . JText::_('By') . " <span class='user'>{$comment->creator} </span> " . JText::_('On') . " {$comment->created} ( <span class='ago'>" . JHTML::_('jwf.timeDifference', $comment->created) . JTEXT::_('Ago') . " </span> )</div>", 2);
             if ($comment->created != $comment->modified) {
                 $output .= JHTML::_('jwf.indentedLine', "<div class='modified'>" . JText::_('Last modified By') . " <span class='user'> {$comment->modifier} </span>" . JText::_('On') . " {$comment->modified} ( <span class='ago'>" . JHTML::_('jwf.timeDifference', $comment->modified) . JTEXT::_('Ago') . "</span> )</div>", 2);
             }
             $output .= JHTML::_('jwf.indentedLine', "<br clear='all' />", 2);
             $output .= JHTML::_('jwf.indentedLine', "<div class='text' id='jwf_comment_{$comment->id}'>" . base64_decode($comment->value) . "</div>", 2);
             $output .= JHTML::_('jwf.indentedLine', "</div>", 2);
         }
     }
     $output .= JHTML::_('jwf.indentedLine', "<div id='jwf_comment_compact_editor' style='display:none'><textarea id='jwf_comment_compact_editor_input'></textarea><br /><input type='button' onclick='saveComment()' value='" . JText::_('Save') . "' /><input type='button' onclick='javascript:cancelEdit()' value='" . JText::_('Cancel') . "' /></div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<div id='jwf_comment_editor'>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<label for='jwf_comment_editor_input'>" . JText::_('Your Comment') . "</label>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<textarea id='jwf_comment_editor_input'></textarea>", 2);
     $output .= JHTML::_('jwf.indentedLine', "<input type='button' value='" . JText::_('Post') . "' onclick='newComment()' />", 2);
     $output .= JHTML::_('jwf.indentedLine', "</div>", 2);
     $output .= JHTML::_('jwf.indentedLine', "</div>", 2);
     return $output;
 }
Exemple #29
0
 function getLinkrUrl($editor = 'text')
 {
     // Linkr URL
     $link = 'index.php?option=com_linkr&amp;view=link&amp;tmpl=component&amp;e_name=' . $editor;
     // Use "popup" mode for IE
     jimport('joomla.environment.browser');
     $browser =& JBrowser::getInstance();
     if ($browser->getBrowser() == 'msie') {
         $link .= '&amp;mode=popup';
     }
     // Return link
     return JRoute::_($link . '&amp;' . JUtility::getToken() . '=1');
 }
Exemple #30
0
 function &getFormData()
 {
     if (!isset($this->_fd)) {
         $i = new JObject();
         $s =& JFactory::getSession();
         $i->set('basepath', $this->getBasePath());
         $i->set('files', $this->getFiles());
         $i->set('uploadURL', JURI::base() . index . '&task=file.upload&mm=1&tool=badges&' . JUtility::getToken() . '=1&' . $s->getName() . '=' . $s->getId());
         $i->set('deleteURL', JURI::base() . index . '&task=file.delete&mm=1&tool=badges&' . JUtility::getToken() . '=1&' . $s->getName() . '=' . $s->getId() . '&file=');
         $this->_fd = $i;
     }
     $ref =& $this->_fd;
     return $ref;
 }