Exemplo n.º 1
0
 /**
  * @param	string	$context	The context for the data
  * @param	int		$data		The user id
  * @param	object
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         // Load the profile data from the database.
         $db = JFactory::getDbo();
         $db->setQuery('SELECT profile_key, profile_value FROM #__user_profiles' . ' WHERE user_id = ' . (int) $userId . " AND profile_key LIKE 'profile.%'" . ' ORDER BY ordering');
         $results = $db->loadRowList();
         // Check for a database error.
         if ($db->getErrorNum()) {
             $this->_subject->setError($db->getErrorMsg());
             return false;
         }
         // Merge the profile data.
         $data->profile = array();
         foreach ($results as $v) {
             $k = str_replace('profile.', '', $v[0]);
             $data->profile[$k] = $v[1];
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
         if (!JHtml::isRegistered('users.tos')) {
             JHtml::register('users.tos', array(__CLASS__, 'tos'));
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Listener for onAfterInitialise event
  *
  * @return  void
  */
 public function onAfterInitialise()
 {
     // Only for site
     if (!$this->app->isSite()) {
         return;
     }
     // Register listeners for JHtml helpers
     if (!JHtml::isRegistered('bootstrap.loadCss')) {
         JHtml::register('bootstrap.loadCss', 'PlgSystemBootstrap3::loadCss');
     }
     if (!JHtml::isRegistered('bootstrap.carousel')) {
         JHtml::register('bootstrap.carousel', 'PlgSystemBootstrap3::carousel');
     }
 }
