Commit 0685366d authored by Artem Pianykh's avatar Artem Pianykh

samples

parents
vendor
node_modules
.idea
.settings
.project
![](http://git.rexsoftproduction.com/uploads/appearance/logo/1/rexsoft.png)
# RexsoftInc Code Samples Repository
## [View Files](http://git.rexsoftproduction.com/rexsoftinc/samples/tree/master)
\ No newline at end of file
import ExpResAgent from './ExpResAgent';
import ExpResDriver from './ExpResDriver';
import ExpResMover from './ExpResMover';
import ExpResTruck from './ExpResTruck';
import ExpResTotal from './ExpResTotal';
import ExpResExpense from './ExpResExpense';
var ExpRes = React.createClass({
getInitialState: function () {
return {
total_summ: [],
salary: 0,
expenses: 0
}
},
set: function(data) {
this.state.total_summ.push(data);
},
totalSalary: function(data) {
this.setState({
salary: parseFloat(data).toFixed(2)
})
},
totalExpenses: function(data) {
this.setState({
expenses: parseFloat(data).toFixed(2)
})
},
render: function () {
return (
<div className="commonblock mod-common container-fluid">
<div className="col-xs-6">
<div className="style">
<div className="form-title col-xs-6">
Resource
</div>
<div className="form-title col-xs-6">
Salary
</div>
<ExpResAgent job_info={this.props.job_info} set={this.set}/>
<ExpResDriver job_info={this.props.job_info} set={this.set}/>
<ExpResMover job_info={this.props.job_info}/>
<ExpResTruck job_info={this.props.job_info} set={this.set}/>
<ExpResTotal job_info={this.props.job_info} totalSalary={this.totalSalary} total={this.state.total_summ}/>
</div>
</div>
<ExpResExpense job_info={this.props.job_info} totalExpenses={this.totalExpenses} />
<div className="col-xs-3">
<div className="style">
<div className="form-title col-xs-6">
Totals
</div>
<table className="table mod-equalhalf" >
<tbody>
<tr>
<td>
Job Total
</td>
<td>
<input value={this.props.job_info.calc_info[0].final_total} readonly className="form-control"/>
</td>
</tr>
<tr>
<td>
Salary
</td>
<td>
<input value={this.state.salary} readonly className="form-control"/>
</td>
</tr>
<tr>
<td>
Expenses
</td>
<td>
<input value={this.state.expenses} readonly className="form-control"/>
</td>
</tr>
<tr>
<td>
Profit
</td>
<td>
<input value={(parseFloat(this.props.job_info.calc_info[0].final_total) - parseFloat(this.state.salary) - parseFloat(this.state.expenses)).toFixed(2)} readonly className="form-control"/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
)
}
});
export default ExpRes;
import JobInfo from './JobInfo';
import JobMovingInfo from './JobMovingInfo';
import JobEstimated from '../jobEstimated/JobEstimated';
import JobNotes from '../jobNotes/JobNotes';
import JobCustomerNotes from '../jobNotes/JobCustomerNotes';
import JobExstraStops from '../jobNotes/JobExstraStops';
import RatePayment from '../ratePayment/RatePayment';
import Storage from '../storage/Storage';
import ExpRes from '../expres/ExpRes';
import Inventory from '../inventory/Inventory';
import PartnerInfo from '../partner/PartnerInfo';
import EmailDetail from '../../emails/EmailDetail.jsx';
import { SimplexConnect } from 'react-simplex';
var Job = React.createClass({
render: function() {
if(!this.props.SelectedJob ) return null;
if( this.props.SelectedJob.hidden ) return null;
var components = [];
switch (this.props.components) {
case 'general':
if(this.props.SelectedJob.job_info[0].type == "3") {
components.push(
<Storage job_info={this.props.SelectedJob}/>
);
} else {
components.push(
<div>
<JobMovingInfo job_info={this.props.SelectedJob} />
<JobCustomerNotes job_info={this.props.SelectedJob} />
<JobNotes job_info={this.props.SelectedJob} />
<JobExstraStops job_info={this.props.SelectedJob} />
</div>
);
}
break;
case 'rate':
components.push(
<RatePayment job_info={this.props.SelectedJob}/>
);
break;
case 'storage':
components.push(
<Storage job_info={this.props.SelectedJob}/>
);
break;
case 'exp':
components.push(
<ExpRes job_info={this.props.SelectedJob}/>
);
break;
case 'partner':
components.push(
<PartnerInfo job_info={this.props.SelectedJob}/>
);
break;
case 'inventory':
components.push(
<Inventory job_info={this.props.SelectedJob}/>
);
break;
case 'jobs-email':
components.push(
<EmailDetail job_info={this.props.SelectedJob} detailEmailObj={this.props.detailEmailObj}/>
);
break;
}
return (
<div>
<div className="commonblock mod-common" style={{'padding-top': 0}}>
<JobInfo job_info={this.props.SelectedJob} />
{this.props.components == 'storage' ? <div></div> : <JobEstimated job_info={this.props.SelectedJob} />}
</div>
{components}
</div>
);
}
});
Job = SimplexConnect( Job, ['SelectedJob'] );
export default Job;
import {SimplexConnect, SimplexMapToProps} from 'react-simplex';
import StorageInfo from './StorageInfo';
import StorageInventory from './StorageInventory';
import StoragePayment from './StoragePayment';
import JobController from '../../../controllers/JobController'
var Storage = React.createClass({
componentDidMount: function() {
this.storage = $( ReactDOM.findDOMNode( this.refs.storage) );
this.storage.select2({
width: "100%",
minimumResultsForSearch: -1
});
this.storage.on("change", (e) => {
this.selectStorage( e );
});
},
componentDidUpdate: function() {
this.storage = $( ReactDOM.findDOMNode( this.refs.storage) );
this.storage.select2({
width: "100%",
minimumResultsForSearch: -1
});
},
selectStorage: function(e) {
var event = Object.assign( {}, e );
JobController.updateWithStorage(Simplex.SelectedJob, event.target.value)
},
render: function() {
var storages = this.props.job_info.storages.map((item)=>{
return <option value={item.id}>{item.name}</option>
});
return (
<div className="container-fluid">
{this.props.job_info.job_info[0].storage_id != "0" ?
<div className="commonblock">
<div className="tabbable page-tabs">
<ul className="nav nav-tabs">
<li className="active">
<a href="#storageinfo" data-toggle="tab">
Storage info
<span href="#" className="ico ico-sign-stop mod-pointer"></span>
<span href="#" className="ico ico-st-out mod-pointer"></span>
</a>
</li>
<li className="">
<a href="#invstored" data-toggle="tab">
Inventory stored
</a>
</li>
<li className="">
<a href="#paymentinfo" data-toggle="tab">
Payment info
</a>
</li>
</ul>
</div>
<div className="tab-content">
<StorageInfo job_info={this.props.job_info}/>
<StorageInventory job_info={this.props.job_info}/>
<StoragePayment job_info={this.props.job_info}/>
</div>
</div>
: <div className="commonblock mod-common">
<div className="container-fluid input-wrap mod-smallerpaddings">
<div className="style">
<div className="input-row text-center">
<div className="col-xs-6 col-xs-offset-3">
<label>Select Storage</label>
<select data-placeholder="Category" ref="storage" name="storage" className="mov-select">
<option selected value=""></option>
{storages}
</select>
</div>
<div className="input-row ">&nbsp;</div>
</div>
</div>
</div>
</div>
}
</div>
)
}
});
export default Storage;
This diff is collapsed.
This diff is collapsed.
;(function( $, window, document, undefined ){
var fileControls = function(el, options) {
this.el = el;
this.$el = $(el);
this.options = options;
this.metadata = this.$el.data('options');
};
fileControls.prototype = {
defaults : {
canUpload: true,
moduleConfig: false,
uploaded: false,
canDownload: false,
url: '',
type: false,
changePlaceholder: 'Change',
deletePlaceholder: 'Delete',
downloadPlaceholder: 'Download',
fileInfo: '',
},
init: function() {
if(this.$el.data('init') || this.$el.hasClass('html')) return;
this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.getConfigFromModule();
this.$input = this.$el.find('input');
this.placeholder = this.$input.attr('placeholder');
if(this.$el.hasClass('image')) {
this.config.type = 'image';
}
if(this.$el.hasClass('file')) {
this.config.type = 'file';
}
if(this.$el.hasClass('photo')) {
this.config.type = 'photo';
}
if(this.$el.hasClass('anchored')) {
this.renderAnchor();
}
this.renderHtml();
this.attachEvents();
this.$el.data('init', true);
return this;
},
getConfigFromModule: function() {
if (this.config.moduleConfig.indexOf('::')) {
var tmp = this.config.moduleConfig.split('::');
var module = Modules.get(tmp[0]);
var moduleConfig = module[tmp[1]];
this.config = $.extend(this.config, moduleConfig);
}
},
renderHtml: function () {
this.placeholder = '<svg class="svg-icon add"><use xlink:href="#ico-add" /></svg>' + this.placeholder;
switch(this.config.type) {
case 'image':
this.$input.wrap('<div class="file-input"></div>').before('<div class="file-input-placeholder">'+this.placeholder+'</div>');
this.$el.wrapInner('<div class="file-wrap"></div>');
this.renderImage();
break;
case 'file':
this.$input.wrap('<div class="file-input"></div>').before('<div class="file-input-placeholder">'+this.placeholder+'</div>');
this.$el.wrapInner('<div class="file-wrap"></div>');
this.renderFile();
break;
case 'photo':
this.$input.wrap('<div class="file-input"></div>');
this.$el.wrapInner('<div class="file-wrap"></div>');
this.renderPhoto();
break;
}
this.$el.wrapInner('<div class="file-cell"></div>');
},
renderImage: function() {
if(this.$el.find('img').length) {
this.setUpdloaded(true);
}
this.$el.append(' \
<div class="file-aside"> \
<a href="#" class="file-change" data-action="change"> \
'+this.config.changePlaceholder+' \
</a> \
<div class="file-info"> \
'+this.config.fileInfo+' \
</div> \
</div> \
');
},
renderFile: function() {
if(this.$el.find('a').length) {
this.setUpdloaded(true);
}
button = (this.config.canDownload) ? 'download' : 'change';
if(button == 'change') {
this.$el.append(' \
<div class="file-aside '+button+'"> \
<a href="#" class="file-'+button+'" data-action="'+button+'"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-download" /> \
</svg> \
'+this.config.changePlaceholder+' \
</a> \
<div class="file-info"> \
'+this.config.fileInfo+' \
</div> \
</div> \
');
}
if(button == 'download') {
var url = this.$el.find('a').attr('href');
this.$el.append(' \
<div class="file-aside '+button+'"> \
<a href="'+url+'" class="file-'+button+'" target="_blank"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-download" /> \
</svg> \
'+this.config.downloadPlaceholder+' \
</a> \
<div class="file-info"> \
'+this.config.fileInfo+' \
</div> \
</div> \
');
}
this.$el.append(' \
<div class="file-aside"> \
<a href="#" class="file-remove" data-action="remove"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-clear" /> \
</svg> \
'+this.config.deletePlaceholder+' \
</a> \
</div> \
');
},
renderPhoto: function() {
if(this.$el.find('img').length) {
this.setUpdloaded(true);
}
this.$el.append(' \
<div class="file-aside add"> \
<a href="#" class="file-add" data-action="change"> \
'+this.placeholder+' \
</a> \
</div> \
');
this.$el.append(' \
<div class="file-aside"> \
<a href="#" class="file-change" data-action="change"> \
'+this.config.changePlaceholder+' \
</a> \
<div class="file-info"> \
'+this.config.fileInfo+' \
</div> \
</div> \
');
this.$el.append(' \
<div class="file-aside"> \
<a href="#" class="file-remove" data-action="remove"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-clear" /> \
</svg> \
'+this.config.deletePlaceholder+' \
</a> \
</div> \
');
},
renderAnchor: function() {
this.$el.append(' \
<div class="file-anchor"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-upload-arrow" /> \
</svg> \
</div> \
');
},
setUpdloaded: function(state) {
this.config.uploaded = state;
if(state) {
this.$el.addClass('uploaded');
} else {
this.$el.removeClass('uploaded');
}
},
setFile: function(url, info) {
this.setUpdloaded(true);
this.$input.val('');
switch(this.config.type) {
case 'image':
if(this.$el.find('img').length) {
this.$el.find('img').attr('src', url);
} else {
this.$el.find('.file-wrap').prepend('<img src="'+url+'" alt="" />');
}
this.$el.find('.file-info').text(info);
break;
case 'file':
this.$el.find('.file-info').text(info);
break;
case 'photo':
if(this.$el.find('img').length) {
this.$el.find('img').attr('src', url);
} else {
this.$el.find('.file-wrap').prepend('<img src="'+url+'" alt="" />');
}
this.$el.find('.file-info').text(info);
break;
}
},
resetInput: function() {
this.$input.wrap('<form>').closest('form').get(0).reset();
this.$input.unwrap();
},
attachEvents: function() {
var _this = this;
this.$el.on('click', '[data-action]', function(e){
e.preventDefault();
var action = $(this).data('action');
if(_this.events.hasOwnProperty(action)) {
_this.events[action](_this, $(this));
}
});
if(this.config.canUpload) {
this.$el.on('change', 'input', function(e){
e.preventDefault();
_this.events.upload(_this, $(this));
});
} else {
this.$el.on('change', 'input', function(e){
e.preventDefault();
_this.events.choose(_this, $(this));
});
}
},
events: {
change: function(_this, $el) {
_this.$input.trigger('click');
},
choose: function(_this, $el) {
_this.setUpdloaded(false);
var fileName = $el.val().split('\\').pop();
if(fileName!='') {
_this.$el.find('.file-input-placeholder').html(fileName);
_this.$el.addClass('choosen');
} else {
_this.$el.find('.file-input-placeholder').html(_this.placeholder);
_this.$el.removeClass('choosen');
}
},
upload: function(_this, $el) {
if(!_this.config.url) return;
var formData = new FormData();
formData.append($el.attr('name'), $el.prop('files')[0]);
formData.append('task', 'upload');
Ajax.json({
url: _this.config.url,
data: formData,
success: function(response) {
_this.$input.val('');
if(response.status) {
_this.setFile(response.url, response.fileInfo);
}
}
});
},
remove: function(_this, $el) {
if(!_this.config.url) return;
var formData = new FormData();
formData.append('file', _this.$input.attr('name'));
formData.append('task', 'remove');
if(_this.config.itemId) {
formData.append('itemId', _this.config.itemId);
}
Ajax.json({
url: _this.config.url,
data: formData,
success: function(response) {
if(response.status) {
_this.setUpdloaded(false);
}
}
});
},
},
};
fileControls.defaults = fileControls.prototype.defaults;
$.fn.fileControls = function(options) {
return this.each(function() {
new fileControls(this, options).init();
});
};
})( jQuery, window , document );
;(function( $, window, document, undefined ){
var inputControls = function(el, options) {
this.el = el;
this.$el = $(el);
this.options = options;
this.metadata = this.$el.data('options');
};
inputControls.prototype = {
defaults : {
animationSpeed: 400,
buttons: 'edit,clear,save',
actions: {
edit: {
visible: true,
call: 'onEdit',
classStr: 'ic-hover'
},
clear: {
visible: true,
call: 'onClear',
classStr: 'ic-hover'
},
add: {
visible: true,
call: 'onAdd',
classStr: ''
},
save: {
visible: true,
call: 'onSave',
classStr: ''
},
blur: {
visible: false,
call: 'onBlur',
classStr: ''
}
},
onEdit: function($wrap, $input) {
$wrap.addClass('preEdit').changeClassDelay('preEdit', 'onEdit');
$input.attr('disabled', false).focus();
pos = $input.val().length * 2;
$input[0].setSelectionRange(pos,pos);
},
onClear: function($wrap, $input) {
$input.val('').trigger('ic:save');
$wrap.reset();
if($input.data('add') && $('.js-inputControls[name="'+ $input.attr('name') +'"]').length > 1) {
$wrap.remove();
}
},
onAdd: function($wrap, $input) {
var $clone = $input.clone();
$clone.val('');
$wrap.after($clone);
$clone.inputControls();
},
onSave: function($wrap, $input) {
$wrap.addClass('onSave'); //.removeClass('onEdit');
},
onBlur: function($wrap, $input) {
var value = $input.val();
if(value==$input.data('sourceVal')) {
$input.attr('disabled', true);
$wrap.reset();
}
},
},
init: function() {
if(this.$el.data('inputControls')) return;
this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.parseDataAttr();
this.$el.data('sourceVal', this.$el.val());
this.$el.data('inputControls', 1);
this.renderHtml();
this.setStyles();
this.setButtons();
this.attachEvents();
return this;
},
parseDataAttr: function() {
if(this.$el.data('add')) {
this.config.buttons += ',add';
}
},
renderHtml: function () {
this.$wrap = this.$el.wrap('<div class="plg-inputControls" />').closest('.plg-inputControls');
this.$wrap.reset = function() {
$(this).attr('class', 'plg-inputControls');
var $input = $(this).find('input');
$input.attr('disabled', 'disabled');
$input.data('sourceVal', $input.val());
};
var delay = this.config.animationSpeed;
this.$wrap.changeClassDelay = function($oldClass, $newClass) {
var $el = $(this);
setTimeout(function() {
$el.removeClass($oldClass).addClass($newClass);
}, delay);
return this;
};
},
setStyles: function() {
var style = '';
var animationDurationVendors = [
'-webkit-animation-duration',
'-moz-animation-duration',
'-ms-animation-duration',
'-o-animation-duration',
'animation-duration'
];
var animStyle = this.config.animationSpeed/1000;
for (var i=0; i < animationDurationVendors.length; i++) {
style += animationDurationVendors[i]+':'+animStyle+'s;';
};
this.$wrap.attr('style', style);
this.$el.attr('disabled', 'disabled');
},
setButtons: function() {
var buttons = this.config.buttons.split(',');
var actions = $.extend( {}, this.config.actions );
for (var i=0; i < buttons.length; i++) {
if(actions[buttons[i]] && actions[buttons[i]].visible) {
actions[buttons[i]] = this.getButtonHtml(buttons[i], actions[buttons[i]].classStr);
}
};
actions = $.map(actions, function(val, i) {
if(typeof(val)=='string') return val;
});
this.$wrap.append(' \
<div class="ic-actionsPanel"> \
'+actions.join('')+' \
</div> \
');
},
getButtonHtml: function(action, classStr) {
return ' \
<a href="#" data-action="'+action+'" class="ic-actionButton '+classStr+'"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-'+action+'" /> \
</svg> \
</a> \
';
},
attachEvents: function() {
var _this = this;
var actions = $.extend( {}, this.config.actions );
for(var i in actions) {
this[actions[i].call](_this);
}
this.$wrap.find('[data-action]').click(function(e){
e.preventDefault();
_this.$el.trigger('ic:'+$(this).data('action'));
});
this.$el.on('ic:reset', function(e){
e.preventDefault();
_this.$wrap.reset();
});
},
onEdit: function(_this) {
this.$el.on('ic:edit',function(e) {
$(this).trigger('ic:onEdit');
_this.config.onEdit(_this.$wrap, $(this));
});
},
onClear: function(_this) {
this.$el.on('ic:clear',function(e) {
$(this).trigger('ic:onClear');
_this.config.onClear(_this.$wrap, $(this));
});
},
onAdd: function(_this) {
this.$el.on('ic:add',function(e) {
$(this).trigger('ic:onAdd');
_this.config.onAdd(_this.$wrap, $(this));
});
},
onSave: function(_this) {
this.$el.on('ic:save',function(e) {
$(this).trigger('ic:onSave');
_this.config.onSave(_this.$wrap, $(this));
});
},
onBlur: function(_this) {
this.$el.on('blur',function(e) {
$(this).trigger('ic:onBlur');
_this.config.onBlur(_this.$wrap, $(this));
});
},
};
inputControls.defaults = inputControls.prototype.defaults;
$.fn.inputControls = function(options) {
return this.each(function() {
new inputControls(this, options).init();
});
};
})( jQuery, window , document );
;(function( $, window, document, undefined ){
var mobilContent = function(el, options) {
this.el = el;
this.$el = $(el);
this.options = options;
this.metadata = this.$el.data('options');
};
mobilContent.prototype = {
opened: false,
defaults : {
container: false,
bordered: false
},
init: function() {
if(this.$el.data('init')) return;
this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.title = this.$el.data('title');
this.renderHtml();
this.attachEvents();
this.$el.data('init', true);
return this;
},
renderHtml: function () {
var wrap_classes = '';
if(this.config.bordered || this.$el.hasClass('bordered')) wrap_classes += ' bordered';
this.$wrap = this.$el.wrap('<div class="plg-mobilContent-wrap'+wrap_classes+'" />').closest('.plg-mobilContent-wrap');
this.$el.addClass('plg-mobilContent');
this.$el.before(' \
<a href="#" class="plg-mobilContent-button open" data-mc-action="open"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-menu" /> \
</svg> \
'+this.title+' \
</a> \
<a href="#" class="plg-mobilContent-button close" data-mc-action="close"> \
<svg class="svg-icon"> \
<use xlink:href="#ico-menu-close" /> \
</svg> \
Hide '+this.title.toLowerCase()+' \
</a> \
');
this.$open_button = this.$wrap.find('.plg-mobilContent-button.open');
this.$close_button = this.$wrap.find('.plg-mobilContent-button.close');
$('.page-body').addClass('mobilContent');
},
attachEvents: function() {
var _this = this;
this.$wrap.find('[data-mc-action]').click(function(e){
e.preventDefault();
_this.$el.trigger('mc:'+$(this).data('mc-action'));
});
this.onOpen(_this);
this.onClose(_this);
},
onOpen: function(_this) {
this.$el.on('mc:open',function(e) {
if(_this.opened == true) return;
_this.opened = true;
$(this).trigger('mc:onOpen');
if(_this.$wrap.hasClass('opened')) {
return;
}
$('body').addClass('plg-mobilContent-body');
_this.$wrap.addClass('opened');
_this.$el.slideDown().animate({opacity: 1},{queue: false});
_this.$open_button.animate({height:0}, 200, function() {
_this.$close_button.animate({height:48},200);
});
});
},
onClose: function(_this) {
this.$el.on('mc:close',function(e) {
if(_this.opened == false) return;
_this.opened = false;
$(this).trigger('mc:onClose');
if(!_this.$wrap.hasClass('opened')) {
return;
}
_this.$el.slideUp().animate({opacity: 0},{queue: false});
_this.$close_button.animate({height:0}, 200, function() {
_this.$open_button.animate({height:48},200);
$('body').removeClass('plg-mobilContent-body');
_this.$wrap.removeClass('opened');
});
});
}
};
mobilContent.defaults = mobilContent.prototype.defaults;
$.fn.mobilContent = function(options) {
return this.each(function() {
new mobilContent(this, options).init();
});
};
})( jQuery, window , document );
\ No newline at end of file
;(function( $, window, document, undefined ){
var tableRender = function(el, options) {
this.el = el;
this.$el = $(el);
this.options = options;
this.metadata = this.$el.data('options');
this.init();
};
tableRender.prototype = {
structure: [],
filter: [],
defaults : {
env: '',
alphaKey: 'email',
baseUrl: '',
formSelector : false,
formSubmitSelector: false,
jsValidation: false,
messages: {
empty: 'No Entries',
button: 'Add'
},
groupHtml: function(obj) {
return '\
<div class="items-group'+((obj.hidden)?' filtered':'')+'" data-key="'+ obj.name +'">\
' + this.list('item', obj.childs) + '\
<div class="items-group-title col-xs-12 col-sm-1">\
' + obj.name + '\
</div>\
</div>\
';
},
itemHtml: function(obj) {
return '';
}
},
init: function() {
this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.templates.group = this.config.groupHtml;
this.templates.item = this.config.itemHtml;
this.title = this.$el.data('title');
var _this = this;
this.getData(function() {
_this.renderHtml();
_this.attachEvents();
});
return this;
},
update: function() {
var _this = this;
this.getData(function() {
_this.$filter.empty();
_this.$content.empty();
_this.renderFilter();
_this.renderContent();
});
return this;
},
ajax: function(url, params, callback) {
params = $.extend(true, {}, {
type: 'post',
url: this.config.baseUrl + url,
dataType: 'json',
cache: false,
success: function(response) {
callback(response);
}
}, params);
$.ajax(params);
},
getData: function(callback) {
var _this = this;
this.ajax('json', {
data: {parentId: this.config.parentId}
}, function(data) {
_this.makeStructure(data);
callback();
});
},
getForm: function() {
if(this.config.formSelector) {
return $(this.config.formSelector);
}
if(this.config.formSubmitSelector) {
return $(this.config.formSubmitSelector).closest('form');
}
},
getFormHtml: function(data, callback) {
var post = $.extend({}, {
companyId: this.config.companyId,
env: this.config.env,
html: 1
}, data);
this.ajax('edit', {
data: post,
}, function(data) {
callback(data);
});
},
makeStructure: function (data) {
this.structure = {};
for(var i in data) {
var key = data[i]['id'];
if(this.config.alphaKey && data[i][this.config.alphaKey]!='') {
key = data[i][this.config.alphaKey][0];
key = key.toUpperCase();
}
if(this.structure[key]==undefined) {
this.structure[key] = {
name: (this.config.alphaKey)? key : '',
type: 'group',
childs: [],
hidden: (this.filter.length && this.filter.indexOf(key) < 0)? true : false,
filter: (this.filter.length && this.filter.indexOf(key) > -1)? true : false,
};
}
this.structure[key].childs.push(data[i]);
}
},
renderHtml: function() {
this.$el.append(' \
<div class="items-title"> \
'+this.title+' \
<div class="filter"> \
</div> \
</div> \
');
this.$el.append(' \
<div class="items-content"> \
</div> \
');
this.$el.append(' \
<div class="add"> \
<a href="#" data-action="scroll" class="ui-button grey width-auto">'+this.config.messages.button+'</a> \
</div> \
');
this.$filter = this.$el.find('.filter');
this.$content = this.$el.find('.items-content');
this.$form = this.getForm();
this.renderFilter();
this.renderContent();
},
renderFilter: function() {
this.$filter.empty();
var length = $.map(this.structure, function(v, i) { return i; }).length;
if(length && this.config.alphaKey) {
this.$filter.append(' \
<span>Filter:</span> \
'+this.templates.render('filter', this.structure)+' \
');
}
},
renderContent: function() {
this.$content.empty();
var length = $.map(this.structure, function(v, i) { return i; }).length;
if(length) {
this.$content.append(this.templates.render('structure', this.structure));
} else {
this.$content.append('<span class="items-empty">'+this.config.messages.empty+'</span>');
}
},
templates: {
render: function(template, data) {
return this[template](data);
},
filter: function(arr) {
var html = '';
for(var i in arr) {
html += '<a href="#" class="'+((arr[i].filter)?'active':'')+'" data-action="filter" data-key="'+i+'">'+i+'</a>';
}
return html;
},
structure: function(arr) {
var html = '';
for(var i in arr) {
html += this.render(arr[i].type, arr[i]);
}
return html;
},
list: function(template, arr) {
var html = '';
for(var i in arr) {
html += this.render(template, arr[i]);
}
return html;
},
group: function(obj) {return '';},
},
attachEvents: function() {
var _this = this;
this.$el.on('click', '[data-action]', function(e){
e.preventDefault();
var action = $(this).data('action');
if(_this.events.hasOwnProperty(action)) {
_this.events[action](_this, $(this));
} else {
console.log('tableRender: Action not registered');
}
});
this.$el.on('tbl:update', function(e) {
_this.update();
$('html, body').animate({
scrollTop: $(_this.$el).offset().top
}, 500);
});
$(document).on('submit', this.$form, function(e) {
e.preventDefault();
if(e.target == _this.$form[0]) {
_this.events.save(_this, _this.$form);
}
return false;
});
},
events: {
scroll: function(_this, $el) {
_this.domWorker.scrollTo(_this.$form);
},
dropdown: function(_this, $el) {
var $item = $el.closest('.item');
if($item.hasClass('opened')) {
$item.attr('style', false);
} else {
$item.css('height', $item.height());
}
$el.closest('.item').toggleClass('opened');
$el.closest('.items-group').next().slideToggle(200);
},
filter: function(_this, $el) {
var key = $el.data('key');
var index = _this.filter.indexOf(key);
if (index > -1) {
_this.filter.splice(index, 1);
} else {
_this.filter.push(key);
}
_this.domWorker.filter($el, _this.filter);
},
edit: function(_this, $el) {
var itemId = $el.closest('.item').data('id');
_this.getFormHtml({ id: itemId }, function(data) {
_this.domWorker.fillForm(_this.$form, data.html);
_this.domWorker.scrollTo(_this.$form);
});
},
save: function(_this, $form) {
var formData = new FormData($form[0]);
_this.ajax('save', {
data: formData,
processData: false,
contentType: false,
}, function(data) {
App.update(data);
if(data.status) {
_this.$el.trigger('tbl:update');
_this.getFormHtml({ id: false }, function(data) {
_this.domWorker.fillForm(_this.$form, data.html);
});
}
});
},
delete: function(_this, $el) {
var itemId = $el.closest('.item').data('id');
_this.ajax('delete/'+itemId, {
companyId: _this.config.companyId,
id: itemId
}, function(data) {
App.update(data);
_this.$el.trigger('tbl:update');
});
},
},
domWorker: {
scrollTo: function($el) {
$('.js-mobilContent').trigger('mc:close');
var fixed_offset = parseInt($('.page-body').css('padding-top')) + 20;
var top = $el.offset().top - fixed_offset;
$('html,body').animate({scrollTop: top}, 200);
},
filter: function($el, keys) {
$el.toggleClass('active');
if(keys.length>0) {
$('.items-group').addClass('filtered');
for(var i in keys) {
$('.items-group.filtered[data-key="'+keys[i]+'"]').removeClass('filtered');
}
} else {
$('.items-group').removeClass('filtered');
}
},
fillForm: function($form, html) {
$form.empty().append(html);
App.stylize();
}
}
};
tableRender.defaults = tableRender.prototype.defaults;
$.fn.tableRender = function(options) {
return this.each(function() {
new tableRender(this, options);
});
};
})( jQuery, window , document );
var Validator = {
init: function() {
var _this = this;
$('form').each(function(index) {
var name = $(this).attr('name');
if(ValitatorRules.hasOwnProperty(name)) {
rules = ValitatorRules[name]();
$(this).validate({
errorContainer: '.ui-validation-wrap',
errorElement: 'label',
focusInvalid: false,
focusCleanup: true,
errorClass: 'ui-validation-error',
rules: rules,
errorPlacement: function(error, el) {
Validator.setError($(el), error);
},
highlight: function(el, errorClass, validClass) {
var $el = Validator.defineElement($(el));
if($el) {
if($el.hasClass('ui-checkbox')) {
$el.addClass('ui-validation-highlight');
return;
};
$el.removeClass(validClass).addClass(errorClass);
}
},
unhighlight: function(el, errorClass, validClass) {
var $el = Validator.defineElement($(el));
if($el) {
$el.removeClass('ui-validation-highlight');
$el.removeClass(errorClass).addClass(validClass);
}
},
invalidHandler: function(e, validator) {
var current = $('body').scrollTop();
var target = $(e.target).offset().top;
if(current > target) {
$('html, body').animate({
scrollTop: $(e.target).offset().top - 75
}, 500);
}
}
});
}
});
},
parseJson: function(errors) {
for (var name in errors) {
Validator.setError($('[name="' + name + '"]'), '<label id="' + name + '-error" class="ui-validation-error" for="' + name + '">' + errors[name][0] + '</label>');
}
},
reset: function() {
$('.ui-validation-error .error').remove();
},
setError: function($el, message) {
var $el = this.defineElement($el);
if($el) {
this.domWorker.error($el);
this.domWorker.message($el, message);
}
},
defineElement: function($el) {
if($el.prop('tagName') == undefined) return;
var tagName = $el.prop('tagName').toLowerCase();
if(tagName=='input') {
switch($el.attr('type')) {
case 'checkbox':
return $el.closest('.ui-checkbox');
break;
default:
return $el;
break;
}
}
if(tagName=='select') {
if($el.closest('.jq-selectbox').length) {
return $el.closest('.jq-selectbox');
}
if($el.closest('.plg-acmSelect').length) {
return $el.closest('.plg-acmSelect');
}
return $el;
}
if(tagName=='textarea') {
if($el.attr('name') == 'g-recaptcha-response') {
return false;
}
return $el;
}
return false;
},
domWorker: {
error: function($el) {
if($el.hasClass('ui-checkbox')) {
$el.addClass('ui-validation-highlight');
return;
};
$el.addClass('ui-validation-error');
},
message: function($el, message) {
if($el.hasClass('ui-checkbox')) return;
if($el.prev('.ui-validation-wrap').length) {
$el.prev('.ui-validation-wrap').empty().append(message);
} else {
$('<div class="ui-validation-wrap"></div>').insertBefore($el).append(message);
}
}
}
};
var ValitatorRules = {
'beta-form': function() {
return {
pass: {
required: true
},
};
},
};
$.validator.addMethod("multiselect", function (value, el) {
var count = $(el).find('option:selected').length;
return count > 0;
});
$.validator.addMethod("emailfull", function (value, el) {
var regexp = /[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/;
return regexp.test(value);
}, 'Enter a valid email address.');
$.validator.addMethod("phonechars", function (value, el) {
if(value=='') return true;
var regexp = /^[\s()+-]*([0-9][\s()+-]*){6,20}$/;
return regexp.test(value);
}, 'Enter a valid phone number.');
$.validator.addMethod("urllinks", function (value, el) {
if(value=='') return true;
//var regexp = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;
var regexp = new RegExp(
"^" +
// protocol identifier (optional) + //
"(?:(?:https?:)?//)?" +
// user:pass authentication (optional)
"(?:\\S+(?::\\S*)?@)?" +
// host (optional) + domain + tld
"(?:(?!-)[-a-z0-9\\u00a1-\\uffff]*[a-z0-9\\u00a1-\\uffff]+(?!./|\\.$)\\.?){2,}" +
// server port number (optional)
"(?::\\d{2,5})?" +
// resource path (optional)
"(?:/\\S*)?" +
"$", "i"
);
return regexp.test(value);
}, 'Enter a valid url.');
function ValidstateCountry() {
var countryId = $('select[name*="countryId"]').val();
return (countryId==1);
}
<?php
return [
'name' => 'Seo',
'sitemap_limit' => 40000,
'sitemap_folder' => '/sitemap'
];
\ No newline at end of file
<?php
return [
'suffix' => ' | CommunicationsMatch',
'default' => [
'title' => 'CommunicationsMatch',
'description' => 'Connecting companies with communications professionals',
'keywords' => '',
'share' => [
'source' => URL::to('/'),
'title' => 'CommunicationsMatch',
'summary' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'summary.twitter' => 'New tool to search for communications companies and people by name, industry sector, expertise, location and size: www.communicationsmatch.com'
]
],
'communicator' => [
'share' => [
'summary' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'summary.twitter' => 'New tool to search for communications companies and people by name, industry sector, expertise, location and size: www.communicationsmatch.com'
]
],
];
\ No newline at end of file
<?php
return [
'suffix' => ' | CommunicationsMatch',
'props_to_add_suffix' => [
'title',
'og:title',
'twitter:title'
],
'global' => [
'title' => 'CommunicationsMatch',
'description' => 'Connecting companies with communications professionals',
'keywords' => '',
// FACEBOOK META
'og:locale' => 'en_US',
'og:type' => 'website',
'og:title' => 'CommunicationsMatch',
'og:description' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'og:url' => URL::to('/'),
'og:site_name' => 'CommunicationsMatch.com',
'og:image' => URL::to('/assets/logo-facebook.jpg'),
// TWITTER META
'twitter:card' => 'summary_large_image',
'twitter:creator' => '@CommMatch',
'twitter:title' => 'CommunicationsMatch',
'twitter:description' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'twitter:image' => URL::to('/assets/logo-twitter.jpg'),
'share' => [
'source' => URL::to('/'),
'title' => 'CommunicationsMatch',
'summary' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'summary.twitter' => 'New tool to search for communications companies and people by name, industry sector, expertise, location and size: www.communicationsmatch.com'
]
]
];
\ No newline at end of file
<?php
return [
'communicator' => [
'og:description' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'twitter:description' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'share' => [
'summary' => 'CommunicationsMatch™ is a new matching search engine that enables business leaders to find U.S. and international communications agencies and professionals by name, industry sector, expertise, location and size.',
'summary.twitter' => 'New tool to search for communications companies and people by name, industry sector, expertise, location and size: www.communicationsmatch.com'
]
],
];
\ No newline at end of file
<?php
return [
'public-auth-registration' => [
'title' => 'Create Profile'
]
];
\ No newline at end of file
<?php namespace Modules\Seo\Entities;
use \Modules\Seo\Entities\MetaTypes;
use \Modules\Seo\Entities\SeoOverrides;
/**
* Class Meta
* @package Modules\Seo\Entities
*/
class Meta
{
/**
* @var bool
*/
private $type;
private $entityIdent;
/**
* Meta constructor.
* @param bool|string $type
* @param bool|int|string $entityIdent
* @internal param bool $page
* @internal param bool $entityId
*/
function __construct($type = FALSE, $entityIdent = FALSE)
{
$this->type = $type;
$this->entityIdent = $entityIdent;
}
/**
* @param bool|int $page
* @param bool|int $entityId
* @return mixed
*/
public static function get($page = FALSE, $entityId = FALSE)
{
$self = new self($page, $entityId);
return $self->fetch();
}
/**
* @param bool $page
* @param bool $entityId
* @return string
*/
public static function render($page = FALSE, $entityId = FALSE)
{
$self = new self($page, $entityId);
$data = $self->fetch();
return \View::make('shared::chunks.meta', [
'data' => $self->getHtml($data)
])->render();
}
/**
* @return array
*/
private function fetch()
{
$global_meta = $this->getGlobals();
$route_meta = $this->fetchMetaByRoute();
$overrides_meta = $this->getOverrides();
$meta = [];
if ($this->type) {
$meta = $this->fetchMetaByPageType($this->type, $this->entityIdent);
}
$meta = array_replace_recursive($global_meta, $route_meta, $meta, $overrides_meta);
$meta = $this->prepareMeta($meta);
return $meta;
}
/**
* @param bool|string $type
* @param bool|int|string $ident
* @param array $meta
* @return array
*/
private function fetchMetaByPageType($type, $ident, $meta = [])
{
return $meta;
}
/**
* @param array $meta
* @return array
*/
private function fetchMetaByRoute($meta = [])
{
$route = \Route::getCurrentRoute()->getName();
switch ($route) {
case 'public-companies-profile-slug':
$config = \Config::get('seo.meta_pages_types.communicator');
$entitySlug = \Request::segment(2);
$meta = MetaTypes::fetchCompany($entitySlug);
$meta = array_replace($config, $meta);
break;
case 'public-people-profile-slug':
$config = \Config::get('seo.meta_pages_types.communicator');
$entitySlug = \Request::segment(2);
$meta = MetaTypes::fetchIndividual($entitySlug);
$meta = array_replace($config, $meta);
break;
case 'public-search-sector-slug':
$entitySlug = \Request::segment(2);
$meta = MetaTypes::fetchSector($entitySlug);
break;
case 'public-search-expertise-slug':
$entitySlug = \Request::segment(2);
$meta = MetaTypes::fetchExpertise($entitySlug);
break;
case 'public-papers-view-slug':
$entitySlug = \Request::segment(3);
$meta = MetaTypes::fetchInsights($entitySlug);
break;
default:
$routes_meta = \Config::get('seo.meta_routes');
if (isset($routes_meta[$route])) {
$meta = $routes_meta[$route];
}
break;
}
return $meta;
}
/**
* @return array
*/
private function getGlobals()
{
return \Config::get('seo.meta_global.global');
}
/**
* @return array
*/
private function getOverrides()
{
$route = \Request::path();
if (strpos($route, '/') !== 0) {
$route = '/' . $route;
}
$overrides = SeoOverrides::select(['title', 'description', 'keywords'])->where('slug', $route)->first();
if ($overrides) {
return $overrides->toArray();
}
return [];
}
/**
* @param array $data
* @return array
*/
private function prepareMeta($data)
{
$data['description'] = $this->stripDescription($data['description']);
$data['keywords'] = $this->stripKeywords($data['keywords']);
$props_to_add_suffix = \Config::get('seo.meta_global.props_to_add_suffix');
foreach ($props_to_add_suffix as $prop) {
if (!isset($data[$prop]) || $data[$prop] == '') continue;
$data[$prop] = trim($data[$prop]) . \Config::get('seo.meta_global.suffix');
}
foreach ($data as $key => $value) {
if (is_array($value)) continue;
$data[$key] = trim($value);
}
return $data;
}
/**
* @param string $text
* @param int $limit
* @return string
*/
private function stripDescription($text, $limit = 250)
{
$words = explode(' ', strip_tags($text));
$words_array = [];
foreach ($words as $word) {
if ($word == null) continue;
$words_array[] = trim($word);
}
$result = '';
foreach ($words_array as $word) {
$count_desc = iconv_strlen($result);
$count_word = iconv_strlen($word);
if (($count_desc + $count_word) > $limit) break;
$result .= $word . ' ';
}
return trim($result);
}
/**
* @param string $keywords
* @return string
*/
private function stripKeywords($keywords)
{
$result = [];
if (is_array($keywords)) {
foreach ($keywords as $word) {
$result[] = trim($word);
}
} else {
$result[] = trim($keywords);
}
return implode(', ', $result);
}
/**
* @param array $data
* @return array
*/
private function getHtml($data = [])
{
foreach ($data as $key => $value) {
if (is_array($value)) {
unset($data[$key]);
continue;
}
switch (TRUE) {
case ($key == 'title'):
$data[$key] = '<title>'.$value.'</title>';
break;
case (strpos($key, 'og:') === 0):
$data[$key] = '<meta property="'.$key.'" content="'.$value.'" />';
break;
default:
$data[$key] = '<meta name="'.$key.'" content="'.$value.'" />';
break;
}
}
return $data;
}
}
\ No newline at end of file
<?php namespace Modules\Seo\Entities;
use Modules\Seo\Helpers\SocialHelper;
use Modules\Companies\Entities\Company;
use Modules\Companies\Entities\CompanyInfo;
use Modules\People\Entities\Person;
use Modules\People\Entities\PersonInfo;
use Modules\People\Entities\PersonCompany;
use Modules\Companies\Entities\Sector;
use Modules\Companies\Entities\Expertise;
use Modules\Papers\Entities\Papers;
/**
* Class MetaTypes
* @package Modules\Seo\Entities
*/
class MetaTypes {
/**
* @param null|int|string $ident
* @return array
*/
public static function fetchCompany($ident = null)
{
if (is_numeric($ident)) {
$company = Company::where('id', $ident)->first();
} else {
$company = Company::where('slug', $ident)->first();
}
if(!$company) {
return [];
}
$info = CompanyInfo::where('companyId', $company->id)->first();
$keywords = [];
if ($info->keywords != '') {
$keywords[] = $info->keywords;
}
$keywords[] = $company->name;
$sectors = $company->sectors()->get();
foreach ($sectors as $sector) {
$keywords[] = $sector->name;
}
$expertises = $company->expertises()->get();
foreach ($expertises as $expertise) {
$keywords[] = $expertise->name;
}
$size = $company->size()->first();
if ($size) {
$keywords[] = $size->name;
}
return [
'title' => $company->name,
'description' => strip_tags($info->additionalNotes),
'keywords' => $keywords,
// FACEBOOK META
'og:title' => $company->name,
'og:url' => route('public-companies-profile') . '/' . $company->slug,
'og:image' => url('/thumbs' . config('companies.upload_path') . $company->image . '?resize=600,600&resizeCanvas=1200,628'),
// TWITTER META
'twitter:title' => $company->name,
'twitter:image' => url('/thumbs' . config('companies.upload_path') . $company->image . '?resize=500,500&resizeCanvas=1024,512'),
'share' => [
'source' => route('public-companies-profile') . '/' . $company->slug,
'title' => $company->name,
]
];
}
/**
* @param null|int|string $ident
* @return array
*/
public static function fetchIndividual($ident = null)
{
if (is_numeric($ident)) {
$person = Person::where('id', $ident)->first();
} else {
$person = Person::where('slug', $ident)->first();
}
if (!$person) {
return [];
}
$info = PersonInfo::where('personId', $person->id)->first();
$company = PersonCompany::where('personId', '=', $person->id)->first();
$keywords = [];
if ($info->keywords != '') {
$keywords[] = $info->keywords;
}
$keywords[] = $person->firstName . ' ' . $person->lastName;
$keywords[] = $company->name;
$sectors = $person->sectors()->get();
foreach ($sectors as $sector) {
$keywords[] = $sector->name;
}
$expertises = $person->expertises()->get();
foreach ($expertises as $expertise) {
$keywords[] = $expertise->name;
}
return [
'title' => $person->firstName . ' ' . $person->lastName . ' - ' . $company->name,
'description' => strip_tags($info->additionalNotes),
'keywords' => $keywords,
// FACEBOOK META
'og:title' => $person->firstName . ' ' . $person->lastName . ' - ' . $company->name,
'og:url' => route('public-people-profile') . '/' . $person->slug,
'og:image' => url('/thumbs' . config('people.upload_path') . $person->image . '?resize=600,600&resizeCanvas=1200,628'),
// TWITTER META
'twitter:title' => $person->firstName . ' ' . $person->lastName . ' - ' . $company->name,
'twitter:image' => url('/thumbs' . config('people.upload_path') . $person->image . '?resize=500,500&resizeCanvas=1024,512'),
'share' => [
'source' => route('public-people-profile') . '/' . $person->slug,
'title' => $person->firstName . ' ' . $person->lastName . ' - ' . $company->name,
]
];
}
/**
* @param null|int|string $ident
* @return array
*/
public static function fetchInsights($ident = null)
{
if (is_numeric($ident)) {
$paper = Papers::where('id', $ident)->first();
} else {
$paper = Papers::where('slug', $ident)->first();
}
if (!$paper) {
return [];
}
$url = '';
$html = new \DOMDocument();
libxml_use_internal_errors(true);
$html->loadHTML($paper->description);
libxml_clear_errors();
$tags = $html->getElementsByTagName('img');
foreach ($tags as $tag) {
$url = $tag->getAttribute('src');
break;
}
return [
'title' => $paper->title,
'description' => $paper->shortDesc,
'keywords' => $paper->keywords,
// FACEBOOK META
'og:title' => $paper->title,
'og:description' => $paper->shortDesc,
'og:url' => route('public-papers-view') . '/' . (($paper->communicatorType) ? 'company' : 'individual') . '/' . $paper->slug,
'og:image' => $url,
// TWITTER META
'twitter:title' => $paper->title,
'twitter:description' => $paper->shortDesc,
'twitter:image' => $url,
'share' => [
'source' => route('public-papers-view') . '/' . (($paper->communicatorType) ? 'company' : 'individual') . '/' . $paper->slug,
'title' => $paper->title,
]
];
}
/**
* @param null|int|string $ident
* @return array
*/
public static function fetchSector($ident = null)
{
if (is_numeric($ident)) {
$sector = Sector::where('id', $ident)->first();
} else {
$sector = Sector::where('slug', $ident)->first();
}
if (!$sector) {
return [];
}
return [
'title' => 'Top professionals in ' . $sector->name . ' sector',
'description' => 'Look for professionals in ' . $sector->name . ' sector? Find professionals on CommunicationsMatch. We can help you to find ' . $sector->name,
'keywords' => $sector->name . ', ' . $sector->name . ' professionals, CommunicationsMatch',
// FACEBOOK META
'og:title' => 'Top professionals in ' . $sector->name . ' sector',
'og:description' => 'Look for professionals in ' . $sector->name . ' sector? Find professionals on CommunicationsMatch. We can help you to find ' . $sector->name,
'og:url' => route('public-search-sector') . '/' . $sector->slug,
// TWITTER META
'twitter:title' => 'Top professionals in ' . $sector->name . ' sector',
'twitter:description' => 'Look for professionals in ' . $sector->name . ' sector? Find professionals on CommunicationsMatch. We can help you to find ' . $sector->name,
'share' => [
'source' => route('public-search-sector') . '/' . $sector->slug,
'title' => 'Top professionals in ' . $sector->name . ' sector',
]
];
}
/**
* @param null|int|string $ident
* @return array
*/
public static function fetchExpertise($ident = null)
{
if (is_numeric($ident)) {
$expertise = Expertise::where('id', $ident)->first();
} else {
$expertise = Expertise::where('slug', $ident)->first();
}
if (!$expertise) {
return [];
}
return [
'title' => 'Top professionals in ' . $expertise->name . ' area',
'description' => 'Look for professionals in ' . $expertise->name . ' area? Find professionals on CommunicationsMatch. We can help you to find ' . $expertise->name,
'keywords' => $expertise->name . ', ' . $expertise->name . ' professionals, CommunicationsMatch',
// FACEBOOK META
'og:title' => 'Top professionals in ' . $expertise->name . ' area',
'og:description' => 'Look for professionals in ' . $expertise->name . ' area? Find professionals on CommunicationsMatch. We can help you to find ' . $expertise->name,
'og:url' => route('public-search-expertise') . '/' . $expertise->slug,
// TWITTER META
'twitter:title' => 'Top professionals in ' . $expertise->name . ' area',
'twitter:description' => 'Look for professionals in ' . $expertise->name . ' area? Find professionals on CommunicationsMatch. We can help you to find ' . $expertise->name,
'share' => [
'source' => route('public-search-expertise') . '/' . $expertise->slug,
'title' => 'Top professionals in ' . $expertise->name . ' area',
]
];
}
}
\ No newline at end of file
<?php namespace Modules\Seo\Entities;
use Illuminate\Database\Eloquent\Model;
/**
* Class SeoOverrides
* @package Modules\Seo\Entities
*/
class SeoOverrides extends Model {
protected $table = 'seo_overrides';
protected $fillable = ['slug', 'title', 'description', 'keywords'];
}
\ No newline at end of file
<?php namespace Modules\Seo\Helpers;
use Modules\Seo\Entities\Meta;
use Modules\Seo\Helpers\SocialHelper;
/**
* Class MetaHelper
* @package Modules\Seo\Helpers
*/
class MetaHelper
{
/**
* @param bool|int|string $page
* @param bool|int|string $entityId
* @return array
*/
public static function get($page = FALSE, $entityId = FALSE)
{
return Meta::get($page, $entityId);
}
/**
* @param bool|int|string $page
* @param bool|int|string $entityId
* @return string
*/
public static function render($page = FALSE, $entityId = FALSE)
{
return Meta::render($page, $entityId);
}
/**
* @param bool|int|string $page
* @param bool|int|string $entityId
* @return array
*/
public static function getShareUrls($page = FALSE, $entityId = FALSE)
{
$data = Meta::get($page, $entityId);
return SocialHelper::getShareUrls($data['share']);
}
}
?>
\ No newline at end of file
<?php namespace Modules\Seo\Helpers;
/**
* Class SocialHelper
* @package Modules\Seo\Helpers
*/
class SocialHelper
{
/**
* @param array $data
* @return array
*/
public static function getShareUrls($data)
{
$links = [
'facebook' => [
'url' => 'https://facebook.com/sharer/sharer.php',
'query' => [
'u' => $data['source']
]
],
'linkedin' => [
'url' => 'https://linkedin.com/shareArticle',
'query' => [
'mini' => 'true',
'url' => $data['source'],
'source' => $data['source'],
'title' => $data['title'],
'summary' => (isset($data['summary.linkedin'])) ? $data['summary.linkedin'] : $data['summary'],
]
],
'twitter' => [
'url' => 'https://twitter.com/intent/tweet',
'query' => [
'url' => $data['source'],
'text' => (isset($data['summary.twitter'])) ? $data['summary.twitter'] : $data['summary']
]
]
];
foreach ($links as $key => $item) {
$links[$key] = $item['url'] . '?' . http_build_query($item['query']);
}
return $links;
}
}
?>
\ No newline at end of file
<head>
<meta charset="utf-8"/>
@yield('meta', MetaHelper::render())
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href='//fonts.googleapis.com/css?family=Roboto+Condensed:400,300,700' rel='stylesheet' type='text/css' />
<!--[if lte IE 9]><meta http-equiv="X-UA-Compatible" content="IE=edge" /><![endif]-->
<script type="text/javascript">
var appID = '';
var Routes = {!! \ViewHelper::getJsRoutes() !!};
</script>
@yield('scripts')
</head>
@foreach($data as $field => $template)
{!! $template !!}
@endforeach
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment