Example #1
0
 public function onBeforeMain()
 {
     // Load system defines
     if (file_exists(APATH_ROOT . '/defines.php')) {
         include_once APATH_ROOT . '/defines.php';
     }
     if (!defined('_JDEFINES')) {
         define('JPATH_BASE', APATH_SITE);
         require_once JPATH_BASE . '/includes/defines.php';
     }
     // Load the rest of the framework include files
     if (file_exists(JPATH_LIBRARIES . '/import.legacy.php')) {
         require_once JPATH_LIBRARIES . '/import.legacy.php';
     } else {
         require_once JPATH_LIBRARIES . '/import.php';
     }
     require_once JPATH_LIBRARIES . '/cms.php';
     // You can't fix stupid… but you can try working around it
     if (!function_exists('json_encode') || !function_exists('json_decode')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/helpers/jsonlib.php';
     }
     // Load the JApplicationCli class
     JLoader::import('joomla.application.web');
     require_once APATH_INSTALLATION . '/angie/assets/runscripts.php';
     $run = JApplicationWeb::getInstance('RunScripts');
     $run->execute();
     return false;
 }
Example #2
0
 /**
  * Class constructor.
  *
  * @since   3.1
  */
 public function __construct()
 {
     // Run the parent constructor
     parent::__construct();
     // Load and set the dispatcher
     $this->loadDispatcher();
     // Enable sessions by default.
     if (is_null($this->config->get('session'))) {
         $this->config->set('session', true);
     }
     // Set the session default name.
     if (is_null($this->config->get('session_name'))) {
         $this->config->set('session_name', 'installation');
     }
     // Create the session if a session name is passed.
     if ($this->config->get('session') !== false) {
         $this->loadSession();
         // Register the session with JFactory
         JFactory::$session = $this->getSession();
     }
     // Store the debug value to config based on the JDEBUG flag
     $this->config->set('debug', JDEBUG);
     // Register the config to JFactory
     JFactory::$config = $this->config;
     // Register the application to JFactory
     JFactory::$application = $this;
     // Set the root in the URI based on the application name
     JUri::root(null, str_ireplace('/installation', '', JUri::base(true)));
 }
Example #3
0
 /**
  * Overrides the parent constructor to set the execution start time.
  *
  * @param   mixed  $input   An optional argument to provide dependency injection for the application's
  *                          input object.  If the argument is a JInput object that object will become
  *                          the application's input object, otherwise a default input object is created.
  * @param   mixed  $config  An optional argument to provide dependency injection for the application's
  *                          config object.  If the argument is a JRegistry object that object will become
  *                          the application's config object, otherwise a default config object is created.
  * @param   mixed  $client  An optional argument to provide dependency injection for the application's
  *                          client object.  If the argument is a JApplicationWebClient object that object will become
  *                          the application's client object, otherwise a default client object is created.
  *
  * @since   11.3
  */
 public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
 {
     $this->_startTime = microtime(true);
     parent::__construct($input, $config, $client);
     $this->errors = new WebServiceApplicationWebErrors($this, $this->input);
     $this->errors->checkSupressResponseCodes();
 }
Example #4
0
 /**
  * Class constructor.
  *
  * @param   mixed  $input   An optional argument to provide dependency injection for the application's
  *                          input object.  If the argument is a JInput object that object will become
  *                          the application's input object, otherwise a default input object is created.
  * @param   mixed  $config  An optional argument to provide dependency injection for the application's
  *                          config object.  If the argument is a JRegistry object that object will become
  *                          the application's config object, otherwise a default config object is created.
  * @param   mixed  $client  An optional argument to provide dependency injection for the application's
  *                          client object.  If the argument is a JApplicationWebClient object that object will become
  *                          the application's client object, otherwise a default client object is created.
  */
 public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
 {
     parent::__construct($input, $config, $client);
     $this->config->set('session', false);
     // Inject the application into JFactory
     JFactory::$application = $this;
 }
Example #5
0
	public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
	{
		parent::__construct($input, $config, $client);

		// Load and set the dispatcher
		$this->loadDispatcher();

		// Register the application to JFactory
		JFactory::$application = $this;

		// Enable sessions by default.
		if (is_null($this->config->get('session')))
		{
			$this->config->set('session', true);
		}

		// Set the session default name.
		if (is_null($this->config->get('session_name')))
		{
			$this->config->set('session_name', 'site');
		}

		// Create the session if a session name is passed.
		if ($this->config->get('session') !== false)
		{
			$this->loadSession();

			// Register the session with JFactory
			JFactory::$session = $this->getSession();
		}
	}
 function __construct()
 {
     parent::__construct();
     $this->db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', JApplicationWeb::getInstance()->get('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest('easyjoomlabackup.limitstart', 'limitstart', 0, 'int');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $search = $app->getUserStateFromRequest('easyfrontendseo.filter.search', 'filter_search', null);
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
     $this->setState('filter.search', $search);
 }
 function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', JApplicationWeb::getInstance()->get('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest('joomlachecksumscanner.limitstart', 'limitstart', 0, 'int');
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $search = $app->getUserStateFromRequest('joomlachecksumscanner.filter.search', 'filter_search', null);
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
     $this->setState('filter.search', $search);
     $this->_db = JFactory::getDbo();
     $this->_input = JFactory::getApplication()->input;
     $this->_params = JComponentHelper::getParams('com_joomlachecksumscanner');
     $this->_snapshot_datetime = JFactory::getDate('now', JFactory::getApplication()->getCfg('offset'));
 }
