示例#1
0
 /**
  * Display information
  *
  */
 public function display($cachable = false, $urlparams = array())
 {
     JFactory::getDocument()->addStylesheet(JUri::base(true) . '/components/com_osmembership/assets/css/style.css', 'text/css', null, null);
     JFactory::getDocument()->addStylesheet(JUri::base(true) . '/components/com_osmembership/assets/css/custom.css', 'text/css', null, null);
     $view = JRequest::getVar('view', '');
     if (!$view) {
         JRequest::setVar('view', 'plans');
         JRequest::setVar('layout', 'default');
     }
     $config = OSMembershipHelper::getConfig();
     if (@$config->load_jquery !== '0') {
         OSMembershipHelper::loadJQuery();
     }
     OSMembershipHelper::loadBootstrap(true);
     JHtml::_('script', OSMembershipHelper::getSiteUrl() . 'components/com_osmembership/assets/js/jquery-noconflict.js', false, false);
     parent::display($cachable, $urlparams);
 }
示例#2
0
 * @subpackage     Membership Pro
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2014 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */
// no direct access
defined('_JEXEC') or die;
$db = JFactory::getDbo();
OSMembershipHelperJquery::validateForm();
$selectedState = '';
$fields = $this->form->getFields();
?>

<script type="text/javascript">
	var siteUrl = '<?php 
echo OSMembershipHelper::getSiteUrl();
?>
';
	
