<?php
/**
 * @version: $Id: help.php 3317 2013-03-28 13:25:35Z Sigrid Suski $
 * @package: SobiPro Library

 * @author
 * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
 * Email: sobi[at]sigsiu.net
 * Url: http://www.Sigsiu.NET

 * @copyright Copyright (C) 2006 - 2013 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
 * @license GNU/LGPL Version 3
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
 * See http://www.gnu.org/licenses/lgpl.html and http://sobipro.sigsiu.net/licenses.

 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

 * $Date: 2013-03-28 14:25:35 +0100 (Thu, 28 Mar 2013) $
 * $Revision: 3317 $
 * $Author: Sigrid Suski $
 * $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Site/lib/ctrl/adm/help.php $
 */

defined( 'SOBIPRO' ) || exit( 'Restricted access' );
SPLoader::loadController( 'controller' );
/**
 * @author Radek Suski
 * @version 1.0
 * @created 23-Jul-2010 13:11:48
 */
class SPHelp extends SPController
{
	/**
	 * @var string
	 */
	protected $_defTask = 'message';

	public function execute()
	{
		$this->_task = strlen( $this->_task ) ? $this->_task : $this->_defTask;
		switch ( $this->_task ) {
			case 'message':
				$this->screen();
			default:
				break;
		}
	}
	private function screen()
	{
		$view =& SPFactory::View( 'view', true );
		$view->setTemplate( 'config.help' );
		if( SPLoader::path( 'etc.repos.sobipro_core.repository', 'front', true, 'xml' ) ) {
			$repository = SPFactory::Instance( 'services.installers.repository' );
			$repository->loadDefinition( SPLoader::path( "etc.repos.sobipro_core.repository", 'front', true, 'xml' ) );
			try {
				$repository->connect();
			}
			catch ( SPException $x ) {
				$view->assign( SPLang::e( 'REPO_ERR', $x->getMessage() ), 'message' );
			}
			try {
				$response = $repository->help( $repository->get( 'token' ), SPRequest::cmd( 'mid' ) );
				$view->assign( $response, 'message' );
			}
			catch ( SPException $x ) {
				$view->assign( SPLang::e( 'REPO_ERR', $x->getMessage() ), 'message' );
			}
		}
		else {
			$view->assign( Sobi::Txt( 'MSG.HELP_ADD_CORE_REPO' ), 'message' );
		}
		$view->display();
	}
}