Example #8
0
 /**
  * Gets a content form.
  *
  * @param   string  $type  The content type.
  *
  * @return  JForm  The form object.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function getForm($type)
 {
     // Get the form name.
     $name = 'JContent' . $type;
     try {
         // Get the base form.
         $form = JForm::getInstance($name, 'content', array('control' => 'jform'));
         // Load the type form.
         $form->loadFile($type, false, false);
         // Trigger the form preparation event.
         $this->app->triggerEvent('onContentPrepareForm', array($form));
     } catch (Exception $error) {
         throw new RuntimeException($error->getMessage(), $error->getCode(), $error);
     }
     return $form;
 }
Example #9
0
 /**
  * Method to check whether the user can check out an item.
  *
  * @return  boolean  True if the item can be checked out, false otherwise.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function canCheckout()
 {
     // Assert the object is loaded.
     $this->assertIsLoaded();
     // Get the session id.
     $sessionId = $this->app->getSession()->getId();
     // Check if the item is checked out at all.
     if (!empty($this->checked_out_session) && $this->checked_out_session != $sessionId) {
         // Build the query to check if the item is editable.
         $query = $this->db->getQuery(true);
         $query->select('a.content_id');
         $query->from('#__content AS a');
         $query->join('INNER', '#__session AS s ON s.session_id = a.checked_out_session');
         $query->where('a.content_id = ' . (int) $this->content_id);
         // Get the checked out state.
         $this->db->setQuery($query);
         $checkedOut = (int) $this->db->loadResult();
         // Check if the checked out session is still valid.
         if ($checkedOut) {
             return false;
         }
     }
     return true;
 }
<?php

/**
 * @package    Joomla.Installation
 *
 * @copyright  Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
/**
 * Define the application's minimum supported PHP version as a constant so it can be referenced within the application.
 */
define('JOOMLA_MINIMUM_PHP', '5.3.10');
if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<')) {
    die('Your host needs to use PHP ' . JOOMLA_MINIMUM_PHP . ' or higher to run this version of Joomla!');
}
/**
 * Constant that is checked in included files to prevent direct access.
 * define() is used in the installation folder rather than "const" to not error for PHP 5.2 and lower
 */
define('_JEXEC', 1);
// Bootstrap the application
require_once dirname(__FILE__) . '/application/bootstrap.php';
// Get the application
$app = JApplicationWeb::getInstance('InstallationApplicationWeb');
// Execute the application
$app->execute();
        //
        // You can append to the body of the response using appendBody.
        //
        // Set up the beginning of the HTML repsonse.
        $this->appendBody('<html>')->appendBody('<head>')->appendBody('<title>JApplicationWeb - Detect Client</title>')->appendBody('</head>')->appendBody('<body style="font-family:verdana;">');
        // Introduce the page.
        $this->appendBody('<p>Welcome to the Joomla! Platform&apos;s <code style="font-size:140%">JApplicationWeb</code> class.</p>');
        // Start a list.
        $this->appendBody('<ul>');
        //
        // The client information is accessible via the get method.
        //
        // Get the user agent string.
        $this->appendBody(sprintf('<li>User-agent: <em>%s</em></li>', $this->client->userAgent));
        // Determine if this is a mobile device.
        $this->appendBody(sprintf('<li>Is a mobile device? <em>%s</em></li>', $this->client->mobile ? 'Yes' : 'No'));
        // Get the platform.
        $this->appendBody(sprintf('<li>Platform: <em>%s</em></li>', $this->client->platform));
        // Get the engine.
        $this->appendBody(sprintf('<li>Engine: <em>%s</em></li>', $this->client->engine));
        // Get the browser and version.
        $this->appendBody(sprintf('<li>Browser: <em>%s (%s)</em></li>', $this->client->browser, $this->client->browserVersion));
        $this->appendBody('</ul>');
        // Finished up the HTML repsonse.
        $this->appendBody('</body>')->appendBody('</html>');
    }
}
// Instantiate the application object, passing the class name to JApplicationWeb::getInstance
// and use chaining to execute the application.
JApplicationWeb::getInstance('DetectClient')->execute();
Example #12
0
 * @package ECR_COM_NAME
 */