jQuery(document).ready(function(){
		jQuery( "div#osm-profile-page input" ).addClass( "form-control" );
		
		
		var hash = document.location.hash;
		var prefix = "";
		if (hash) {
			jQuery('.nav-tabs a[href='+hash.replace(prefix,"")+']').tab('show');
		} 
		
		// Change hash for page-reload
		jQuery('.nav-tabs a').on('shown.bs.tab', function (e) {
示例#3
0
    /**
     * validate form
     */
    public static function validateForm()
    {
        $document = JFactory::getDocument();
        $siteUrl = OSMembershipHelper::getSiteUrl();
        $document->addStyleSheet(JUri::root(true) . '/components/com_osmembership/assets/js/validate/css/validationEngine.jquery.css');
        $document->addScriptDeclaration('
			OSM.jQuery(function($){
			    $.fn.validationEngineLanguage = function(){
			    };
			    $.validationEngineLanguage = {
			        newLang: function(){
			            $.validationEngineLanguage.allRules = {
			                "required": { // Add your regex rules here, you can take telephone as an example
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_FIELD_REQUIRED') . '",
			                    "alertTextCheckboxMultiple": "' . JText::_('OSM_PLEASE_SELECT_AN_OPTION') . '",
			                    "alertTextCheckboxe": "' . JText::_('OSM_CHECKBOX_REQUIRED') . '",
			                    "alertTextDateRange": "' . JText::_('OSM_BOTH_DATE_RANGE_FIELD_REQUIRED') . '"
			                },
			                "requiredInFunction": {
			                    "func": function(field, rules, i, options){
			                        return (field.val() == "test") ? true : false;
			                    },
			                    "alertText": "' . JText::_('OSM_FIELD_MUST_EQUAL_TEST') . '"
			                },
			                "dateRange": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_INVALID') . '",
			                    "alertText2": "Date Range"
			                },
			                "dateTimeRange": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_INVALID') . '",
			                    "alertText2": "' . JText::_('OSM_DATE_TIME_RANGE') . '"
			                },
			                "minSize": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_MINIMUM') . ' ",
			                    "alertText2": " characters required"
			                },
			                "maxSize": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_MAXIMUM') . '",
			                    "alertText2": "' . JText::_('OSM_CHACTERS_ALLOWED') . '"
			                },
							"groupRequired": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_GROUP_REQUIRED') . '"
			                },
			                "min": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_MIN') . '"
			                },
			                "max": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_MAX') . '"
			                },
			                "past": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_DATE_PRIOR_TO') . '"
			                },
			                "future": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_DATE_PAST') . '"
			                },
			                "maxCheckbox": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_MAXIMUM') . '",
			                    "alertText2": "' . JText::_('OSM_OPTION_ALLOW') . '"
			                },
			                "minCheckbox": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_PLEASE_SELECT') . '",
			                    "alertText2": " options"
			                },
			                "equals": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_FIELDS_DO_NOT_MATCH') . '"
			                },
			                "creditCard": {
			                    "regex": "none",
			                    "alertText": "' . JText::_('OSM_INVALID_CREDIT_CARD_NUMBER') . '"
			                },
			                "phone": {
			                    // credit: jquery.h5validate.js / orefalo
			                    "regex": /^([\\+][0-9]{1,3}[\\ \\.\\-])?([\\(]{1}[0-9]{2,6}[\\)])?([0-9\\ \\.\\-\\/]{3,20})((x|ext|extension)[\\ ]?[0-9]{1,4})?$/,
			                    "alertText": "' . JText::_('OSM_INVALID_PHONE_NUMBER') . '"
			                },
			                "email": {
			                    // HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#    e-mail-state-%28type=email%29 )
			                    "regex": /^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,
			                    "alertText": "' . JText::_('OSM_INVALID_EMAIL_ADDRESS') . '"
			                },
			                "integer": {
			                    "regex": /^[\\-\\+]?\\d+$/,
			                    "alertText": "' . JText::_('OSM_NOT_A_VALID_INTEGER') . '"
			                },
			                "number": {
			                    // Number, including positive, negative, and floating decimal. credit: orefalo
			                    "regex": /^[\\-\\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\\.]([0-9]+))?$/,
			                    "alertText": "' . JText::_('OSM_INVALID_FLOATING_DECIMAL_NUMBER') . '"
			                },
			                "date": {
			                    //	Check if date is valid by leap year
							"func": function (field) {
								var pattern = new RegExp(/^(\\d{4})[\\/\\-\\.](0?[1-9]|1[012])[\\/\\-\\.](0?[1-9]|[12][0-9]|3[01])$/);
								var match = pattern.exec(field.val());
								if (match == null)
								   return false;
	
								var year = match[1];
								var month = match[2]*1;
								var day = match[3]*1;
								var date = new Date(year, month - 1, day); // because months starts from 0.
	
								return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day);
							},
						 	"alertText": "' . JText::_('OSM_INVALID_DATE') . '"
			                },
			                "ipv4": {
			                    "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
			                    "alertText": "' . JText::_('OSM_INVALID_IP_ADDRESS') . '"
			                },
			                "url": {
			                    "regex": /(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/,
			                    "alertText": "' . JText::_('OSM_INVALID_URL') . '"
			                },
			                "onlyNumberSp": {
			                    "regex": /^[0-9\\ ]+$/,
			                    "alertText": "' . JText::_('OSM_NUMBER_ONLY') . '"
			                },
			                "onlyLetterSp": {
			                    "regex": /^[a-zA-Z\\ \']+$/,
			                    "alertText": "' . JText::_('OSM_LETTERS_ONLY') . '"
			                },
			                "onlyLetterNumber": {
			                    "regex": /^[0-9a-zA-Z]+$/,
			                    "alertText": "' . JText::_('OSM_NO_SPECIAL_CHACTERS_ALLOWED') . '"
			                },
			                // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
			                "ajaxUserCall": {
			                	"url": "' . $siteUrl . 'index.php?option=com_osmembership&task=validate_username",
			                    // you may want to pass extra data on the ajax call
			                    "extraData": "name=eric",
			                    "alertText": "' . JText::_('OSM_INVALID_USERNAME') . '",
			                },
			                "ajaxEmailCall": {
			                	"url": "' . $siteUrl . 'index.php?option=com_osmembership&task=validate_email",
			                    // you may want to pass extra data on the ajax call
			                    "extraData": "email=eric",
			                    "alertText": "' . JText::_('OSM_INVALID_EMAIL') . '",
			                },
							"ajaxValidatePassword": {
			                	"url": "' . $siteUrl . 'index.php?option=com_osmembership&task=validate_password",
			                    "alertText": "' . JText::_('OSM_INVALID_PASSWORD') . '",
			                },
				            //tls warning:homegrown not fielded
			                "dateFormat":{
			                    "regex": /^\\d{4}[\\/\\-](0?[1-9]|1[012])[\\/\\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\\/|-)(?:29|30)))(\\/|-)(?:[1-9]\\d\\d\\d|\\d[1-9]\\d\\d|\\d\\d[1-9]\\d|\\d\\d\\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\\/|-)(?:0?[1-9]|1\\d|2[0-8]))(\\/|-)(?:[1-9]\\d\\d\\d|\\d[1-9]\\d\\d|\\d\\d[1-9]\\d|\\d\\d\\d[1-9])$|^(0?2(\\/|-)29)(\\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\\d\\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
			                    "alertText": "' . JText::_('OSM_INVALID_DATE') . '"
			                },
			                //tls warning:homegrown not fielded
							"dateTimeFormat": {
				                "regex": /^\\d{4}[\\/\\-](0?[1-9]|1[012])[\\/\\-](0?[1-9]|[12][0-9]|3[01])\\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\\/|-)(?:29|30)))(\\/|-)(?:[1-9]\\d\\d\\d|\\d[1-9]\\d\\d|\\d\\d[1-9]\\d|\\d\\d\\d[1-9])$|^((1[012]|0?[1-9]){1}\\/(0?[1-9]|[12][0-9]|3[01]){1}\\/\\d{2,4}\\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\\s+(am|pm|AM|PM){1})$/,
			                    "alertText": "* Invalid Date or Date Format",
			                    "alertText2": "' . JText::_('OSM_EXPECTED_FORMAT') . '",
			                    "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ",
			                    "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
				            }
			            };
			     
			        }
			    };
			    $.validationEngineLanguage.newLang();
			});
		');
        self::addScript(JUri::root(true) . '/components/com_osmembership/assets/js/validate/js/jquery.validationEngine.js');
    }
 //OS Framework
 require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/defines.php';
 require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/inflector.php';
 require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/autoload.php';
 $document = JFactory::getDocument();
 $user = JFactory::getUser();
 $db =& JFactory::getDBO();
 OSMembershipHelper::loadLanguage();
 $styleUrl = JURI::base(true) . '/components/com_osmembership/assets/css/style.css';
 $document->addStylesheet($styleUrl, 'text/css', null, null);
 $config = OSMembershipHelper::getConfig();
 if (@$config->load_jquery !== '0') {
     OSMembershipHelper::loadJQuery();
 }
 OSMembershipHelper::loadBootstrap(true);
 JHtml::_('script', OSMembershipHelper::getSiteUrl() . 'components/com_osmembership/assets/js/jquery-noconflict.js', false, false);
 $Itemid = JRequest::getInt('Itemid');
 $planIds = $params->get('plan_ids', '*');
 $layout = $params->get('layout_type', 'default');
 $fieldSuffix = OSMembershipHelper::getFieldSuffix();
 if (!$planIds) {
     $planIds = '*';
 }
 if ($planIds == '*') {
     $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 ORDER BY a.ordering';
 } elseif (strpos($planIds, 'cat-') !== false) {
     $catId = (int) substr($planIds, 4);
     $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 AND a.category_id=' . $catId . ' ORDER BY a.ordering';
 } else {
     $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 AND a.id IN (' . $planIds . ') ORDER BY a.ordering';
 }