Exemplo n.º 3
0
 public function onAfterRoute()
 {
     if (JFactory::getApplication()->isAdmin()) {
         jimport('joomla.filesystem.file');
         //check if the compnent is removed (not the package)
         if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_falang/classes/FalangManager.class.php')) {
             return;
         }
         require_once JPATH_ADMINISTRATOR . "/components/com_falang/classes/FalangManager.class.php";
         $falangManager = FalangManager::getInstance();
         $input = JFactory::getApplication()->input;
         $option = $input->get('option', null, 'cmd');
         $view = $input->get('view', null, 'cmd');
         $task = $input->get('task', null, 'cmd');
         jimport('joomla.application.component.helper');
         $params = JComponentHelper::getParams('com_falang');
         //get supported component <form></form>
         $component = $this->loadComponent();
         if (!isset($component)) {
             return;
         }
         if (!is_null($view) || is_null($task)) {
             if (is_null($view)) {
                 $view = 'default';
             }
             //$view = $jd->getView($option, $view);
         } elseif (!is_null($task)) {
             //$view = $jd->getViewByTask($option, $task);
         }
         //display only on view $taksk is null
         if (is_null($task)) {
             $supported_views = explode(',', $component[3]);
             if (!in_array($view, $supported_views)) {
                 return;
             }
         }
         if (isset($view)) {
             // Intercept the grid.id HTML Field to insert translation status
             if ($params->get('show_list', true)) {
                 JHtml::register('Grid.id', array($this, 'gridIdHook'));
             }
             if ($params->get('show_form', true)) {
                 // Add the Toolbar in edit layout only on joomla 3
                 if (version_compare(JVERSION, '3.0', 'ge')) {
                     $this->addToolbar();
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function __construct(&$subject, $config = array())
 {
     parent::__construct($subject, $config);
     JHTML::register('users.jform_user_profile_avatar', function ($value) {
         echo '<img
                 
                 src="' . JURI::root() . 'images/users/' . $value . '?rand=' . rand(0, 99999) . '"/>';
     });
     JHtml::register('users.jform_business_profile_business_logo', function ($value) {
         echo '<img
                 
                 src="' . JURI::root() . 'images/business/' . $value . '?rand=' . rand(0, 99999) . '"/>';
     });
     JHtml::register('users.jform_business_profile_business_banner', function ($value) {
         echo '<img
                 height="100"
                 src="' . JURI::root() . 'images/business/' . $value . '?rand=' . rand(0, 99999) . '"/>';
     });
 }
Exemplo n.º 5
0
 /**
  * Class loader method
  *
  * Additional arguments may be supplied and are passed to the sub-class.
  * Additional include paths are also able to be specified for third-party use
  *
  * @param	string	The name of helper method to load, (prefix).(class).function
  *					prefix and class are optional and can be used to load custom
  *					html helpers.
  */
 public static function _($type)
 {
     $type = preg_replace('#[^A-Z0-9_\\.]#i', '', $type);
     // Check to see if we need to load a helper file
     $parts = explode('.', $type);
     $prefix = count($parts) == 3 ? array_shift($parts) : 'JHtml';
     $file = count($parts) == 2 ? array_shift($parts) : '';
     $func = array_shift($parts);
     $key = strtolower($prefix . '.' . $file . '.' . $func);
     if (array_key_exists($key, self::$registry)) {
         $function = self::$registry[$key];
         $args = func_get_args();
         // remove function name from arguments
         array_shift($args);
         return JHtml::call($function, $args);
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JHtml::$includePaths, strtolower($file) . '.php')) {
             require_once $path;
             if (!class_exists($className)) {
                 JError::raiseError(500, $className . '::' . $func . ' not found in file.');
                 return false;
             }
         } else {
             JError::raiseError(500, $prefix . $file . ' not supported. File not found.');
             return false;
         }
     }
     $toCall = array($className, $func);
     if (is_callable($toCall)) {
         JHtml::register($key, $toCall);
         $args = func_get_args();
         // remove function name from arguments
         array_shift($args);
         return JHtml::call($toCall, $args);
     } else {
         JError::raiseError(500, $className . '::' . $func . ' not supported.');
         return false;
     }
 }
Exemplo n.º 6
0
	/**
	 * @param	string	$context	The context for the data
	 * @param	int		$data		The user id
	 * @param	object
	 *
	 * @return	boolean
	 * @since	1.6
	 */
	function onContentPrepareData($context, $data)
	{
		// Check we are manipulating a valid form.
		if (!in_array($context, self::$forms)) {
			return true;
		}

		if (is_object($data)) {
			$userId = isset($data->id) ? $data->id : 0;

			if (!isset($data->gravatar) and $userId > 0) {	
				// Add the gravatar data.
				$data->gravatar = array();
				$data->gravatar['avatar'] = md5(strtolower(trim($data->email)));
			}

			if (!JHtml::isRegistered('users.gravatar')) {
				JHtml::register('users.gravatar', array(__CLASS__, 'gravatar'));
			}
		}

		return true;
	}
Exemplo n.º 7
0
 public function onAfterRoute()
 {
     if (JFactory::getApplication()->isAdmin()) {
         $falangManager = FalangManager::getInstance();
         $input = JFactory::getApplication()->input;
         $option = $input->get('option', null, 'cmd');
         $view = $input->get('view', null, 'cmd');
         $task = $input->get('task', null, 'cmd');
         jimport('joomla.application.component.helper');
         $params = JComponentHelper::getParams('com_falang');
         //get supported component <form></form>
         $component = $this->loadComponent();
         if (!isset($component)) {
             return;
         }
         if (!is_null($view) || is_null($task)) {
             if (is_null($view)) {
                 $view = 'default';
             }
             //$view = $jd->getView($option, $view);
         } elseif (!is_null($task)) {
             //$view = $jd->getViewByTask($option, $task);
         }
         if (isset($view)) {
             // Intercept the grid.id HTML Field to insert translation status
             if ($params->get('show_list', true)) {
                 JHtml::register('Grid.id', array($this, 'gridIdHook'));
             }
             if ($params->get('show_form', true)) {
                 // Add the Toolbar in edit layout only on joomla 3
                 if (version_compare(JVERSION, '3.0', 'ge')) {
                     $this->addToolbar();
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Class loader method
  *
  * Additional arguments may be supplied and are passed to the sub-class.
  * Additional include paths are also able to be specified for third-party use
  *
  * @param   string  $key   The name of helper method to load, (prefix).(class).function
  *                         prefix and class are optional and can be used to load custom
  *                         html helpers.
  *
  * @return   mixed  JHtml::call($function, $args) or False on error
  * @since    11.1
  */
 public static function _($key)
 {
     list($key, $prefix, $file, $func) = self::extract($key);
     if (array_key_exists($key, self::$registry)) {
         $function = self::$registry[$key];
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return JHtml::call($function, $args);
     }
     $className = $prefix . ucfirst($file);
     if (!class_exists($className)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JHtml::$includePaths, strtolower($file) . '.php')) {
             require_once $path;
             if (!class_exists($className)) {
                 JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTFOUNDINFILE', $className, $func));
                 return false;
             }
         } else {
             JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTSUPPORTED_NOFILE', $prefix, $file));
             return false;
         }
     }
     $toCall = array($className, $func);
     if (is_callable($toCall)) {
         JHtml::register($key, $toCall);
         $args = func_get_args();
         // Remove function name from arguments
         array_shift($args);
         return JHtml::call($toCall, $args);
     } else {
         JError::raiseError(500, JText::sprintf('JLIB_HTML_ERROR_NOTSUPPORTED', $className, $func));
         return false;
     }
 }
Exemplo n.º 9
0
	/**
	 * @todo Implement testFetchElement().
	 */
	public function testFetchElement()
	{
		$mock = $this->getMock('MyMockClass', array('calendar', 'behavior_calendar', 'attributes'));
		$mock->expects($this->once())
			->method('behavior_calendar')
			->with();

		$mock->expects($this->once())
			->method('calendar')
			->with('value', 'Calendar[test_calendar]', 'Calendartest_calendar', '%m-%d-%Y', array('class' => 'test_calendar_class'));

		JHtml::register('calendar', array($mock, 'calendar'));
		JHtml::register('behavior.calendar', array($mock, 'behavior_calendar'));

		$mock->expects($this->any())
			->method('attributes')
			->will($this->returnCallback(array($this, 'mockCallback')));

		$this->mockValues['format'] = '%m-%d-%Y';
		$this->mockValues['class'] = 'test_calendar_class';

		JElementCalendar::fetchElement('test_calendar','value', $mock, 'Calendar');

	}
Exemplo n.º 10
0
 /**
  * @param   string     $context  The context for the data
  * @param   integer    $data     The user id
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Get application
     $application = JFactory::getApplication();
     // Valid contexts
     $contexts = array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile');
     // Condition
     if ($application->isSite() && in_array($context, $contexts) && is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->k2Profile) and $userId > 0) {
             $k2User = K2Users::getInstance($userId);
             $data->k2Profile = array();
             $data->k2Profile['description'] = $k2User->description;
             $data->k2Profile['image'] = $k2User->image;
             $data->k2Profile['site'] = $k2User->site;
             $data->k2Profile['gender'] = $k2User->gender;
         }
         JHtml::register('users.description', 'PlgUserK2::description');
         JHtml::register('users.image', 'PlgUserK2::image');
         JHtml::register('users.gender', 'PlgUserK2::gender');
         JHtml::register('users.site', 'PlgUserK2::site');
     }
     return true;
 }
Exemplo n.º 11
0
 /**
  * Test...
  *
  * @return void
  */
 public function testGetInputUser_UTC()
 {
     // We create stubs for config and session/user objects
     $config = new JObject();
     // Put the stub in place
     JFactory::$config = $config;
     $sessionMock = $this->getMock('sessionMock', array('get'));
     require_once JPATH_PLATFORM . '/joomla/user/user.php';
     $userObject = new JUser();
     $sessionMock->expects($this->any())->method('get')->with('user')->will($this->returnValue($userObject));
     // Put the stub in place
     JFactory::$session = $sessionMock;
     $languageMock = $this->getMock('languageMock', array('getTag'));
     $languageMock->expects($this->any())->method('getTag')->will($this->returnValue('en-GB'));
     // Put the stub in place
     JFactory::$language = $languageMock;
     // Include our inspector which will allow us to manipulate and call protected methods and attributes
     require_once __DIR__ . '/inspectors/JFormFieldCalendar.php';
     $calendar = new JFormFieldCalendarInspector();
     // Setup our values from our data set
     $calendar->setProtectedProperty('element', array('format' => '%m-%Y-%d', 'size' => '25', 'maxlength' => '45', 'class' => 'myClass', 'readonly' => 'true', 'disabled' => 'false', 'onchange' => '', 'filter' => 'USER_UTC'));
     $calendar->setProtectedProperty('name', 'myElementName');
     $calendar->setProtectedProperty('id', 'myElementId');
     // 1269442718
     $calendar->setProtectedProperty('value', 1269442718);
     // +4
     $config->set('offset', 'Asia/Muscat');
     // We don't set the user param to see if it properly falls back to the server time (as it should)
     // Create the mock to implant into JHtml so that we can check our values
     $mock = $this->getMock('calendarHandler', array('calendar'));
     // Setup the expectation with the values from the dataset
     $mock->expects($this->once())->method('calendar')->with('2010-03-24 18:58:38', 'myElementName', 'myElementId', '%m-%Y-%d', array('size' => '25', 'maxlength' => '45', 'class' => 'myClass', 'readonly' => 'readonly'));
     // Register our mock with JHtml
     JHtml::register('calendar', array($mock, 'calendar'));
     // Invoke our method
     $calendar->getInput();
     // Unregister the mock
     JHtml::unregister('jhtml..calendar');
     // Create the mock to implant into JHtml so that we can check our values
     $mock2 = $this->getMock('calendarHandler', array('calendar'));
     // Setup the expectation with the values from the dataset
     $mock2->expects($this->once())->method('calendar')->with('2010-03-24 22:58:38', 'myElementName', 'myElementId', '%m-%Y-%d', array('size' => '25', 'maxlength' => '45', 'class' => 'myClass', 'readonly' => 'readonly'));
     // -5
     $config->set('offset', 'US/Eastern');
     // +4		// now we set the user param to test it out.
     $userObject->setParam('timezone', 'Asia/Muscat');
     // Register our mock with JHtml
     JHtml::register('calendar', array($mock2, 'calendar'));
     // Invoke our method
     $calendar->getInput();
     // Unregister the mock
     JHtml::unregister('jhtml..calendar');
 }
Exemplo n.º 12
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->sibdiet) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT * FROM #__sibdiet_profiles' . ' WHERE users_id = ' . (int) $userId);
             try {
                 $data->sibdiet = $db->loadAssoc();
                 $data->sibdiet['image'] = $data->sibdiet['id'] . '.jpg';
             } catch (RuntimeException $e) {
                 $this->_subject->setError($e->getMessage());
                 return false;
             }
         }
         if (!JHtml::isRegistered('users.Genders')) {
             JHtml::register('users.Genders', array(__CLASS__, 'Genders'));
         }
         if (!JHtml::isRegistered('users.Birthday')) {
             JHtml::register('users.Birthday', array(__CLASS__, 'Birthday'));
         }
         if (!JHtml::isRegistered('users.Maritals')) {
             JHtml::register('users.Maritals', array(__CLASS__, 'Maritals'));
         }
         if (!JHtml::isRegistered('users.Educations')) {
             JHtml::register('users.Educations', array(__CLASS__, 'Educations'));
         }
         if (!JHtml::isRegistered('users.Bloods')) {
             JHtml::register('users.Bloods', array(__CLASS__, 'Bloods'));
         }
         if (!JHtml::isRegistered('users.Countries')) {
             JHtml::register('users.Countries', array(__CLASS__, 'Countries'));
         }
         if (!JHtml::isRegistered('users.ProfilePic')) {
             JHtml::register('users.ProfilePic', array(__CLASS__, 'ProfilePic'));
         }
     }
     return true;
 }
Exemplo n.º 13
0
	/**
	 * testIsRegistered().
	 */
	public function testIsRegistered()
	{
		$registered = $this->getMock('MyHtmlClass', array('mockFunction'));

		// test that we can register the method
		JHtml::register('prefix.file.testfunction', array($registered, 'mockFunction'));

		$this->assertThat(
			JHtml::isRegistered('prefix.file.testfunction'),
			$this->isTrue(),
			'Function is not registered'
		);

		JHtml::unregister('prefix.file.testfunction');

		$this->assertThat(
			JHtml::isRegistered('prefix.file.testfunction'),
			$this->isFalse(),
			'Function is registered'
		);
	}
Exemplo n.º 14
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select(array($db->qn('profile_key'), $db->qn('profile_value')))->from('#__user_profiles')->where($db->qn('user_id') . ' = ' . $db->q((int) $userId))->where($db->qn('profile_key') . ' LIKE ' . $db->qn('profile.%'))->order($db->qn('ordering'));
             $db->setQuery($query);
             $results = $db->loadRowList();
             // Merge the profile data.
             $data->profile = array();
             foreach ($results as $v) {
                 $k = str_replace('profile.', '', $v[0]);
                 $data->profile[$k] = json_decode($v[1], true);
                 if ($data->profile[$k] === null) {
                     $data->profile[$k] = $v[1];
                 }
             }
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
         if (!JHtml::isRegistered('users.tos')) {
             JHtml::register('users.tos', array(__CLASS__, 'tos'));
         }
         if (!JHtml::isRegistered('users.dob')) {
             JHtml::register('users.dob', array(__CLASS__, 'dob'));
         }
     }
     return true;
 }