class ECR_COM_NAME extends JApplicationWeb
{
    /**
     * Overrides the parent doExecute method to run the web application.
     *
     * This method should include your custom code that runs the application.
     *
     * @return  void
     */
    protected function doExecute()
    {
        // This application will just output a simple HTML document.
        // Use the setBody method to set the output.
        // JApplicationWeb will take care of all the headers and such for you.
        $this->setBody('
            <html>
                <head>
                    <title>Hello WWW</title>
                </head>
                <body style="font-family:verdana;">
                    <p>Hello WWW!</p>
                </body>
            </html>');
    }
}
// Instantiate the application object, passing the class name to JApplicationWeb::getInstance
// and use chaining to execute the application.
JApplicationWeb::getInstance('ECR_COM_NAME')->execute();
Example #13
0
                $result = $db->loadObject();

                if ($result && $result->otpKey != '')
                {
                    //jimport('sourcecoast.utilities');
                    //SCStringUtilities::loadLanguage('mod_sclogin');
                    JFactory::getLanguage()->load('mod_sclogin');

                    //$password = JRequest::getString('p', '', 'POST', JREQUEST_ALLOWRAW);
                    //if (JUserHelper::verifyPassword($password, $result->password, $result->id))
                    //{
                    $response->needsOtp = 'true';
                    ob_start();
                    require(JModuleHelper::getLayoutPath('mod_sclogin', 'otp'));
                    $response->form = ob_get_clean();
                    //}
                }
            }
        }

        echo json_encode($response);
        exit;
    }
}

// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
$app = JApplicationWeb::getInstance('SourcecoastTfaCheckWeb');
// Loading the 'site' application to make sure our session (and other) data is from the 'site'.. sounds obvious, but documenting it, because it won't be the next time I look at this.
JFactory::getApplication('site');
$app->execute();
Example #14
0
/**
 * Web server entry point for the WebService Application.
 *
 * @package    WebService.Application
 *
 * @copyright  Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
// Bootstrap the application.
$path = getenv('WEBSERVICE_HOME');
if ($path) {
    require_once $path . '/bootstrap.php';
} else {
    require_once realpath(__DIR__ . '/../code/bootstrap.php');
}
try {
    // Instantiate the application.
    $application = JApplicationWeb::getInstance('WebServiceApplicationWeb');
    // Set the default JInput class for the application to use JSON input.
    // 	$application->input = new JInputJson;
    // Store the application.
    JFactory::$application = $application;
    // Execute the application.
    $application->loadDatabase()->loadRouter()->execute();
} catch (Exception $e) {
    // Set the server response code.
    header('Status: 500', true, 500);
    // An exception has been caught, echo the message and exit.
    echo json_encode(array('message' => $e->getMessage(), 'code' => $e->getCode(), 'type' => get_class($e)));
    exit;
}
Example #15
0
 /**
  * Redirect to another URL.
  *
  * If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently"
  * or "303 See Other" code in the header pointing to the new location. If the headers have already been
  * sent this will be accomplished using a JavaScript statement.
  *
  * @param   string   $url    The URL to redirect to. Can only be http/https URL
  * @param   boolean  $moved  True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function redirect($url, $moved = false)
 {
     // Handle B/C by checking if a message was passed to the method, will be removed at 4.0
     if (func_num_args() > 1) {
         $args = func_get_args();
         /*
          * Do some checks on the $args array, values below correspond to legacy redirect() method
          *
          * $args[0] = $url
          * $args[1] = Message to enqueue
          * $args[2] = Message type
          * $args[3] = $moved
          */
         if (isset($args[1]) && !empty($args[1]) && !is_bool($args[1])) {
             // Log that passing the message to the function is deprecated
             JLog::add('Passing a message and message type to JFactory::getApplication()->redirect() is deprecated. ' . 'Please set your message via JFactory::getApplication()->enqueueMessage() prior to calling redirect().', JLog::WARNING, 'deprecated');
             $message = $args[1];
             // Set the message type if present
             if (isset($args[2]) && !empty($args[2])) {
                 $type = $args[2];
             } else {
                 $type = 'message';
             }
             // Enqueue the message
             $this->enqueueMessage($message, $type);
             // Reset the $moved variable
             $moved = isset($args[3]) ? (bool) $args[3] : false;
         }
     }
     // Persist messages if they exist.
     if (count($this->_messageQueue)) {
         $session = JFactory::getSession();
         $session->set('application.queue', $this->_messageQueue);
     }
     // Hand over processing to the parent now
     parent::redirect($url, $moved);
 }