示例#5
0
 /**
  * Replace callback function
  *
  * @param array $matches
  */
 function displayPlans($matches)
 {
     require_once JPATH_ROOT . '/components/com_osmembership/libraries/rad/bootstrap.php';
     //OS Framework
     require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/defines.php';
     require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/inflector.php';
     require_once JPATH_ROOT . '/administrator/components/com_osmembership/libraries/autoload.php';
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     $config = OSMembershipHelper::getConfig();
     if (@$config->load_jquery !== '0') {
         OSMembershipHelper::loadJQuery();
     }
     OSMembershipHelper::loadBootstrap(true);
     JHtml::_('script', OSMembershipHelper::getSiteUrl() . 'components/com_osmembership/assets/js/jquery-noconflict.js', false, false);
     OSMembershipHelper::loadLanguage();
     $styleUrl = JURI::base(true) . '/components/com_osmembership/assets/css/style.css';
     $document->addStylesheet($styleUrl, 'text/css', null, null);
     OSMembershipHelper::loadBootstrap(false);
     $Itemid = OSMembershipHelper::getItemid();
     $planIds = $matches[1];
     $fieldSuffix = OSMembershipHelper::getFieldSuffix();
     $layout = $this->params->get('layout_type', 'default');
     if ($planIds == '*') {
         $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 ORDER BY a.ordering';
     } elseif (strpos($planIds, 'cat-') !== false) {
         $catId = (int) substr($planIds, 4);
         $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 AND a.category_id=' . $catId . ' ORDER BY a.ordering';
     } else {
         $sql = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a WHERE a.published = 1 AND a.id IN (' . $planIds . ') ORDER BY a.ordering';
     }
     $db->setQuery($sql);
     $rows = $db->loadObjectList();
     if ($user->id) {
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             $row = $rows[$i];
             $taxRate = OSMembershipHelper::calculateTaxRate($row->id);
             if ($config->show_price_including_tax && $taxRate > 0) {
                 $row->price = $row->price * (1 + $taxRate / 100);
                 $row->trial_amount = $row->trial_amount * (1 + $taxRate / 100);
             }
             if (!$row->enable_renewal) {
                 $sql = 'SELECT COUNT(*) FROM #__osmembership_subscribers WHERE (email="' . $user->email . '" OR user_id=' . $user->id . ') AND plan_id=' . $row->id . ' AND published != 0 ';
                 $db->setQuery($sql);
                 $total = (int) $db->loadResult();
                 if ($total) {
                     $row->disable_subscribe = 1;
                 }
             }
         }
     } elseif ($config->show_price_including_tax) {
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             $row = $rows[$i];
             $taxRate = OSMembershipHelper::getPlanTaxRate($row->id);
             if ($taxRate > 0) {
                 $row->price = $row->price * (1 + $taxRate / 100);
                 $row->trial_amount = $row->trial_amount * (1 + $taxRate / 100);
             }
         }
     }
     if ($layout == 'default') {
         return '<div class="osm-container row-fluid clearfix">' . OSMembershipHelperHtml::loadCommonLayout('common/default_plans.php', array('items' => $rows, 'config' => $config, 'Itemid' => $Itemid)) . '</div>';
     } else {
         return '<div class="osm-container row-fluid clearfix">' . OSMembershipHelperHtml::loadCommonLayout('common/columns_plans.php', array('items' => $rows, 'config' => $config, 'Itemid' => $Itemid)) . '</div>';
     }
 }