Exemplo n.º 15
0
 /**
  * @param	JForm	$form	The form to be altered.
  * @param	array	$data	The associated data for the form.
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     if (!JHtml::isRegistered('users.url')) {
         JHtml::register('users.url', array(__CLASS__, 'url'));
     }
     if (!JHtml::isRegistered('users.calendar')) {
         JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
     }
     if (!JHtml::isRegistered('users.tos')) {
         JHtml::register('users.tos', array(__CLASS__, 'tos'));
     }
     // Check we are manipulating a valid form.
     $context = $form->getName();
     // The frontend and backend editor use the same form...
     if (!in_array($context, array('com_content.article'))) {
         return true;
     }
     // Note: The frontend form is generated by a custom view, we
     // have to alter it using template override to use our new fields
     // Load all needed field types (these are provided by the component)
     JForm::addFieldPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Add the geotag fields to the form.
     JForm::addFormPath(dirname(__FILE__) . '/geotag');
     $form->loadFile('geotag', false);
     //throw new Exception(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Set whether location is requried
     $form->setFieldAttribute('latitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     $form->setFieldAttribute('longitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     return true;
 }
Exemplo n.º 16
0
 /**
  * Test...
  *
  * @return void
  */
 public function testGetInputUser_UTC()
 {
     // Create a stub JConfig
     $config = new JObject();
     // Put the stub in place
     JFactory::$config = $config;
     $sessionMock = $this->getMock('sessionMock', array('get'));
     $userObject = new JUser();
     $sessionMock->expects($this->any())->method('get')->with('user')->will($this->returnValue($userObject));
     // Put the stub in place
     JFactory::$session = $sessionMock;
     // Instantiate the calendar field
     $calendar = new JFormFieldCalendar();
     // Setup our values from our data set
     TestReflection::setValue($calendar, 'id', 'myElementId');
     TestReflection::setValue($calendar, 'name', 'myElementName');
     TestReflection::setValue($calendar, 'format', '%m-%Y-%d');
     TestReflection::setValue($calendar, 'size', 25);
     TestReflection::setValue($calendar, 'maxlength', 45);
     TestReflection::setValue($calendar, 'class', 'myClass');
     TestReflection::setValue($calendar, 'readonly', true);
     TestReflection::setValue($calendar, 'disabled', false);
     TestReflection::setValue($calendar, 'onchange', '');
     TestReflection::setValue($calendar, 'filter', 'USER_UTC');
     // 1269442718
     TestReflection::setValue($calendar, 'value', 1269442718);
     // +4
     $config->set('offset', 'Asia/Muscat');
     // We don't set the user param to see if it properly falls back to the server time (as it should)
     // Create the mock to implant into JHtml so that we can check our values
     $mock = $this->getMock('calendarHandler', array('calendar'));
     // Setup the expectation with the values from the dataset
     $mock->expects($this->once())->method('calendar')->with('2010-03-24 18:58:38', 'myElementName', 'myElementId', '%m-%Y-%d', array('size' => 25, 'maxlength' => 45, 'class' => 'myClass', 'readonly' => 'readonly'));
     // Register our mock with JHtml
     JHtml::register('calendar', array($mock, 'calendar'));
     // Invoke our method
     TestReflection::invoke($calendar, 'getInput');
     // Unregister the mock
     JHtml::unregister('jhtml..calendar');
     // Create the mock to implant into JHtml so that we can check our values
     $mock2 = $this->getMock('calendarHandler', array('calendar'));
     // Setup the expectation with the values from the dataset
     $mock2->expects($this->once())->method('calendar')->with('2010-03-24 22:58:38', 'myElementName', 'myElementId', '%m-%Y-%d', array('size' => 25, 'maxlength' => 45, 'class' => 'myClass', 'readonly' => 'readonly'));
     // -5
     $config->set('offset', 'US/Eastern');
     // +4		// now we set the user param to test it out.
     $userObject->setParam('timezone', 'Asia/Muscat');
     // Register our mock with JHtml
     JHtml::register('calendar', array($mock2, 'calendar'));
     // Invoke our method
     TestReflection::invoke($calendar, 'getInput');
     // Unregister the mock
     JHtml::unregister('jhtml..calendar');
 }
Exemplo n.º 17
0
                if ($config->get('jg_tooltips') == 2) {
                    $params['template'] = '<div class="tooltip jg-tooltip-wrap" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>';
                }
                JHtml::_('bootstrap.tooltip', '.' . $class, $params);
                $loaded = true;
            }
            if ($addclass) {
                $html = ' class="' . $class . '" title="' . JHtml::tooltipText($title, $text, $translate, $translate) . '"';
            } else {
                $html = ' ' . $class . '" title="' . JHtml::tooltipText($title, $text, $translate, $translate);
            }
        }
        return $html;
    }
}
JHtml::register('joomgallery.tip', array('JHtmlJoomGalleryBootone', 'tip'));
?>
<div class="jg-bootone gallery">
<?php 
if ($displayData->params->get('show_page_heading')) {
    ?>
  <h2>
    <?php 
    echo $displayData->escape($displayData->params->get('page_heading'));
    ?>
  </h2>
<?php 
}
if ($displayData->params->get('show_top_modules')) {
    ?>
  <div class="jg-modules-top">
Exemplo n.º 18
0
 /**
  * @param	string	The context for the data
  * @param	int		The user id
  * @param	object
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.registration', 'com_users.user', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if ($userId) {
             $juser = JFactory::getUser($userId);
             if ($this->params->get('raidplanner-profile-group', 1) == 0) {
                 $data_key = 'params';
             } else {
                 $data_key = 'raidplanner';
             }
             $data->{$data_key} = array('characters' => $juser->getParam('characters', ''), 'calendar_secret' => $juser->getParam('calendar_secret', ''), 'vacation' => $juser->getParam('vacation', ''));
         }
         if (!JHtml::isRegistered('users.characters')) {
             JHtml::register('users.characters', array(__CLASS__, 'characters'));
         }
     }
     return true;
 }
Exemplo n.º 19
0
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->joomlamailer) && $userId > 0) {
             $user = JFactory::getUser($userId);
             // check if user is subscribed
             $db = JFactory::getDBO();
             $query = $db->getQuery(true)->select(1)->from($db->qn('#__joomailermailchimpintegration'))->where($db->qn('userid') . ' = ' . $db->q($userId))->where($db->qn('listid') . ' = ' . $db->q($this->listId));
             try {
                 $isSubscribed = $db->setQuery($query)->loadResult() ? 1 : 0;
             } catch (Exception $e) {
                 $isSubscribed = false;
             }
             $data->joomlamailer['subscribe'] = $isSubscribed;
             if (!JHtml::isRegistered('users.subscribe')) {
                 JHtml::register('users.subscribe', array(__CLASS__, 'subscribe'));
             }
             if (!$isSubscribed) {
                 return;
             }
             $userData = $this->api->listMemberInfo($this->listId, $user->email);
             if (isset($userData['merges']) && count($userData['merges'])) {
                 foreach ($userData['merges'] as $key => $value) {
                     $data->joomlamailer_merges[$key] = $value;
                 }
             }
             if (isset($userData['merges']['GROUPINGS']) && count($userData['merges']['GROUPINGS'])) {
                 foreach ($userData['merges']['GROUPINGS'] as $group) {
                     $data->joomlamailer_groupings[$group['id']] = $group['groups'];
                 }
             }
             if (!JHtml::isRegistered('users.birthday')) {
                 JHtml::register('users.birthday', array(__CLASS__, 'birthday'));
             }
             if (!JHtml::isRegistered('users.address')) {
                 JHtml::register('users.address', array(__CLASS__, 'address'));
             }
         }
     }
     return true;
 }
Exemplo n.º 20
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.registration', 'com_users.user', 'com_admin.profile'))) {
         return true;
     }
     $userinfo = $this->checkUserInfo();
     if (!$userinfo) {
         return true;
     }
     $userId = isset($data->id) ? $data->id : 0;
     // Load the profile data from the database.
     $db = JFactory::getDbo();
     $db->setQuery('SELECT profile_key, profile_value FROM #__user_profiles' . ' WHERE user_id = ' . (int) $userId . ' AND profile_key LIKE \'zygo_profile.%\'' . ' ORDER BY ordering');
     $results = $db->loadRowList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         $this->_subject->setError($db->getErrorMsg());
         return false;
     }
     // Merge the profile data.
     if (is_array($data)) {
         $data['zygo_profile'] = array();
     } else {
         $data->zygo_profile = array();
     }
     $fNamesToTypes = array();
     $fields_avatars = array();
     foreach ($userinfo->fieldName as $fieldNum => $fname) {
         if (is_array($userinfo->fieldType)) {
             $fNamesToTypes[$fname] = $userinfo->fieldType[$fieldNum];
         } else {
             $fNamesToTypes[$fname] = $userinfo->fieldType->{$fieldNum};
         }
         if ($fNamesToTypes[$fname] == "avatar") {
             $fields_avatars[] = $fname;
         }
         if ($fNamesToTypes[$fname] == "html") {
             if (is_array($userinfo->fieldParams)) {
                 $fieldParams = $userinfo->fieldParams[$fieldNum];
             } else {
                 $fieldParams = $userinfo->fieldParams->{$fieldNum};
             }
             if (is_array($data)) {
                 $data['zygo_profile'][$fname] = $fieldParams;
             } else {
                 $data->zygo_profile[$fname] = $fieldParams;
             }
             JHtml::register('users.' . $fname, array('plgUserZygo_profile', 'textInProfile'));
         }
     }
     foreach ($results as $v) {
         $k = str_replace('zygo_profile.', '', $v[0]);
         if (isset($fNamesToTypes[$k]) && $fNamesToTypes[$k] != 'textarea') {
             $v1arr = $this->layout == 'edit' ? explode("\n", $v[1]) : str_replace("\n", ", ", $v[1]);
         } else {
             $v1arr = $v[1];
         }
         if (!$this->layout) {
             if (!empty($fields_avatars) && in_array($k, $fields_avatars)) {
                 $avatarArr = explode(",", $v1arr);
                 $v1arr = $avatarArr[0];
                 JHtml::register('users.' . $k, array('plgUserZygo_profile', 'avInProfile'));
             } else {
                 JHtml::register('users.' . $k, array('plgUserZygo_profile', 'textInProfile'));
             }
             if (isset($fNamesToTypes[$k]) && $fNamesToTypes[$k] == 'checkbox') {
                 $v[1] = (int) $v[1] ? JText::_("JYES") : JText::_("JNO");
             }
         }
         if (is_array($data)) {
             $data['zygo_profile'][$k] = !empty($v1arr) && isset($v1arr[1]) ? $v1arr : $v[1];
         } else {
             $data->zygo_profile[$k] = !empty($v1arr) && isset($v1arr[1]) ? $v1arr : $v[1];
         }
     }
     return true;
 }
Exemplo n.º 21
0
 /**
  * Tests the isRegistered method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testIsRegistered()
 {
     $registered = $this->getMock('MyHtmlClass', array('mockFunction'));
     // test that we can register the method
     JHtml::register('prefix.isregistered.method', array($registered, 'mockFunction'));
     $this->assertThat(JHtml::isRegistered('prefix.isregistered.method'), $this->isTrue(), 'Calling isRegistered on a valid method should pass.');
     $this->assertThat(JHtml::isRegistered('prefix.isregistered.nomethod'), $this->isFalse(), 'Calling isRegistered on a missing method should fail.');
 }
Exemplo n.º 22
0
 /**
  * On content prepare data.
  *
  * @param    string $context The context for the data
  * @param    int    $data    The user id
  *
  * @return   boolean
  */
 public function onContentPrepareData($context, $data)
 {
     $this->initComponent();
     $params = JComponentHelper::getParams('com_userxtd');
     JHtml::register('users.uploadimage', array('\\Userxtd\\Form\\FieldDisplay', 'showImage'));
     // Check we are manipulating a valid form.
     if (!in_array($context, $this->allow_context)) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->profile) and $userId > 0) {
             // Load the profile data from the database.
             // ===============================================================
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             // Filter categories
             $cats = (array) $params->get('CoreRegistration_Categories_InUserInfo', array('*'));
             if (!in_array('*', $cats)) {
                 $query->where('b.catid IN (' . implode(',', $cats) . ')');
             }
             $query->select("a.key, a.value, b.field_type, b.attrs")->from("#__userxtd_profiles AS a")->leftJoin('#__userxtd_fields AS b ON a.key=b.name')->where('a.user_id = ' . (int) $userId)->order("b.ordering");
             try {
                 $results = $db->setQuery($query)->loadRowList();
             } catch (RuntimeException $e) {
                 $this->_subject->setError($e->getMessage());
                 return false;
             }
             // Merge the profile data.
             // ===============================================================
             $data->profile = array();
             foreach ($results as $v) {
                 $k = $v[0];
                 // Convert String to Array if multiple
                 $v[3] = json_decode($v[3], true);
                 if (JArrayHelper::getValue($v[3], 'multiple')) {
                     $v[1] = explode(',', $v[1]);
                 }
                 // merge data
                 $data->profile[$k] = $v[1];
                 if ($data->profile[$k] === null) {
                     $data->profile[$k] = $v[1];
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 23
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT profile_key, profile_value FROM #__users_profiles' . ' WHERE user_id = ' . (int) $userId . " AND profile_key LIKE 'profile.%'" . ' ORDER BY ordering');
             try {
                 $results = $db->loadRowList();
             } catch (RuntimeException $e) {
                 $this->_subject->setError($e->getMessage());
                 return false;
             }
             // Merge the profile data.
             $data->profile = array();
             foreach ($results as $v) {
                 $k = str_replace('profile.', '', $v[0]);
                 $data->profile[$k] = json_decode($v[1], true);
                 if ($data->profile[$k] === null) {
                     $data->profile[$k] = $v[1];
                 }
             }
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
     }
     return true;
 }
<?php

/**
 * @package		Joomla.Site
 * @subpackage	com_users
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 * @since		1.6
 */
defined('_JEXEC') or die;
JLoader::register('JHtmlUsers', JPATH_COMPONENT . '/helpers/html/users.php');
JHtml::register('users.spacer', array('JHtmlUsers', 'spacer'));
$fieldsets = $this->form->getFieldsets();
if (isset($fieldsets['core'])) {
    unset($fieldsets['core']);
}
if (isset($fieldsets['params'])) {
    unset($fieldsets['params']);
}
foreach ($fieldsets as $group => $fieldset) {
    // Iterate through the form fieldsets
    $fields = $this->form->getFieldset($group);
    if (count($fields)) {
        ?>

<fieldset id="users-profile-custom" class="users-profile-custom-<?php 
        echo $group;
        ?>
">
	<?php 
        if (isset($fieldset->label)) {
Exemplo n.º 25
0
 function onContentPrepareData($context, $data)
 {
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->djcatalog2profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT u.*, c.country_name FROM #__djc2_users as u INNER JOIN #__djc2_countries as c on c.id = u.country_id ' . ' WHERE user_id = ' . (int) $userId);
             $results = $db->loadAssoc();
             // Check for a database error.
             if ($db->getErrorNum()) {
                 $this->_subject->setError($db->getErrorMsg());
                 return false;
             }
             if (count($results)) {
                 // Merge the profile data.
                 $data->djcatalog2profile = array();
                 foreach ($results as $k => $v) {
                     $data->djcatalog2profile[$k] = $v;
                 }
             }
         }
     }
     if (!JHtml::isRegistered('users.country_id')) {
         JHtml::register('users.country_id', array(__CLASS__, 'country'));
     }
     if (!JHtml::isRegistered('users.www')) {
         JHtml::register('users.www', array(__CLASS__, 'www'));
     }
     return true;
 }
Exemplo n.º 26
0
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - Copyrighted Commercial Software
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites:  http://www.joomlart.com -  http://www.joomlancers.com
 * This file may not be redistributed in whole or significant part.
 * ------------------------------------------------------------------------
 */
defined('_JEXEC') or die;
JLoader::register('JHtmlUsers', JPATH_COMPONENT . '/helpers/html/users.php');
JHtml::register('users.spacer', array('JHtmlUsers', 'spacer'));
JHtml::register('users.helpsite', array('JHtmlUsers', 'helpsite'));
JHtml::register('users.templatestyle', array('JHtmlUsers', 'templatestyle'));
JHtml::register('users.admin_language', array('JHtmlUsers', 'admin_language'));
JHtml::register('users.language', array('JHtmlUsers', 'language'));
JHtml::register('users.editor', array('JHtmlUsers', 'editor'));
$fields = $this->form->getFieldset('params');
if (count($fields)) {
    ?>
<fieldset id="users-profile-custom">
	<legend><?php 
    echo JText::_('COM_USERS_SETTINGS_FIELDSET_LABEL');
    ?>
</legend>
	<dl class="dl-horizontal">
	<?php 
    foreach ($fields as $field) {
        if (!$field->hidden) {
            ?>
		<dt><?php 
            echo $field->title;
Exemplo n.º 27
0
 public function onContentPrepareData($context, $data)
 {
     // only operate on known contexts
     if (!in_array($context, array('com_admin.profile', 'com_users.user', 'com_users.profile')) || !is_object($data)) {
         return true;
     }
     // register helpers to render tfa fields
     foreach (array('activate', 'authentication', 'backup') as $field) {
         if (!JHtml::isRegistered($key = 'users.' . $field)) {
             JHtml::register($key, array(__CLASS__, $field));
         }
     }
 }