*/
class HelloWww extends JApplicationWeb
{
    /**
     * Overrides the parent doExecute method to run the web application.
     *
     * This method should include your custom code that runs the application.
     *
     * @return  void
     *
     * @since   11.3
     */
    protected function doExecute()
    {
        // This application will just output a simple HTML document.
        // Use the setBody method to set the output.
        // JApplicationWeb will take care of all the headers and such for you.
        $this->setBody('<html>
			<head>
				<title>Hello WWW</title>
			</head>
			<body style="font-family:verdana;">
				<p>Hello WWW!</p>
			</body>
			</html>');
    }
}
// Instantiate the application object, passing the class name to JApplicationWeb::getInstance
// and use chaining to execute the application.
JApplicationWeb::getInstance('HelloWww')->execute();
Example #17
0
}
if (!defined('JPATH_CACHE')) {
    define('JPATH_CACHE', '/tmp/cache');
}
if (!defined('JPATH_CONFIGURATION')) {
    define('JPATH_CONFIGURATION', $JAPIHOME . '/etc');
}
if (!defined('JPATH_API')) {
    define('JPATH_API', $JAPIHOME . '/api');
}
if (!defined('JPATH_PLUGINS')) {
    define('JPATH_PLUGINS', $JAPIHOME . '/plugins');
}
try {
    // Fire up the API importer.
    if (file_exists(JPATH_API . '/import.php')) {
        require JPATH_API . '/import.php';
    }
    // Instantiate the application.
    $application = JApplicationWeb::getInstance('ApiApplicationWeb');
    // Store the application.
    JFactory::$application = $application;
    // Execute the application.
    $application->loadSession()->loadDatabase()->loadIdentity()->loadDispatcher()->fetchStandardMaps()->loadRouter()->execute();
} catch (Exception $e) {
    // Set the server response code.
    header('Status: 500', true, 500);
    // An exception has been caught, echo the message and exit.
    echo json_encode(array('message' => $e->getMessage(), 'code' => $e->getCode(), 'type' => get_class($e)));
    exit;
}
Example #18
0
 public function download()
 {
     // turn off all error reporting to prevent errors showing in download file
     error_reporting(0);
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.archive.zip');
     jimport('joomla.application.web');
     JApplicationWeb::clearHeaders();
     $path = JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/templates/';
     $folder = JRequest::getVar('template', '', '', 'string');
     $fullPath = JPath::clean($path . '/' . $folder);
     $files = JFolder::files($fullPath, '.', false, false);
     $archive = $path . $folder . '.zip';
     $filesData = array();
     for ($i = 0; $i < count($files); $i++) {
         $filesData[$i]['name'] = $files[$i];
         $filesData[$i]['data'] = file_get_contents($fullPath . '/' . $files[$i]);
     }
     // delete file if it already exists
     @chmod($path . '/' . $folder . '.zip', 0777);
     @unlink($path . '/' . $folder . '.zip');
     $JArchiveZip = JArchive::getAdapter('zip');
     $JArchiveZip->create($archive, $filesData);
     // push download
     ob_end_clean();
     ob_start();
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header("Content-Description: File Transfer");
     header("Content-type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"{$folder}.zip\"");
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . filesize($archive));
     readfile($archive);
     ob_end_flush();
 }
Example #19
0
 /**
  * Method to send the application response to the client.  All headers will be sent prior to the main
  * application output data.
  *
  * @return  void
  *
  * @since   3.2
  */
 protected function respond()
 {
     $runtime = microtime(true) - $this->_startTime;
     // Set the Server and X-Powered-By Header.
     $this->setHeader('Server', '', true);
     $this->setHeader('X-Powered-By', 'JoomlaWebAPI/1.0', true);
     $this->setHeader('X-Runtime', $runtime, true);
     $this->setHeader('Access-Control-Allow-Origin', '*', true);
     // Copy document encoding and charset into application.
     $this->mimeType = $this->getDocument()->getMimeEncoding();
     $this->charSet = $this->getDocument()->getCharset();
     parent::respond();
 }
	/**
	 * Display
	 *
	 * @return bool
	 *
	 * @throws \Exception
	 * @since       1.7.2
	 */
	public function display()
	{
		// Get model data.
		$item = $this->get('Item');

		$middlename = null;

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			Throw new Exception(implode("\n", $errors));
		}

		JFactory::getDocument()->setMetaData('Content-Type', 'text/directory', true);

		// Compute lastname, firstname and middlename
		$item->name = trim($item->name);

		// "Lastname, Firstname Midlename" format support
		// e.g. "de Gaulle, Charles"
		$namearray = explode(',', $item->name);

		if (count($namearray) > 1)
		{
			$lastname         = $namearray[0];
			$card_name        = $lastname;
			$name_and_midname = trim($namearray[1]);

			$firstname = '';

			if (!empty($name_and_midname))
			{
				$namearray = explode(' ', $name_and_midname);

				$firstname  = $namearray[0];
				$middlename = (count($namearray) > 1) ? $namearray[1] : '';
				$card_name  = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name;
			}
		}
		// "Firstname Middlename Lastname" format support
		else
		{
			$namearray = explode(' ', $item->name);

			$middlename = (count($namearray) > 2) ? $namearray[1] : '';
			$firstname  = array_shift($namearray);
			$lastname   = count($namearray) ? end($namearray) : '';
			$card_name  = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : '');
		}

		$rev = date('c', strtotime($item->modified));

		$web = new JApplicationWeb;
		$web->setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true);

		$vcard = [];
		$vcard[] .= 'BEGIN:VCARD';
		$vcard[] .= 'VERSION:3.0';
		$vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename;
		$vcard[] = 'FN:' . $item->name;
		$vcard[] = 'TITLE:' . $item->con_position;
		$vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone;
		$vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax;
		$vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile;
		$vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country;
		$vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country;
		$vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to;
		$vcard[] = 'URL:' . $item->webpage;
		$vcard[] = 'REV:' . $rev . 'Z';
		$vcard[] = 'END:VCARD';

		echo implode("\n", $vcard);

		return true;
	}
 /**
  * CVS Dump
  *
  * @param   object  $items   Items to pass through
  * @param   string  $report  Name of report to return.
  *
  * @return bool
  *
  * @since    1.7.0
  */
 public function getCsv($items, $report)
 {
     $date = new JDate('now');
     $jWeb = new JApplicationWeb();
     $csv = fopen('php://output', 'w');
     $jWeb->clearHeaders();
     // Clean the output buffer,
     @ob_end_clean();
     @ob_start();
     header("Content-type: text/csv");
     header("Content-Disposition: attachment; filename=report." . $report . '.' . $date->format('Y-m-d-His') . ".csv");
     header("Pragma: no-cache");
     header("Expires: 0");
     $count = 0;
     foreach ($items as $line) {
         foreach ($line as $c => $item) {
             if ($c == 'params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'attribs') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 $params_att = new stdClass();
                 foreach ($params as $p => $item_p) {
                     $p = 'att_' . $p;
                     if ($p == 'sex') {
                         switch ($item_p) {
                             case 0:
                                 $params_att->{$p} = 'M';
                                 break;
                             case 1:
                                 $params_att->{$p} = 'F';
                                 break;
                         }
                     } else {
                         $params_att->{$p} = $item_p;
                     }
                 }
                 unset($line->attribs);
                 $line = (object) array_merge((array) $line, (array) $params_att);
             } elseif ($c == 'kml_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->kml_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'category_params') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->category_params);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'metadata') {
                 $reg = new Joomla\Registry\Registry();
                 $reg->loadString($item);
                 $params = $reg->toObject();
                 unset($line->metadata);
                 $line = (object) array_merge((array) $line, (array) $params);
             } elseif ($c == 'con_position') {
                 $pos = [];
                 if ($item != 0) {
                     $positions = explode(',', $item);
                     foreach ($positions as $p => $position) {
                         $query = $this->db->getQuery(true);
                         // Join on Position.
                         $query->select('name');
                         $query->from('#__churchdirectory_position');
                         $query->where('id =' . $position);
                         $this->db->setQuery($query);
                         $pos[] = $this->db->loadResult();
                     }
                 } else {
                     $pos[] = null;
                 }
                 unset($line->con_position);
                 $line = (object) array_merge((array) $line, ['con_position' => implode(",", $pos)]);
             } elseif ($c == 'image') {
                 $line->{$c} = JUri::root() . $item;
             }
         }
         if ($count == 0) {
             $array = get_object_vars($line);
             fputcsv($csv, array_keys($array));
         }
         $count = 1;
         fputcsv($csv, (array) $line);
     }
     @ob_flush();
     @flush();
     fclose($csv);
     exit;
 }
        // Iterate through the elements in the stream.
        foreach ($reader->entry as $entry) {
            echo '<div class="cell">';
            echo $entry->content->data();
            echo '</div>';
        }
        // Get the buffer output.
        $output = ob_get_clean();
        // Push the output into the document buffer.
        $this->document->setBuffer($output, array('type' => 'component', 'name' => 'main'));
    }
    /**
     * Method to get the template name. This is needed for compatability with JApplication.
     *
     * @return  string  The theme name.
     *
     * @since   12.1
     */
    public function getTemplate()
    {
        return $this->get('theme');
    }
}
// Instantiate the application.
$application = JApplicationWeb::getInstance('FlickrFeed');
// Initialise the application.
$application->initialise();
// Store the application.
JFactory::$application = $application;
// Execute the application.
$application->execute();
 /**
  * Tests the JApplicationWeb::getInstance method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInstance()
 {
     $this->assertInstanceOf('JApplicationWebInspector', JApplicationWeb::getInstance('JApplicationWebInspector'), 'Tests that getInstance will instantiate a valid child class of JApplicationWeb.');
     TestReflection::setValue('JApplicationWeb', 'instance', 'foo');
     $this->assertThat(JApplicationWeb::getInstance('JApplicationWebInspector'), $this->equalTo('foo'), 'Tests that singleton value is returned.');
     TestReflection::setValue('JApplicationWeb', 'instance', null);
     $this->assertInstanceOf('JApplicationWeb', JApplicationWeb::getInstance('Foo'), 'Tests that getInstance will instantiate a valid child class of JApplicationWeb given a non-existent type.');
 }
Example #24
0
File: web.php Project: 01J/topm
 /**
  * Class constructor.
  *
  * @param   mixed  $input   An optional argument to provide dependency injection for the application's
  *                          input object.  If the argument is a JInput object that object will become
  *                          the application's input object, otherwise a default input object is created.
  * @param   mixed  $config  An optional argument to provide dependency injection for the application's
  *                          config object.  If the argument is a JRegistry object that object will become
  *                          the application's config object, otherwise a default config object is created.
  * @param   mixed  $client  An optional argument to provide dependency injection for the application's
  *                          client object.  If the argument is a JApplicationWebClient object that object will become
  *                          the application's client object, otherwise a default client object is created.
  *
  * @since   11.3
  * @deprecated  12.3 (Platform) & 4.0 (CMS) Use JApplicationWeb instead.
  */
 public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null)
 {
     JLog::add('JWeb is deprecated. Use JApplicationWeb instead.', JLog::WARNING, 'deprecated');
     parent::__construct($input, $config, $client);
 }
Example #25
0
 /**
  * Returns a reference to the global JApplicationWeb object, only creating it if it doesn't already exist.
  *
  * This method must be invoked as: $web = JApplicationWeb::getInstance();
  *
  * @param   string  $name  The name (optional) of the JApplicationWeb class to instantiate.
  *
  * @return  JApplicationWeb
  *
  * @since   11.3
  */
 public static function getInstance($name = null)
 {
     // Only create the object if it doesn't exist.
     if (empty(self::$instance)) {
         if (class_exists($name) && is_subclass_of($name, 'JApplicationWeb')) {
             self::$instance = new $name();
         } else {
             self::$instance = new JApplicationWeb();
         }
     }
     return self::$instance;
 }
Example #26
0
<?php

// Set the Joomla execution flag.
define('_JEXEC', 1);
##*HEADER*##
version_compare(PHP_VERSION, '5.3', '>=') || die('This script requires PHP >= 5.3');
try {
    require_once realpath(__DIR__ . '/../code/bootstrap.php');
    // Instantiate the application.
    $application = JApplicationWeb::getInstance('ECR_CLASS_PREFIXApplicationWeb');
    defined('JDEBUG') || define('JDEBUG', $application->get('debug') ? 1 : 0);
    // Set all loggers to echo.
    if (JDEBUG) {
        JLog::addLogger(array('logger' => 'echo'), JLog::ALL);
    }
    // Store the application.
    JFactory::$application = $application;
    // Execute the application.
    $application->execute();
} catch (Exception $e) {
    // An exception has been caught, just echo the message.
    echo '<p style="color: red">' . $e->getMessage() . '</p>';
    debug_print_backtrace();
    echo '<pre>' . print_r($e, 1) . '</pre>';
    JLog::add($e->getMessage(), JLog::ERROR);
    exit($e->getCode());
}
 /**
  * Tests the JApplicationWeb::getInstance method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInstance()
 {
     $this->assertInstanceOf('JApplicationWebInspector', JApplicationWeb::getInstance('JApplicationWebInspector'));
     TestReflection::setValue('JApplicationWeb', 'instance', 'foo');
     $this->assertEquals('foo', JApplicationWeb::getInstance('JApplicationWebInspector'));
     TestReflection::setValue('JApplicationWeb', 'instance', null);
     $this->assertInstanceOf('JApplicationWeb', JApplicationWeb::getInstance('Foo'));
 }
Example #28
0
<?php

/**
 * Constant that is checked in included files to prevent direct access.
 */
const _JEXEC = 1;
// Define the paths we need
const JPATH_BASE = __DIR__;
const JPATH_ROOT = __DIR__;
define('JPATH_THEMES', JPATH_BASE . '/templates');
define('JPATH_LIBRARIES', dirname(JPATH_ROOT) . '/libraries');
// Set up the environment
error_reporting(E_ALL);
ini_set('display_errors', true);
const JDEBUG = false;
// Import the Joomla Platform.
require_once JPATH_LIBRARIES . '/import.php';
// Register the prefix for our classes
JLoader::registerPrefix('G', JPATH_BASE);
// Get the application
$app = JApplicationWeb::getInstance('GApplicationWeb');
// Execute the application
$app->execute();
        foreach ($result as $r) {
            echo '<a href="' . $r['full_url'] . '" title="' . $r['title'] . '">
                  <img src="' . $r['thumbnail_url'] . '" width="' . $r['thumbnail_width'] . '" height="' . $r['thumbnail_height'] . '" alt="' . $r['title'] . '" />
                  </a>';
        }
        // Get the buffer output.
        $output = ob_get_clean();
        // Push the output into the document buffer.
        $this->document->setBuffer($output, array('type' => 'component', 'name' => 'main'));
    }
    /**
    * Method to get the template name. This is needed for compatability with JApplication.
    *
    * @return string The theme name.
    *
    * @since 12.1
    */
    public function getTemplate()
    {
        return $this->get('theme');
    }
}
// Instantiate the application.
$application = JApplicationWeb::getInstance('PicasaPhotos');
// Initialise the application.
$application->initialise();
// Store the application.
JFactory::$application = $application;
// Execute the application.
$application->execute();
//echo 'PicasaPhotos';
	/**
	 * Display the view
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  mixed  A string if successful, otherwise a Error object.
	 *
	 * @since       1.7.2
	 */
	public function display($tpl = null)
	{
		$app    = JFactory::getApplication();
		$params = JComponentHelper::getParams('com_churchdirectory');

		// Get some data from the models
		$state    = $this->get('State');
		$items    = $this->get('Items');
		$category = $this->get('Category');

		// Check whether category access level allows access.
		$user   = JFactory::getUser();
		$groups = $user->getAuthorisedViewLevels();

		if (!in_array($category->access, $groups))
		{
			$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');

			return false;
		}

		if ($items == false)
		{
			$app->enqueueMessage(JText::_('COM_CHURCHDIRECTOY_ERROR_DIRECTORY_NOT_FOUND'), 'error');

			return false;
		}

		$this->count    = count($items);
		$this->subcount = count($items);
		$children       = $this->get('Children');
		$pagination     = $this->get('Pagination');
		$this->loadHelper('render');
		$renderHelper = new ChurchDirectoryRenderHelper;
		$this->span   = $renderHelper->rowWidth($params->get('rows_per_page'));
		JLoader::register('DirectoryHeaderHelper', JPATH_SITE . '/components/com_churchdirectory/helpers/directoryheader.php');
		$this->header = new DirectoryHeaderHelper;
		$this->header->setPages($params);

		// Prepare the data.
		// Compute the contact slug.
		for ($i = 0, $n = $this->count; $i < $n; $i++)
		{
			$item       = & $items[$i];
			$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
			$temp       = new Joomla\Registry\Registry;
			$temp->loadString($item->params);
			$item->params = clone $params;
			$item->params->merge($temp);

			if ($item->params->get('show_email', 0) == 1)
			{
				$item->email_to = trim($item->email_to);

				if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to))
				{
					$item->email_to = '<a href="mailto::' . $item->email_to . '">' . $item->email_to . '</a>';
				}
				else
				{
					$item->email_to = '';
				}
			}

			if ($item->params->get('dr_show_street_address') || $item->params->get('dr_show_suburb')
				|| $item->params->get('dr_show_state') || $item->params->get('dr_show_postcode') || $item->params->get('dr_show_country'))
			{
				$params->set('address_check', 1);
			}
			else
			{
				$params->set('address_check', 0);
			}

			if ($item->params->get('dr_show_email') || $item->params->get('dr_show_telephone')
				|| $item->params->get('dr_show_fax') || $item->params->get('dr_show_mobile')
				|| $item->params->get('dr_show_webpage') || $item->params->get('dr_show_spouse')
				|| $item->params->get('dr_show_children'))
			{
				$params->set('other_check', 1);
			}
			else
			{
				$params->set('other_check', 0);
			}

			switch ($params->get('dr_churchdirectory_icons'))
			{
				case 1 :
					// Text
					$params->set('marker_address', JText::_('COM_CHURCHDIRECTORY_ADDRESS') . ": ");
					$params->set('marker_email', JText::_('JGLOBAL_EMAIL') . ": ");
					$params->set('marker_telephone', JText::_('COM_CHURCHDIRECTORY_TELEPHONE') . ": ");
					$params->set('marker_fax', JText::_('COM_CHURCHDIRECTORY_FAX') . ": ");
					$params->set('marker_mobile', JText::_('COM_CHURCHDIRECTORY_MOBILE') . ": ");
					$params->set('marker_misc', JText::_('COM_CHURCHDIRECTORY_OTHER_INFORMATION') . ": ");
					$params->set('marker_class', 'jicons-text');
					break;

				case 2 :
					// None
					$params->set('marker_address', '');
					$params->set('marker_email', '');
					$params->set('marker_telephone', '');
					$params->set('marker_mobile', '');
					$params->set('marker_fax', '');
					$params->set('marker_misc', '');
					$params->set('marker_class', 'jicons-none');
					break;

				default :
					// Icons
					$image1 = JHtml::_('image', 'contacts/' . $params->get('icon_address', 'con_address.png'), JText::_('COM_CHURCHDIRECTORY_ADDRESS') .
							": ", null, true
					);
					$image2 = JHtml::_('image', 'contacts/' . $params->get('icon_email', 'emailButton.png'), JText::_('JGLOBAL_EMAIL') . ": ", null, true);
					$image3 = JHtml::_('image', 'contacts/' . $params->get('icon_telephone', 'con_tel.png'), JText::_('COM_CHURCHDIRECTORY_TELEPHONE') .
							": ", null, true
					);
					$image4 = JHtml::_('image', 'contacts/' . $params->get('icon_fax', 'con_fax.png'), JText::_('COM_CHURCHDIRECTORY_FAX') . ": ", null, true);
					$image5 = JHtml::_('image', 'contacts/' . $params->get('icon_misc', 'con_info.png'), JText::_('COM_CHURCHDIRECTORY_OTHER_INFORMATION') .
							": ", null, true
					);
					$image6 = JHtml::_('image', 'contacts/' . $params->get('icon_mobile', 'con_mobile.png'), JText::_('COM_CHURCHDIRECTORY_MOBILE') .
							": ", null, true
					);

					$params->set('marker_address', $image1);
					$params->set('marker_email', $image2);
					$params->set('marker_telephone', $image3);
					$params->set('marker_fax', $image4);
					$params->set('marker_misc', $image5);
					$params->set('marker_mobile', $image6);
					$params->set('marker_class', 'jicons-icons');
					break;
			}
		}

		$params->set('prepare_content', '0');

		// Setup the category parameters.
		$cparams          = $category->getParams();
		$category->params = clone $params;
		$category->params->merge($cparams);
		$children = [$category->id => $children];
		$maxLevel = $params->get('maxLevel', -1);
		$items    = $renderHelper->groupit(['items' => & $items, 'field' => 'lname']);

		if (0)
		{
			foreach ($items as $s1)
			{
				$items[$s1] = $renderHelper->groupit(['items' => $items[$s1], 'field' => 'suburb']);
			}
		}

		$this->renderHelper = $renderHelper;
		$this->maxLevel     = & $maxLevel;
		$this->state        = & $state;
		$this->items        = $items;
		$this->category     = & $category;
		$this->children     = & $children;
		$this->params       = & $params;
		$this->pagination   = & $pagination;

		// Escape strings for HTML output
		$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));

		$menus = $app->getMenu();
		$title = 'directory_prent_out';

		// Because the application sets a default page title,
		// we need to get it from the menu item itself
		$menu = $menus->getActive();

		// Clean the output buffer
		@ob_end_clean();

		// Create new PDF document
		$this->pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

		// Set document information
		$this->pdf->SetCreator(PDF_CREATOR);
		$this->pdf->SetAuthor('NFSDA Church');
		$this->pdf->SetTitle($this->params->get('page_title', ''));
		$this->pdf->SetSubject('Church Directory');
		$this->pdf->SetKeywords('Directory, PDF, Members');

		// Set default header data
		$this->pdf->setHeaderData(
			$params->get('pdf_logo'),
			$params->get('pdf_logo_width'),
			$this->params->get('page_heading'),
			$params->get('pdf_header_string')
		);

		// Remove default header/footer
		$this->pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
		$this->pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

		// Set default monospaced font
		$this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

		// Set margins
		$this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
		$this->pdf->setHeaderMargin(PDF_MARGIN_HEADER);
		$this->pdf->setFooterMargin(PDF_MARGIN_FOOTER);

		// Set auto page breaks
		$this->pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);

		$this->pdf->setCellHeightRatio(1.25);

		// Set image scale factor
		$this->pdf->setImageScale(2.5);

		// ---------------------------------------------------------

		// Set font
		$this->pdf->SetFont('times', 'BI', 8, '', 'false');

		// Set some text to print
		$html = $this->loadTemplate($tpl);

		$jweb  = new JApplicationWeb;
		$jweb->clearHeaders();

		// Close and output PDF document
		$this->pdf->Output($title . '.pdf', 'I');

		return null;
	}